The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: "Joe Damato" <joe@dama.to>,
	sdf@fomichev.me, "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Alexander Aring" <alex.aring@gmail.com>,
	"Stefan Schmidt" <stefan@datenfreihafen.org>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Remi Denis-Courmont" <courmisch@gmail.com>,
	"Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Sabrina Dubroca" <sd@queasysnail.net>,
	"Shuah Khan" <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-wpan@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH net-next v2 3/7] ieee802154: convert dgram getsockopt to sockopt_t
Date: Fri, 24 Jul 2026 02:43:42 -0700	[thread overview]
Message-ID: <amMvRiiPI7BY3Bqw@gmail.com> (raw)
In-Reply-To: <amDIUv4Sa/i7MfEq@devvm20253.cco0.facebook.com>

On Wed, Jul 22, 2026 at 06:40:34AM -0700, Joe Damato wrote:
> On Mon, Jul 20, 2026 at 09:17:44AM -0700, Breno Leitao wrote:
> > Continue converting the proto-layer getsockopt callbacks to the sockopt_t
> > interface, splitting dgram_getsockopt() into a do_dgram_getsockopt() helper
> > that takes a sockopt_t.
> > 
> > No functional change.
> > 
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> >  net/ieee802154/socket.c | 38 ++++++++++++++++++++++++++------------
> >  1 file changed, 26 insertions(+), 12 deletions(-)
> > 
> > diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
> > index 85dce296d7513..763f63e48afe4 100644
> > --- a/net/ieee802154/socket.c
> > +++ b/net/ieee802154/socket.c
> > @@ -831,20 +831,12 @@ static int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)
> >  	return ret;
> >  }
> >  
> > -static int dgram_getsockopt(struct sock *sk, int level, int optname,
> > -			    char __user *optval, int __user *optlen)
> > +static int do_dgram_getsockopt(struct sock *sk, int optname, sockopt_t *opt)
> >  {
> >  	struct dgram_sock *ro = dgram_sk(sk);
> > -
> >  	int val, len;
> >  
> > -	if (level != SOL_IEEE802154)
> > -		return -EOPNOTSUPP;
> > -
> > -	if (get_user(len, optlen))
> > -		return -EFAULT;
> > -
> > -	len = min_t(unsigned int, len, sizeof(int));
> > +	len = min_t(unsigned int, opt->optlen, sizeof(int));
> 
> Does the same min() feedback David gave on the last revision apply here as
> well?

yes, but it should be umin() and not min() as suggeted by David.

min() is not good at comparing different types (len as int, and sizeof
as unsigned int) and fails to compile with sign mismatch.

  BUILD_BUG_ON_MSG(!__types_ok(ux, uy), "min(...) signedness error");

On the other side, umin() is the rigth approach, given we know that len
is positive (sockopt_init_user() rejects negative optlen), and it It
avoids narrowing the size_t, which is makes no difference in practice,
given this is getsockopt operations, but, it is still more correct.

That said, I will update this to umin() and respin.

Thanks for the review and catching this up.
--breno

--
pw-bot: cr

  reply	other threads:[~2026-07-24  9:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 16:17 [PATCH net-next v2 0/7] net: convert rawv6, ieee802154, phonet and tls getsockopt to sockopt_t Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 1/7] ipv6: raw: drop unused level argument from do_rawv6_getsockopt Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 2/7] ipv6: raw: convert do_rawv6_getsockopt to sockopt_t Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 3/7] ieee802154: convert dgram getsockopt " Breno Leitao
2026-07-22 13:40   ` Joe Damato
2026-07-24  9:43     ` Breno Leitao [this message]
2026-07-20 16:17 ` [PATCH net-next v2 4/7] phonet: pep: do not write beyond optlen in getsockopt Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 5/7] phonet: pep: convert getsockopt to sockopt_t Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 6/7] tls: " Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 7/7] selftests: net: getsockopt_iter: cover rawv6, ieee802154, phonet and tls Breno Leitao
     [not found]   ` <amHs_xGASCAA1J3k@krikkit>
2026-07-24  9:48     ` Breno Leitao
2026-07-22 13:42 ` [PATCH net-next v2 0/7] net: convert rawv6, ieee802154, phonet and tls getsockopt to sockopt_t Joe Damato
2026-07-23 14:05   ` 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=amMvRiiPI7BY3Bqw@gmail.com \
    --to=leitao@debian.org \
    --cc=alex.aring@gmail.com \
    --cc=courmisch@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=joe@dama.to \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=remi.denis-courmont@nokia.com \
    --cc=sd@queasysnail.net \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=stefan@datenfreihafen.org \
    /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