From: Bastien Nocera <hadess@hadess.net>
To: Eric-Terminal <ericterminal@gmail.com>,
marcel@holtmann.org, johan.hedberg@gmail.com,
luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org
Subject: Re: [PATCH v2] Bluetooth: HIDP: cap report descriptor size in HID setup
Date: Sun, 01 Mar 2026 10:19:19 +0100 [thread overview]
Message-ID: <ee5fc583c7d6dad138db759cddd84e409190d1ae.camel@hadess.net> (raw)
In-Reply-To: <20260228172657.53040-1-ericterminal@gmail.com>
On Sun, 2026-03-01 at 01:26 +0800, Eric-Terminal wrote:
> From: Yufan Chen <ericterminal@gmail.com>
>
> hidp_setup_hid() duplicates the report descriptor from userspace
> based on
> req->rd_size. Large values can trigger oversized copies.
>
> Do not reject the connection when rd_size exceeds
> HID_MAX_DESCRIPTOR_SIZE. Instead, cap rd_size in hidp_setup_hid()
> and use the capped value for memdup_user() and session->rd_size.
>
> This keeps compatibility with existing userspace behavior while
> bounding memory usage in the HID setup path.
Cross-sending this to linux-input@ for review, they would know the best
way to deal with oversized HID descriptors.
>
> Signed-off-by: Yufan Chen <ericterminal@gmail.com>
> ---
> net/bluetooth/hidp/core.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
> index 6fe815241..31aeffa39 100644
> --- a/net/bluetooth/hidp/core.c
> +++ b/net/bluetooth/hidp/core.c
> @@ -755,13 +755,16 @@ static int hidp_setup_hid(struct hidp_session
> *session,
> const struct hidp_connadd_req *req)
> {
> struct hid_device *hid;
> + unsigned int rd_size;
> int err;
>
> - session->rd_data = memdup_user(req->rd_data, req->rd_size);
> + rd_size = min_t(unsigned int, req->rd_size,
> HID_MAX_DESCRIPTOR_SIZE);
> +
> + session->rd_data = memdup_user(req->rd_data, rd_size);
> if (IS_ERR(session->rd_data))
> return PTR_ERR(session->rd_data);
>
> - session->rd_size = req->rd_size;
> + session->rd_size = rd_size;
>
> hid = hid_allocate_device();
> if (IS_ERR(hid)) {
next prev parent reply other threads:[~2026-03-01 9:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 1:35 [PATCH] Bluetooth: HIDP: reject oversized report descriptor Eric-Terminal
2026-02-27 15:04 ` Luiz Augusto von Dentz
2026-02-28 17:26 ` [PATCH v2] Bluetooth: HIDP: cap report descriptor size in HID setup Eric-Terminal
2026-03-01 9:19 ` Bastien Nocera [this message]
2026-03-11 10:18 ` Benjamin Tissoires
2026-03-22 15:37 ` Eric_Terminal
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=ee5fc583c7d6dad138db759cddd84e409190d1ae.camel@hadess.net \
--to=hadess@hadess.net \
--cc=ericterminal@gmail.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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
Powered by JetHome