From: Breno Leitao <leitao@debian.org>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 1/6] atm: convert to getsockopt_iter
Date: Thu, 14 May 2026 07:52:32 -0700 [thread overview]
Message-ID: <agXhTGVurhrJmBNu@gmail.com> (raw)
In-Reply-To: <20260514124501.43BC2C2BCB3@smtp.kernel.org>
On Thu, May 14, 2026 at 12:45:00PM +0000, sashiko-bot@kernel.org wrote:
> > 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?
Good catch, dear LLM. This seems a real regression!
val should be "int" or u32 instead of "long int" in this case. I will
update.
--
pw-bot: cr
next prev parent reply other threads:[~2026-05-14 14:52 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 [this message]
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=agXhTGVurhrJmBNu@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