Skip to content

fix off-by-one write in proc/cpuinfo hardware/revision parse#414

Open
soma0212 wants to merge 1 commit into
pytorch:mainfrom
soma0212:proc-cpuinfo-value-bound
Open

fix off-by-one write in proc/cpuinfo hardware/revision parse#414
soma0212 wants to merge 1 commit into
pytorch:mainfrom
soma0212:proc-cpuinfo-value-bound

Conversation

@soma0212

Copy link
Copy Markdown

In parse_line (src/arm/linux/cpuinfo.c) the Hardware and Revision handlers null-terminate with state->hardware[value_length] = '\0' in the branch taken when the value fits. But the length guard uses > CPUINFO_HARDWARE_VALUE_MAX (and > CPUINFO_REVISION_VALUE_MAX), so a value whose length is exactly the max still takes that branch. Those destinations are exactly MAX bytes (64 and 9), so a Hardware line with a 64-byte value, or a Revision line with a 9-byte value, writes the terminator one byte past the buffer.

Change both comparisons to >= so an equal-length value goes through the truncation path instead. That leaves the buffer full and unterminated, which is already the contract downstream code relies on (the chipset decoders read these fields with strnlen(buf, MAX)), so keeping the bound at the write site is enough and no consumer needs to change.

@meta-cla

meta-cla Bot commented Jul 11, 2026

Copy link
Copy Markdown

Hi @soma0212!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

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.

1 participant