Skip to content

Fix out-of-bounds write from failed bytes-list skips in fast parsing#120631

Open
Abhinav-143x wants to merge 1 commit into
tensorflow:masterfrom
Abhinav-143x:parse-sequence-skip-error
Open

Fix out-of-bounds write from failed bytes-list skips in fast parsing#120631
Abhinav-143x wants to merge 1 commit into
tensorflow:masterfrom
Abhinav-143x:parse-sequence-skip-error

Conversation

@Abhinav-143x

@Abhinav-143x Abhinav-143x commented Jun 8, 2026

Copy link
Copy Markdown

This change fixes a memory-safety issue in the fast example parser by making the bytes-list counting path reject failed CodedInputStream::Skip() calls.

Today the copy path returns an error when ReadRaw() fails, but the count path can continue after a failed Skip(). For malformed bytes-list input, that can make the parser record an element count during the count pass and then observe an error during the copy pass. In sparse SequenceExample parsing, that count/copy mismatch can lead to sparse-index writes past the allocated tensor buffer.

The fix propagates the failed Skip() as an error so malformed input is rejected consistently before sparse-index output construction.

A regression test covers a malformed sparse string SequenceExample where a bytes-list value declares more bytes than are present.

Tested:

  • git diff --check
  • Local focused parser test target with the same Skip() fix: PASSED

@google-ml-butler google-ml-butler Bot added the size:S CL Change Size: Small label Jun 8, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request improves error handling in ParseBytesFeature by checking the return value of stream->Skip(bytes_length) and returning -1 if it fails. Additionally, a new unit test SparseStringMalformedBytesListReportsError has been added to example_proto_fast_parsing_test.cc to verify that parsing a malformed bytes list correctly reports an error. There are no review comments to address, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Abhinav-143x Abhinav-143x changed the title Propagate bytes-list skip failures in fast parsing Fix out-of-bounds write from failed bytes-list skips in fast parsing Jun 8, 2026
@nithyak0204 nithyak0204 added the comp:core issues related to core part of tensorflow label Jun 9, 2026
@github-project-automation github-project-automation Bot moved this to Assigned Reviewer in PR Queue Jun 9, 2026
@nithyak0204 nithyak0204 requested a review from dmiltr3 June 9, 2026 04:53
@google-ml-butler google-ml-butler Bot added the awaiting review Pull request awaiting review label Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review Pull request awaiting review comp:core issues related to core part of tensorflow size:S CL Change Size: Small

Projects

Status: Assigned Reviewer

Development

Successfully merging this pull request may close these issues.

3 participants