forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-02-17 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc
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
From a043f8e14d9e5f80124e34f6fde322760ff2cb71 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 13 Feb 2019 09:51:14 -0800
Subject: [PATCH] Define TEMP_FAILURE_RETRY and __si_fields
 
__si_fields is defined for non-glibc systems
TEMP_FAILURE_RETRY is defined if its not already defined
 
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 sandbox/linux/seccomp-bpf/trap.cc | 5 +++++
 sandbox/linux/suid/sandbox.c      | 9 +++++++++
 2 files changed, 14 insertions(+)
 
diff --git a/sandbox/linux/seccomp-bpf/trap.cc b/sandbox/linux/seccomp-bpf/trap.cc
index f5b86a73ac..6a08b6d08d 100644
--- a/sandbox/linux/seccomp-bpf/trap.cc
+++ b/sandbox/linux/seccomp-bpf/trap.cc
@@ -25,6 +25,11 @@
 #include "sandbox/linux/system_headers/linux_seccomp.h"
 #include "sandbox/linux/system_headers/linux_signal.h"
 
+// musl libc defines siginfo_t __si_fields instead of _sifields
+#if defined(__linux__) && !defined(__GLIBC__)
+#define _sifields __si_fields
+#endif
+
 namespace {
 
 struct arch_sigsys {
diff --git a/sandbox/linux/suid/sandbox.c b/sandbox/linux/suid/sandbox.c
index 5fdb4817af..09b81ef7e4 100644
--- a/sandbox/linux/suid/sandbox.c
+++ b/sandbox/linux/suid/sandbox.c
@@ -44,6 +44,15 @@
 
 static bool DropRoot();
 
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+  (__extension__                                                             \
+    ({ long int __result;                                                    \
+       do __result = (long int) (expression);                                \
+       while (__result == -1L && errno == EINTR);                            \
+       __result; }))
+#endif
+
 #define HANDLE_EINTR(x) TEMP_FAILURE_RETRY(x)
 
 static void FatalError(const char* msg, ...)