psmouse_disconnect lockdep splat

Started by Borislav Petkov on Aug 28, 2016 · 3 messages from 2 authors · Last reply Oct 28, 2017

open the first message on its own page

Message details and related content
Hi,

just saw this while booting rc3+tip/master. Thought I should report it
in case it hasn't been caught and fixed yet.

---

...
[    6.257924] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12
[    6.280232] iTCO_vendor_support: vendor-support=0
[    6.282063] snd_hda_intel 0000:00:1b.0: bound 0000:00:02.0 (ops i915_audio_component_bind_ops)
[    6.285810] psmouse serio2: Failed to deactivate mouse on synaptics-pt/serio0
[    6.286331] iTCO_wdt: Intel TCO WatchDog Timer Driver v1.11
[    6.286392] iTCO_wdt: Found a Panther Point TCO device (Version=2, TCOBASE=0x0460)
[    6.290473] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
[    6.293635] input: HDA Intel PCH Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
[    6.298520] input: HDA Intel PCH Dock Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
[    6.300605] iTCO_wdt: initialized. heartbeat=30 sec (nowayout=0)
[    6.303861] input: HDA Intel PCH Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
[    6.307117] input: HDA Intel PCH Dock Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
[    6.310045] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
[    6.311645] input: HDA Intel PCH HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input16
[    6.312865] input: HDA Intel PCH HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input17
[    6.346990] usb 1-1: New USB device found, idVendor=8087, idProduct=0024
[    6.348316] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    6.350870] hub 1-1:1.0: USB hub found
[    6.352530] hub 1-1:1.0: 6 ports detected
[    6.390558] usb 2-1: New USB device found, idVendor=8087, idProduct=0024
[    6.391706] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    6.393209] hub 2-1:1.0: USB hub found
[    6.394534] hub 2-1:1.0: 8 ports detected
[    6.415139] random: crng init done
[    6.590812] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[    6.749939] psmouse serio2: Failed to enable mouse on synaptics-pt/serio0

[    7.000430] ======================================================
[    7.001447] [ INFO: possible circular locking dependency detected ]
[    7.002453] 4.8.0-rc3+ #1 Not tainted
[    7.003420] -------------------------------------------------------
[    7.004366] kworker/0:1/45 is trying to acquire lock:

115 more lines

Message details and related content
Adding more people to CC.

I still see this after 4.8 is out.

So PeterZ suggested something like this:

---
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index fb4b185dea96..9112c3cecad7 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1420,14 +1420,16 @@ static void psmouse_disconnect(struct serio *serio)
 		psmouse_deactivate(parent);
 	}
 
-	if (psmouse->disconnect)
-		psmouse->disconnect(psmouse);
-
 	if (parent && parent->pt_deactivate)
 		parent->pt_deactivate(parent);
 
 	psmouse_set_state(psmouse, PSMOUSE_IGNORE);
 
+	mutex_unlock(&psmouse_mutex);
+	if (psmouse->disconnect)
+		psmouse->disconnect(psmouse);
+	mutex_lock(&psmouse_mutex);
+
 	serio_close(serio);
 	serio_set_drvdata(serio, NULL);
 	input_unregister_device(psmouse->dev);
---
to fix the lock inversion but that might have the other problem of
being racy by maybe ->reconnect() accessing psmouse->private in
trackpoint_sync() outside of the psmouse_mutex lock and that won't be
nice.

But someone more knowledgeable with this code should take a look and
suggest a proper fix.

Thanks!

(Leaving in the rest for reference).

On Sun, Aug 28, 2016 at 11:30:11AM +0200, Borislav Petkov wrote:
Hi,

just saw this while booting rc3+tip/master. Thought I should report it
in case it hasn't been caught and fixed yet.

---

