[patch 17/26] audit: fix oops removing watch if audit disabled

Greg KH
2007-07-31T04:37:34Z

[-- Attachment #1: audit-fix-oops-removing-watch-if-audit-disabled.patch --]
[-- Type: text/plain, Size: 1112 bytes --]

-stable review patch. If anyone has any objections, please let us know.

------------------

From: Tony Jones <tonyj@suse.de>

Removing a watched file will oops if audit is disabled (auditctl -e 0).

To reproduce:
- auditctl -e 1
- touch /tmp/foo
- auditctl -w /tmp/foo
- auditctl -e 0
- rm /tmp/foo (or mv)

Signed-off-by: Tony Jones <tonyj@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---

kernel/auditfilter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.21.6.orig/kernel/auditfilter.c
+++ linux-2.6.21.6/kernel/auditfilter.c
@@ -905,7 +905,7 @@ static void audit_update_watch(struct au

/* If the update involves invalidating rules, do the inode-based
* filtering now, so we don't omit records. */
- if (invalidating &&
+ if (invalidating && current->audit_context &&
audit_filter_inodes(current, current->audit_context) == AUDIT_RECORD_CONTEXT)
audit_set_auditable(current->audit_context);

--