aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/audit.h16
-rw-r--r--kernel/auditsc.c9
-rw-r--r--net/socket.c6
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
87struct filename; 90struct 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
190extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); 193extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
191extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); 194extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
192extern int __audit_bprm(struct linux_binprm *bprm); 195extern int __audit_bprm(struct linux_binprm *bprm);
193extern void __audit_socketcall(int nargs, unsigned long *args); 196extern int __audit_socketcall(int nargs, unsigned long *args);
194extern int __audit_sockaddr(int len, void *addr); 197extern int __audit_sockaddr(int len, void *addr);
195extern void __audit_fd_pair(int fd1, int fd2); 198extern void __audit_fd_pair(int fd1, int fd2);
196extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); 199extern 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}
227static inline void audit_socketcall(int nargs, unsigned long *args) 230static 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}
232static inline int audit_sockaddr(int len, void *addr) 236static 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}
357static inline void audit_socketcall(int nargs, unsigned long *args) 361static inline int audit_socketcall(int nargs, unsigned long *args)
358{ } 362{
363 return 0;
364}
359static inline void audit_fd_pair(int fd1, int fd2) 365static inline void audit_fd_pair(int fd1, int fd2)
360{ } 366{ }
361static inline int audit_sockaddr(int len, void *addr) 367static 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 */
2498void __audit_socketcall(int nargs, unsigned long *args) 2498int __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
2437SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) 2437SYSCALL_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];