Skip to content

Commit 422ce07

Browse files
committed
Merge tag 'audit-pr-20170816' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit
Pull audit fixes from Paul Moore: "Two small fixes to the audit code, both explained well in the respective patch descriptions, but the quick summary is one use-after-free fix, and one silly fanotify notification flag fix" * tag 'audit-pr-20170816' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: audit: Receive unmount event audit: Fix use after free in audit_remove_watch_rule()
2 parents 510c8a8 + b5fed47 commit 422ce07

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎kernel/audit_watch.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static struct fsnotify_group *audit_watch_group;
6666

6767
/* fsnotify events we care about. */
6868
#define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\
69-
FS_MOVE_SELF | FS_EVENT_ON_CHILD)
69+
FS_MOVE_SELF | FS_EVENT_ON_CHILD | FS_UNMOUNT)
7070

7171
static void audit_free_parent(struct audit_parent *parent)
7272
{
@@ -457,13 +457,15 @@ void audit_remove_watch_rule(struct audit_krule *krule)
457457
list_del(&krule->rlist);
458458

459459
if (list_empty(&watch->rules)) {
460+
/*
461+
* audit_remove_watch() drops our reference to 'parent' which
462+
* can get freed. Grab our own reference to be safe.
463+
*/
464+
audit_get_parent(parent);
460465
audit_remove_watch(watch);
461-
462-
if (list_empty(&parent->watches)) {
463-
audit_get_parent(parent);
466+
if (list_empty(&parent->watches))
464467
fsnotify_destroy_mark(&parent->mark, audit_watch_group);
465-
audit_put_parent(parent);
466-
}
468+
audit_put_parent(parent);
467469
}
468470
}
469471

0 commit comments

Comments
 (0)