[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210830094301.4f6ada72@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Mon, 30 Aug 2021 09:43:01 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: ebiederm@...ssion.com (Eric W. Biederman),
Andrey Ignatov <rdna@...com>, <netdev@...r.kernel.org>,
<davem@...emloft.net>, <kernel-team@...com>
Subject: Re: [PATCH net] rtnetlink: Return correct error on changing device
netns
On Mon, 30 Aug 2021 07:59:48 -0700 Stephen Hemminger wrote:
> On Thu, 26 Aug 2021 11:15:22 -0500
> ebiederm@...ssion.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@...ssion.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 */
> [...]
> 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.
It's a false positive. There's only one caller with ifname=NULL:
static int rtnl_group_changelink(const struct sk_buff *skb,
...
err = do_setlink(skb, dev, ifm, extack, tb, NULL, 0);
if (err < 0)
return err;
Which has one caller, under this condition:
if (ifm->ifi_index == 0 && tb[IFLA_GROUP])
return rtnl_group_changelink(skb, net, ...
condition which excludes evaluating the check in question:
if (ifm->ifi_index > 0 && ifname[0]) {
err = dev_change_name(dev, ifname);
Proving ifm->ifi_index has to be 0 for ifname to be NULL.
Powered by blists - more mailing lists