Subject: Re: [PATCH net-next 3/4] ethtool: strset: check nla_len overflow before nla_nest_end

From: Hangbin Liu <[email-masked]>
Date: Thu, 2 Apr 2026 01:30:24 +0000

On Wed, Apr 01, 2026 at 05:49:56PM -0700, Jakub Kicinski wrote:
> On Wed, 1 Apr 2026 07:27:40 +0000 Hangbin Liu wrote:
> > On Tue, Mar 31, 2026 at 06:46:37PM -0700, Jakub Kicinski wrote:
> > > On Tue, 31 Mar 2026 11:56:13 +0800 Hangbin Liu wrote:  
> > > > +		if (skb_tail_pointer(skb) - (unsigned char *)strings_attr > U16_MAX)
> > > > +			goto nla_put_failure;  
> > > 
> > > bit ugly, let's add a variant of nla_nest_end() which can return 
> > > an error on overflow (without the warning from patch 4) ?  
> > 
> > I was tried to not touch nla_nest_end() as it is used everywhere. But it makes
> > sense to me to add a new function to check this. I'm not very good at naming,
> > maybe `nla_nest_end_validate()` ? Or any other name if you have?
> 
> I was thinking nla_nest_end_check() to match the __must_check
> attribute. But I also like nla_nest_end_safe()
> _validate() is a little long but anything <=5 chars is fine.

OK, I will use nla_nest_end_safe() until we have a better name.