From: Paolo Abeni <pabeni@redhat.com>
To: Roded Zats <rzats@paloaltonetworks.com>,
benve@cisco.com, satishkh@cisco.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org
Cc: orcohen@paloaltonetworks.com, netdev@vger.kernel.org
Subject: Re: [PATCH net] enic: Validate length of nl attributes in enic_set_vf_port
Date: Tue, 21 May 2024 12:38:16 +0200 [thread overview]
Message-ID: <81d39fab6a85981b28329a67b454ca92e7e377f8.camel@redhat.com> (raw)
In-Reply-To: <20240516154248.33134-1-rzats@paloaltonetworks.com>
On Thu, 2024-05-16 at 18:42 +0300, Roded Zats wrote:
> enic_set_vf_port assumes that the nl attribute IFLA_PORT_PROFILE
> is of length PORT_PROFILE_MAX and that the nl attributes
> IFLA_PORT_INSTANCE_UUID, IFLA_PORT_HOST_UUID are of length PORT_UUID_MAX.
> These attributes are validated (in the function do_setlink in rtnetlink.c)
> using the nla_policy ifla_port_policy. The policy defines IFLA_PORT_PROFILE
> as NLA_STRING, IFLA_PORT_INSTANCE_UUID as NLA_BINARY and
> IFLA_PORT_HOST_UUID as NLA_STRING. That means that the length validation
> using the policy is for the max size of the attributes and not on exact
> size so the length of these attributes might be less than the sizes that
> enic_set_vf_port expects. This might cause an out of bands
> read access in the memcpys of the data of these
> attributes in enic_set_vf_port.
>
> Fixes: f8bd909183ac ("net: Add ndo_{set|get}_vf_port support for enic dynamic vnics")
> Signed-off-by: Roded Zats <rzats@paloaltonetworks.com>
> ---
> drivers/net/ethernet/cisco/enic/enic_main.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
> index f604119efc80..4179c6f9580d 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_main.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
> @@ -1117,18 +1117,30 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,
> pp->request = nla_get_u8(port[IFLA_PORT_REQUEST]);
>
> if (port[IFLA_PORT_PROFILE]) {
> + if (nla_len(port[IFLA_PORT_PROFILE]) != PORT_PROFILE_MAX) {
> + memcpy(pp, &prev_pp, sizeof(*pp));
> + return -EOPNOTSUPP;
I think -EOPNOTSUPP is misleading here (and below), -EINVAL should be
appropriate.
Thanks,
Paolo
next prev parent reply other threads:[~2024-05-21 10:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240516065755.6bce136f@kernel.org>
2024-05-16 15:42 ` [PATCH net] enic: Validate length of nl attributes in enic_set_vf_port Roded Zats
2024-05-21 10:38 ` Paolo Abeni [this message]
2024-05-22 7:30 ` [PATCH net v2] " Roded Zats
2024-05-27 9:42 ` patchwork-bot+netdevbpf
2024-06-27 23:20 ` Stephen Hemminger
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=81d39fab6a85981b28329a67b454ca92e7e377f8.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=orcohen@paloaltonetworks.com \
--cc=rzats@paloaltonetworks.com \
--cc=satishkh@cisco.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