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 1/6] atm: convert to getsockopt_iter
Date: Thu, 14 May 2026 12:45:00 +0000	[thread overview]
Message-ID: <20260514124501.43BC2C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260513-getsock_four-v1-1-fe7f0e756fac@debian.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] getsockopt(..., SO_SETCLP, ...) unconditionally fails with -EFAULT on 64-bit systems due to a size mismatch.
--

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

atm: convert to getsockopt_iter

This commit converts the ATM SVC and PVC sockets, along with the shared
vcc_getsockopt() helper, to use the new getsockopt_iter callback with
sockopt_t.

> diff --git a/net/atm/common.c b/net/atm/common.c
> --- a/net/atm/common.c
> +++ b/net/atm/common.c
[ ... ]
> @@ -797,13 +798,13 @@ int vcc_setsockopt(struct socket *sock, int level, int optname,
>  }
>  
>  int vcc_getsockopt(struct socket *sock, int level, int optname,
> -		   char __user *optval, int __user *optlen)
> +		   sockopt_t *opt)
>  {
>  	struct atm_vcc *vcc;
> +	unsigned long val;
>  	int len;
>  
> -	if (get_user(len, optlen))
> -		return -EFAULT;
> +	len = opt->optlen;
>  	if (__SO_LEVEL_MATCH(optname, level) && len != __SO_SIZE(optname))
>  		return -EINVAL;
[ ... ]
>  	case SO_SETCLP:
> -		return put_user(vcc->atm_options & ATM_ATMOPT_CLP ? 1 : 0,
> -				(unsigned long __user *)optval) ? -EFAULT : 0;
> +		val = vcc->atm_options & ATM_ATMOPT_CLP ? 1 : 0;
> +		return copy_to_iter(&val, sizeof(val), &opt->iter_out) !=
> +		       sizeof(val) ? -EFAULT : 0;

On 64-bit systems, val is an unsigned long (8 bytes). However, __SO_SIZE
for SO_SETCLP is 4 bytes, which is enforced by the length check above.

Since the opt->iter_out iterator is restricted to 4 bytes, copy_to_iter()
will truncate the copy to 4 bytes and return 4. Does this mean the
subsequent check against sizeof(val) (8 bytes) will always fail and return
-EFAULT unconditionally?

Additionally, on 64-bit big-endian systems, does copying the first 4 bytes
of an 8-byte unsigned long always copy zeroes, ignoring the actual flag
value?

Would declaring val as an int instead of an unsigned long resolve both the
copy size mismatch and the potential endianness issue here?

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

  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 [this message]
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
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=20260514124501.43BC2C2BCB3@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