[PATCH] selinux: use explicit 64-bit division
From: Arnd Bergmann
Date: Tue Sep 15 2026 - 15:57:41 EST
From: Arnd Bergmann <arnd@xxxxxxxx>
On 32-bit targets, the division of a 64-bit integer by 33 causes a
function call:
arm-linux-gnueabi-ld: security/selinux/selinuxfs.o: in function `sel_read_class':
selinuxfs.c:(.text+0xdcc): undefined reference to `__aeabi_uldivmod'
arm-linux-gnueabi-ld: security/selinux/selinuxfs.o: in function `sel_read_perm':
selinuxfs.c:(.text+0xed0): undefined reference to `__aeabi_uldivmod'
Replace this with an explicit call to div_u64() and div_u64_rem() to
annotate that these are potentially very slow.
Fixes: fc68b6a45f16 ("selinux: convert selinuxfs inode numbers from unsigned long to u64")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
security/selinux/selinuxfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index f60f92e2ac34..7894a2f480f7 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1573,7 +1573,7 @@ static inline u64 sel_class_to_ino(u16 class)
static inline u16 sel_ino_to_class(u64 ino)
{
- return (ino & SEL_INO_MASK) / (SEL_VEC_MAX + 1);
+ return div_u64(ino & SEL_INO_MASK, SEL_VEC_MAX + 1);
}
static inline u64 sel_perm_to_ino(u16 class, u32 perm)
@@ -1583,7 +1583,11 @@ static inline u64 sel_perm_to_ino(u16 class, u32 perm)
static inline u32 sel_ino_to_perm(u64 ino)
{
- return (ino & SEL_INO_MASK) % (SEL_VEC_MAX + 1);
+ u32 rem;
+
+ div_u64_rem(ino & SEL_INO_MASK, SEL_VEC_MAX + 1, &rem);
+
+ return rem;
}
static ssize_t sel_read_class(struct file *file, char __user *buf,
--
2.53.0