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

lscpu: lscpu_cputype_get_default() return value used without NULL check -> segfaults on rv64 #1401

Closed
mkszuba opened this issue Jul 30, 2021 · 3 comments

Comments

@mkszuba
Copy link

mkszuba commented Jul 30, 2021

according to sys-utils/lscpu-cputype.c#L99, lscpu_cputype_get_default() can return a null pointer. However, with print_summary() having called this function in sys-utils/lscpu.c#L975 lscpu proceeds to dereference the return value (lines: 994, 1036 and 1038) without checking it for NULL first. This results in a segmentation fault when lscpu is run on a Linux/rv64 system. For more details on the segfault, see here: https://bugs.gentoo.org/802606#c8 .

Nb. as far as I can see every other time lscpu_cputype_get_default() is called (once more in lscpu.c, once in lscpu-virt.c, three times in lscpu-cputype.c) its return value is checked before dereferencing.

@karelzak
Copy link
Collaborator

Good catch. Thanks!

Please, can you send me /proc and /sys dump from your Linux/rv64? There is a script to create the dump, see:
https://raw.githubusercontent.com/karelzak/util-linux/master/tests/ts/lscpu/mk-input.sh

It would be nice to have a dump from the system in util-linux test suite to detect this kind of bug.

karelzak added a commit that referenced this issue Jul 30, 2021
Fixes: #1401
Signed-off-by: Karel Zak <kzak@redhat.com>
@mkszuba
Copy link
Author

mkszuba commented Jul 30, 2021

Here you go! This is for a dual-core SiFive U74 (specifically from the prototype BeagleV Starlight board) but I expect it will look much the same on other U74 systems, HiFive Unmatched for instance.
rv64-linux.tar.gz

karelzak added a commit that referenced this issue Jul 30, 2021
References: #1401
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
Copy link
Collaborator

Thanks!

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

No branches or pull requests

2 participants