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

Little-Big Endian #2

Closed
keithbusch opened this issue Feb 13, 2015 · 2 comments
Closed

Little-Big Endian #2

keithbusch opened this issue Feb 13, 2015 · 2 comments

Comments

@keithbusch
Copy link
Contributor

I know it's crazy, but I hear some people don't use x86. I don't want those folks to feel dejected, so I'll post the issue so they know the little people are looking out for the big people (pun intended).

@sbates130272
Copy link
Contributor

There is an issue compiling for ppc64el as of 62bbb67.

batesste@ubuntu-ppc:~/nvme-cli$ make nvme
cc -c -I -m64 -std=gnu99 -O2 -g -pthread -D_GNU_SOURCE -D_REENTRANT -Wall -Werror ./src/argconfig.c
cc -c -I -m64 -std=gnu99 -O2 -g -pthread -D_GNU_SOURCE -D_REENTRANT -Wall -Werror ./src/suffix.c
cc -I -m64 -std=gnu99 -O2 -g -pthread -D_GNU_SOURCE -D_REENTRANT -Wall -Werror nvme.c -lm -o nvme argconfig.o suffix.o
nvme.c: In function ‘show_error_log’:
nvme.c:167:3: error: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘__u64’ [-Werror=format=]
printf("error_count : %lld\n", err_log[i].error_count);
^
nvme.c:172:3: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__u64’ [-Werror=format=]
printf("lba : %#llx\n", err_log[i].lba);
^
nvme.c: In function ‘show_nvme_resv_report’:
nvme.c:195:3: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__le64’ [-Werror=format=]
printf(" hostid : %llx\n", le64toh(status->regctl_ds[i].hostid));
^
nvme.c:196:3: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__le64’ [-Werror=format=]
printf(" rkey : %llx\n", le64toh(status->regctl_ds[i].rkey));
^
nvme.c: In function ‘show_fw_log’:
nvme.c:222:7: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ [-Werror=format=]
fw_to_string(fw_log->frs[i]));
^
nvme.c: In function ‘show_lba_range’:
nvme.c:753:3: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__u64’ [-Werror=format=]
printf("slba : %#llx", lbrt[i].slba);
^
nvme.c:754:3: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__u64’ [-Werror=format=]
printf("nlb : %#llx", lbrt[i].nlb);
^
nvme.c: In function ‘show_nvme_id_ns’:
nvme.c:903:2: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__le64’ [-Werror=format=]
printf("nsze : %#llx\n", ns->nsze);
^
nvme.c:904:2: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__le64’ [-Werror=format=]
printf("ncap : %#llx\n", ns->ncap);
^
nvme.c:905:2: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__le64’ [-Werror=format=]
printf("nuse : %#llx\n", ns->nuse);
^
cc1: all warnings being treated as errors
Makefile:25: recipe for target 'nvme' failed
make: *** [nvme] Error 1

@keithbusch
Copy link
Contributor Author

I think all the le*toh's are in place now. Will close this.

ScottyBauer pushed a commit to ScottyBauer/nvme-cli that referenced this issue Sep 22, 2016
Fixes:

==15224==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffffcf55 at pc 0x7ffff6ecb9f5 bp 0x7fffffffcd80 sp 0x7fffffffc510
WRITE of size 22 at 0x7fffffffcf55 thread T0
    #0 0x7ffff6ecb9f4 in __interceptor_vsprintf (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x619f4)
    #1 0x7ffff6ecbcc9 in __interceptor_sprintf (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x61cc9)
    linux-nvme#2 0x420357 in json_nvme_id_ctrl /home/sbauer/nvme_code/nvme-cli/nvme-print.c:1266
    linux-nvme#3 0x4072f1 in __id_ctrl /home/sbauer/nvme_code/nvme-cli/nvme.c:935
    linux-nvme#4 0x40742f in id_ctrl /home/sbauer/nvme_code/nvme-cli/nvme.c:950
    linux-nvme#5 0x42fa63 in handle_plugin /home/sbauer/nvme_code/nvme-cli/plugin.c:140
    linux-nvme#6 0x410c46 in main /home/sbauer/nvme_code/nvme-cli/nvme.c:2729
    linux-nvme#7 0x7ffff6ac182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    linux-nvme#8 0x402268 in _start (/home/sbauer/nvme_code/nvme-cli/nvme+0x402268)

Address 0x7fffffffcf55 is located in stack of thread T0 at offset 117 in frame
    #0 0x42011f in json_nvme_id_ctrl /home/sbauer/nvme_code/nvme-cli/nvme-print.c:1254

  This frame has 3 object(s):
    [32, 41) 'fr'
    [96, 117) 'sn' <== Memory access at offset 117 overflows this variable
    [160, 201) 'mn'

Signed-off-by: Scott Bauer <scott.bauer@intel.com>
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