netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: Tariq Toukan <tariqt@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Aya Levin <ayal@nvidia.com>,
	Gal Pressman <gal@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [PATCH net] net: ping6: Fix ping -6 with interface name
Date: Tue, 10 May 2022 14:27:18 -0600	[thread overview]
Message-ID: <c083d69e-2310-39d3-960b-1971f095463c@kernel.org> (raw)
In-Reply-To: <20220510172739.30823-1-tariqt@nvidia.com>

On 5/10/22 11:27 AM, Tariq Toukan wrote:
> From: Aya Levin <ayal@nvidia.com>
> 
> When passing interface parameter to ping -6:
> $ ping -6 ::11:141:84:9 -I eth2
> Results in:
> PING ::11:141:84:10(::11:141:84:10) from ::11:141:84:9 eth2: 56 data bytes
> ping: sendmsg: Invalid argument
> ping: sendmsg: Invalid argument
> 
> Initialize the fl6's outgoing interface (OIF) before triggering
> ip6_datagram_send_ctl.
> 
> Fixes: 13651224c00b ("net: ping6: support setting basic SOL_IPV6 options via cmsg")
> Signed-off-by: Aya Levin <ayal@nvidia.com>
> Reviewed-by: Gal Pressman <gal@nvidia.com>
> Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
>  net/ipv6/ping.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
> index ff033d16549e..83f014559c0d 100644
> --- a/net/ipv6/ping.c
> +++ b/net/ipv6/ping.c
> @@ -106,6 +106,8 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
>  
>  		opt.tot_len = sizeof(opt);
>  		ipc6.opt = &opt;
> +		memset(&fl6, 0, sizeof(fl6));
> +		fl6.flowi6_oif = oif;
>  
>  		err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, &fl6, &ipc6);
>  		if (err < 0)

I agree that fl6 is used unitialized here, but right after this is:

        memset(&fl6, 0, sizeof(fl6));

        fl6.flowi6_proto = IPPROTO_ICMPV6;
        fl6.saddr = np->saddr;
        fl6.daddr = *daddr;
        fl6.flowi6_oif = oif;

so adding a memset before the call to ip6_datagram_send_ctl duplicates
the existing one. Best to move the memset before the 'if
(msg->msg_controllen) {'

  reply	other threads:[~2022-05-10 20:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 17:27 [PATCH net] net: ping6: Fix ping -6 with interface name Tariq Toukan
2022-05-10 20:27 ` David Ahern [this message]
2022-05-12 13:02   ` Aya Levin

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=c083d69e-2310-39d3-960b-1971f095463c@kernel.org \
    --to=dsahern@kernel.org \
    --cc=ayal@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.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).