* [LTP] [PATCH v3] syscalls: Check for time64 unsafe syscalls before using them
@ 2020-02-20 6:52 Khem Raj
2020-02-26 23:52 ` Khem Raj
0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2020-02-20 6:52 UTC (permalink / raw)
To: ltp
musl is using 64bit time_t now on 32bit architectures and these syscalls
no longer exist, therefore its better to check for them being available
before using them
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
lib/tst_clocks.c | 11 ++++++-----
.../kernel/syscalls/gettimeofday/gettimeofday01.c | 6 ++----
.../kernel/syscalls/gettimeofday/gettimeofday02.c | 8 +++-----
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
index 5195da38f3..155551170d 100644
--- a/lib/tst_clocks.c
+++ b/lib/tst_clocks.c
@@ -10,21 +10,22 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <time.h>
-#include <sys/syscall.h>
-
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
#include "tst_clocks.h"
+#include "lapi/syscalls.h"
int tst_clock_getres(clockid_t clk_id, struct timespec *res)
{
- return syscall(SYS_clock_getres, clk_id, res);
+ return tst_syscall(__NR_clock_getres, clk_id, res);
}
int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
{
- return syscall(SYS_clock_gettime, clk_id, ts);
+ return tst_syscall(__NR_clock_gettime, clk_id, ts);
}
int tst_clock_settime(clockid_t clk_id, struct timespec *ts)
{
- return syscall(SYS_clock_settime, clk_id, ts);
+ return tst_syscall(__NR_clock_settime, clk_id, ts);
}
diff --git a/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c b/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
index 583d8f7b9b..08ea1673ad 100644
--- a/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
+++ b/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
@@ -38,10 +38,8 @@
#include <sys/time.h>
#include <errno.h>
#include "test.h"
-#include <sys/syscall.h>
#include <unistd.h>
-
-#define gettimeofday(a,b) syscall(__NR_gettimeofday,a,b)
+#include "lapi/syscalls.h"
char *TCID = "gettimeofday01";
int TST_TOTAL = 1;
@@ -63,7 +61,7 @@ int main(int ac, char **av)
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
- TEST(gettimeofday((void *)-1, (void *)-1));
+ TEST(ltp_syscall(__NR_gettimeofday, (void *)-1, (void *)-1));
/* gettimeofday returns an int, so we need to turn the long
* TEST_RETURN into an int to test with */
diff --git a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
index 1d60f448e8..5170ad2f78 100644
--- a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
+++ b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
@@ -16,14 +16,12 @@
#include <stdint.h>
#include <sys/time.h>
#include <stdlib.h>
-#include <sys/syscall.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include "tst_test.h"
-
-#define gettimeofday(a,b) syscall(__NR_gettimeofday,a,b)
+#include "lapi/syscalls.h"
static volatile sig_atomic_t done;
static char *str_rtime;
@@ -48,13 +46,13 @@ static void verify_gettimeofday(void)
alarm(rtime);
- if (gettimeofday(&tv1, NULL)) {
+ if (tst_syscall(__NR_gettimeofday, &tv1, NULL)) {
tst_res(TBROK | TERRNO, "gettimeofday() failed");
return;
}
while (!done) {
- if (gettimeofday(&tv2, NULL)) {
+ if (tst_syscall(__NR_gettimeofday, &tv2, NULL)) {
tst_res(TBROK | TERRNO, "gettimeofday() failed");
return;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH v3] syscalls: Check for time64 unsafe syscalls before using them
2020-02-20 6:52 [LTP] [PATCH v3] syscalls: Check for time64 unsafe syscalls before using them Khem Raj
@ 2020-02-26 23:52 ` Khem Raj
2020-02-27 19:41 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2020-02-26 23:52 UTC (permalink / raw)
To: ltp
ping
On 2/19/20 10:52 PM, Khem Raj wrote:
> musl is using 64bit time_t now on 32bit architectures and these syscalls
> no longer exist, therefore its better to check for them being available
> before using them
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> lib/tst_clocks.c | 11 ++++++-----
> .../kernel/syscalls/gettimeofday/gettimeofday01.c | 6 ++----
> .../kernel/syscalls/gettimeofday/gettimeofday02.c | 8 +++-----
> 3 files changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
> index 5195da38f3..155551170d 100644
> --- a/lib/tst_clocks.c
> +++ b/lib/tst_clocks.c
> @@ -10,21 +10,22 @@
> #define _GNU_SOURCE
> #include <unistd.h>
> #include <time.h>
> -#include <sys/syscall.h>
> -
> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"
> #include "tst_clocks.h"
> +#include "lapi/syscalls.h"
>
> int tst_clock_getres(clockid_t clk_id, struct timespec *res)
> {
> - return syscall(SYS_clock_getres, clk_id, res);
> + return tst_syscall(__NR_clock_getres, clk_id, res);
> }
>
> int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
> {
> - return syscall(SYS_clock_gettime, clk_id, ts);
> + return tst_syscall(__NR_clock_gettime, clk_id, ts);
> }
>
> int tst_clock_settime(clockid_t clk_id, struct timespec *ts)
> {
> - return syscall(SYS_clock_settime, clk_id, ts);
> + return tst_syscall(__NR_clock_settime, clk_id, ts);
> }
> diff --git a/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c b/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
> index 583d8f7b9b..08ea1673ad 100644
> --- a/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
> +++ b/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
> @@ -38,10 +38,8 @@
> #include <sys/time.h>
> #include <errno.h>
> #include "test.h"
> -#include <sys/syscall.h>
> #include <unistd.h>
> -
> -#define gettimeofday(a,b) syscall(__NR_gettimeofday,a,b)
> +#include "lapi/syscalls.h"
>
> char *TCID = "gettimeofday01";
> int TST_TOTAL = 1;
> @@ -63,7 +61,7 @@ int main(int ac, char **av)
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> tst_count = 0;
>
> - TEST(gettimeofday((void *)-1, (void *)-1));
> + TEST(ltp_syscall(__NR_gettimeofday, (void *)-1, (void *)-1));
>
> /* gettimeofday returns an int, so we need to turn the long
> * TEST_RETURN into an int to test with */
> diff --git a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
> index 1d60f448e8..5170ad2f78 100644
> --- a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
> +++ b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
> @@ -16,14 +16,12 @@
> #include <stdint.h>
> #include <sys/time.h>
> #include <stdlib.h>
> -#include <sys/syscall.h>
> #include <unistd.h>
> #include <time.h>
> #include <errno.h>
>
> #include "tst_test.h"
> -
> -#define gettimeofday(a,b) syscall(__NR_gettimeofday,a,b)
> +#include "lapi/syscalls.h"
>
> static volatile sig_atomic_t done;
> static char *str_rtime;
> @@ -48,13 +46,13 @@ static void verify_gettimeofday(void)
>
> alarm(rtime);
>
> - if (gettimeofday(&tv1, NULL)) {
> + if (tst_syscall(__NR_gettimeofday, &tv1, NULL)) {
> tst_res(TBROK | TERRNO, "gettimeofday() failed");
> return;
> }
>
> while (!done) {
> - if (gettimeofday(&tv2, NULL)) {
> + if (tst_syscall(__NR_gettimeofday, &tv2, NULL)) {
> tst_res(TBROK | TERRNO, "gettimeofday() failed");
> return;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH v3] syscalls: Check for time64 unsafe syscalls before using them
2020-02-26 23:52 ` Khem Raj
@ 2020-02-27 19:41 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2020-02-27 19:41 UTC (permalink / raw)
To: ltp
Hi Khem,
> ping
Sorry for the delay, merged (with tiny changes: cleared comment, _GNU_SOURCE and
unistd.h include).
Kind regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-27 19:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-20 6:52 [LTP] [PATCH v3] syscalls: Check for time64 unsafe syscalls before using them Khem Raj
2020-02-26 23:52 ` Khem Raj
2020-02-27 19:41 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox