All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH 1/9] Bluetooth: HIDP: Fix GET_REPORT and SET_REPORT for unnumbered reports
Date: Tue, 13 Oct 2026 03:57:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-168943@kernel.org> (raw)
In-Reply-To: <20261012-hid-core-report-validation-v1-1-e0dd5cb60b2e@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bluetooth: hidp: skb memory leak on timeout in hidp_get_raw_report()
--

commit 9c135d466dcba28a7f3598e00e865c9ade48ff0c
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Bluetooth: HIDP: Fix GET_REPORT and SET_REPORT for unnumbered reports

Adjust Bluetooth HIDP transport callbacks to adhere to the kernel HID
subsystem convention of using report ID 0 for unnumbered reports. When
fetching or setting an unnumbered report, the report ID is appended or
stripped to ensure correct lengths and formatting over the control channel.

> diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
> index f5bdf9f1ca638..004a8eed51fb1 100644
> --- a/net/bluetooth/hidp/core.c
> +++ b/net/bluetooth/hidp/core.c
[ ... ]
> @@ -302,11 +302,25 @@ static int hidp_get_raw_report(struct hid_device *hid,
>  		}
>  	}
>  

[Severity: Medium]
Does this code leak the sk_buff if a timeout or signal occurs concurrently
with the device response?

If wait_event_interruptible_timeout() in hidp_get_raw_report() times out or is
interrupted by a signal, it proceeds to the err label, which clears the
HIDP_WAITING_FOR_RETURN flag and unlocks the mutex without freeing
session->report_return.

Concurrently, if the device response arrives and is processed by
hidp_recv_ctrl_frame(), it can set session->report_return right as the timeout
occurs:

hidp_recv_ctrl_frame() {
        ...
        /* hidp_get_raw_report() is waiting on this report. */
        session->report_return = skb;
        done_with_skb = 0;
        clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
        wake_up_interruptible(&session->report_queue);
}

Because the error path does not check or free session->report_return, the
sk_buff is permanently leaked as subsequent requests will overwrite
session->report_return without freeing the old one.

> +	/*
> +	 * In case of unnumbered reports the response from the device will
> +	 * not have the report ID that the upper layers expect, so we need
> +	 * to stash it in the buffer ourselves and adjust the data size.
> +	 */
> +	if (!report_number) {
> +		data[0] = 0;
> +		data++;
> +		count--;
> +	}
> +
>  	skb = session->report_return;
>  	if (skb) {
> -		len = skb->len < count ? skb->len : count;
> +		len = min_t(size_t, skb->len, count);
>  		memcpy(data, skb->data, len);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-hid-core-report-validation-v1-0-e0dd5cb60b2e@gmail.com?part=1

  parent reply	other threads:[~2026-10-13  3:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  3:42 [PATCH 0/9] HID: Hardening report validation and unnumbered report handling Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 1/9] Bluetooth: HIDP: Fix GET_REPORT and SET_REPORT for unnumbered reports Dmitry Torokhov
2026-10-13  3:56   ` HID: Hardening report validation and unnumbered report handling bluez.test.bot
2026-10-13  3:57   ` sashiko-bot [this message]
2026-10-13  3:42 ` [PATCH 2/9] HID: core: Fix GET_REPORT input processing for unnumbered reports Dmitry Torokhov
2026-10-13  4:00   ` sashiko-bot
2026-10-13  3:42 ` [PATCH 3/9] HID: core: Reject mixing numbered and " Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 4/9] HID: core: Validate GET_REPORT report ID centrally Dmitry Torokhov
2026-10-13  4:00   ` sashiko-bot
2026-10-13  3:42 ` [PATCH 5/9] HID: i2c-hid: Drop redundant report ID validation Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 6/9] HID: goodix-spi: " Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 7/9] HID: intel-thc-hid: Drop redundant report ID validation in quicki2c Dmitry Torokhov
2026-10-13  3:57   ` sashiko-bot
2026-10-13  3:42 ` [PATCH 8/9] HID: multitouch: Drop redundant report ID validation in mt_get_feature Dmitry Torokhov
2026-10-13  3:42 ` [PATCH 9/9] HID: playstation: Drop redundant report ID validation in ps_get_report Dmitry Torokhov

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=sashiko-outbox-168943@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.