Re: [PATCH] audit: fix UAF in kauditd_send_queue()

From: Paul Moore

Date: Tue Dec 01 2026 - 16:48:42 EST


On Sat, Nov 28, 2026 at 7:57 AM Guicai Ma <maguicai@xxxxxxxxxx> wrote:
> On Tue, Nov 17, 2026 at 11:36:19AM +0100, Jérémy Jean wrote:
> > retry:
> > - /* grab an extra skb reference in case of error */
> > - skb_get(skb);
> > - rc = netlink_unicast(sk, skb, portid, 0);
> > + /* clone the skb for retries in case of error */
> > + skb_retry = skb_clone(skb, GFP_KERNEL);
> > + if (skb_retry)
> > + rc = netlink_unicast(sk, skb, portid, 0);
> > + else
> > + rc = -EAGAIN;
> > if (rc < 0) {
> > + if (!skb_retry) {
> > + /* No send was attempted, so return the
> > skb for a later pass. */
> > + skb_queue_head(queue, skb);
> > + rc = 0;
> > + break;
> > + }
> > +
> > + if (skb == skb_tail)
> > + skb_tail = skb_retry;
> > + skb = skb_retry;
>
> Requeuing onto audit_queue on skb_clone() failure breaks the main queue
> path in kauditd_thread() ...

Yes, we don't want to do that; the other queues exist for a reason.

Jérémy, this (likely whitespace damaged) code snippet below is
completely untested, but this is what I was thinking when I sent that
pseudo-code earlier. Feel free to steal it and see if it solves the
problem you identified :)

diff --git a/kernel/audit.c b/kernel/audit.c
index d0c2036bde75..0d8156a7ddf9 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -790,6 +790,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid,
{
int rc = 0;
struct sk_buff *skb = NULL;
+ struct sk_buff *skb_retry;
struct sk_buff *skb_tail;
unsigned int failed = 0;

@@ -810,9 +811,12 @@ static int kauditd_send_queue(struct sock *sk, u32 portid,
}

retry:
- /* grab an extra skb reference in case of error */
- skb_get(skb);
- rc = netlink_unicast(sk, skb, portid, 0);
+ /* clone the skb for retries in case of error */
+ skb_retry = skb_clone(skb, GFP_KERNEL);
+ if (skb_retry)
+ rc = netlink_unicast(sk, skb_retry, portid, 0);
+ else
+ rc = -EAGAIN;
if (rc < 0) {
/* send failed - try a few times unless fatal error */
if (++failed >= retry_limit ||
@@ -827,7 +831,7 @@ static int kauditd_send_queue(struct sock *sk, u32 portid,
} else
goto retry;
} else {
- /* skb sent - drop the extra reference and continue */
+ /* skb sent - consume the original and continue */
consume_skb(skb);
failed = 0;
}

--
paul-moore.com