You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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>
This commit is contained in:
+6
-3
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user