public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: eulgyukim@snu.ac.kr
Cc: bpf@vger.kernel.org, byoungyoung@snu.ac.kr, davem@davemloft.net,
	 edumazet@google.com, horms@kernel.org, jakub@cloudflare.com,
	 jjy600901@snu.ac.kr, john.fastabend@gmail.com, kuba@kernel.org,
	 linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com
Subject: Re: [BUG] KASAN: slab-use-after-free in __sk_msg_recvmsg
Date: Mon,  4 May 2026 07:52:19 +0000	[thread overview]
Message-ID: <20260504075232.3861715-1-kuniyu@google.com> (raw)
In-Reply-To: <20260504072325.23474-1-eulgyukim@snu.ac.kr>

From: Eulgyu Kim <eulgyukim@snu.ac.kr>
Date: Mon,  4 May 2026 16:23:25 +0900
> Hello,
> 
> We encountered a "KASAN: slab-use-after-free in __sk_msg_recvmsg"
> on kernel version v7.1.0-rc1.
> 
> As this issue was identified via fuzzing and we have limited background,
> we find it challenging to identify the exact root cause or propose a correct fix.
> Therefore, please consider the following analysis as a best-effort guess,
> which may still be incomplete or incorrect.
> 
> The issue is that sk_psock_peek_msg() only protects the list lookup; after it
> drops ingress_lock, the returned sk_msg can be concurrently consumed and freed
> by another recvmsg caller.
> 
> Following is the harmful sequence:
> 
> 1. Thread A calls recvmmsg() on the socket and reaches __sk_msg_recvmsg()
> through udp_bpf_recvmsg() -> sk_msg_recvmsg() -> __sk_msg_recvmsg().
> 
> 2. __sk_msg_recvmsg() calls sk_psock_peek_msg() and obtains msg_rx, the
> first struct sk_msg on psock->ingress_msg. The ingress_lock is dropped
> immediately after the peek.
> 
> 3. Thread A copies data to userspace and still holds local pointers to
> msg_rx and sge = sk_msg_elem(msg_rx, i), but has not yet updated
> sge->offset/sge->length or dequeued the message.
> 
> 4. Thread B concurrently calls recvmmsg() on the same socket.
> 
> 5. Because udp_bpf_recvmsg() does not hold a per-socket receive lock,

This reminds me that I forgot to respin this series.
https://lore.kernel.org/bpf/20260221233234.3814768-1-kuniyu@google.com/

I'll rebase and respin it.

      reply	other threads:[~2026-05-04  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04  7:23 [BUG] KASAN: slab-use-after-free in __sk_msg_recvmsg Eulgyu Kim
2026-05-04  7:52 ` Kuniyuki Iwashima [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260504075232.3861715-1-kuniyu@google.com \
    --to=kuniyu@google.com \
    --cc=bpf@vger.kernel.org \
    --cc=byoungyoung@snu.ac.kr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eulgyukim@snu.ac.kr \
    --cc=horms@kernel.org \
    --cc=jakub@cloudflare.com \
    --cc=jjy600901@snu.ac.kr \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox