All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: Natalia Petrova <n.petrova@fintech.ru>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>
Cc: lvc-project@linuxtesting.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	intel-wired-lan@lists.osuosl.org,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Intel-wired-lan] [PATCH v3] i40e: Add checking for null for nlmsg_find_attr()
Date: Thu, 2 Feb 2023 09:23:09 -0800	[thread overview]
Message-ID: <b285cdee-b591-5266-5a74-e8c08b034f76@intel.com> (raw)
In-Reply-To: <20230201090610.52782-1-n.petrova@fintech.ru>

On 2/1/2023 1:06 AM, Natalia Petrova wrote:
> The result of nlmsg_find_attr() 'br_spec' is dereferenced in
> nla_for_each_nested(), but it can take NULL value in nla_find() function,
> which will result in an error.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 51616018dd1b ("i40e: Add support for getlink, setlink ndo ops")
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> ---

Thanks for the patch. I've applied it, however, for the future if you 
could specify the target tree. Simon mentioned it in v2, but his example 
omitted the tree.

i.e.
[PATCH v3 net] i40e: Add checking for null for nlmsg_find_attr()

Thanks,
Tony

> v3: Fixed mailing list.
> v2: The remark about the error code by Simon Horman <simon.horman@corigine.com>
> was taken into account; return value -ENOENT was changed to -EINVAL.
>   drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 53d0083e35da..4626d2a1af91 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -13167,6 +13167,8 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev,
>   	}
>   
>   	br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
> +	if (!br_spec)
> +		return -EINVAL;
>   
>   	nla_for_each_nested(attr, br_spec, rem) {
>   		__u16 mode;
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

WARNING: multiple messages have this Message-ID (diff)
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: Natalia Petrova <n.petrova@fintech.ru>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: Re: [PATCH v3] i40e: Add checking for null for nlmsg_find_attr()
Date: Thu, 2 Feb 2023 09:23:09 -0800	[thread overview]
Message-ID: <b285cdee-b591-5266-5a74-e8c08b034f76@intel.com> (raw)
In-Reply-To: <20230201090610.52782-1-n.petrova@fintech.ru>

On 2/1/2023 1:06 AM, Natalia Petrova wrote:
> The result of nlmsg_find_attr() 'br_spec' is dereferenced in
> nla_for_each_nested(), but it can take NULL value in nla_find() function,
> which will result in an error.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 51616018dd1b ("i40e: Add support for getlink, setlink ndo ops")
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> ---

Thanks for the patch. I've applied it, however, for the future if you 
could specify the target tree. Simon mentioned it in v2, but his example 
omitted the tree.

i.e.
[PATCH v3 net] i40e: Add checking for null for nlmsg_find_attr()

Thanks,
Tony

> v3: Fixed mailing list.
> v2: The remark about the error code by Simon Horman <simon.horman@corigine.com>
> was taken into account; return value -ENOENT was changed to -EINVAL.
>   drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 53d0083e35da..4626d2a1af91 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -13167,6 +13167,8 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev,
>   	}
>   
>   	br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
> +	if (!br_spec)
> +		return -EINVAL;
>   
>   	nla_for_each_nested(attr, br_spec, rem) {
>   		__u16 mode;

  reply	other threads:[~2023-02-02 17:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 14:13 [Intel-wired-lan] [PATCH] i40e: Add checking for null for nlmsg_find_attr() Natalia Petrova
2023-01-25 14:13 ` Natalia Petrova
2023-01-25 15:08 ` [Intel-wired-lan] " Simon Horman
2023-01-25 15:08   ` Simon Horman
2023-01-25 15:57 ` Deepak R Varma
2023-01-25 20:09 ` [Intel-wired-lan] " Paul Menzel
2023-01-25 20:09   ` Paul Menzel
2023-01-30 22:11 ` [Intel-wired-lan] [PATCH v2] " Natalia Petrova
2023-01-30 22:11   ` Natalia Petrova
2023-01-30 22:13   ` kernel test robot
2023-01-31  5:17   ` [Intel-wired-lan] " Greg Kroah-Hartman
2023-01-31  5:17     ` Greg Kroah-Hartman
2023-01-31 16:23     ` [Intel-wired-lan] " Simon Horman
2023-01-31 16:23       ` Simon Horman
2023-02-01  9:06 ` [Intel-wired-lan] [PATCH v3] " Natalia Petrova
2023-02-01  9:06   ` Natalia Petrova
2023-02-02 17:23   ` Tony Nguyen [this message]
2023-02-02 17:23     ` Tony Nguyen
2023-02-07 10:48   ` [Intel-wired-lan] " G, GurucharanX
2023-02-07 10:48     ` G, GurucharanX

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=b285cdee-b591-5266-5a74-e8c08b034f76@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=n.petrova@fintech.ru \
    --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 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.