Skip to content

Commit 4004cfb

Browse files
committed
cmd/snap-confine: Unconditionally allow cgroup access to binder devices
binder and hwbinder are devices residing in their own filesystem. In order to allow access to them they need to be unconditionally allowed in the cgroup for libhybris drivers to work accordingly. Note that binderfs is checked before binder in order to distinguish between an Android 11+ and lower kernels since newer ones place a compatibility symlink at the old and familiar path.
1 parent 5be0439 commit 4004cfb

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

cmd/snap-confine/udev-support.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,34 @@ static void sc_udev_allow_nvidia(sc_device_cgroup *cgroup)
116116
}
117117
}
118118

119+
/** Allow access to hybris devices.
120+
*
121+
* Required by Halium-based GNU/Linux adaptations to make use of certain device nodes.
122+
*
123+
* Note: Binder devices on newer Android kernels reside inside of their own binderfs mountpount.
124+
**/
125+
static void sc_udev_allow_hybris(sc_device_cgroup *cgroup)
126+
{
127+
struct stat sbuf;
128+
129+
if (stat("/dev/binderfs/binder", &sbuf) == 0) {
130+
sc_device_cgroup_allow(cgroup, S_IFCHR, major(sbuf.st_rdev),
131+
minor(sbuf.st_rdev));
132+
}
133+
if (stat("/dev/binderfs/hwbinder", &sbuf) == 0) {
134+
sc_device_cgroup_allow(cgroup, S_IFCHR, major(sbuf.st_rdev),
135+
minor(sbuf.st_rdev));
136+
}
137+
if (stat("/dev/binder", &sbuf) == 0) {
138+
sc_device_cgroup_allow(cgroup, S_IFCHR, major(sbuf.st_rdev),
139+
minor(sbuf.st_rdev));
140+
}
141+
if (stat("/dev/hwbinder", &sbuf) == 0) {
142+
sc_device_cgroup_allow(cgroup, S_IFCHR, major(sbuf.st_rdev),
143+
minor(sbuf.st_rdev));
144+
}
145+
}
146+
119147
/**
120148
* Allow access to /dev/uhid.
121149
*
@@ -199,6 +227,7 @@ static void sc_udev_setup_acls_common(sc_device_cgroup *cgroup)
199227
sc_udev_allow_common(cgroup);
200228
sc_udev_allow_pty_slaves(cgroup);
201229
sc_udev_allow_nvidia(cgroup);
230+
sc_udev_allow_hybris(cgroup);
202231
sc_udev_allow_uhid(cgroup);
203232
sc_udev_allow_dev_net_tun(cgroup);
204233
}

0 commit comments

Comments
 (0)