linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, Denis Kirjanov <kda@linux-powerpc.org>,
	"Felipe Balbi" <felipe.balbi@linux.intel.com>,
	"Kiruthika Varadarajan" <Kiruthika.Varadarajan@harman.com>
Subject: [PATCH 3.16 15/47] usb: gadget: ether: Fix race between gether_disconnect and rx_submit
Date: Fri, 25 Oct 2019 19:03:16 +0100	[thread overview]
Message-ID: <lsq.1572026582.212582703@decadent.org.uk> (raw)
In-Reply-To: <lsq.1572026581.992411028@decadent.org.uk>

3.16.76-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Kiruthika Varadarajan <Kiruthika.Varadarajan@harman.com>

commit d29fcf7078bc8be2b6366cbd4418265b53c94fac upstream.

On spin lock release in rx_submit, gether_disconnect get a chance to
run, it makes port_usb NULL, rx_submit access NULL port USB, hence null
pointer crash.

Fixed by releasing the lock in rx_submit after port_usb is used.

Fixes: 2b3d942c4878 ("usb ethernet gadget: split out network core")
Signed-off-by: Kiruthika Varadarajan <Kiruthika.Varadarajan@harman.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
[bwh: Backported to 3.16: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/usb/gadget/u_ether.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -202,11 +202,12 @@ rx_submit(struct eth_dev *dev, struct us
 		out = dev->port_usb->out_ep;
 	else
 		out = NULL;
-	spin_unlock_irqrestore(&dev->lock, flags);
 
 	if (!out)
+	{
+		spin_unlock_irqrestore(&dev->lock, flags);
 		return -ENOTCONN;
-
+	}
 
 	/* Padding up to RX_EXTRA handles minor disagreements with host.
 	 * Normally we use the USB "terminate on short read" convention;
@@ -227,6 +228,7 @@ rx_submit(struct eth_dev *dev, struct us
 
 	if (dev->port_usb->is_fixed)
 		size = max_t(size_t, size, dev->port_usb->fixed_out_len);
+	spin_unlock_irqrestore(&dev->lock, flags);
 
 	skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags);
 	if (skb == NULL) {


  parent reply	other threads:[~2019-10-25 18:08 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 18:03 [PATCH 3.16 00/47] 3.16.76-rc1 review Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 01/47] eCryptfs: fix a couple type promotion bugs Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 02/47] ARM: riscpc: fix DMA Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 03/47] 9p/virtio: Add cleanup path in p9_virtio_init Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 04/47] tty: serial: cpm_uart - fix init when SMC is relocated Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 05/47] signal/pid_namespace: Fix reboot_pid_ns to use send_sig not force_sig Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 06/47] xfrm: Fix xfrm sel prefix length validation Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 07/47] af_key: fix leaks in key_pol_get_resp and dump_sp Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 08/47] crypto: talitos - check AES key size Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 09/47] crypto: ghash - fix unaligned memory access in ghash_setkey() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 10/47] s390/qdio: handle PENDING state for QEBSM devices Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 11/47] memstick: Fix error cleanup path of memstick_init Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 12/47] gpio: omap: fix lack of irqstatus_raw0 for OMAP4 Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 13/47] xfrm: fix sa selector validation Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 14/47] PCI: Do not poll for PME if the device is in D3cold Ben Hutchings
2019-10-25 18:03 ` Ben Hutchings [this message]
2019-10-25 18:03 ` [PATCH 3.16 16/47] powerpc/32s: fix suspend/resume when IBATs 4-7 are used Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 17/47] powerpc/watchpoint: Restore NV GPRs while returning from exception Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 18/47] USB: serial: option: add GosunCn ZTE WeLink ME3630 Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 19/47] USB: serial: option: add support for GosunCn ME3630 RNDIS mode Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 20/47] s390: fix stfle zero padding Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 21/47] VMCI: Fix integer overflow in VMCI handle arrays Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 22/47] mwifiex: Don't abort on small, spec-compliant vendor IEs Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 23/47] mwifiex: fix 802.11n/WPA detection Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 24/47] media: v4l2: Test type instead of cfg->type in v4l2_ctrl_new_custom() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 25/47] EDAC: Fix global-out-of-bounds write when setting edac_mc_poll_msec Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 26/47] carl9170: fix misuse of device driver API Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 27/47] x86/ptrace: Fix possible spectre-v1 in ptrace_get_debugreg() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 28/47] x86/tls: Fix possible spectre-v1 in do_get_thread_area() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 29/47] USB: serial: ftdi_sio: add ID for isodebug v1 Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 30/47] igmp: fix memory leak in igmpv3_del_delrec() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 31/47] s390/qdio: (re-)initialize tiqdio list entries Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 32/47] s390/qdio: don't touch the dsci in tiqdio_add_input_queues() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 33/47] net: bridge: stp: don't cache eth dest pointer before skb pull Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 34/47] lib/scatterlist: Fix mapping iterator when sg->offset is greater than PAGE_SIZE Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 35/47] bonding: validate ip header before check IPPROTO_IGMP Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 36/47] NFSv4: Handle the special Linux file open access mode Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 37/47] ARC: hide unused function unw_hdr_alloc Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 38/47] udf: Fix incorrect final NOT_ALLOCATED (hole) extent length Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 39/47] mm/mmu_notifier: use hlist_add_head_rcu() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 40/47] net: neigh: fix multiple neigh timer scheduling Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 41/47] ALSA: seq: Break too long mutex context in the write loop Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 42/47] coda: pass the host file in vma->vm_file on mmap Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 43/47] caif-hsi: fix possible deadlock in cfhsi_exit_module() Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 44/47] parisc: Fix kernel panic due invalid values in IAOQ0 or IAOQ1 Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 45/47] padata: use smp_mb in padata_reorder to avoid orphaned padata jobs Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 46/47] Input: psmouse - fix build error of multiple definition Ben Hutchings
2019-10-25 18:03 ` [PATCH 3.16 47/47] KVM: x86/vPMU: refine kvm_pmu err msg when event creation failed Ben Hutchings
2019-10-25 19:05   ` Joe Perches
2019-10-31 22:14     ` Ben Hutchings
2019-10-31 22:53       ` Joe Perches
2019-10-31 22:56         ` Paolo Bonzini
2019-11-01  8:07         ` Sasha Levin
2019-11-01 15:40           ` Joe Perches
2019-11-02  7:39             ` Sasha Levin
2019-10-26  1:35 ` [PATCH 3.16 00/47] 3.16.76-rc1 review Guenter Roeck
2019-10-26 18:00   ` Ben Hutchings

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=lsq.1572026582.212582703@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=Kiruthika.Varadarajan@harman.com \
    --cc=akpm@linux-foundation.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=kda@linux-powerpc.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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).