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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
--- sys/amd64/linux/linux_machdep.c.orig
+++ sys/amd64/linux/linux_machdep.c
@@ -81,6 +81,8 @@
#include <x86/ifunc.h>
#include <x86/sysarch.h>
+#include <security/audit/audit.h>
+
#include <amd64/linux/linux.h>
#include <amd64/linux/linux_proto.h>
#include <compat/linux/linux_emul.h>
@@ -107,6 +109,7 @@
free(path, M_TEMP);
if (error == 0)
error = linux_common_execve(td, &eargs);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
--- sys/amd64/linux32/linux32_machdep.c.orig
+++ sys/amd64/linux32/linux32_machdep.c
@@ -69,6 +69,8 @@
#include <vm/vm.h>
#include <vm/vm_map.h>
+#include <security/audit/audit.h>
+
#include <compat/freebsd32/freebsd32_util.h>
#include <amd64/linux32/linux.h>
#include <amd64/linux32/linux32_proto.h>
@@ -138,6 +140,7 @@
free(path, M_TEMP);
if (error == 0)
error = linux_common_execve(td, &eargs);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
--- sys/arm64/linux/linux_machdep.c.orig
+++ sys/arm64/linux/linux_machdep.c
@@ -38,6 +38,8 @@
#include <sys/proc.h>
#include <sys/sdt.h>
+#include <security/audit/audit.h>
+
#include <arm64/linux/linux.h>
#include <arm64/linux/linux_proto.h>
#include <compat/linux/linux_dtrace.h>
@@ -74,6 +76,7 @@
free(path, M_TEMP);
if (error == 0)
error = linux_common_execve(td, &eargs);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
--- sys/compat/freebsd32/freebsd32_misc.c.orig
+++ sys/compat/freebsd32/freebsd32_misc.c
@@ -440,6 +440,7 @@
if (error == 0)
error = kern_execve(td, &eargs, NULL, oldvmspace);
post_execve(td, error, oldvmspace);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
@@ -460,6 +461,7 @@
error = kern_execve(td, &eargs, NULL, oldvmspace);
}
post_execve(td, error, oldvmspace);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
--- sys/i386/linux/linux_machdep.c.orig
+++ sys/i386/linux/linux_machdep.c
@@ -61,6 +61,8 @@
#include <vm/vm.h>
#include <vm/vm_map.h>
+#include <security/audit/audit.h>
+
#include <i386/linux/linux.h>
#include <i386/linux/linux_proto.h>
#include <compat/linux/linux_emul.h>
@@ -111,6 +113,7 @@
free(newpath, M_TEMP);
if (error == 0)
error = linux_common_execve(td, &eargs);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
--- sys/kern/kern_exec.c.orig
+++ sys/kern/kern_exec.c
@@ -224,6 +224,7 @@
if (error == 0)
error = kern_execve(td, &args, NULL, oldvmspace);
post_execve(td, error, oldvmspace);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
@@ -251,6 +252,7 @@
error = kern_execve(td, &args, NULL, oldvmspace);
}
post_execve(td, error, oldvmspace);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
}
@@ -279,6 +281,7 @@
if (error == 0)
error = kern_execve(td, &args, uap->mac_p, oldvmspace);
post_execve(td, error, oldvmspace);
+ AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td);
return (error);
#else
return (ENOSYS);
--- sys/kern/subr_syscall.c.orig
+++ sys/kern/subr_syscall.c
@@ -142,6 +142,16 @@
AUDIT_SYSCALL_ENTER(sa->code, td);
error = (sa->callp->sy_call)(td, sa->args);
+
+ /*
+ * Note that some syscall implementations (e.g., sys_execve)
+ * will commit the audit record just before their final return.
+ * These were done under the assumption that nothing of interest
+ * would happen between their return and here, where we would
+ * normally commit the audit record. These assumptions will
+ * need to be revisited should any substantial logic be added
+ * above.
+ */
AUDIT_SYSCALL_EXIT(error, td);
/* Save the latest error return value. */
|