public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] audit: init ab->skb_list earlier in audit_buffer_alloc()
@ 2025-09-04  7:25 Eric Dumazet
  2025-09-04 15:06 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2025-09-04  7:25 UTC (permalink / raw)
  To: Casey Schaufler, Paul Moore
  Cc: linux-kernel, netdev, Eric Dumazet, Eric Dumazet,
	syzbot+bb185b018a51f8d91fd2, Eric Paris, audit

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: syzbot+bb185b018a51f8d91fd2@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/68b93e3c.a00a0220.eb3d.0000.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Eric Paris <eparis@redhat.com>
Cc: audit@vger.kernel.org
---
 kernel/audit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index bd7474fd8d2c..707483879648 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -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))
-- 
2.51.0.338.gd7d06c2dae-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] audit: init ab->skb_list earlier in audit_buffer_alloc()
  2025-09-04  7:25 [PATCH] audit: init ab->skb_list earlier in audit_buffer_alloc() Eric Dumazet
@ 2025-09-04 15:06 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2025-09-04 15:06 UTC (permalink / raw)
  To: Eric Dumazet, Casey Schaufler
  Cc: linux-kernel, netdev, Eric Dumazet, Eric Dumazet,
	syzbot+bb185b018a51f8d91fd2, Eric Paris, audit

On Sep  4, 2025 Eric Dumazet <edumazet@google.com> 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: syzbot+bb185b018a51f8d91fd2@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/68b93e3c.a00a0220.eb3d.0000.GAE@google.com/T/#u
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Casey Schaufler <casey@schaufler-ca.com>
> Cc: Paul Moore <paul@paul-moore.com>
> Cc: Eric Paris <eparis@redhat.com>
> Cc: audit@vger.kernel.org
> ---
>  kernel/audit.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Thanks Eric, merged into audit/dev.

--
paul-moore.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-04 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04  7:25 [PATCH] audit: init ab->skb_list earlier in audit_buffer_alloc() Eric Dumazet
2025-09-04 15:06 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox