Skip to content

lisafs: fix uint32 truncation in PReadResp.CheckedUnmarshal bounds check (+ regression test) - #14491

Open
elassasmohamed8-prog wants to merge 1 commit into
google:masterfrom
elassasmohamed8-prog:fix/lisafs-preadresp-truncation
Open

lisafs: fix uint32 truncation in PReadResp.CheckedUnmarshal bounds check (+ regression test)#14491
elassasmohamed8-prog wants to merge 1 commit into
google:masterfrom
elassasmohamed8-prog:fix/lisafs-preadresp-truncation

Conversation

@elassasmohamed8-prog

Copy link
Copy Markdown

Fixes #14424

What

The NumBytes bounds check truncated to uint32 while the subsequent Buf slice used the full uint64 value. NumBytes = 0x0000000C00000000 truncates to 0, passes all checks, and panics at r.Buf[:51539607552].

Fix

Use full-width uint64 comparisons in the guard (same correction as #14464, which this independently verifies).

Extra: regression test

Includes TestReproPReadRespNumBytesTruncation — reproduces the panic on the pre-fix tree (confirmed locally) and passes with this change. Original root-cause analysis, suggested fix, and this verification are from #14424 (issue author).

Both directions verified on a local Bazel build of this tree.

The NumBytes bounds check truncated to uint32 while the subsequent
Buf slice used the full uint64 value. A NumBytes with high bits set
(e.g. 0x0000000C00000000) truncates to 0, passes all checks, and
panics at r.Buf[:51539607552].

Use full-width comparisons in the guard, and add a regression test
reproducing the panic on the pre-fix tree.

Fixes google#14424
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.

pkg/lisafs: PReadResp.CheckedUnmarshal panics on malformed NumBytes due to uint32 truncation in bounds check

1 participant