On Fri, Sep 04, 2026 at 11:26:48AM +0530, Suraj Theekshana wrote:
> Hi Greg,
>
> Sorry about that. I have switched Gmail to plain-text mode and am
>
> resending with replies inline below.
>
> > How was this found and tested?
>
> I found it while reviewing authentication.c. I then manually reviewed
> the affected calculations and exercised them
> using a userspace ASan harness based on the Greybus structures.
>
> The harness demonstrated the 2047-byte and 1983-byte copies into the
> 1600-byte and 320-byte destinations, respectively. It did not exercise a
> live CAP ioctl or Greybus transport and did not produce an in-kernel
> KASAN report.
>
> I also built drivers/staging/greybus/authentication.o with W=1 on arm64,
> and the submitted patch passed checkpatch without warnings. I do not
> have access to real Greybus hardware, so it has not been tested on a
> physical device.
How well does the userspace harness actually exercise the code? Can you
turn it into a valid kselftest test that we can add to the kernel tree
to test the kernel code?
> > And doesn't this info come from the hardware itself? Is it not trusted here?
>
> Yes, the response length comes from the Greybus endpoint hardware or its
> firmware. My assumption was that a faulty or compromised endpoint should
> not be able to cause an out-of-bounds copy, especially during component
> authentication.
>
> However, I did not establish that hostile Greybus hardware is within the
> kernel's intended threat model. If the endpoint is considered fully
> trusted here, then I agree that this would be defensive hardening rather
> than a demonstrated security-boundary issue.
Our documentation (which your LLM should have read), says that we trust
hardware :)
> > Did you forget an Assisted-by: tag?
>
> Yes. That was my mistake. I used OpenAI Codex while preparing,
> and validating the patch.
Please read:
https://lore.kernel.org/r/2026080354-skater-urgent-31b2@gregkh
thanks,
greg k-h
On Fri, Sep 04, 2026 at 10:54:49AM +0530, Suraj Theekshana wrote:
> Hello Greg,
Sorry, but the mailing list rejects html emails, please fix your email
client and try again? Also, please try to not top-post.
thanks,
greg k-h
On Fri, Sep 04, 2026 at 03:46:28AM +0000, Suraj Theekshana wrote:
> cap_get_ims_certificate() and cap_authenticate() derive copy
> lengths from response payload sizes without checking the response
> header size or destination capacity.
How was this found and tested?
And doesn't this info come from the hardware itself? Is it not trusted
here?
> Reject responses smaller than their headers with -EMSGSIZE. Reject
> certificate and signature data larger than their fixed ioctl buffers
> with -E2BIG.
>
> Signed-off-by: Suraj Theekshana <surajtheekshana1111(a)gmail.com>
Did you forget an Assisted-by: tag?
thanks,
greg k-h
On Thu, Sep 03, 2026 at 11:35:13PM +0530, Suraj Theekshana wrote:
> Reproduce (no Greybus hardware)
> ===============================
>
> git clone --depth 1 https://github.com/torvalds/linux.git
> # tree used: 8ab1afb
>
> gcc -fsanitize=address -g -O0 -fno-builtin -U_FORTIFY_SOURCE \
> -I gb-poc \
> -I linux/drivers/staging/greybus \
> -I linux/include/linux/greybus \
> gb-poc/poc_cap_headers.c -o poc_cap_headers
>
> ./poc_cap_headers
> ./poc_cap_headers auth
That's not a reproducer if you don't have the hardware, right?
> Files in the attached zip
> =========================
As Willy said, please just provide a patch, like the documentation asked
for, that you have tested with your reproducer.
thanks,
greg k-h
Hello,
On Thu, Sep 03, 2026 at 11:35:13PM +0530, Suraj Theekshana wrote:
> Hello,
>
> I am reporting an unbounded memcpy in the Greybus CAP driver.
Note, there's no need to Cc security@ since you're also reporting to
public lists.
> Product: Linux kernel
> File: drivers/staging/greybus/authentication.c
> Header: drivers/staging/greybus/greybus_authentication.h
> include/linux/greybus/greybus_protocols.h
> Tree: torvalds/linux 8ab1afb
>
> Observed
> ========
>
> cap_get_ims_certificate() and cap_authenticate() do:
>
> *size = op->response->payload_size - sizeof(*response);
> memcpy(dest, src, *size);
>
> The response buffer is allocated with gb_operation_get_payload_size_max()
> and GB_OPERATION_FLAG_SHORT_RESPONSE.
>
> The ioctl destinations are fixed:
>
> certificate[CAP_CERTIFICATE_MAX_SIZE] /* 1600 */
> signature[CAP_SIGNATURE_MAX_SIZE] /* 320 */
>
> There is no check that payload_size >= sizeof(*response)
> and no cap to 1600 / 320.
>
> A 2048-byte payload therefore copies:
>
> IMS: 2048 - 1 = 2047 bytes into certificate[1600]
> AUTH: 2048 - 65 = 1983 bytes into signature[320]
>
> A payload shorter than the response header wraps the unsigned subtract and
> memcpy uses a huge length.
>
> Expected
> ========
>
> Reject payload_size < sizeof(*response) (-EMSGSIZE).
> Reject copy length > CAP_CERTIFICATE_MAX_SIZE /
> CAP_SIGNATURE_MAX_SIZE (-E2BIG).
>
> Reproduce (no Greybus hardware)
> ===============================
>
> git clone --depth 1 https://github.com/torvalds/linux.git
> # tree used: 8ab1afb
>
> gcc -fsanitize=address -g -O0 -fno-builtin -U_FORTIFY_SOURCE \
> -I gb-poc \
> -I linux/drivers/staging/greybus \
> -I linux/include/linux/greybus \
> gb-poc/poc_cap_headers.c -o poc_cap_headers
>
> ./poc_cap_headers
> ./poc_cap_headers auth
>
> ASan excerpt (IMS)
> ==================
>
> CAP_CERTIFICATE_MAX_SIZE=1600 CAP_SIGNATURE_MAX_SIZE=320
> [IMS] payload=2048 dest=1600 mode=ims
> =================================================================
> ERROR: AddressSanitizer: stack-buffer-overflow
> WRITE of size 2047
> #0 memcpy
> #1 cap_get_ims_certificate poc_cap_headers.c:18
> #2 main poc_cap_headers.c:61
> Address is located in stack of thread T0
> This frame has 2 object(s):
> [48, 481) 'a'
> [560, 2173) 'ims' <== overflows certificate[1600]
> SUMMARY: AddressSanitizer: stack-buffer-overflow in memcpy
> ABORTING
>
> ASan excerpt (AUTH)
> ===================
>
> CAP_CERTIFICATE_MAX_SIZE=1600 CAP_SIGNATURE_MAX_SIZE=320
> [AUTH] payload=2048 dest=320
> =================================================================
> ERROR: AddressSanitizer: stack-buffer-overflow
> WRITE of size 1983
> #0 memcpy
> #1 cap_authenticate poc_cap_headers.c:26
> #2 main poc_cap_headers.c:54
> Address is located in stack of thread T0
> This frame has 2 object(s):
> [48, 481) 'a' <== overflows signature[320]
> [560, 2173) 'ims'
> SUMMARY: AddressSanitizer: stack-buffer-overflow in memcpy
> ABORTING
>
> The PoC includes greybus_authentication.h and
> greybus_protocols.h from this tree. It is not a live
> CAP_IOC_* ioctl and there is no in-kernel KASAN frame.
>
> Impact
> ======
>
> Local overflow in the CAP ioctl path if a CAP connection exists and a
> module answers GET_IMS_CERTIFICATE or AUTHENTICATE with an oversized or
> truncated payload.
> Not unauthenticated remote RCE. Same trust model as a malicious or buggy
> Greybus module.
>
> Files in the attached zip
> =========================
Please avoid sending binary files, as developers are unlikely to open
them.
> poc_cap_headers.c
> ktypes.h
> asan_ims.txt
> asan_auth.txt
As requested in the doc where you found the security list's email,
please always try to propose a working patch so you can get full
credit for finding and fixing issues and you can save maintainers'
time. Please also see Docuemntation/process/submitting-patches.rst.
> Regards,
> Suraj Theekshana
Thanks,
Willy
On Wed, Sep 02, 2026 at 10:17:00AM -0500, Yudi Yang wrote:
> I found this with an internal program-analysis tool that I cannot disclose
> yet, then manually verified the finding. intf_name and dir are 32-byte
> arrays, while the unbounded %s conversions allow tokens from w->sname
> longer than 31 characters to overflow them. Using %31s limits each
> conversion to 31 characters.
Please read our documentation which describes how you need to identify
when you use tools like this.
> I do not have Greybus hardware, so testing was limited to building the
> affected object and running checkpatch.pl
That's not really testing the code :(
Please resubmit based on the documentation requirements.
thanks,
greg k-h
The incoming message size from the device header (header.size) is
trusted without checking that it is at least the size of the message
header itself, but a value smaller than sizeof(struct gb_operation_msg_hdr)
underflows request_size in gb_operation_create_incoming(), wraps around
in gb_operation_message_alloc(), and results in a tiny buffer that is
then written past its end in gb_operation_message_init().
Reject undersized messages before parsing the message header.
Fixes: d37b1db13f8b ("greybus: refactor gb_connection_recv()")
Reported-by: syzbot+2fd6aefc361af86911d5(a)syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=2fd6aefc361af86911d5
Cc: stable(a)vger.kernel.org
Signed-off-by: Adriano Cordova <adrianox(a)gmail.com>
---
drivers/greybus/operation.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
index 7e12ffb2dd..df6daee4fb 100644
--- a/drivers/greybus/operation.c
+++ b/drivers/greybus/operation.c
@@ -1047,6 +1047,14 @@ void gb_connection_recv(struct gb_connection *connection,
/* Use memcpy as data may be unaligned */
memcpy(&header, data, sizeof(header));
msg_size = le16_to_cpu(header.size);
+ if (msg_size < sizeof(header)) {
+ dev_err_ratelimited(dev,
+ "%s: malformed message 0x%04x of type 0x%02x received (%zu < %zu)\n",
+ connection->name,
+ le16_to_cpu(header.operation_id),
+ header.type, msg_size, sizeof(header));
+ return;
+ }
if (size < msg_size) {
dev_err_ratelimited(dev,
"%s: incomplete message 0x%04x of type 0x%02x received (%zu < %zu)\n",
--
2.51.0