linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	syzbot+784ccb935f9900cc7c9e@syzkaller.appspotmail.com,
	Alan Stern <stern@rowland.harvard.edu>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 4.19 53/87] HID: hiddev: Fix race in in hiddev_disconnect()
Date: Tue,  3 Mar 2020 18:43:44 +0100	[thread overview]
Message-ID: <20200303174355.132315650@linuxfoundation.org> (raw)
In-Reply-To: <20200303174349.075101355@linuxfoundation.org>

From: dan.carpenter@oracle.com <dan.carpenter@oracle.com>

commit 5c02c447eaeda29d3da121a2e17b97ccaf579b51 upstream.

Syzbot reports that "hiddev" is used after it's free in hiddev_disconnect().
The hiddev_disconnect() function sets "hiddev->exist = 0;" so
hiddev_release() can free it as soon as we drop the "existancelock"
lock.  This patch moves the mutex_unlock(&hiddev->existancelock) until
after we have finished using it.

Reported-by: syzbot+784ccb935f9900cc7c9e@syzkaller.appspotmail.com
Fixes: 7f77897ef2b6 ("HID: hiddev: fix potential use-after-free")
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hid/usbhid/hiddev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -954,9 +954,9 @@ void hiddev_disconnect(struct hid_device
 	hiddev->exist = 0;
 
 	if (hiddev->open) {
-		mutex_unlock(&hiddev->existancelock);
 		hid_hw_close(hiddev->hid);
 		wake_up_interruptible(&hiddev->wait);
+		mutex_unlock(&hiddev->existancelock);
 	} else {
 		mutex_unlock(&hiddev->existancelock);
 		kfree(hiddev);



  parent reply	other threads:[~2020-03-03 18:00 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 17:42 [PATCH 4.19 00/87] 4.19.108-stable review Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 01/87] irqchip/gic-v3-its: Fix misuse of GENMASK macro Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 02/87] iwlwifi: pcie: fix rb_allocator workqueue allocation Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 03/87] ipmi:ssif: Handle a possible NULL pointer reference Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 04/87] drm/msm: Set dma maximum segment size for mdss Greg Kroah-Hartman
