From: sashiko-bot@kernel.org
To: "Jizhou Tong" <fqwqf@fqwqf.xyz>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [RFC PATCH v4 1/5] HID: spi-hid: isolate DMA transfers from protocol buffers
Date: Tue, 01 Dec 2026 04:19:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-242495@kernel.org> (raw)
In-Reply-To: <010601a22fcdfd0b-f430ecea-23d6-4a94-a299-80778f7e80ff-000000@ap-northeast-1.amazonses.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: spi-hid: field-spanning memcpy() into body in
spi_hid_input_sync()
--
commit 6f9ca8d0befdcf83f68834411f181c202482a7d3
Author: Jizhou Tong <fqwqf@fqwqf.xyz>
HID: spi-hid: isolate DMA transfers from protocol buffers
This commit allocates a separate DMA-aligned transfer buffer for SPI TX
and RX regions and copies protocol data into and out of it instead of
passing protocol buffer pointers directly to the SPI subsystem.
Link: https://lore.kernel.org/all/sashiko-outbox-199924@kernel.org/
> diff --git a/drivers/hid/spi-hid/spi-hid-core.c b/drivers/hid/spi-hid/spi-hid-core.c
> index f2b21066003cb..0754ce81c585f 100644
> --- a/drivers/hid/spi-hid/spi-hid-core.c
> +++ b/drivers/hid/spi-hid/spi-hid-core.c
[ ... ]
> @@ -193,14 +194,19 @@ static void spi_hid_populate_output_header(u8 *buf,
> static int spi_hid_input_sync(struct spi_hid *shid, void *buf, u16 length,
> bool is_header)
> {
> + u8 *rx = shid->xfer_buf + SPI_HID_RX_OFFSET;
> int error;
>
> - shid->input_transfer[0].tx_buf = is_header ?
> - shid->read_approval_header :
> - shid->read_approval_body;
> + if (length > shid->xfer_size - SPI_HID_RX_OFFSET)
> + return -EMSGSIZE;
> +
> + memcpy(shid->xfer_buf, is_header ? shid->read_approval_header :
> + shid->read_approval_body,
> + SPI_HID_READ_APPROVAL_LEN);
> + shid->input_transfer[0].tx_buf = shid->xfer_buf;
> shid->input_transfer[0].len = SPI_HID_READ_APPROVAL_LEN;
>
> - shid->input_transfer[1].rx_buf = buf;
> + shid->input_transfer[1].rx_buf = rx;
> shid->input_transfer[1].len = length;
>
> spi_message_init_with_transfers(&shid->input_message,
> @@ -217,12 +223,17 @@ static int spi_hid_input_sync(struct spi_hid *shid, void *buf, u16 length,
> return error;
> }
>
> + memcpy(buf, rx, length);
> return 0;
> }
[Severity: Medium]
Does this memcpy() trigger a CONFIG_FORTIFY_SOURCE field-spanning write
WARN_ONCE when reading a report body?
In struct spi_hid_input_buf, body is a 4-byte array (u8 body[4]) followed
by the flexible array content[]:
drivers/hid/spi-hid/spi-hid-core.h:
struct spi_hid_input_buf {
u8 header[HIDSPI_INPUT_HEADER_SIZE];
u8 body[HIDSPI_INPUT_BODY_HEADER_SIZE];
u8 content[];
};
When spi_hid_dev_irq() calls spi_hid_input_sync(shid, shid->input->body,
header.report_length, false) and spi_hid_input_sync() is inlined,
__member_size(buf) evaluates to sizeof(shid->input->body) (4 bytes) while
header.report_length covers both the 4-byte body header and the payload in
content[], so any report with a non-empty payload trips the fortified
memcpy() check.
--
Sashiko AI review · https://sashiko.dev/#/patchset/010601a22fcab279-8d1e3d0c-e1a6-41ab-8841-3108078d406a-000000@ap-northeast-1.amazonses.com?part=1
next prev parent reply other threads:[~2026-12-01 4:19 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 22:25 [PATCH v5 00/11] Add spi-hid transport driver Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 01/11] Documentation: Correction in HID output_report callback description Jingyuan Liang
2026-10-09 22:29 ` sashiko-bot
2026-10-13 20:49 ` Jingyuan Liang
2026-10-12 6:04 ` Krzysztof Kozlowski
2026-10-13 20:49 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 02/11] HID: Add BUS_SPI support and define HID_SPI_DEVICE macro Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 03/11] HID: spi-hid: add transport driver skeleton for HID over SPI bus Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 04/11] HID: spi-hid: add spi-hid driver HID layer Jingyuan Liang
2026-10-09 22:42 ` sashiko-bot
2026-10-13 21:21 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 05/11] HID: spi-hid: add HID SPI protocol implementation Jingyuan Liang
2026-10-09 22:42 ` sashiko-bot
2026-10-13 22:07 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 06/11] HID: spi-hid: add spi_hid traces Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 07/11] HID: spi-hid: add ACPI support for HID over SPI Jingyuan Liang
2026-10-09 22:41 ` sashiko-bot
2026-10-13 22:15 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 08/11] HID: spi-hid: add device tree " Jingyuan Liang
2026-10-12 12:49 ` Uwe Kleine-König
2026-10-13 22:26 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 09/11] dt-bindings: input: Document hid-over-spi DT schema Jingyuan Liang
2026-10-12 6:05 ` Krzysztof Kozlowski
2026-10-13 22:28 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 10/11] HID: spi-hid: add power management implementation Jingyuan Liang
2026-10-09 22:43 ` sashiko-bot
2026-10-13 22:57 ` Jingyuan Liang
2026-10-09 22:25 ` [PATCH v5 11/11] HID: spi-hid: add panel follower support Jingyuan Liang
2026-10-09 22:36 ` sashiko-bot
2026-10-13 23:06 ` Jingyuan Liang
2026-10-10 16:57 ` [PATCH 0/2] HID: spi-hid: handle reset assertion and resume handshake failures fQwQf
2026-10-13 2:54 ` [PATCH v2 " Jizhou Tong
2026-10-13 3:11 ` [PATCH v2 1/2] HID: spi-hid: propagate reset assertion errors during initialization Jizhou Tong
2026-10-13 3:11 ` [PATCH v2 2/2] HID: spi-hid: report a missing reset handshake on resume Jizhou Tong
2026-11-05 19:01 ` [PATCH v3 0/2] HID: spi-hid: propagate reset GPIO errors Jizhou Tong
2026-11-05 19:15 ` [PATCH v3 1/2] HID: spi-hid: propagate reset assertion errors during initialization Jizhou Tong
2026-11-05 19:15 ` [PATCH v3 2/2] HID: spi-hid: propagate reset GPIO errors from resume Jizhou Tong
2026-10-10 16:57 ` [RFC PATCH 0/6] HID: spi-hid: add Romulus13 quad-SPI support on v5 fQwQf
2026-10-13 3:13 ` [RFC PATCH v2 " Jizhou Tong
2026-10-13 3:28 ` [RFC PATCH v2 1/6] HID: spi-hid: isolate DMA transfers from protocol buffers Jizhou Tong
2026-10-13 3:28 ` [RFC PATCH v2 2/6] HID: spi-hid: add spi-mem quad-SPI transfers Jizhou Tong
2026-10-13 3:28 ` [RFC PATCH v2 3/6] HID: spi-hid: assemble bounded fragmented input reports Jizhou Tong
2026-10-13 3:28 ` [RFC PATCH v2 4/6] dt-bindings: input: describe the Romulus13 QSPI touchpad Jizhou Tong
2026-10-28 17:58 ` Conor Dooley
2026-10-13 3:28 ` [RFC PATCH v2 5/6] HID: spi-hid: support " Jizhou Tong
2026-10-13 3:28 ` [RFC PATCH v2 6/6] HID: spi-hid: expose readiness for reset diagnostics Jizhou Tong
2026-11-05 19:19 ` [RFC PATCH v3 0/5] HID: spi-hid: add quad-SPI support for Romulus13 Jizhou Tong
2026-11-05 19:22 ` [RFC PATCH v3 1/5] HID: spi-hid: isolate DMA transfers from protocol buffers Jizhou Tong
2026-11-05 19:33 ` sashiko-bot
2026-11-06 16:32 ` Jizhou Tong
2026-11-05 19:23 ` [RFC PATCH v3 2/5] HID: spi-hid: add spi-mem quad-SPI transfers Jizhou Tong
2026-11-05 19:23 ` [RFC PATCH v3 3/5] HID: spi-hid: assemble bounded fragmented input reports Jizhou Tong
2026-11-05 19:23 ` [RFC PATCH v3 4/5] dt-bindings: input: hid-over-spi: add the Surface Laptop 7 touchpad Jizhou Tong
2026-11-06 17:43 ` Conor Dooley
2026-11-21 16:24 ` Jizhou Tong
2026-11-23 17:01 ` Conor Dooley
2026-11-05 19:23 ` [RFC PATCH v3 5/5] HID: spi-hid: support the Romulus13 QSPI touchpad Jizhou Tong
2026-12-01 4:09 ` [RFC PATCH v4 0/5] HID: spi-hid: add quad-SPI support for Romulus13 Jizhou Tong
2026-12-01 4:12 ` [RFC PATCH v4 1/5] HID: spi-hid: isolate DMA transfers from protocol buffers Jizhou Tong
2026-12-01 4:19 ` sashiko-bot [this message]
2026-12-01 4:12 ` [RFC PATCH v4 2/5] HID: spi-hid: add spi-mem quad-SPI transfers Jizhou Tong
2026-12-01 4:12 ` [RFC PATCH v4 3/5] HID: spi-hid: assemble bounded fragmented input reports Jizhou Tong
2026-12-01 4:13 ` [RFC PATCH v4 4/5] dt-bindings: input: hid-over-spi: add the Surface Laptop 7 touchpad Jizhou Tong
2026-12-01 4:13 ` [RFC PATCH v4 5/5] HID: spi-hid: support the Romulus13 QSPI touchpad Jizhou Tong
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-242495@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=fqwqf@fqwqf.xyz \
--cc=linux-input@vger.kernel.org \
--cc=robh@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.