BPF List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/7] af_iucv: take socket lock around SO_MSGSIZE getsockopt
Date: Wed, 20 May 2026 09:14:13 -0700	[thread overview]
Message-ID: <ag3dctqXsRO-1akg@gmail.com> (raw)
In-Reply-To: <20260516083434.6FC23C19425@smtp.kernel.org>

On Sat, May 16, 2026 at 08:34:33AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The commit message incorrectly claims the bug is unexploitable and targets the patch to `net-next` without a `Fixes` tag, bypassing stable backports for a reachable NULL pointer dereference or use-after-free.
> --
> 
> commit 2d366eacb5715c7a757195706a39c7382bd391e0
> Author: Breno Leitao <leitao@debian.org>
> af_iucv: take socket lock around SO_MSGSIZE getsockopt
> 
> This commit adds socket locking around the SO_MSGSIZE case in
> iucv_sock_getsockopt() to prevent concurrent modifications to hs_dev.
> The commit message states this is purely defensive and targets net-next.
> 
> > This is not an exploitable bug. iucv_sock_close() is the only writer
> > of iucv->hs_dev and only runs from the protocol release callback,
> > which the socket layer invokes after the last file reference drops.
> > The getsockopt() syscall holds an fd reference for its entire
> > duration via fdget()/fdput(), so iucv_sock_close() cannot run
> > concurrently with the SO_MSGSIZE read on the same socket.
> 
> Is it strictly true that iucv_sock_close() only runs from the release
> callback?
> 
> Looking at iucv_sock_recvmsg(), it appears to directly invoke
> iucv_sock_close() when the message limit is exceeded:
> 
> net/iucv/af_iucv.c:iucv_sock_recvmsg() {
>         ...
>         if (atomic_read(&iucv->msg_recv) > iucv->msglimit) {
>                 ...
>                 iucv_sock_close(sk);
>                 ...
>         }
>         ...
> }
> 
> Since recvmsg() executes with an active file descriptor reference, could
> this path be triggered concurrently with a getsockopt() call evaluating
> SO_MSGSIZE on the same socket?
> 
> If so, evaluating iucv->hs_dev and then dereferencing iucv->hs_dev->mtu
> in getsockopt() before this patch could be vulnerable to a race with
> iucv_sock_close(), potentially leading to a null pointer dereference or
> use-after-free.

You are right. iucv_sock_recvmsg() does call iucv_sock_close() directly
on the AF_IUCV_TRANS_HIPER msglimit-exceeded branch, in syscall context
on a live fd. Two threads sharing an fd (or two fds for the same struct
sock after dup/fork) can then run recvmsg() and getsockopt(SO_MSGSIZE)
concurrently, if the dev_put() drops the last reference, A can be left
dereferencing a freed netdev.

That said, I will separate this patch and send it to 'net'.

  reply	other threads:[~2026-05-20 16:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15  8:32 [PATCH net-next v2 0/7] net: convert atm/xdp/af_iucv/l2tp_ppp/rxrpc/tipc to getsockopt_iter Breno Leitao
2026-05-15  8:32 ` [PATCH net-next v2 1/7] af_iucv: take socket lock around SO_MSGSIZE getsockopt Breno Leitao
2026-05-15 20:45   ` Stanislav Fomichev
2026-05-18 12:00     ` Alexandra Winter
2026-05-20 16:03       ` Breno Leitao
2026-05-20 16:49         ` Breno Leitao
2026-05-16  8:34   ` sashiko-bot
2026-05-20 16:14     ` Breno Leitao [this message]
2026-05-15  8:32 ` [PATCH net-next v2 2/7] af_iucv: convert to getsockopt_iter Breno Leitao
2026-05-18 12:00   ` Alexandra Winter
2026-05-15  8:32 ` [PATCH net-next v2 3/7] atm: " Breno Leitao
2026-05-19 14:04   ` Paolo Abeni
2026-05-20 15:50     ` Breno Leitao
2026-05-15  8:32 ` [PATCH net-next v2 4/7] xdp: " Breno Leitao
2026-05-15  8:32 ` [PATCH net-next v2 5/7] l2tp: ppp: " Breno Leitao
2026-05-15  8:32 ` [PATCH net-next v2 6/7] rxrpc: " Breno Leitao
2026-05-15  8:32 ` [PATCH net-next v2 7/7] tipc: " Breno Leitao
2026-05-19 14:08   ` Paolo Abeni
2026-05-20 15:51     ` Breno Leitao

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=ag3dctqXsRO-1akg@gmail.com \
    --to=leitao@debian.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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