Skip to contentSkip to conversation

audit: init ab->skb_list earlier in audit_buffer_alloc()

PATCH In review Eric Dumazet 2 participants 2 messages Sep 4, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 audit: init ab->skb_list earlier in audit_buffer_alloc()

syzbot found a bug in audit_buffer_alloc() if nlmsg_new() returns NULL.

We need to initialize ab->skb_list before calling audit_buffer_free() which will use both the skb_list spinlock and list pointers.

Fixes eb59d494eebd ("audit: add record for multiple task security contexts")
Reported-by [email protected]
Cc Casey Schaufler <[email protected]>
Cc Paul Moore <[email protected]>
Cc Eric Paris <[email protected]>
---
 kernel/audit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/audit.c +2 -1
index bd7474fd8d2c..707483879648 100644
@@ -1831,11 +1831,12 @@ static struct audit_buffer *audit_buffer_alloc(struct audit_context *ctx,
 	if (!ab)
 		return NULL;
 
+	skb_queue_head_init(&ab->skb_list);
+
 	ab->skb = nlmsg_new(AUDIT_BUFSIZ, gfp_mask);
 	if (!ab->skb)
 		goto err;
 
-	skb_queue_head_init(&ab->skb_list);
 	skb_queue_tail(&ab->skb_list, ab->skb);
 
 	if (!nlmsg_put(ab->skb, 0, 0, type, 0, 0))
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog
maintainer
#1 lore raw
Quoted 14 lines · On Sep 4, 2025 Eric Dumazet <[email protected]> wrote:

syzbot found a bug in audit_buffer_alloc() if nlmsg_new() returns NULL.

We need to initialize ab->skb_list before calling audit_buffer_free() which will use both the skb_list spinlock and list pointers.

Fixes eb59d494eebd ("audit: add record for multiple task security contexts")
Reported-by [email protected]
Cc Casey Schaufler <[email protected]>
Cc Paul Moore <[email protected]>
Cc Eric Paris <[email protected]>
Quoted 3 lines
---
 kernel/audit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Thanks Eric, merged into audit/dev.

--
paul-moore.com