Skip to content
Snippets Groups Projects
Select Git revision
  • 5cf9dd55a0ec26428f2824aadd16bfa305a5b603
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

callback.c

Blame
  • audit_watch.c 13.67 KiB
    // SPDX-License-Identifier: GPL-2.0-or-later
    /* audit_watch.c -- watching inodes
     *
     * Copyright 2003-2009 Red Hat, Inc.
     * Copyright 2005 Hewlett-Packard Development Company, L.P.
     * Copyright 2005 IBM Corporation
     */
    
    #include <linux/file.h>
    #include <linux/kernel.h>
    #include <linux/audit.h>
    #include <linux/kthread.h>
    #include <linux/mutex.h>
    #include <linux/fs.h>
    #include <linux/fsnotify_backend.h>
    #include <linux/namei.h>
    #include <linux/netlink.h>
    #include <linux/refcount.h>
    #include <linux/sched.h>
    #include <linux/slab.h>
    #include <linux/security.h>
    #include "audit.h"
    
    /*
     * Reference counting:
     *
     * audit_parent: lifetime is from audit_init_parent() to receipt of an FS_IGNORED
     * 	event.  Each audit_watch holds a reference to its associated parent.
     *
     * audit_watch: if added to lists, lifetime is from audit_init_watch() to
     * 	audit_remove_watch().  Additionally, an audit_watch may exist
     * 	temporarily to assist in searching existing filter data.  Each
     * 	audit_krule holds a reference to its associated watch.
     */
    
    struct audit_watch {
    	refcount_t		count;	/* reference count */
    	dev_t			dev;	/* associated superblock device */
    	char			*path;	/* insertion path */
    	unsigned long		ino;	/* associated inode number */
    	struct audit_parent	*parent; /* associated parent */
    	struct list_head	wlist;	/* entry in parent->watches list */
    	struct list_head	rules;	/* anchor for krule->rlist */
    };
    
    struct audit_parent {
    	struct list_head	watches; /* anchor for audit_watch->wlist */
    	struct fsnotify_mark mark; /* fsnotify mark on the inode */
    };
    
    /* fsnotify handle. */
    static struct fsnotify_group *audit_watch_group;
    
    /* fsnotify events we care about. */
    #define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\
    			FS_MOVE_SELF | FS_UNMOUNT)
    
    static void audit_free_parent(struct audit_parent *parent)
    {
    	WARN_ON(!list_empty(&parent->watches));
    	kfree(parent);
    }
    
    static void audit_watch_free_mark(struct fsnotify_mark *entry)
    {
    	struct audit_parent *parent;
    
    	parent = container_of(entry, struct audit_parent, mark);
    	audit_free_parent(parent);
    }