[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240219125605.GA40273@kernel.org>
Date: Mon, 19 Feb 2024 12:56:05 +0000
From: Simon Horman <horms@...nel.org>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: Re: [RFC] netlink: check for NULL attribute in
nla_parse_nested_deprecated
On Thu, Feb 15, 2024 at 05:52:48PM -0800, Stephen Hemminger wrote:
> Lots of code in network schedulers has the pattern:
> if (!nla) {
> NL_SET_ERR_MSG_MOD(extack, "missing attributes");
> return -EINVAL;
> }
>
> err = nla_parse_nested_deprecated(tb, TCA_CSUM_MAX, nla, csum_policy,
> NULL);
> if (err < 0)
> return err;
>
> The check for nla being NULL can be moved into nla_parse_nested_deprecated().
> Which simplifies lots of places.
>
> This is safer and won't break other places since:
> err = nla_parse_nested_deprecated(tb, TCA_XXXX, NULL, some_policy, NULL);
> would have crashed kernel because nla_parse_deprecated derefences the nla
> argument before calling __nla_parse.
>
> Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
Hi Stephen,
this seems like a good approach to me.
Would you also plan to update the schedules at some point?
Powered by blists - more mailing lists