sgx-lkl
sgx-lkl copied to clipboard
[Tests] Syscall "gethostbyname_r" is not returning ERANGE error when we pass small buffer size
When we executing the LTP test case found that gethostbyname_r syscall is not returning ERANGE when invalid buffer length is passed. As per the man page "https://linux.die.net/man/3/gethostbyname_r" it should return ERANGE error. Please find below text from man page.
"In addition to the errors returned by the nonreentrant versions of these functions, if buf is too small, the functions will return ERANGE, and the call should be retried with a larger buffer."
Test case Description: This test case is to test the ERANGE error is getting returned when an invalid buffer length is passed.
Link: https://github.com/linux-test-project/ltp/blob/c5311d26fb80988de010301c0855a5f65442c6c0/testcases/kernel/syscalls/gethostbyname_r/gethostbyname_r01.c#L84
GDB_Logs & parameters values:
------------GDB logs ----------------
Thread 6 "ENCLAVE" hit Breakpoint 1, gethostbyname_r (name=0x7fff40b5e9b0 '0' <repeats 200 times>..., h=0x7fff40b5e990,
buf=0x7fff3dcd8040 <temp> "buffer", buflen=1024, res=0x7fff40b5e988, err=0x7fff40b5e984) at src/network/gethostbyname_r.c:10
10 return gethostbyname2_r(name, AF_INET, h, buf, buflen, res, err);
(gdb) s
gethostbyname2_r (name=0x7fff40b5e9b0 '0' <repeats 200 times>..., af=2, h=0x7fff40b5e990, buf=0x7fff3dcd8040 <temp> "buffer",
buflen=1024, res=0x7fff40b5e988, err=0x7fff40b5e984) at src/network/gethostbyname2_r.c:20
20 *res = 0;
(gdb) bt
0 gethostbyname2_r (name=0x7fff40b5e9b0 '0' <repeats 200 times>..., af=2, h=0x7fff40b5e990, buf=0x7fff3dcd8040 <temp> "buffer",
buflen=1024, res=0x7fff40b5e988, err=0x7fff40b5e984) at src/network/gethostbyname2_r.c:20
1 0x00007fff00577970 in gethostbyname_r (name=0x7fff40b5e9b0 '0' <repeats 200 times>..., h=0x7fff40b5e990,
buf=0x7fff3dcd8040 <temp> "buffer", buflen=1024, res=0x7fff40b5e988, err=0x7fff40b5e984) at src/network/gethostbyname_r.c:10
2 0x00007fff3dabe76c in check_vulnerable () at gethostbyname_r01.c:84
3 0x00007fff3dabe58a in main (ac=<optimized out>, av=<optimized out>) at gethostbyname_r01.c:54
4 0x00007fff00538402 in libc_start_main_stage2 (main=0x7fff3dabe550 <main>, argc=1, argv=0x7fff40b5ee80)
at src/env/__libc_start_main.c:168
5 0x00007fff00538361 in __libc_start_main (main=0x7fff3dabe550 <main>, argc=1, argv=0x7fff40b5ee80) at src/env/__libc_start_main.c:153
6 0x00007fff3dabe5d8 in _start_c (p=<optimized out>) at crt/crt1.c:17
7 0x00007fff3dabe5b0 in _start ()
8 0x00007fff00b6a6c0 in ?? ()
9 0x0000000000000001 in ?? ()
10 0x00007fff00b65890 in ?? ()
11 0x0000000000000000 in ?? ()
-----------GDB logs end -------------
When we execute the test case on other Linux machine this test case is passed. In sgx-lkl environment "gethostbyname_r" consistently returning ENOENT.
Can you fix the markdown formatting? Where is ENOENT returned?
@prp , updated the details.
@shaikshavali1, please put the failure message correctly formatted.