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 <[email protected]>
> > ---
> >  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 via email to