Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix Out-of-Bounds Memory Read in sk_buff Processing - #41

Open
maxugly wants to merge 1 commit into
mainfrom
fix-skb-oob-read-16371425559276823586
Open

πŸ›‘οΈ Sentinel: [HIGH] Fix Out-of-Bounds Memory Read in sk_buff Processing#41
maxugly wants to merge 1 commit into
mainfrom
fix-skb-oob-read-16371425559276823586

Conversation

@maxugly

@maxugly maxugly commented Aug 4, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Out-of-bounds kernel memory read when processing fragmented (non-linear) sk_buff structures using memcpy.
🎯 Impact: Potential kernel panic or memory disclosure due to reading past the allocated linear data buffer of an sk_buff.
πŸ”§ Fix: Replaced memcpy() with skb_copy_bits() which safely handles non-linear sk_buff data, checking for read errors and returning -EFAULT if it fails.
βœ… Verification: Module builds successfully and tests pass via sudo ./scripts/nata-bench-once.sh.


PR created automatically by Jules for task 16371425559276823586 started by @maxugly

Summary by CodeRabbit

  • Bug Fixes
    • Improved packet handling for non-linear network data.
    • Prevented potential out-of-bounds reads during packet transmission.
    • Reported a clear error when packet data cannot be copied safely.
  • Documentation
    • Added a security note documenting the corrected packet-copying issue.

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Out-of-bounds kernel memory read when processing fragmented (non-linear) `sk_buff` structures using `memcpy`.
🎯 Impact: Potential kernel panic or memory disclosure due to reading past the allocated linear data buffer of an `sk_buff`.
πŸ”§ Fix: Replaced `memcpy()` with `skb_copy_bits()` which safely handles non-linear sk_buff data, checking for read errors and returning `-EFAULT` if it fails.
βœ… Verification: Module builds successfully and tests pass via `sudo ./scripts/nata-bench-once.sh`.

Co-authored-by: maxugly <64644401+maxugly@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ‘‹ 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.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

sim_tx_packet now uses skb_copy_bits() for fragmented sk_buff payloads and returns -EFAULT when copying fails. The change also documents the out-of-bounds read and the required safe-copy approach.

Changes

Packet copy safety

Layer / File(s) Summary
Safe payload copy and vulnerability record
module/nata_blk.c, .jules/sentinel.md
sim_tx_packet uses skb_copy_bits() instead of direct memcpy() access and returns -EFAULT on failure. The security documentation records the non-linear sk_buff vulnerability and required API.
Estimated code review effort: 2 (Simple) ~5 minutes

Possibly related PRs

  • maxugly/nata#27: Replaces unsafe memcpy usage in sim_tx_packet with skb_copy_bits().
  • maxugly/nata#29: Applies the same non-linear sk_buff payload-copy fix.
  • maxugly/nata#39: Implements the same sim_tx_packet fix and security documentation.
πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly identifies the high-severity out-of-bounds read fix in sk_buff processing.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-skb-oob-read-16371425559276823586

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.jules/sentinel.md:
- Around line 10-13: Update the as-built specification for sim_tx_packet to
document that skb_copy_bits() failures return -EFAULT and leave the ring entry
unpublished, in addition to the existing -ENOSPC full-ring behavior. Synchronize
dependent references in the statistics section and .jules/sentinel.md with this
failure contract.
πŸͺ„ Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 38493bee-2e8c-48f3-9f4c-cb21ec4d7bf9

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 6d5b3ed and 63ee70d.

πŸ“’ Files selected for processing (2)
  • .jules/sentinel.md
  • module/nata_blk.c

Comment thread .jules/sentinel.md
Comment on lines +10 to +13
## 2024-05-24 - Out-of-Bounds Read in Non-Linear sk_buff
**Vulnerability:** Out-of-bounds kernel memory read in `sim_tx_packet` caused by assuming `sk_buff` payloads are contiguous and using `memcpy` directly from `skb->data`.
**Learning:** `sk_buff` structures from the networking stack can be fragmented (non-linear). Direct memory copies can read past the end of the linear data segment.
**Prevention:** Always use `skb_copy_bits()` instead of `memcpy()` when reading from `sk_buff` structures that may originate from higher levels of the networking stack.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Maintainability & Code Quality | 🟑 Minor | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Applicable AGENTS.md files:"
fd --hidden --type f 'AGENTS\.md$' .

echo "Candidate as-built specifications:"
fd --hidden --type f . | rg -i 'as[-_ ]built|spec|design|nata|docs?'

echo "Current packet-copy contract references:"
rg -n -i 'sim_tx_packet|skb_copy_bits|EFAULT|non-linear' \
  --glob 'AGENTS.md' --glob '*.md' .

Repository: maxugly/nata

Length of output: 6019


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo ".jules/sentinel.md:"
sed -n '1,30p' .jules/sentinel.md

echo
echo "sim_tx_packet implementation references:"
rg -n -C 8 'sim_tx_packet|skb_copy_bits|skb->data|EFAULT|ring' module firmware sim --glob '*.c' --glob '*.h' --glob '*.v' || true

echo
echo "docs/specs/04-kernel-module.md relevant sections:"
sed -n '100,270p' docs/specs/04-kernel-module.md

Repository: maxugly/nata

Length of output: 25983


Add the sim_tx_packet failure contract to the spec’s as-built section.

The owning docs/specs/04-kernel-module.md entry still says sim_tx_packet only reports -ENOSPC on full ring. Add the copied behavior from the code: skb_copy_bits() failure returns -EFAULT and the ring entry remains unpublished. Dependents such as the statistics section and .jules/sentinel.md should be updated in the same pass.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.jules/sentinel.md around lines 10 - 13, Update the as-built specification
for sim_tx_packet to document that skb_copy_bits() failures return -EFAULT and
leave the ring entry unpublished, in addition to the existing -ENOSPC full-ring
behavior. Synchronize dependent references in the statistics section and
.jules/sentinel.md with this failure contract.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant