Skip to content

Commit 0a73dcc

Browse files
author
Al Viro
committed
[PATCH] validate rule fields' types
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent f368c07 commit 0a73dcc

1 file changed

Lines changed: 48 additions & 9 deletions

File tree

‎kernel/auditfilter.c‎

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,31 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
348348
f->val = rule->values[i];
349349

350350
err = -EINVAL;
351-
if (f->type & AUDIT_UNUSED_BITS)
352-
goto exit_free;
353-
354351
switch(f->type) {
355-
case AUDIT_SE_USER:
356-
case AUDIT_SE_ROLE:
357-
case AUDIT_SE_TYPE:
358-
case AUDIT_SE_SEN:
359-
case AUDIT_SE_CLR:
360-
case AUDIT_WATCH:
352+
default:
361353
goto exit_free;
354+
case AUDIT_PID:
355+
case AUDIT_UID:
356+
case AUDIT_EUID:
357+
case AUDIT_SUID:
358+
case AUDIT_FSUID:
359+
case AUDIT_GID:
360+
case AUDIT_EGID:
361+
case AUDIT_SGID:
362+
case AUDIT_FSGID:
363+
case AUDIT_LOGINUID:
364+
case AUDIT_PERS:
365+
case AUDIT_ARCH:
366+
case AUDIT_MSGTYPE:
367+
case AUDIT_DEVMAJOR:
368+
case AUDIT_DEVMINOR:
369+
case AUDIT_EXIT:
370+
case AUDIT_SUCCESS:
371+
case AUDIT_ARG0:
372+
case AUDIT_ARG1:
373+
case AUDIT_ARG2:
374+
case AUDIT_ARG3:
375+
break;
362376
case AUDIT_INODE:
363377
err = audit_to_inode(&entry->rule, f);
364378
if (err)
@@ -432,6 +446,29 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
432446
f->se_str = NULL;
433447
f->se_rule = NULL;
434448
switch(f->type) {
449+
case AUDIT_PID:
450+
case AUDIT_UID:
451+
case AUDIT_EUID:
452+
case AUDIT_SUID:
453+
case AUDIT_FSUID:
454+
case AUDIT_GID:
455+
case AUDIT_EGID:
456+
case AUDIT_SGID:
457+
case AUDIT_FSGID:
458+
case AUDIT_LOGINUID:
459+
case AUDIT_PERS:
460+
case AUDIT_ARCH:
461+
case AUDIT_MSGTYPE:
462+
case AUDIT_PPID:
463+
case AUDIT_DEVMAJOR:
464+
case AUDIT_DEVMINOR:
465+
case AUDIT_EXIT:
466+
case AUDIT_SUCCESS:
467+
case AUDIT_ARG0:
468+
case AUDIT_ARG1:
469+
case AUDIT_ARG2:
470+
case AUDIT_ARG3:
471+
break;
435472
case AUDIT_SE_USER:
436473
case AUDIT_SE_ROLE:
437474
case AUDIT_SE_TYPE:
@@ -474,6 +511,8 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
474511
if (err)
475512
goto exit_free;
476513
break;
514+
default:
515+
goto exit_free;
477516
}
478517
}
479518

0 commit comments

Comments
 (0)