From: Christian Göttsche Date: Mon, 7 Aug 2023 17:11:38 +0000 (+0200) Subject: selinux: make left shifts well defined X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=aa4b60518280834529f75cb7667ffac91967abea;p=linux.git selinux: make left shifts well defined The loops upper bound represent the number of permissions used (for the current class or in general). The limit for this is 32, thus we might left shift of one less, 31. Shifting a base of 1 results in undefined behavior; use (u32)1 as base. Signed-off-by: Christian Göttsche Signed-off-by: Paul Moore --- diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index dacec2ebdcd7d..1eeffc66ea7d7 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -207,22 +207,22 @@ static void map_decision(struct selinux_map *map, for (i = 0, result = 0; i < n; i++) { if (avd->allowed & mapping->perms[i]) - result |= 1<perms[i]) - result |= 1<allowed = result; for (i = 0, result = 0; i < n; i++) if (avd->auditallow & mapping->perms[i]) - result |= 1<auditallow = result; for (i = 0, result = 0; i < n; i++) { if (avd->auditdeny & mapping->perms[i]) - result |= 1<perms[i]) - result |= 1<auditdeny = result; } }