aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditfilter.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/auditfilter.c')
-rw-r--r--kernel/auditfilter.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 92062fd6cc8c..8e9bc9c3dbb7 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -19,6 +19,8 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/kernel.h> 24#include <linux/kernel.h>
23#include <linux/audit.h> 25#include <linux/audit.h>
24#include <linux/kthread.h> 26#include <linux/kthread.h>
@@ -226,7 +228,7 @@ static int audit_match_signal(struct audit_entry *entry)
226#endif 228#endif
227 229
228/* Common user-space to kernel rule translation. */ 230/* Common user-space to kernel rule translation. */
229static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule) 231static inline struct audit_entry *audit_to_entry_common(struct audit_rule_data *rule)
230{ 232{
231 unsigned listnr; 233 unsigned listnr;
232 struct audit_entry *entry; 234 struct audit_entry *entry;
@@ -249,7 +251,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule)
249 ; 251 ;
250 } 252 }
251 if (unlikely(rule->action == AUDIT_POSSIBLE)) { 253 if (unlikely(rule->action == AUDIT_POSSIBLE)) {
252 printk(KERN_ERR "AUDIT_POSSIBLE is deprecated\n"); 254 pr_err("AUDIT_POSSIBLE is deprecated\n");
253 goto exit_err; 255 goto exit_err;
254 } 256 }
255 if (rule->action != AUDIT_NEVER && rule->action != AUDIT_ALWAYS) 257 if (rule->action != AUDIT_NEVER && rule->action != AUDIT_ALWAYS)
@@ -403,7 +405,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
403 int i; 405 int i;
404 char *str; 406 char *str;
405 407
406 entry = audit_to_entry_common((struct audit_rule *)data); 408 entry = audit_to_entry_common(data);
407 if (IS_ERR(entry)) 409 if (IS_ERR(entry))
408 goto exit_nofree; 410 goto exit_nofree;
409 411
@@ -431,6 +433,19 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
431 f->val = 0; 433 f->val = 0;
432 } 434 }
433 435
436 if ((f->type == AUDIT_PID) || (f->type == AUDIT_PPID)) {
437 struct pid *pid;
438 rcu_read_lock();
439 pid = find_vpid(f->val);
440 if (!pid) {
441 rcu_read_unlock();
442 err = -ESRCH;
443 goto exit_free;
444 }
445 f->val = pid_nr(pid);
446 rcu_read_unlock();
447 }
448
434 err = audit_field_valid(entry, f); 449 err = audit_field_valid(entry, f);
435 if (err) 450 if (err)
436 goto exit_free; 451 goto exit_free;
@@ -479,8 +494,8 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
479 /* Keep currently invalid fields around in case they 494 /* Keep currently invalid fields around in case they
480 * become valid after a policy reload. */ 495 * become valid after a policy reload. */
481 if (err == -EINVAL) { 496 if (err == -EINVAL) {
482 printk(KERN_WARNING "audit rule for LSM " 497 pr_warn("audit rule for LSM \'%s\' is invalid\n",
483 "\'%s\' is invalid\n", str); 498 str);
484 err = 0; 499 err = 0;
485 } 500 }
486 if (err) { 501 if (err) {
@@ -709,8 +724,8 @@ static inline int audit_dupe_lsm_field(struct audit_field *df,
709 /* Keep currently invalid fields around in case they 724 /* Keep currently invalid fields around in case they
710 * become valid after a policy reload. */ 725 * become valid after a policy reload. */
711 if (ret == -EINVAL) { 726 if (ret == -EINVAL) {
712 printk(KERN_WARNING "audit rule for LSM \'%s\' is " 727 pr_warn("audit rule for LSM \'%s\' is invalid\n",
713 "invalid\n", df->lsm_str); 728 df->lsm_str);
714 ret = 0; 729 ret = 0;
715 } 730 }
716 731
@@ -1240,12 +1255,14 @@ static int audit_filter_user_rules(struct audit_krule *rule, int type,
1240 1255
1241 for (i = 0; i < rule->field_count; i++) { 1256 for (i = 0; i < rule->field_count; i++) {
1242 struct audit_field *f = &rule->fields[i]; 1257 struct audit_field *f = &rule->fields[i];
1258 pid_t pid;
1243 int result = 0; 1259 int result = 0;
1244 u32 sid; 1260 u32 sid;
1245 1261
1246 switch (f->type) { 1262 switch (f->type) {
1247 case AUDIT_PID: 1263 case AUDIT_PID:
1248 result = audit_comparator(task_pid_vnr(current), f->op, f->val); 1264 pid = task_pid_nr(current);
1265 result = audit_comparator(pid, f->op, f->val);
1249 break; 1266 break;
1250 case AUDIT_UID: 1267 case AUDIT_UID:
1251 result = audit_uid_comparator(current_uid(), f->op, f->uid); 1268 result = audit_uid_comparator(current_uid(), f->op, f->uid);