linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xianying Wang <wangxianying546@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [BUG] general protection fault in input_unregister_device
Date: Tue, 27 May 2025 16:21:40 +0800	[thread overview]
Message-ID: <CAOU40uDDL9-ivR=8nx67T9_j+1+2dCXNyBUqFvOPyv0cpPr5Yg@mail.gmail.com> (raw)

Hi,

I discovered a kernel crash described as "general protection fault in
input_unregister_device." The crash occurs in the input subsystem,
specifically in the function input_unregister_device
(drivers/input/input.c:2500), due to dereferencing a non-canonical
address, resulting in a general protection fault.

According to the crash report, the faulting address is
0xdffffc00000000a4, which corresponds to a KASAN shadow memory region.
The crash is triggered when mac_hid_toggle_emumouse calls
mac_hid_stop_emulation, which in turn invokes
mac_hid_destroy_emumouse, eventually leading to a call to
input_unregister_device with an invalid or uninitialized input_dev
pointer.

The report indicates that a corrupted or NULL input_dev structure was
passed into input_unregister_device, possibly due to a use-after-free,
double unregister, or incomplete initialization in the emumouse path
in mac_hid.

This can be reproduced on:

HEAD commit:

commit adc218676eef25575469234709c2d87185ca223a

report: https://pastebin.com/raw/4TeX6E8M

console output : https://pastebin.com/raw/ZE2AZ1Gq

kernel config : https://pastebin.com/raw/BpCtvUt2

C reproducer :

part1:https://pastebin.com/raw/jhU9v99k

part2:https://pastebin.com/raw/dcaKCHZ1

part3:https://pastebin.com/raw/CzgGBb7C

part4:https://pastebin.com/raw/MnwtYcjd

part5:https://pastebin.com/raw/VE8xNmHT

Best regards,

Xianying

             reply	other threads:[~2025-05-27  8:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27  8:21 Xianying Wang [this message]
2025-05-27 21:02 ` [BUG] general protection fault in input_unregister_device Dmitry Torokhov
2025-05-28 13:43   ` Xianying Wang

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='CAOU40uDDL9-ivR=8nx67T9_j+1+2dCXNyBUqFvOPyv0cpPr5Yg@mail.gmail.com' \
    --to=wangxianying546@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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).