From: Alec Hall <signshop.alec@gmail.com>
To: pepemontfort@gmail.com
Cc: jikos@kernel.org, bentiss@kernel.org,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Alec Hall <signshop.alec@gmail.com>
Subject: Re: [PATCH v2] HID: magicmouse: avoid NULL pointer deref when there is no input device
Date: Sun, 2 Aug 2026 23:37:09 -0400 [thread overview]
Message-ID: <20260803033711.17170-1-signshop.alec@gmail.com> (raw)
In-Reply-To: <20260728184059.688513-1-pepemontfort@gmail.com>
On Tue, Jul 28, 2026, Jose Villaseñor Montfort wrote:
> Bail out of both callbacks when msc->input is NULL and leave the report
> to the generic HID paths, which is what those interfaces get today.
> Rejecting the bind in magicmouse_probe() instead would unbind interfaces
> that a healthy device legitimately exposes and drop their hidraw nodes.
Apologies for the near-week delay in getting back to you -- I was away on
an anniversary trip and without physical access to the test machine for
part of it, which this needed. Sorry to have left you waiting.
This is the right shape, and thanks for turning the v1 report around so
quickly. Both callbacks return 0, so reports on the input-less interfaces
keep flowing through the generic HID paths exactly as they do today, and
nothing about which interfaces bind changes.
Your ->event analysis holds up on a read of the code: hid_process_event()
calls ->event before the HID_CLAIMED_INPUT test, and with no usage_table
in this driver hid_match_usage() returns 1 for every usage, so the guard
in magicmouse_event() is doing real work rather than being defensive.
Tested on a Magic Trackpad 2 (05ac:0265) on 7.1.5, over both transports.
My tree carries the DOUBLE_REPORT_ID recursion fix [1], so the raw_event
guard went into __magicmouse_raw_event() -- the trivial rebase you
described; it sits above the size check, as in your patch.
Over USB all four HID interfaces bind to magicmouse and keep their nodes:
0003:05AC:0265.0014 input48 hiddev102,hidraw7
0003:05AC:0265.0015 input49 hiddev109,hidraw15
0003:05AC:0265.0016 <none> hiddev110,hidraw16
0003:05AC:0265.0017 <none> hiddev111,hidraw17
Interfaces 2 and 3 bind with msc->input == NULL, as they always have, and
there are no probe failures in dmesg -- the two "magicmouse input not
registered" lines per plug that v1 produced are gone. Pointer motion,
multi-finger gestures and clicks are unchanged, and the battery reads
74% "Charging" while cabled.
Over Bluetooth the trackpad reconnects and behaves the same, battery 74%
"Discharging" after unplugging, and a Magic Keyboard on the same host is
unaffected. No splats or call traces in dmesg on either transport.
Reviewed-by: Alec Hall <signshop.alec@gmail.com>
Tested-by: Alec Hall <signshop.alec@gmail.com>
[1] https://lore.kernel.org/linux-input/20260715053526.574725-1-pepemontfort@gmail.com/
next prev parent reply other threads:[~2026-08-03 3:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 19:58 [PATCH] HID: magicmouse: reject devices that bind without an input device Jose Villaseñor Montfort
2026-07-28 7:25 ` Alec Hall
2026-07-28 18:37 ` Jose Villaseñor Montfort
2026-07-28 18:40 ` [PATCH v2] HID: magicmouse: avoid NULL pointer deref when there is no " Jose Villaseñor Montfort
2026-07-28 18:55 ` sashiko-bot
2026-07-29 4:07 ` Jose Villaseñor Montfort
2026-08-03 3:37 ` Alec Hall [this message]
2026-08-04 2:50 ` Jose Villaseñor Montfort
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=20260803033711.17170-1-signshop.alec@gmail.com \
--to=signshop.alec@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pepemontfort@gmail.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