From: "Keller, Jacob E" <jacob.e.keller@intel.com>
To: Jiri Pirko <jiri@resnulli.us>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>
Subject: RE: [patch net-next] genetlink: add explicit ordering break check for split ops
Date: Fri, 21 Jul 2023 16:45:33 +0000 [thread overview]
Message-ID: <CO1PR11MB5089ADDBFA04502A6F7D56ABD63FA@CO1PR11MB5089.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230720111354.562242-1-jiri@resnulli.us>
> -----Original Message-----
> From: Jiri Pirko <jiri@resnulli.us>
> Sent: Thursday, July 20, 2023 4:14 AM
> To: netdev@vger.kernel.org
> Cc: kuba@kernel.org; pabeni@redhat.com; davem@davemloft.net;
> edumazet@google.com; Keller, Jacob E <jacob.e.keller@intel.com>
> Subject: [patch net-next] genetlink: add explicit ordering break check for split ops
>
> From: Jiri Pirko <jiri@nvidia.com>
>
> Currently, if cmd in the split ops array is of lower value than the
> previous one, genl_validate_ops() continues to do the checks as if
> the values are equal. This may result in non-obvious WARN_ON() hit in
> these check.
>
> Instead, check the incorrect ordering explicitly and put a WARN_ON()
> in case it is broken.
>
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Good fix.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> net/netlink/genetlink.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index a157247a1e45..6bd2ce51271f 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -593,8 +593,12 @@ static int genl_validate_ops(const struct genl_family
> *family)
> return -EINVAL;
>
> /* Check sort order */
> - if (a->cmd < b->cmd)
> + if (a->cmd < b->cmd) {
> continue;
> + } else if (a->cmd > b->cmd) {
> + WARN_ON(1);
> + return -EINVAL;
> + }
>
> if (a->internal_flags != b->internal_flags ||
> ((a->flags ^ b->flags) & ~(GENL_CMD_CAP_DO |
> --
> 2.41.0
next prev parent reply other threads:[~2023-07-21 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 11:13 [patch net-next] genetlink: add explicit ordering break check for split ops Jiri Pirko
2023-07-21 2:32 ` Jakub Kicinski
2023-07-21 16:45 ` Keller, Jacob E [this message]
2023-07-22 2:10 ` patchwork-bot+netdevbpf
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=CO1PR11MB5089ADDBFA04502A6F7D56ABD63FA@CO1PR11MB5089.namprd11.prod.outlook.com \
--to=jacob.e.keller@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).