Skip to content

fix(USB): increase socket buffer and handle panic#2710

Merged
Aryan-sharma11 merged 1 commit into
kubearmor:mainfrom
AryanBakliwal:fix-usb-buffer
Jun 25, 2026
Merged

fix(USB): increase socket buffer and handle panic#2710
Aryan-sharma11 merged 1 commit into
kubearmor:mainfrom
AryanBakliwal:fix-usb-buffer

Conversation

@AryanBakliwal

Copy link
Copy Markdown
Member

Purpose of PR?:
This PR fixes a hard crash (slice bounds out of range [:-1]) in the USBDeviceHandler that occurs when the kernel's Netlink event queue overflows.
image

When the default Netlink socket receive buffer fills up, unix.Recvfrom returns the ENOBUFS (No buffer space available) error and -1 for the number of bytes read (nr).
Because the loop previously logged the error but did not continue to the next iteration, the code attempted to slice the buffer with the negative index, resulting in a panic.

Fixes #

Does this PR introduce a breaking change?
No

If the changes in this PR are manually verified, list down the scenarios covered:
image

Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

  • Bug fix. Fixes #
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Commit has unit tests
  • Commit has integration tests

@achrefbensaad achrefbensaad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Aryan-sharma11 Aryan-sharma11 merged commit bbe97b8 into kubearmor:main Jun 25, 2026
19 of 20 checks passed
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.

4 participants