Skip to content

libnvme: examples: validate AE numbers in mi-mctp-ae - #3915

Open
prabhakarpujeri wants to merge 1 commit into
linux-nvme:masterfrom
prabhakarpujeri:fix-mi-mctp-ae-args
Open

libnvme: examples: validate AE numbers in mi-mctp-ae#3915
prabhakarpujeri wants to merge 1 commit into
linux-nvme:masterfrom
prabhakarpujeri:fix-mi-mctp-ae-args

Conversation

@prabhakarpujeri

Copy link
Copy Markdown

Problem

Port of linux-nvme/libnvme#1127 to libnvme3: the example in this tree has the identical argv-parsing bug as the 1.x version: atoi() values index the 256-entry aem_config.enabled_map.enabled[] stack array unchecked (OOB stack write for out-of-range / negative inputs), and argc == 4 accepts exactly one AE number although the usage text ([AE #s separated by spaces]) and the loop are written for a variable count.

Fix

  • Reject AE numbers outside 0-255 before indexing.
  • Lift argc == 4 to argc >= 4, matching the documented usage.

Testing

  • Full meson suite green; argv handling verified decay-free in the 1.x PR (the sandbox has no MCTP interfaces, so endpoint-level runtime checks are not possible here).

Port of linux-nvme/libnvme#1127.  atoi() results were used
unchecked to index the 256-entry aem_config.enabled_map.enabled[]
array on the stack, so a value outside 0-255 (or negative) is an
out-of-bounds stack write.  Reject them.  Lift 'argc == 4' to
'argc >= 4' so more than one AE can actually be enabled per the
usage text.

Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
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