Skip to content

fix: Harden RDMA recv against peer-supplied length - #352

Open
bjosv wants to merge 1 commit into
valkey-io:mainfrom
bjosv:rdma-hardening
Open

bjosv wants to merge 1 commit into
valkey-io:mainfrom
bjosv:rdma-hardening

Conversation

@bjosv

@bjosv bjosv commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

The length passed to connRdmaHandleRecvImm() is the immediate value chosen by the peer, but it was only checked with an assertion, which is elided with -DNDEBUG.
Check it against the space remaining in the receive buffer and return an error instead, comparing against the space left rather than summing since byte_len + rx_offset can wrap.

Found during an assert inventory to identify asserts that can be externally triggered.

The length passed to connRdmaHandleRecvImm() is the immediate value
chosen by the peer, but it was only checked with an assertion, which is
elided with -DNDEBUG. Check it against the space remaining in the
receive buffer and return an error instead, comparing against the space
left rather than summing since byte_len + rx_offset can wrap.

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
@bjosv

bjosv commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator Author

@pizhenwei Does this seem right?

@pizhenwei pizhenwei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

RdmaContext *ctx = c->privctx;, so only valkeyContext *c is also fine for connRdmaHandleRecvImm. Both styles are fine to me.

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.

2 participants