summaryrefslogtreecommitdiff
path: root/kernel/auditsc.c
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-04-07 08:55:23 (GMT)
committerEric Paris <eparis@redhat.com>2013-04-10 17:31:12 (GMT)
commit2950fa9d3291b90e9b7663b6a409ea37a97a5e35 (patch)
tree59d613c0734447257a48974d81035538e8397b48 /kernel/auditsc.c
parent65ada7bc02e2dcea6dea1f11876e712d5ea7e9ba (diff)
downloadlinux-fsl-qoriq-2950fa9d3291b90e9b7663b6a409ea37a97a5e35.tar.xz
kernel: audit: beautify code, for extern function, better to check its parameters by itself
__audit_socketcall is an extern function. better to check its parameters by itself. also can return error code, when fail (find invalid parameters). also use macro instead of real hard code number also give related comments for it. Signed-off-by: Chen Gang <gang.chen@asianux.com> [eparis: fix the return value when !CONFIG_AUDIT] Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r--kernel/auditsc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index b59ffb2..d57ad32 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -226,7 +226,7 @@ struct audit_context {
union {
struct {
int nargs;
- long args[6];
+ long args[AUDITSC_ARGS];
} socketcall;
struct {
kuid_t uid;
@@ -2491,17 +2491,20 @@ int __audit_bprm(struct linux_binprm *bprm)
/**
* audit_socketcall - record audit data for sys_socketcall
- * @nargs: number of args
+ * @nargs: number of args, which should not be more than AUDITSC_ARGS.
* @args: args array
*
*/
-void __audit_socketcall(int nargs, unsigned long *args)
+int __audit_socketcall(int nargs, unsigned long *args)
{
struct audit_context *context = current->audit_context;
+ if (nargs <= 0 || nargs > AUDITSC_ARGS || !args)
+ return -EINVAL;
context->type = AUDIT_SOCKETCALL;
context->socketcall.nargs = nargs;
memcpy(context->socketcall.args, args, nargs * sizeof(unsigned long));
+ return 0;
}
/**