]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selinux: add __GFP_NOWARN to hashtab_init() allocations
authorPaul Moore <paul@paul-moore.com>
Wed, 18 Jun 2025 16:17:33 +0000 (12:17 -0400)
committerPaul Moore <paul@paul-moore.com>
Thu, 19 Jun 2025 21:24:57 +0000 (17:24 -0400)
As reported by syzbot, hashtab_init() can be affected by abnormally
large policy loads which would cause the kernel's allocator to emit
a warning in some configurations.  Since the SELinux hashtab_init()
code handles the case where the allocation fails, due to a large
request or some other reason, we can safely add the __GFP_NOWARN flag
to squelch these abnormally large allocation warnings.

Reported-by: syzbot+bc2c99c2929c3d219fb3@syzkaller.appspotmail.com
Tested-by: syzbot+bc2c99c2929c3d219fb3@syzkaller.appspotmail.com
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/hashtab.c

index 383fd2d70878e52487dade8c0b4c58c93e74fb2d..1382eb3bfde1088d1b92b65a8a77f0f983e1bb00 100644 (file)
@@ -40,7 +40,8 @@ int hashtab_init(struct hashtab *h, u32 nel_hint)
        h->htable = NULL;
 
        if (size) {
-               h->htable = kcalloc(size, sizeof(*h->htable), GFP_KERNEL);
+               h->htable = kcalloc(size, sizeof(*h->htable),
+                                   GFP_KERNEL | __GFP_NOWARN);
                if (!h->htable)
                        return -ENOMEM;
                h->size = size;