Skip to content

libnvme: examples: bound device-supplied lengths in mi-mctp, fix ssid print - #3919

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

libnvme: examples: bound device-supplied lengths in mi-mctp, fix ssid print#3919
prabhakarpujeri wants to merge 1 commit into
linux-nvme:masterfrom
prabhakarpujeri:fix-mi-mctp-example-bounds

Conversation

@prabhakarpujeri

Copy link
Copy Markdown

Problem

Port of linux-nvme/libnvme#1140. Same three issues as the 1.x example:

  1. do_controllers() iterates le16_to_cpu(ctrl_list.num) entries of ctrl_list.identifier[]; num is 16-bit while the array holds NVME_ID_CTRL_LIST_MAX (2047) entries. A non-conformant device reporting more than that makes the loop read ~63 KB past the array and issue thousands of spurious MI transactions.
  2. do_security_info() validates n_proto against data_len (covering the whole 264-byte buffer) rather than protocols[256], so a full-length response can pass with counts of 257-258 → the print loop reads past the array.
  3. show_ctrl() prints ctrl.ssvid (vendor ID) a second time for "PCI subsys device" instead of ctrl.ssid.

Fix

Clamp the controller count with a warning; reject oversized n_proto; print ctrl.ssid.

Testing

  • Full meson suite green. Example MI paths need real MCTP hardware; build/review-validated only.

… print

Port of linux-nvme/libnvme#1140:

- do_controllers() iterates le16_to_cpu(ctrl_list.num) entries of
  ctrl_list.identifier[]; num is 16-bit while the array holds
  NVME_ID_CTRL_LIST_MAX entries.  Clamp with a warning.
- do_security_info() validates n_proto against data_len (which
  covers the whole 264-byte buffer), not against protocols[256];
  reject oversized counts.
- print ctrl.ssid instead of ctrl.ssvid for the PCI subsystem
  device ID.

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