Skip to contentSkip to conversation

selinux: add __GFP_NOWARN to hashtab_init() allocations

PATCH Applied Paul Moore 1 participant 2 messages Jun 18, 2025 – Jun 19, 2025 SELinux security module

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 selinux: add __GFP_NOWARN to hashtab_init() allocations

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.

---
 security/selinux/ss/hashtab.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
security/selinux/ss/hashtab.c +2 -1
index 383fd2d70878..1382eb3bfde1 100644
@@ -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;
Signature · 1 line
2.50.0
author maintainer Applied
#1 lore raw
Quoted 8 lines · On Jun 18, 2025 Paul Moore <[email protected]> wrote:

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.

Quoted 6 lines
---
 security/selinux/ss/hashtab.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Merged into selinux/dev, thanks me.

--
paul-moore.com