]> www.infradead.org Git - users/willy/xarray.git/commit
selinux: match extended permissions to their base permissions
authorThiƩbaud Weksteen <tweek@google.com>
Fri, 20 Dec 2024 04:25:58 +0000 (15:25 +1100)
committerPaul Moore <paul@paul-moore.com>
Sun, 5 Jan 2025 01:58:46 +0000 (20:58 -0500)
commit5e7f0efd23238039bcd4fc72ff28d94f364ec26b
tree2e7cd4c949f3d8a0939dc09e45c95a601bd50699
parent900f83cf376bdaf798b6f5dcb2eae0c822e908b6
selinux: match extended permissions to their base permissions

In commit d1d991efaf34 ("selinux: Add netlink xperm support") a new
extended permission was added ("nlmsg"). This was the second extended
permission implemented in selinux ("ioctl" being the first one).

Extended permissions are associated with a base permission. It was found
that, in the access vector cache (avc), the extended permission did not
keep track of its base permission. This is an issue for a domain that is
using both extended permissions (i.e., a domain calling ioctl() on a
netlink socket). In this case, the extended permissions were
overlapping.

Keep track of the base permission in the cache. A new field "base_perm"
is added to struct extended_perms_decision to make sure that the
extended permission refers to the correct policy permission. A new field
"base_perms" is added to struct extended_perms to quickly decide if
extended permissions apply.

While it is in theory possible to retrieve the base permission from the
access vector, the same base permission may not be mapped to the same
bit for each class (e.g., "nlmsg" is mapped to a different bit for
"netlink_route_socket" and "netlink_audit_socket"). Instead, use a
constant (AVC_EXT_IOCTL or AVC_EXT_NLMSG) provided by the caller.

Fixes: d1d991efaf34 ("selinux: Add netlink xperm support")
Signed-off-by: ThiƩbaud Weksteen <tweek@google.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/include/avc.h
security/selinux/include/security.h
security/selinux/ss/services.c