Skip to content

fix stack overread on truncated range in cpulist parse_entry - #431

Open
soma0212 wants to merge 1 commit into
pytorch:mainfrom
soma0212:cpulist-range-bound
Open

fix stack overread on truncated range in cpulist parse_entry#431
soma0212 wants to merge 1 commit into
pytorch:mainfrom
soma0212:cpulist-range-bound

Conversation

@soma0212

Copy link
Copy Markdown

parse_entry dereferences number_start without checking that anything actually follows the '-':

  • cpuinfo_linux_parse_cpulist hands it entry_end == &buffer[BUFFER_SIZE] whenever a full read turns up no ',', since the leftover then gets reparsed as one entry spanning the whole buffer
  • an entry ending in '-' leaves number_start at entry_end, parse_number consumes nothing, and the failure branch reads *number_start, which is buffer[256]
  • cpuinfo_log_warning is an inline static variadic function, so that argument is evaluated whatever CPUINFO_LOG_LEVEL is set to
  • ASan calls it a 1-byte stack-buffer-overflow read at cpulist.c:119 on a cpu list of 255 digits followed by '-'

Bailing out before the dereference leaves the entry rejected exactly as it already was, so the callback sequence and return value are the same on every input I tried, valid or malformed.

@meta-cla

meta-cla Bot commented Jul 31, 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