...
[    6.257924] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12
[    6.280232] iTCO_vendor_support: vendor-support=0
[    6.282063] snd_hda_intel 0000:00:1b.0: bound 0000:00:02.0 (ops i915_audio_component_bind_ops)
[    6.285810] psmouse serio2: Failed to deactivate mouse on synaptics-pt/serio0
[    6.286331] iTCO_wdt: Intel TCO WatchDog Timer Driver v1.11
[    6.286392] iTCO_wdt: Found a Panther Point TCO device (Version=2, TCOBASE=0x0460)
[    6.290473] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
[    6.293635] input: HDA Intel PCH Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
[    6.298520] input: HDA Intel PCH Dock Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
[    6.300605] iTCO_wdt: initialized. heartbeat=30 sec (nowayout=0)
[    6.303861] input: HDA Intel PCH Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
[    6.307117] input: HDA Intel PCH Dock Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
[    6.310045] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
[    6.311645] input: HDA Intel PCH HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input16
[    6.312865] input: HDA Intel PCH HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input17
[    6.346990] usb 1-1: New USB device found, idVendor=8087, idProduct=0024
[    6.348316] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    6.350870] hub 1-1:1.0: USB hub found
[    6.352530] hub 1-1:1.0: 6 ports detected
[    6.390558] usb 2-1: New USB device found, idVendor=8087, idProduct=0024
[    6.391706] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    6.393209] hub 2-1:1.0: USB hub found
[    6.394534] hub 2-1:1.0: 8 ports detected
[    6.415139] random: crng init done
[    6.590812] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[    6.749939] psmouse serio2: Failed to enable mouse on synaptics-pt/serio0

[    7.000430] ======================================================
[    7.001447] [ INFO: possible circular locking dependency detected ]
[    7.002453] 4.8.0-rc3+ #1 Not tainted
[    7.003420] -------------------------------------------------------
[    7.004366] kworker/0:1/45 is trying to acquire lock:

116 more quoted lines

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
Message details and related content
On Tue, Oct 18, 2016 at 02:09:22PM +0200, Borislav Petkov wrote:
quoted hunk
Adding more people to CC.

I still see this after 4.8 is out.

So PeterZ suggested something like this:

---
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index fb4b185dea96..9112c3cecad7 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1420,14 +1420,16 @@ static void psmouse_disconnect(struct serio *serio)
 		psmouse_deactivate(parent);
 	}
 
-	if (psmouse->disconnect)
-		psmouse->disconnect(psmouse);
-
 	if (parent && parent->pt_deactivate)
 		parent->pt_deactivate(parent);
 
 	psmouse_set_state(psmouse, PSMOUSE_IGNORE);
 
+	mutex_unlock(&psmouse_mutex);
+	if (psmouse->disconnect)
+		psmouse->disconnect(psmouse);
+	mutex_lock(&psmouse_mutex);
+
 	serio_close(serio);
 	serio_set_drvdata(serio, NULL);
 	input_unregister_device(psmouse->dev);
---
to fix the lock inversion but that might have the other problem of
being racy by maybe ->reconnect() accessing psmouse->private in
trackpoint_sync() outside of the psmouse_mutex lock and that won't be
nice.

But someone more knowledgeable with this code should take a look and
suggest a proper fix.

4 more quoted lines

The splat still persists on up-to-date kernel. See below. That's for
current -tip tree, but it's in mainline too.

Nobody cares?

======================================================
WARNING: possible circular locking dependency detected
4.14.0-rc6-00555-g34aa400565bc #151 Tainted: G        W      
------------------------------------------------------
kworker/0:1/38 is trying to acquire lock:
 (kn->count#188){++++}, at: [<ffffffff8233ba60>] kernfs_remove_by_name_ns+0x40/0x80

but task is already holding lock:
 (psmouse_mutex){+.+.}, at: [<ffffffff82805b37>] psmouse_disconnect+0x67/0x160

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (psmouse_mutex){+.+.}:
       __mutex_lock+0x85/0x960
       psmouse_attr_set_helper+0x2d/0x140
       kernfs_fop_write+0x112/0x1a0
       __vfs_write+0x23/0x130
       vfs_write+0xc9/0x1d0
       SyS_write+0x45/0xb0
       entry_SYSCALL_64_fastpath+0x23/0xc2

-> #0 (kn->count#188){++++}:
       lock_acquire+0xc1/0x220
       __kernfs_remove+0x248/0x2b0
       kernfs_remove_by_name_ns+0x40/0x80
       remove_files.isra.0+0x31/0x70
       sysfs_remove_group+0x3d/0x80
       trackpoint_disconnect+0x20/0x40
       psmouse_disconnect+0x94/0x160
       serio_disconnect_driver+0x2d/0x40
       serio_driver_remove+0x11/0x20

64 more lines

Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help