All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC] netlink: check for NULL attribute in nla_parse_nested_deprecated
Date: Mon, 19 Feb 2024 12:56:05 +0000	[thread overview]
Message-ID: <20240219125605.GA40273@kernel.org> (raw)
In-Reply-To: <20240216015257.10020-1-stephen@networkplumber.org>

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@networkplumber.org>

Hi Stephen,

this seems like a good approach to me.
Would you also plan to update the schedules at some point?

  reply	other threads:[~2024-02-19 12:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16  1:52 [RFC] netlink: check for NULL attribute in nla_parse_nested_deprecated Stephen Hemminger
2024-02-19 12:56 ` Simon Horman [this message]
2024-02-19 19:13 ` Jakub Kicinski

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=20240219125605.GA40273@kernel.org \
    --to=horms@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.