summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0001-syscalls-Check-for-time64-unsafe-syscalls-before-usi.patch
blob: c43166971634d616fd50995f2d9afb9791f047f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From b66905b094e08a84c30bc135003c3611f65d53ec Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 12 Feb 2020 22:22:17 -0800
Subject: [PATCH] syscalls: Check for time64 unsafe syscalls before using them

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

Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/1241258/]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 lib/tst_clocks.c                                        | 9 +++++----
 testcases/kernel/syscalls/gettimeofday/gettimeofday01.c | 6 ++----
 testcases/kernel/syscalls/gettimeofday/gettimeofday02.c | 8 +++-----
 3 files changed, 10 insertions(+), 13 deletions(-)

--- a/lib/tst_clocks.c
+++ b/lib/tst_clocks.c
@@ -22,21 +22,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);
 }
--- 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 */
--- 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;
 		}