All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: ebiederm@xmission.com (Eric W. Biederman)
Cc: Andrey Ignatov <rdna@fb.com>, <netdev@vger.kernel.org>,
	<davem@davemloft.net>, <kuba@kernel.org>, <kernel-team@fb.com>
Subject: Re: [PATCH net] rtnetlink: Return correct error on changing device netns
Date: Mon, 30 Aug 2021 07:59:48 -0700	[thread overview]
Message-ID: <20210830075948.73fda029@hermes.local> (raw)
In-Reply-To: <8735qwi3mt.fsf@disp2133>

On Thu, 26 Aug 2021 11:15:22 -0500
ebiederm@xmission.com (Eric W. Biederman) wrote:

> The analysis and the fix looks good to me.
> 
> The code calling do_setlink is inconsistent.  One caller of do_setlink
> passes a NULL to indicate not name has been specified.  Other callers
> pass a string of zero bytes to indicate no name has been specified.
> 
> I wonder if we might want to fix the callers to uniformly pass NULL,
> instead of a string of length zero.
> 
> There is a slight chance this will trigger a regression somewhere
> because we are changing the error code but this change looks easy enough
> to revert in the unlikely event this breaks existing userspace.
> 
> Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>

This patch causes a new warning from Coverity:
________________________________________________________________________________________________________
*** CID 1490867:  Null pointer dereferences  (FORWARD_NULL)
/net/core/rtnetlink.c: 2701 in do_setlink()
2695     
2696     	/*
2697     	 * Interface selected by interface index but interface
2698     	 * name provided implies that a name change has been
2699     	 * requested.
2700     	 */
>>>     CID 1490867:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "ifname".  
2701     	if (ifm->ifi_index > 0 && ifname[0]) {
2702     		err = dev_change_name(dev, ifname);
2703     		if (err < 0)
2704     			goto errout;
2705     		status |= DO_SETLINK_MODIFIED;
2706     

Originally, the code was not accepting ifname == NULL and would
crash. Somewhere along the way some new callers seem to have gotten
confused.

What code is call do_setlink() with NULL as ifname, that should be fixed.

  reply	other threads:[~2021-08-30 15:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26  0:25 [PATCH net] rtnetlink: Return correct error on changing device netns Andrey Ignatov
2021-08-26 11:10 ` patchwork-bot+netdevbpf
2021-08-26 16:15 ` Eric W. Biederman
2021-08-30 14:59   ` Stephen Hemminger [this message]
2021-08-30 16:43     ` 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=20210830075948.73fda029@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=kernel-team@fb.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rdna@fb.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.