Re: [PATCH net] net/mlx5: fix a stack over-read in the QP debugfs files
From: Aibing Chen
Date: Fri Nov 20 2026 - 04:54:37 EST
Hi,
How it was found: by code inspection, not from a report or a tool - while
looking at how the mlx5 debugfs field readers use the return value of
snprintf().
Was it triggered: no, I did not reproduce it at runtime. It is statically
decidable from the code: snprintf() returns the length the output would
have had (23 for "Invalid transport type" plus the newline) instead of the
number of bytes written (18), and simple_read_from_buffer() uses that
value to bound the copy to userspace. It is only reachable when the
device reports a QP transport value that mlx5_qp_type_str() does not name.
Hardware: not tested on real hardware, I do not have mlx5 hardware
available. The change only uses scnprintf() so that the length passed to
simple_read_from_buffer() can no longer exceed the buffer, and enlarges
the buffer so that the longest string still fits; neither needs device
specific behaviour.
Thanks,
Aibing Chen