2020-03-04 15:13   ` Pavel Machek
2020-03-04 17:18     ` Greg Kroah-Hartman
2020-03-09 10:14       ` [PATCH] drm/msm: fix leaks if initialization fails Pavel Machek
2020-03-10 21:03         ` Doug Anderson
2020-03-03 17:42 ` [PATCH 4.19 05/87] sched/core: Dont skip remote tick for idle CPUs Greg Kroah-Hartman
2020-03-04 15:15   ` Pavel Machek
2020-03-04 17:17     ` Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 06/87] dax: pass NOWAIT flag to iomap_apply Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 07/87] mac80211: consider more elements in parsing CRC Greg Kroah-Hartman
2020-03-03 17:42 ` [PATCH 4.19 08/87] cfg80211: check wiphy driver existence for drvinfo report Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 09/87] s390/zcrypt: fix card and queue total counter wrap Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 10/87] qmi_wwan: re-add DW5821e pre-production variant Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 11/87] qmi_wwan: unconditionally reject 2 ep interfaces Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 12/87] arm/ftrace: Fix BE text poking Greg Kroah-Hartman
2020-03-05 13:49   ` Pavel Machek
2020-03-05 14:53     ` Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 13/87] ARM: dts: sti: fixup sound frame-inversion for stihxxx-b2120.dtsi Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 14/87] soc/tegra: fuse: Fix build with Tegra194 configuration Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 15/87] net: ena: fix potential crash when rxfh key is NULL Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 16/87] net: ena: fix uses of round_jiffies() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 17/87] net: ena: add missing ethtool TX timestamping indication Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 18/87] net: ena: fix incorrect default RSS key Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 19/87] net: ena: rss: fix failure to get indirection table Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 20/87] net: ena: rss: store hash function as values and not bits Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 21/87] net: ena: fix incorrectly saving queue numbers when setting RSS indirection table Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 22/87] net: ena: ethtool: use correct value for crc32 hash Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 23/87] net: ena: ena-com.c: prevent NULL pointer dereference Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 24/87] cifs: Fix mode output in debugging statements Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 25/87] bcache: ignore pending signals when creating gc and allocator thread Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 26/87] cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 27/87] sysrq: Restore original console_loglevel when sysrq disabled Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 28/87] sysrq: Remove duplicated sysrq message Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 29/87] net: fib_rules: Correctly set table field when table number exceeds 8 bits Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 30/87] net: mscc: fix in frame extraction Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 31/87] net: phy: restore mdio regs in the iproc mdio driver Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 32/87] net: sched: correct flower port blocking Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 33/87] nfc: pn544: Fix occasional HW initialization failure Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 34/87] sctp: move the format error check out of __sctp_sf_do_9_1_abort Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 35/87] ipv6: Fix route replacement with dev-only route Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 36/87] ipv6: Fix nlmsg_flags when splitting a multipath route Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 37/87] qede: Fix race between rdma destroy workqueue and link change event Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 38/87] net/tls: Fix to avoid gettig invalid tls record Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 39/87] ext4: potential crash on allocation error in ext4_alloc_flex_bg_array() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 40/87] audit: fix error handling in audit_data_to_entry() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 41/87] ACPICA: Introduce ACPI_ACCESS_BYTE_WIDTH() macro Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 42/87] ACPI: watchdog: Fix gas->access_width usage Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 43/87] KVM: VMX: check descriptor table exits on instruction emulation Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 44/87] HID: ite: Only bind to keyboard USB interface on Acer SW5-012 keyboard dock Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 45/87] HID: core: fix off-by-one memset in hid_report_raw_event() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 46/87] HID: core: increase HID report buffer size to 8KiB Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 47/87] macintosh: therm_windtunnel: fix regression when instantiating devices Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 48/87] tracing: Disable trace_printk() on post poned tests Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 49/87] Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs" Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 50/87] amdgpu/gmc_v9: save/restore sdpif regs during S3 Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 51/87] vhost: Check docket sk_family instead of call getname Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 52/87] HID: alps: Fix an error handling path in alps_input_configured() Greg Kroah-Hartman
2020-03-03 17:43 ` Greg Kroah-Hartman [this message]
2020-03-03 17:43 ` [PATCH 4.19 54/87] MIPS: VPE: Fix a double free and a memory leak in release_vpe() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 55/87] i2c: altera: Fix potential integer overflow Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 56/87] i2c: jz4780: silence log flood on txabrt Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 57/87] drm/i915/gvt: Fix orphan vgpu dmabuf_objs lifetime Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 58/87] drm/i915/gvt: Separate display reset from ALL_ENGINES reset Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 59/87] hv_netvsc: Fix unwanted wakeup in netvsc_attach() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 60/87] usb: charger: assign specific number for enum value Greg Kroah-Hartman
2020-03-04 17:27   ` Pavel Machek
2020-03-04 17:39     ` Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 61/87] s390/qeth: vnicc Fix EOPNOTSUPP precedence Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 62/87] net: netlink: cap max groups which will be considered in netlink_bind() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 63/87] net: atlantic: fix use after free kasan warn Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 64/87] net: atlantic: fix potential error handling Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 65/87] net/smc: no peer ID in CLC decline for SMCD Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 66/87] net: ena: make ena rxfh support ETH_RSS_HASH_NO_CHANGE Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 67/87] namei: only return -ECHILD from follow_dotdot_rcu() Greg Kroah-Hartman
2020-03-03 17:43 ` [PATCH 4.19 68/87] mwifiex: drop most magic numbers from mwifiex_process_tdls_action_frame() Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 69/87] mwifiex: delete unused mwifiex_get_intf_num() Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 70/87] KVM: SVM: Override default MMIO mask if memory encryption is enabled Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 71/87] KVM: Check for a bad hva before dropping into the ghc slow path Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 72/87] sched/fair: Optimize update_blocked_averages() Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 73/87] sched/fair: Fix O(nr_cgroups) in the load balancing path Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 74/87] perf stat: Use perf_evsel__is_clocki() for clock events Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 75/87] perf stat: Fix shadow stats " Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 76/87] drivers: net: xgene: Fix the order of the arguments of alloc_etherdev_mqs() Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 77/87] kprobes: Set unoptimized flag after unoptimizing code Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 78/87] pwm: omap-dmtimer: put_device() after of_find_device_by_node() Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 79/87] perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 80/87] KVM: x86: Remove spurious kvm_mmu_unload() from vcpu destruction path Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 81/87] KVM: x86: Remove spurious clearing of async #PF MSR Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 82/87] thermal: brcmstb_thermal: Do not use DT coefficients Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 83/87] netfilter: nft_tunnel: no need to call htons() when dumping ports Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 84/87] netfilter: nf_flowtable: fix documentation Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 85/87] padata: always acquire cpu_hotplug_lock before pinst->lock Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 86/87] mm/huge_memory.c: use head to check huge zero page Greg Kroah-Hartman
2020-03-03 17:44 ` [PATCH 4.19 87/87] mm, thp: fix defrag setting if newline is not used Greg Kroah-Hartman
2020-03-03 22:10 ` [PATCH 4.19 00/87] 4.19.108-stable review Jon Hunter
2020-03-03 23:18 ` shuah
2020-03-04  7:09 ` Naresh Kamboju
2020-03-04 16:52 ` Guenter Roeck

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=20200303174355.132315650@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=syzbot+784ccb935f9900cc7c9e@syzkaller.appspotmail.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).