netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
To: torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org
Cc: bjorn-yOkvZcmFvRU@public.gmane.org,
	oneukum-IBi9RG/b67k@public.gmane.org,
	andreyknvl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	glider-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	kcc-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Possible double-free in the usbnet driver
Date: Mon, 07 Mar 2016 14:11:00 -0500 (EST)	[thread overview]
Message-ID: <20160307.141100.1511700720120062677.davem@davemloft.net> (raw)
In-Reply-To: <CA+55aFw43uKkUK-h=VMwXcb9NM+g2AdeB960kWb4YihmjQ8DRw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

From: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Date: Mon, 7 Mar 2016 10:13:09 -0800

> On Sat, Mar 5, 2016 at 11:53 AM, Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org> wrote:
>>
>>
>> Definitely.  The patch is so obviously correct that we can only wonder how it was possible to miss it it the first place :)
>>
>> Will take a look to see if we could do a better job cleaning up in other places.
> 
> What should I do for 4.5? Will there be a pull request for this, or
> should I just commit my cdc_ncm_bind() patch directly?

Yes I plan to send you a pull request today with Oliver's fix.

Assuming this is what you guys are referring to:

commit 1666984c8625b3db19a9abc298931d35ab7bc64b
Author: Oliver Neukum <oneukum-IBi9RG/b67k@public.gmane.org>
Date:   Mon Mar 7 11:31:10 2016 +0100

    usbnet: cleanup after bind() in probe()
    
    In case bind() works, but a later error forces bailing
    in probe() in error cases work and a timer may be scheduled.
    They must be killed. This fixes an error case related to
    the double free reported in
    http://www.spinics.net/lists/netdev/msg367669.html
    and needs to go on top of Linus' fix to cdc-ncm.
    
    Signed-off-by: Oliver Neukum <ONeukum-IBi9RG/b67k@public.gmane.org>
    Signed-off-by: David S. Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 0b0ba7e..1079812 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1769,6 +1769,13 @@ out3:
 	if (info->unbind)
 		info->unbind (dev, udev);
 out1:
+	/* subdrivers must undo all they did in bind() if they
+	 * fail it, but we may fail later and a deferred kevent
+	 * may trigger an error resubmitting itself and, worse,
+	 * schedule a timer. So we kill it all just in case.
+	 */
+	cancel_work_sync(&dev->kevent);
+	del_timer_sync(&dev->delay);
 	free_netdev(net);
 out:
 	return status;
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-03-07 19:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 21:26 Possible double-free in the usbnet driver Linus Torvalds
     [not found] ` <CA+55aFxqwjs5gs6Fw2jmTteWM4hZTnr7Ls111ExNTieObLs82Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-04 22:26   ` Andrey Konovalov
     [not found]     ` <CA+fCnZfS51F7WZEM1YTSPDMWSzvBTJWGf5cRWv5LrNCSOf_-qA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-04 22:42       ` Oliver Neukum
     [not found]         ` <1457131342.8935.2.camel-l3A5Bk7waGM@public.gmane.org>
2016-03-04 23:00           ` Andrey Konovalov
2016-03-04 23:22             ` Andrey Konovalov
2016-03-04 22:43     ` Linus Torvalds
2016-03-04 23:00       ` Andrey Konovalov
2016-03-05 15:51       ` Oliver Neukum
     [not found]         ` <1457193090.8935.7.camel-IBi9RG/b67k@public.gmane.org>
2016-03-05 19:53           ` Bjørn Mork
     [not found]             ` <DBDB517D-E4A4-4422-AECE-52194FE2AED0-yOkvZcmFvRU@public.gmane.org>
2016-03-07 18:13               ` Linus Torvalds
     [not found]                 ` <CA+55aFw43uKkUK-h=VMwXcb9NM+g2AdeB960kWb4YihmjQ8DRw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-07 19:11                   ` David Miller [this message]
     [not found]                     ` <20160307.141100.1511700720120062677.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2016-03-07 19:50                       ` Andrey Konovalov
     [not found]                         ` <CA+fCnZdurxGBsOrANb_m5BLK1BKzH3J_GmZ=dbH=ABThgFNGxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-07 19:54                           ` David Miller
2016-03-07 20:15                             ` [PATCH] cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind Bjørn Mork
     [not found]                               ` <87k2le815w.fsf_-_-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2016-03-07 20:58                                 ` David Miller
2016-03-08 19:43                               ` Linus Torvalds
     [not found]                                 ` <CA+55aFxt7zWW+-EkwCbAWCb9wkgVswYJNAz86bc_QRcv1pBHZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-08 20:12                                   ` Oliver Neukum
2016-03-08 20:18                                   ` Bjørn Mork
     [not found]                                     ` <871t7k7mgo.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2016-03-08 20:20                                       ` Oliver Neukum
2016-03-08 20:37                                     ` Ben Hutchings
2016-03-07 21:39                           ` Possible double-free in the usbnet driver Oliver Neukum
     [not found]                             ` <1457386754.3404.15.camel-IBi9RG/b67k@public.gmane.org>
2016-03-08 11:42                               ` Andrey Konovalov
     [not found]       ` <CA+55aFwxbs_hLG58Q_xSK2vpufjmwMk-xkqxTNh_5h-A8y4vbg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-07  9:08         ` Dmitry Vyukov

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=20160307.141100.1511700720120062677.davem@davemloft.net \
    --to=davem-ft/pcqaiutieiz0/mpfg9q@public.gmane.org \
    --cc=andreyknvl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=bjorn-yOkvZcmFvRU@public.gmane.org \
    --cc=dvyukov-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=glider-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=kcc-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=oneukum-IBi9RG/b67k@public.gmane.org \
    --cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    /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).