Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linux virtual root device parsing #188

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

vathpela
Copy link
Contributor

@vathpela vathpela commented Dec 7, 2021

When some Samsung NVMe devices have mutlipath mode enabled, that
switches which kind of NVMe device shows up in sysfs, and we get a
path link that's like
"../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1". The first
part of that, "../../devices/virtual/nvme-subsystem/", is supposed to be
consumed by the parser in linux-virtual-root.c. Unfortunately, that
parse loop incorrectly expects that sscanf will return nonzero when it
parses the format string "%n../../devices/virtual/%n", but libc does not
consider %n to be a conversion, and does not count it. In the log, we
see it find the string and set pos, but rc is 0, and "current" is not
advanced:

linux-virtual-root.c:47 parse_virtual_root(): searching for ../../devices/virtual
linux-virtual-root.c:50 parse_virtual_root(): current:'../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1' rc:0 pos0:0 pos1:22
linux-virtual-root.c:51 parse_virtual_root(): ^^^^^^^^^^^^^^^^^^^^^^
linux-virtual-root.c:47 parse_virtual_root(): searching for nvme-subsystem/
linux-virtual-root.c:50 parse_virtual_root(): current:'../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1' rc:0 pos0:0 pos1:-1

This patch makes it expect rc == 0, in the same way parse_acpi_root() in
linux-acpi-root.c does.

Signed-off-by: Peter Jones pjones@redhat.com

When some Samsung NVMe devices have mutlipath mode enabled, that
switches which kind of NVMe device shows up in sysfs, and we get a
path link that's like
"../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1".  The first
part of that, "../../devices/virtual/nvme-subsystem/", is supposed to be
consumed by the parser in linux-virtual-root.c.  Unfortunately, that
parse loop incorrectly expects that sscanf will return nonzero when it
parses the format string "%n../../devices/virtual/%n", but libc does not
consider %n to be a conversion, and does not count it.  In the log, we
see it find the string and set pos, but rc is 0, and "current" is not
advanced:

linux-virtual-root.c:47 parse_virtual_root(): searching for ../../devices/virtual
linux-virtual-root.c:50 parse_virtual_root(): current:'../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1' rc:0 pos0:0 pos1:22
linux-virtual-root.c:51 parse_virtual_root():          ^^^^^^^^^^^^^^^^^^^^^^
linux-virtual-root.c:47 parse_virtual_root(): searching for nvme-subsystem/
linux-virtual-root.c:50 parse_virtual_root(): current:'../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1' rc:0 pos0:0 pos1:-1

This patch makes it expect rc == 0, in the same way parse_acpi_root() in
linux-acpi-root.c does.

Signed-off-by: Peter Jones <pjones@redhat.com>
@vathpela vathpela force-pushed the fix-linux-virtual-root-parser branch from 7fb77bc to ef4646e Compare December 9, 2021 15:07
@frozencemetery
Copy link
Member

I have received confirmation from one affected user that this resolves the issue. No reply from the others yet.

@frozencemetery frozencemetery merged commit b920a6c into rhboot:main Dec 9, 2021
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.

None yet

2 participants