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

From: Guicai Ma

Date: Sat Nov 28 2026 - 07:57:19 EST


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(). kauditd_send_multicast_skb() already ran via
skb_hook before the clone. Putting skb back on audit_queue and
returning 0 leaves audit_queue non-empty, so wait_event_freezable()
returns immediately and kauditd_thread() spins on the same record. Even
a single failed clone sends a duplicate multicast copy.

v1 handled this cleanly: pass the clone to netlink_unicast(), keep skb
for retries, and let a failed clone fall through as -EAGAIN to err_hook.
For audit_queue, kauditd_retry_skb() moves the record to
audit_retry_queue, which has no skb_hook, while rc is still cleared to 0
so auditd_reset() is not called. Keeping skb also avoids swapping skb
and skb_tail on failure.

Thanks,
Guicai