summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKrzysztof Wilczyński <kwilczynski@kernel.org>2026-06-12 18:24:48 +0000
committerBjorn Helgaas <bhelgaas@google.com>2026-06-23 15:19:09 -0500
commit92742802ecbf215a2b60dcfd326d2213595010f1 (patch)
treeba42a7167a9769d804bb470b80c08885f4e4dd28 /include
parentc9b4bd6c0839c855b7cc221af0283c1900036fc6 (diff)
PCI/sysfs: Use kstrtobool() to parse the ROM attribute input
pci_write_rom() controls access to the ROM content through the corresponding sysfs attribute, and treats the input as a request to disable only when it matches the string "0\n" exactly: if ((off == 0) && (*buf == '0') && (count == 2)) The count == 2 condition encodes the trailing newline that echo(1) appends. This was found when userspace wrote "0" without a trailing newline aiming to disable access, which failed to match the condition above and enabled access instead. For example: $ echo 0 > rom # "0\n", count 2, access disabled $ echo -n 0 > rom # "0", count 1, access enabled $ echo > rom # "", count 1, access enabled (likely not desirable) Parse the input with kstrtobool(), which handles common boolean inputs such as "0", "1", "n", "y" or "off", "on", with or without a trailing newline, so both of the above disable access, and update the now stale comment. As a side effect, input that does not parse as a boolean is rejected with -EINVAL rather than enabling access. The documented "0" and "1" continue to work as before, and rejecting malformed input brings the attribute in line with how sysfs attributes typically handle it. Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20260612182448.552406-1-kwilczynski@kernel.org
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions