* [PATCH] selinux: avoid 64-bit division of inode numbers
@ 2026-09-15 21:38 Paul Moore
2026-09-15 21:44 ` sashiko-bot
2026-09-16 3:32 ` Paul Moore
0 siblings, 2 replies; 3+ messages in thread
From: Paul Moore @ 2026-09-15 21:38 UTC (permalink / raw)
To: selinux; +Cc: Arnd Bergmann
As reported by Arnd, a previous change to convert the selinuxfs inode
numbers to u64 to match the rest of the kernel caused a problem on 32-bit
systems:
arm-linux-gnueabi-ld: .../selinuxfs.o: in function `sel_read_class':
selinuxfs.c:(.text+0xdcc): undefined reference to `__aeabi_uldivmod'
arm-linux-gnueabi-ld: .../selinuxfs.o: in function `sel_read_perm':
selinuxfs.c:(.text+0xed0): undefined reference to `__aeabi_uldivmod'
Since we don't currently use more than 24-bits in the selinuxfs inodes
(see SEL_INO_MASK), fix this by applying the SEL_INO_MASK to the
selinuxfs inode numbers and casting to a u32 before performing any
division operations.
Fixes: fc68b6a45f16 ("selinux: convert selinuxfs inode numbers from unsigned long to u64")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Paul Moore <paul@paul-moore.com>
---
security/selinux/selinuxfs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 292302eb60f3..d864c314c873 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1574,7 +1574,8 @@ 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);
+ u32 ino_masked = ino & SEL_INO_MASK;
+ return ino_masked / (SEL_VEC_MAX + 1);
}
static inline u64 sel_perm_to_ino(u16 class, u32 perm)
@@ -1584,7 +1585,8 @@ 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 ino_masked = ino & SEL_INO_MASK;
+ return ino_masked % (SEL_VEC_MAX + 1);
}
static ssize_t sel_read_class(struct file *file, char __user *buf,
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] selinux: avoid 64-bit division of inode numbers
2026-09-15 21:38 [PATCH] selinux: avoid 64-bit division of inode numbers Paul Moore
@ 2026-09-15 21:44 ` sashiko-bot
2026-09-16 3:32 ` Paul Moore
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-15 21:44 UTC (permalink / raw)
Cc: selinux
> As reported by Arnd, a previous change to convert the selinuxfs inode
> numbers to u64 to match the rest of the kernel caused a problem on 32-bit
> systems:
>
> arm-linux-gnueabi-ld: .../selinuxfs.o: in function `sel_read_class':
> selinuxfs.c:(.text+0xdcc): undefined reference to `__aeabi_uldivmod'
> arm-linux-gnueabi-ld: .../selinuxfs.o: in function `sel_read_perm':
> selinuxfs.c:(.text+0xed0): undefined reference to `__aeabi_uldivmod'
>
> Since we don't currently use more than 24-bits in the selinuxfs inodes
> (see SEL_INO_MASK), fix this by applying the SEL_INO_MASK to the
> selinuxfs inode numbers and casting to a u32 before performing any
> division operations.
>
> Fixes: fc68b6a45f16 ("selinux: convert selinuxfs inode numbers from unsigned long to u64")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915213807.481355-2-paul@paul-moore.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selinux: avoid 64-bit division of inode numbers
2026-09-15 21:38 [PATCH] selinux: avoid 64-bit division of inode numbers Paul Moore
2026-09-15 21:44 ` sashiko-bot
@ 2026-09-16 3:32 ` Paul Moore
1 sibling, 0 replies; 3+ messages in thread
From: Paul Moore @ 2026-09-16 3:32 UTC (permalink / raw)
To: selinux; +Cc: Arnd Bergmann
On Tue, Sep 15, 2026 at 5:38 PM Paul Moore <paul@paul-moore.com> wrote:
>
> As reported by Arnd, a previous change to convert the selinuxfs inode
> numbers to u64 to match the rest of the kernel caused a problem on 32-bit
> systems:
>
> arm-linux-gnueabi-ld: .../selinuxfs.o: in function `sel_read_class':
> selinuxfs.c:(.text+0xdcc): undefined reference to `__aeabi_uldivmod'
> arm-linux-gnueabi-ld: .../selinuxfs.o: in function `sel_read_perm':
> selinuxfs.c:(.text+0xed0): undefined reference to `__aeabi_uldivmod'
>
> Since we don't currently use more than 24-bits in the selinuxfs inodes
> (see SEL_INO_MASK), fix this by applying the SEL_INO_MASK to the
> selinuxfs inode numbers and casting to a u32 before performing any
> division operations.
>
> Fixes: fc68b6a45f16 ("selinux: convert selinuxfs inode numbers from unsigned long to u64")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
> security/selinux/selinuxfs.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Merged into selinux/dev.
--
paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-16 3:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 21:38 [PATCH] selinux: avoid 64-bit division of inode numbers Paul Moore
2026-09-15 21:44 ` sashiko-bot
2026-09-16 3:32 ` Paul Moore
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.