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

Jakub Kicinski
2026-04-02T00:49:59Z

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.