diff options
-rw-r--r-- | include/linux/audit.h | 16 | ||||
-rw-r--r-- | kernel/auditsc.c | 9 | ||||
-rw-r--r-- | net/socket.c | 6 |
3 files changed, 21 insertions, 10 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index 37464c592c92..8f92e1dea966 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -84,6 +84,9 @@ extern int audit_classify_arch(int arch); | |||
84 | #define AUDIT_TYPE_CHILD_DELETE 3 /* a child being deleted */ | 84 | #define AUDIT_TYPE_CHILD_DELETE 3 /* a child being deleted */ |
85 | #define AUDIT_TYPE_CHILD_CREATE 4 /* a child being created */ | 85 | #define AUDIT_TYPE_CHILD_CREATE 4 /* a child being created */ |
86 | 86 | ||
87 | /* maximized args number that audit_socketcall can process */ | ||
88 | #define AUDITSC_ARGS 6 | ||
89 | |||
87 | struct filename; | 90 | struct filename; |
88 | 91 | ||
89 | #ifdef CONFIG_AUDITSYSCALL | 92 | #ifdef CONFIG_AUDITSYSCALL |
@@ -190,7 +193,7 @@ extern void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk | |||
190 | extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); | 193 | extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); |
191 | extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); | 194 | extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); |
192 | extern int __audit_bprm(struct linux_binprm *bprm); | 195 | extern int __audit_bprm(struct linux_binprm *bprm); |
193 | extern void __audit_socketcall(int nargs, unsigned long *args); | 196 | extern int __audit_socketcall(int nargs, unsigned long *args); |
194 | extern int __audit_sockaddr(int len, void *addr); | 197 | extern int __audit_sockaddr(int len, void *addr); |
195 | extern void __audit_fd_pair(int fd1, int fd2); | 198 | extern void __audit_fd_pair(int fd1, int fd2); |
196 | extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); | 199 | extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); |
@@ -224,10 +227,11 @@ static inline int audit_bprm(struct linux_binprm *bprm) | |||
224 | return __audit_bprm(bprm); | 227 | return __audit_bprm(bprm); |
225 | return 0; | 228 | return 0; |
226 | } | 229 | } |
227 | static inline void audit_socketcall(int nargs, unsigned long *args) | 230 | static inline int audit_socketcall(int nargs, unsigned long *args) |
228 | { | 231 | { |
229 | if (unlikely(!audit_dummy_context())) | 232 | if (unlikely(!audit_dummy_context())) |
230 | __audit_socketcall(nargs, args); | 233 | return __audit_socketcall(nargs, args); |
234 | return 0; | ||
231 | } | 235 | } |
232 | static inline int audit_sockaddr(int len, void *addr) | 236 | static inline int audit_sockaddr(int len, void *addr) |
233 | { | 237 | { |
@@ -354,8 +358,10 @@ static inline int audit_bprm(struct linux_binprm *bprm) | |||
354 | { | 358 | { |
355 | return 0; | 359 | return 0; |
356 | } | 360 | } |
357 | static inline void audit_socketcall(int nargs, unsigned long *args) | 361 | static inline int audit_socketcall(int nargs, unsigned long *args) |
358 | { } | 362 | { |
363 | return 0; | ||
364 | } | ||
359 | static inline void audit_fd_pair(int fd1, int fd2) | 365 | static inline void audit_fd_pair(int fd1, int fd2) |
360 | { } | 366 | { } |
361 | static inline int audit_sockaddr(int len, void *addr) | 367 | static inline int audit_sockaddr(int len, void *addr) |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index b59ffb293ded..d57ad32db367 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -226,7 +226,7 @@ struct audit_context { | |||
226 | union { | 226 | union { |
227 | struct { | 227 | struct { |
228 | int nargs; | 228 | int nargs; |
229 | long args[6]; | 229 | long args[AUDITSC_ARGS]; |
230 | } socketcall; | 230 | } socketcall; |
231 | struct { | 231 | struct { |
232 | kuid_t uid; | 232 | kuid_t uid; |
@@ -2491,17 +2491,20 @@ int __audit_bprm(struct linux_binprm *bprm) | |||
2491 | 2491 | ||
2492 | /** | 2492 | /** |
2493 | * audit_socketcall - record audit data for sys_socketcall | 2493 | * audit_socketcall - record audit data for sys_socketcall |
2494 | * @nargs: number of args | 2494 | * @nargs: number of args, which should not be more than AUDITSC_ARGS. |
2495 | * @args: args array | 2495 | * @args: args array |
2496 | * | 2496 | * |
2497 | */ | 2497 | */ |
2498 | void __audit_socketcall(int nargs, unsigned long *args) | 2498 | int __audit_socketcall(int nargs, unsigned long *args) |
2499 | { | 2499 | { |
2500 | struct audit_context *context = current->audit_context; | 2500 | struct audit_context *context = current->audit_context; |
2501 | 2501 | ||
2502 | if (nargs <= 0 || nargs > AUDITSC_ARGS || !args) | ||
2503 | return -EINVAL; | ||
2502 | context->type = AUDIT_SOCKETCALL; | 2504 | context->type = AUDIT_SOCKETCALL; |
2503 | context->socketcall.nargs = nargs; | 2505 | context->socketcall.nargs = nargs; |
2504 | memcpy(context->socketcall.args, args, nargs * sizeof(unsigned long)); | 2506 | memcpy(context->socketcall.args, args, nargs * sizeof(unsigned long)); |
2507 | return 0; | ||
2505 | } | 2508 | } |
2506 | 2509 | ||
2507 | /** | 2510 | /** |
diff --git a/net/socket.c b/net/socket.c index 2ca51c719ef9..1bbc37b7a312 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -2436,7 +2436,7 @@ static const unsigned char nargs[21] = { | |||
2436 | 2436 | ||
2437 | SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) | 2437 | SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) |
2438 | { | 2438 | { |
2439 | unsigned long a[6]; | 2439 | unsigned long a[AUDITSC_ARGS]; |
2440 | unsigned long a0, a1; | 2440 | unsigned long a0, a1; |
2441 | int err; | 2441 | int err; |
2442 | unsigned int len; | 2442 | unsigned int len; |
@@ -2452,7 +2452,9 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) | |||
2452 | if (copy_from_user(a, args, len)) | 2452 | if (copy_from_user(a, args, len)) |
2453 | return -EFAULT; | 2453 | return -EFAULT; |
2454 | 2454 | ||
2455 | audit_socketcall(nargs[call] / sizeof(unsigned long), a); | 2455 | err = audit_socketcall(nargs[call] / sizeof(unsigned long), a); |
2456 | if (err) | ||
2457 | return err; | ||
2456 | 2458 | ||
2457 | a0 = a[0]; | 2459 | a0 = a[0]; |
2458 | a1 = a[1]; | 2460 | a1 = a[1]; |