Skip to content

conn: align receive buffer to nlmsgAlign boundary#280

Merged
nickgarlis merged 1 commit intomdlayher:mainfrom
aojea:netlinkbuf
Apr 10, 2026
Merged

conn: align receive buffer to nlmsgAlign boundary#280
nickgarlis merged 1 commit intomdlayher:mainfrom
aojea:netlinkbuf

Conversation

@aojea
Copy link
Copy Markdown
Contributor

@aojea aojea commented Apr 10, 2026

getBuffer() used MSG_PEEK|MSG_TRUNC to determine the exact byte count of the next message, then allocated a buffer of exactly that size. When the peeked length is not a multiple of 4 (the netlink alignment boundary), parseMessagesIter rounds the slice index up with nlmsgAlign, which immediately panics with "slice bounds out of range".

Fixes: #279

getBuffer() used MSG_PEEK|MSG_TRUNC to determine the exact byte count
of the next message, then allocated a buffer of exactly that size.
When the peeked length is not a multiple of 4 (the netlink alignment
boundary), parseMessagesIter rounds the slice index up with nlmsgAlign,
which immediately panics with "slice bounds out of range".
@nickgarlis
Copy link
Copy Markdown
Collaborator

nickgarlis commented Apr 10, 2026

This looks good. Thanks @aojea !

Question: The main branch is now on Go 1.25. Would you prefer a patch on 1.24 or are you okay with upgrading ?

@nickgarlis nickgarlis merged commit 1ae4967 into mdlayher:main Apr 10, 2026
6 checks passed
nickgarlis pushed a commit that referenced this pull request Apr 10, 2026
getBuffer() used MSG_PEEK|MSG_TRUNC to determine the exact byte count
of the next message, then allocated a buffer of exactly that size.
When the peeked length is not a multiple of 4 (the netlink alignment
boundary), parseMessagesIter rounds the slice index up with nlmsgAlign,
which immediately panics with "slice bounds out of range".
nickgarlis pushed a commit that referenced this pull request Apr 10, 2026
getBuffer() used MSG_PEEK|MSG_TRUNC to determine the exact byte count
of the next message, then allocated a buffer of exactly that size.
When the peeked length is not a multiple of 4 (the netlink alignment
boundary), parseMessagesIter rounds the slice index up with nlmsgAlign,
which immediately panics with "slice bounds out of range".
nickgarlis pushed a commit that referenced this pull request Apr 10, 2026
getBuffer() used MSG_PEEK|MSG_TRUNC to determine the exact byte count
of the next message, then allocated a buffer of exactly that size.
When the peeked length is not a multiple of 4 (the netlink alignment
boundary), parseMessagesIter rounds the slice index up with nlmsgAlign,
which immediately panics with "slice bounds out of range".
@aojea
Copy link
Copy Markdown
Contributor Author

aojea commented Apr 10, 2026

This looks good. Thanks @aojea !

Question: The main branch is now on Go 1.25. Would you prefer a patch on 1.24 or are you okay with upgrading ?

I didn;t find any issue so far on my projects, so this lgtm

@aojea
Copy link
Copy Markdown
Contributor Author

aojea commented Apr 10, 2026

@nickgarlis can you cut a new release?

I wonder if we should use the retract directive to mark the v1.10.0 version https://go.dev/ref/mod#go-mod-file-retract

@nickgarlis
Copy link
Copy Markdown
Collaborator

nickgarlis commented Apr 10, 2026

@nickgarlis can you cut a new release?

@aojea I can do that. I was initially thinking of doing v1.10.1 based on this branch to keep the release in Go 1.24. But since we are okay with 1.25, I'll do a v1.11.0 instead. Let me know if you have any objections.

I wonder if we should use the retract directive to mark the v1.10.0 version https://go.dev/ref/mod#go-mod-file-retract

Yes we should. Thanks for the suggestion.

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.

panic: runtime error: slice bounds out of range

2 participants