Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix TOCTOU and buffer overflow in trelay#55

Open
ManupaKDU wants to merge 4 commits intomainfrom
sentinel-trelay-toctou-3008699587815432785
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix TOCTOU and buffer overflow in trelay#55
ManupaKDU wants to merge 4 commits intomainfrom
sentinel-trelay-toctou-3008699587815432785

Conversation

@ManupaKDU
Copy link
Copy Markdown

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: In package/kernel/trelay/src/trelay.c, the trelay_do_add function previously evaluated strlen(name) + 1 directly inside struct_size for allocating memory with kzalloc, and subsequently used an unbounded strcpy to copy the name string into the structure's flexible array member. If the name buffer contents changed between the memory allocation and the string copy (Time-of-Check to Time-of-Use), it could result in an unbounded strcpy leading to a buffer overflow.
🎯 Impact: In a kernel module, an out-of-bounds write buffer overflow can lead to immediate system panics, arbitrary code execution, or severe memory corruption.
πŸ”§ Fix: Extracted strlen(name) + 1 into a cached name_len variable. Used this variable for both the memory allocation and a newly bounded strscpy call, ensuring consistent length guarantees and preventing TOCTOU vulnerabilities. Added a corresponding journal entry to .jules/sentinel.md.
βœ… Verification: Visual inspection confirms the change is syntactically valid C. Syntax checking gcc -fsyntax-only package/kernel/trelay/src/trelay.c failed due to missing Linux kernel headers, as expected in the current environment.


PR created automatically by Jules for task 3008699587815432785 started by @manupawickramasinghe

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: In `package/kernel/trelay/src/trelay.c`, the `trelay_do_add` function previously evaluated `strlen(name) + 1` directly inside `struct_size` for allocating memory with `kzalloc`, and subsequently used an unbounded `strcpy` to copy the `name` string into the structure's flexible array member. If the `name` buffer contents changed between the memory allocation and the string copy (Time-of-Check to Time-of-Use), it could result in an unbounded `strcpy` leading to a buffer overflow.
🎯 Impact: In a kernel module, an out-of-bounds write buffer overflow can lead to immediate system panics, arbitrary code execution, or severe memory corruption.
πŸ”§ Fix: Extracted `strlen(name) + 1` into a cached `name_len` variable. Used this variable for both the memory allocation and a newly bounded `strscpy` call, ensuring consistent length guarantees and preventing TOCTOU vulnerabilities. Added a corresponding journal entry to `.jules/sentinel.md`.
βœ… Verification: Visual inspection confirms the change is syntactically valid C. Syntax checking `gcc -fsyntax-only package/kernel/trelay/src/trelay.c` failed due to missing Linux kernel headers, as expected in the current environment.

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules bot and others added 3 commits April 13, 2026 02:00
🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: In `package/kernel/trelay/src/trelay.c`, the `trelay_do_add` function previously evaluated `strlen(name) + 1` directly inside `struct_size` for allocating memory with `kzalloc`, and subsequently used an unbounded `strcpy` to copy the `name` string into the structure's flexible array member. If the `name` buffer contents changed between the memory allocation and the string copy (Time-of-Check to Time-of-Use), it could result in an unbounded `strcpy` leading to a buffer overflow.
🎯 Impact: In a kernel module, an out-of-bounds write buffer overflow can lead to immediate system panics, arbitrary code execution, or severe memory corruption.
πŸ”§ Fix: Extracted `strlen(name) + 1` into a cached `name_len` variable. Used this variable for both the memory allocation and a newly bounded `strscpy` call, ensuring consistent length guarantees and preventing TOCTOU vulnerabilities. Added a corresponding journal entry to `.jules/sentinel.md`.
βœ… Verification: Visual inspection confirms the change is syntactically valid C. Syntax checking `gcc -fsyntax-only package/kernel/trelay/src/trelay.c` failed due to missing Linux kernel headers, as expected in the current environment.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: In `package/kernel/trelay/src/trelay.c`, the `trelay_do_add` function previously evaluated `strlen(name) + 1` directly inside `struct_size` for allocating memory with `kzalloc`, and subsequently used an unbounded `strcpy` to copy the `name` string into the structure's flexible array member. If the `name` buffer contents changed between the memory allocation and the string copy (Time-of-Check to Time-of-Use), it could result in an unbounded `strcpy` leading to a buffer overflow.
🎯 Impact: In a kernel module, an out-of-bounds write buffer overflow can lead to immediate system panics, arbitrary code execution, or severe memory corruption.
πŸ”§ Fix: Extracted `strlen(name) + 1` into a cached `name_len` variable. Used this variable for both the memory allocation and a newly bounded `strscpy` call, ensuring consistent length guarantees and preventing TOCTOU vulnerabilities. Added a corresponding journal entry to `.jules/sentinel.md`.
βœ… Verification: Visual inspection confirms the change is syntactically valid C. Syntax checking `gcc -fsyntax-only package/kernel/trelay/src/trelay.c` failed due to missing Linux kernel headers, as expected in the current environment.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: In `package/kernel/trelay/src/trelay.c`, the `trelay_do_add` function previously evaluated `strlen(name) + 1` directly inside `struct_size` for allocating memory with `kzalloc`, and subsequently used an unbounded `strcpy` to copy the `name` string into the structure's flexible array member. If the `name` buffer contents changed between the memory allocation and the string copy (Time-of-Check to Time-of-Use), it could result in an unbounded `strcpy` leading to a buffer overflow.
🎯 Impact: In a kernel module, an out-of-bounds write buffer overflow can lead to immediate system panics, arbitrary code execution, or severe memory corruption.
πŸ”§ Fix: Extracted `strlen(name) + 1` into a cached `name_len` variable. Used this variable for both the memory allocation and a newly bounded `strscpy` call, ensuring consistent length guarantees and preventing TOCTOU vulnerabilities. Added a corresponding journal entry to `.jules/sentinel.md`.
βœ… Verification: Visual inspection confirms the change is syntactically valid C. Syntax checking `gcc -fsyntax-only package/kernel/trelay/src/trelay.c` failed due to missing Linux kernel headers, as expected in the current environment.

Signed-off-by: google-labs-jules <google-labs-jules@users.noreply.github.com>

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment