2023-05-30 14:21:27

by Thomas Weißschuh

[permalink] [raw]
Subject: [PATCH] selftests/nolibc: remove test gettimeofday_null

gettimeofday() is not guaranteed by posix to handle a NULL value as first
argument gracefully.
On glibc for example it crashes. (When not going through the vdso)

Link: https://lore.kernel.org/lkml/[email protected]/
Signed-off-by: Thomas Weißschuh <[email protected]>
---
tools/testing/selftests/nolibc/nolibc-test.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 7de46305f419..0fe615ebb086 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -583,7 +583,6 @@ int run_syscall(int min, int max)
CASE_TEST(fork); EXPECT_SYSZR(1, test_fork()); break;
CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break;
CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break;
- CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break;
#ifdef NOLIBC
CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break;
CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break;

---
base-commit: 5b21219d67d3483144d10332709d0c04f733ab93
change-id: 20230530-nolibc-gettimeofday-6c72a10ba1a3

Best regards,
--
Thomas Weißschuh <[email protected]>



2023-06-02 02:56:24

by Zhangjin Wu

[permalink] [raw]
Subject: [PATCH] selftests/nolibc: remove test gettimeofday_null

Hi, Willy

I plan to send the v3 of rv32 series, but this patch may conflict with:

selftests/nolibc: remove gettimeofday_bad1/2 completely [1]

If this is mergable, perhaps I should wait for your new
2023xxxx-nolibc-rv32+stkp6 ;-)

And I plan to add the gettimeofday_tv and gettimeofday_tv_tz in the new generic
part1.

selftests/nolibc: add new gettimeofday test cases [2]

Best regards,
Zhangjin

[1]: https://lore.kernel.org/linux-riscv/485fe4e27c1fd1a84d11e9fc47178a48de39263b.1685387484.git.falcon@tinylab.org/T/#u
[2]: https://lore.kernel.org/linux-riscv/[email protected]/T/#u

> gettimeofday() is not guaranteed by posix to handle a NULL value as first
> argument gracefully.
> On glibc for example it crashes. (When not going through the vdso)
>
> Link: https://lore.kernel.org/lkml/[email protected]/
> Signed-off-by: Thomas Weißschuh <[email protected]>
> ---
> tools/testing/selftests/nolibc/nolibc-test.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 7de46305f419..0fe615ebb086 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -583,7 +583,6 @@ int run_syscall(int min, int max)
> CASE_TEST(fork); EXPECT_SYSZR(1, test_fork()); break;
> CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break;
> CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break;
> - CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break;
> #ifdef NOLIBC
> CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break;
> CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break;
>
> ---
> base-commit: 5b21219d67d3483144d10332709d0c04f733ab93
> change-id: 20230530-nolibc-gettimeofday-6c72a10ba1a3
>
> Best regards,
> --
> Thomas Weißschuh <[email protected]>