All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: magicmouse: fix NULL-deref on disconnect
@ 2021-05-17 10:04 Johan Hovold
  2021-05-26 10:51 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2021-05-17 10:04 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Benjamin Tissoires, linux-input, linux-kernel, Johan Hovold,
	syzbot+ee6f6e2e68886ca256a8, stable, Claudio Mettler,
	Marek Wyborski, Sean O'Brien

Commit 9d7b18668956 ("HID: magicmouse: add support for Apple Magic
Trackpad 2") added a sanity check for an Apple trackpad but returned
success instead of -ENODEV when the check failed. This means that the
remove callback will dereference the never-initialised driver data
pointer when the driver is later unbound (e.g. on USB disconnect).

Reported-by: syzbot+ee6f6e2e68886ca256a8@syzkaller.appspotmail.com
Fixes: 9d7b18668956 ("HID: magicmouse: add support for Apple Magic Trackpad 2")
Cc: stable@vger.kernel.org      # 4.20
Cc: Claudio Mettler <claudio@ponyfleisch.ch>
Cc: Marek Wyborski <marek.wyborski@emwesoft.com>
Cc: Sean O'Brien <seobrien@chromium.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/hid/hid-magicmouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 2bb473d8c424..56dda50aa3d8 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -693,7 +693,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 	if (id->vendor == USB_VENDOR_ID_APPLE &&
 	    id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
 	    hdev->type != HID_TYPE_USBMOUSE)
-		return 0;
+		return -ENODEV;
 
 	msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
 	if (msc == NULL) {
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] HID: magicmouse: fix NULL-deref on disconnect
  2021-05-17 10:04 [PATCH] HID: magicmouse: fix NULL-deref on disconnect Johan Hovold
@ 2021-05-26 10:51 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2021-05-26 10:51 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Benjamin Tissoires, linux-input, linux-kernel,
	syzbot+ee6f6e2e68886ca256a8, stable, Claudio Mettler,
	Marek Wyborski, Sean O'Brien

On Mon, 17 May 2021, Johan Hovold wrote:

> Commit 9d7b18668956 ("HID: magicmouse: add support for Apple Magic
> Trackpad 2") added a sanity check for an Apple trackpad but returned
> success instead of -ENODEV when the check failed. This means that the
> remove callback will dereference the never-initialised driver data
> pointer when the driver is later unbound (e.g. on USB disconnect).
> 
> Reported-by: syzbot+ee6f6e2e68886ca256a8@syzkaller.appspotmail.com
> Fixes: 9d7b18668956 ("HID: magicmouse: add support for Apple Magic Trackpad 2")
> Cc: stable@vger.kernel.org      # 4.20
> Cc: Claudio Mettler <claudio@ponyfleisch.ch>
> Cc: Marek Wyborski <marek.wyborski@emwesoft.com>
> Cc: Sean O'Brien <seobrien@chromium.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied, thanks Johan.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-26 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 10:04 [PATCH] HID: magicmouse: fix NULL-deref on disconnect Johan Hovold
2021-05-26 10:51 ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.