BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Breno Leitao" <leitao@debian.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 3/6] af_iucv: convert to getsockopt_iter
Date: Thu, 14 May 2026 12:45:01 +0000	[thread overview]
Message-ID: <20260514124502.5C2ABC2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260513-getsock_four-v1-3-fe7f0e756fac@debian.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unlocked access to `iucv->hs_dev` in the `SO_MSGSIZE` case can lead to a NULL pointer dereference or use-after-free.
--

commit f3b71ba02ea8266fcb82046dd3417eeb5b94f2d5
Author: Breno Leitao <leitao@debian.org>

af_iucv: convert to getsockopt_iter

This commit converts the IUCV socket getsockopt implementation to use the
getsockopt_iter callback with sockopt_t. It replaces direct user copy
functions with copy_to_iter.

> diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
> index 72dfccd4e3d58..7a5ce93a83d9c 100644
> --- a/net/iucv/af_iucv.c
> +++ b/net/iucv/af_iucv.c

[ ... ]

> @@ -1535,7 +1536,7 @@ static int iucv_sock_setsockopt(struct socket *sock, int level, int optname,
>  }
>  
>  static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
> -				char __user *optval, int __user *optlen)
> +				sockopt_t *opt)
>  {
>  	struct sock *sk = sock->sk;

[ ... ]

> @@ -1574,9 +1573,8 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,

While reviewing this conversion, I noticed a pre-existing issue in this
function. Does the SO_MSGSIZE case need socket lock protection when accessing
iucv->hs_dev?

In iucv_sock_getsockopt():

        case SO_MSGSIZE:
                if (sk->sk_state == IUCV_OPEN)
                        return -EBADFD;
                val = (iucv->hs_dev) ? iucv->hs_dev->mtu -
                                sizeof(struct af_iucv_trans_hdr) - ETH_HLEN :
                                0x7fffffff;
                break;

If iucv->hs_dev is cleared concurrently by another thread holding the lock
(such as during iucv_sock_close), could the compiler emit two separate
memory loads for hs_dev since READ_ONCE() isn't used?

If the pointer is set to NULL between the check and the dereference for mtu,
could this result in a NULL pointer dereference, or a use-after-free if the
socket held the final reference to the net_device being unregistered?

> -	if (put_user(len, optlen))
> -		return -EFAULT;
> -	if (copy_to_user(optval, &val, len))
> +	opt->optlen = len;
> +	if (copy_to_iter(&val, len, &opt->iter_out) != len)
>  		return -EFAULT;
>  
>  	return 0;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513-getsock_four-v1-0-fe7f0e756fac@debian.org?part=3

  parent reply	other threads:[~2026-05-14 12:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 12:34 [PATCH net-next 0/6] net: convert atm/xdp/af_iucv/l2tp_ppp/rxrpc/tipc to getsockopt_iter Breno Leitao
2026-05-13 12:34 ` [PATCH net-next 1/6] atm: convert " Breno Leitao
2026-05-13 15:29   ` Stanislav Fomichev
2026-05-14 12:45   ` sashiko-bot
2026-05-14 14:52     ` Breno Leitao
2026-05-13 12:34 ` [PATCH net-next 2/6] xdp: " Breno Leitao
2026-05-13 15:30   ` Stanislav Fomichev
2026-05-13 12:34 ` [PATCH net-next 3/6] af_iucv: " Breno Leitao
2026-05-13 15:30   ` Stanislav Fomichev
2026-05-14 12:45   ` sashiko-bot [this message]
2026-05-14 16:52     ` Breno Leitao
2026-05-13 12:34 ` [PATCH net-next 4/6] l2tp: ppp: " Breno Leitao
2026-05-13 15:32   ` Stanislav Fomichev
2026-05-13 12:34 ` [PATCH net-next 5/6] rxrpc: " Breno Leitao
2026-05-13 15:33   ` Stanislav Fomichev
2026-05-13 12:34 ` [PATCH net-next 6/6] tipc: " Breno Leitao
2026-05-13 15:34   ` Stanislav Fomichev

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=20260514124502.5C2ABC2BCB3@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=leitao@debian.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