From: Davide Beatrici <me@davidebeatrici.dev>
To: Benjamin Tissoires <bentiss@kernel.org>
Cc: Terry Junge <linuxhid@cosmicgizmosystems.com>,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
jikos@kernel.org, benjamin.tissoires@redhat.com
Subject: Re: [PATCH] HID: validate report length and constants
Date: Thu, 04 Dec 2025 20:48:50 +0100 [thread overview]
Message-ID: <b3131f6c322ac4c62c4b00142b55fde7@davidebeatrici.dev> (raw)
In-Reply-To: <dob7q77qxuv3rmr4kliqp5kic36updvh6qxj4ld2be353zi7ba@5qte5m5fsuwy>
> However, the device also shows an output report of size 1, but it is
> not
> supposed to send it as an input report. I wonder if the firmware bug is
> not that it tries to give the host the current state of its output
> report at plug (which is wrong but Windows must be papering over it).
On that note, I noticed the malformed packet is not sent upon
reconnecting the
device if it's been plugged in for some time.
When that happens I can reproduce the issue by enabling a wireless mode
through
the switch on the bottom and wait a bit before disabling it and
connecting the
device again.
I suspect the battery gets slightly discharged and the device sends a
"charging complete" signal or something.
> - the URB is of size 1, so the fact that the constant field is not 0
> means that we are just reading random memory at offset 1 in the
> provided data, so you might have a chance that it eventually becomes 0
Good point, if it's effectively random memory we cannot rely on that.
> - the fix should be focusing on the length of the provided report, not
> on the content. However, in hid_report_raw_event(), just before you
> inserted your call to your hid_validate_report(), there is already a
> check on the length of the report which memsets to 0 the rest of the
> buffer. This seems a little bit optimistic if the provided buffer from
> USB is exactly the size of the provided "size" argument.
> But then, why would you get random data in the const fields if there
> is a memset if the provided length is "1"?
>
> So, can you add a printk before your call to hid_validate_report() to
> show the provided "size" argument (csize), or just enable the hid_dbg()
> trace output which should tell us if we enter that test and do the
> memset (which I suppose we are not).
report 8 has csize=16 rsize=16
report 0 has csize=1 rsize=8
report 0 is too short, (1 < 8)
Which means we do enter the test and execute the memset()...
next prev parent reply other threads:[~2025-12-04 19:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 5:36 Davide Beatrici
2025-12-02 8:22 ` Benjamin Tissoires
2025-12-02 19:41 ` Davide Beatrici
2025-12-02 21:40 ` Terry Junge
2025-12-02 21:54 ` Davide Beatrici
2025-12-04 9:53 ` Benjamin Tissoires
2025-12-04 19:48 ` Davide Beatrici [this message]
2025-12-04 23:43 ` Davide Beatrici
2025-12-08 8:54 ` Benjamin Tissoires
2025-12-12 6:22 ` Davide Beatrici
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=b3131f6c322ac4c62c4b00142b55fde7@davidebeatrici.dev \
--to=me@davidebeatrici.dev \
--cc=benjamin.tissoires@redhat.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxhid@cosmicgizmosystems.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
all inboxes | Powered by JetHome®