• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INT_SYSCALL_HOOKS_H
17 #define INT_SYSCALL_HOOKS_H
18 
19 #include <features.h>
20 #include <stddef.h>
21 
22 extern hidden volatile const char *g_syscall_hooks_table __attribute__((aligned(8)));
23 extern hidden volatile void *g_syscall_hooks_entry __attribute__((aligned(8)));
24 
25 #ifdef ENABLE_HWASAN
26 __attribute__((no_sanitize("hwaddress")))
27 #endif
is_syscall_hooked(long n)28 static inline int is_syscall_hooked(long n)
29 {
30 	return g_syscall_hooks_table != NULL && g_syscall_hooks_table[n] != 0;
31 }
32 
__syscall_hooks_entry0(long n)33 static inline long __syscall_hooks_entry0(long n)
34 {
35 	return ((long (*)(long))g_syscall_hooks_entry)(n);
36 }
37 
__syscall_hooks_entry1(long n,long a)38 static inline long __syscall_hooks_entry1(long n, long a)
39 {
40 	return ((long (*)(long, long))g_syscall_hooks_entry)(n, a);
41 }
42 
__syscall_hooks_entry2(long n,long a,long b)43 static inline long __syscall_hooks_entry2(long n, long a, long b)
44 {
45 	return ((long (*)(long, long, long))g_syscall_hooks_entry)(n, a, b);
46 }
47 
__syscall_hooks_entry3(long n,long a,long b,long c)48 static inline long __syscall_hooks_entry3(long n, long a, long b, long c)
49 {
50 	return ((long (*)(long, long, long, long))g_syscall_hooks_entry)(n, a, b, c);
51 }
52 
__syscall_hooks_entry4(long n,long a,long b,long c,long d)53 static inline long __syscall_hooks_entry4(long n, long a, long b, long c, long d)
54 {
55 	return ((long (*)(long, long, long, long, long))g_syscall_hooks_entry)(n, a, b, c, d);
56 }
57 
__syscall_hooks_entry5(long n,long a,long b,long c,long d,long e)58 static inline long __syscall_hooks_entry5(long n, long a, long b, long c, long d, long e)
59 {
60 	return ((long (*)(long, long, long, long, long, long))g_syscall_hooks_entry)(n, a, b, c, d, e);
61 }
62 
__syscall_hooks_entry6(long n,long a,long b,long c,long d,long e,long f)63 static inline long __syscall_hooks_entry6(long n, long a, long b, long c, long d, long e, long f)
64 {
65 	return ((long (*)(long, long, long, long, long, long, long))g_syscall_hooks_entry)(n, a, b, c, d, e, f);
66 }
67 #endif