]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selinux: simplify avc_xperms_audit_required()
authorZhen Lei <thunder.leizhen@huawei.com>
Thu, 22 Aug 2024 14:08:58 +0000 (22:08 +0800)
committerPaul Moore <paul@paul-moore.com>
Wed, 28 Aug 2024 17:42:11 +0000 (13:42 -0400)
commit68cfb28332420e0515cb6ffdb46921d59ba9739f
tree05359c4b18ebbdc7fa17bb7d4006b33ebf1f863a
parenta3422eb4facdebb685b9b4688feb60430450e3c9
selinux: simplify avc_xperms_audit_required()

By associative and commutative laws, the result of the two 'audited' is
zero. Take the second 'audited' as an example:
  1) audited = requested & avd->auditallow;
  2) audited &= ~requested;
  ==> audited = ~requested & (requested & avd->auditallow);
  ==> audited = (~requested & requested) & avd->auditallow;
  ==> audited = 0 & avd->auditallow;
  ==> audited = 0;

In fact, it is more readable to directly write zero. The value of the
first 'audited' is 0 because AUDIT is not allowed. The second 'audited'
is zero because there is no AUDITALLOW permission.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/avc.c