-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsecure.h
More file actions
31 lines (27 loc) · 1.05 KB
/
secure.h
File metadata and controls
31 lines (27 loc) · 1.05 KB
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
#ifndef __SECURE__h
#define __SECURE__h
/*
* Macro to validate that a function pointer matches a specific signature.
* Usage: DECL_FUNC_CHECK(your_func_ptr, expected_signature)
* Life before c11 introduced-_-
*/
#define DECL_FUNC_CHECK(ptr, signature) \
_Static_assert( \
__builtin_types_compatible_p(__typeof__(ptr), signature), \
"Error: Function pointer '" #ptr "' does not match expected signature '" #signature "'." \
)
/*
* Signature definitions — trusted syscall function pointer types
* Add new ones here as needed
* But Unique function signature!-__-!
*/
#define SIG_SEQ_SHOW long (*)(struct seq_file *, void *)
#define SIG_MKDIR long (*)(const struct pt_regs *)
#define SIG_GET_PID long (*)(const struct pt_regs *)
#define SIG_IP_RCV int (*)(struct sk_buff *,struct net_device *,struct packet_type *, struct net_device *)
/*
* Example usage:
* typedef asmlinkage long (*my_tcp4_hook)(struct seq_file *seq, void *v);
* DECL_FUNC_CHECK(my_tcp4_hook, SIG_SEQ_SHOW);
*/
#endif // SECURE