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

"ufs-utils list_bsg" crashes on 32-bit platforms #58

Open
yizhao1 opened this issue Sep 13, 2024 · 0 comments
Open

"ufs-utils list_bsg" crashes on 32-bit platforms #58

yizhao1 opened this issue Sep 13, 2024 · 0 comments

Comments

@yizhao1
Copy link

yizhao1 commented Sep 13, 2024

ufs-utils version: 4.13.5 and latest git rev

"ufs-utils list_bsg" crashes on 32-bit platforms. e.g. x86, arm.

On x86 platform:
root@qemux86:~# ufs-utils list_bsg
free(): invalid pointer
Aborted

On arm platform:
root@qemuarm:~# ufs-utils list_bsg
Directory cannot be opened!: No such file or directory
Directory cannot be opened!: No such file or directory
corrupted size vs. prev_size
Aborted

There is no such issue on x86-64 platform:
root@qemux86-64:~# ufs-utils list_bsg
Didn't found UFS BSG device

After some investigation I found that the crash occurs in the find_bsg_device() function in ufs_cmds.c.

I put this function into a test file, compiled and ran it, and had the same issue. Please see the attached test.c.
On x86 platform:
root@qemux86:# gcc -o test test.c
root@qemux86:
# ./test
/dev/cpu
/dev/cpu/0
/dev/cpu/1
/dev/cpu/2
/dev/cpu/3
/dev/dri
/dev/dri/by-path
/dev/bus
/dev/bus/usb
/dev/bus/usb/001
free(): invalid pointer
Aborted
root@qemux86:~#

On arm platform:
root@qemuarm:# gcc -o test test.c
root@qemuarm:
# ./test
/dev/dri
/dev/dri/by-path
/dev/bus
/dev/bus/usb
/dev/bus/usb)�/001
Directory cannot be opened!: No such file or directory
/dev/bus/usb)�/002
Directory cannot be opened!: No such file or directory
/dev/mapper
/dev/input
/dev/input/by-id
/dev/input/by-path
/dev/pts
/dev/shm
/dev/char
/dev/block
/dev/disk
/dev/disk/by-diskseq
corrupted size vs. prev_size
Aborted

test.c

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

1 participant