]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
fanotify: do not dereference inode_mark when it is unset
authorEric Paris <eparis@redhat.com>
Wed, 18 Aug 2010 16:25:49 +0000 (12:25 -0400)
committerEric Paris <eparis@redhat.com>
Mon, 23 Aug 2010 00:09:41 +0000 (20:09 -0400)
The fanotify code is supposed to get the group from the mark.  It accidentally
only used the inode_mark.  If the vfsmount_mark was set but not the inode_mark
it would deref the NULL inode_mark.  Get the group from the correct place.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@sophos.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
fs/notify/fsnotify.c

index 3970392b272264810574ca6536eed74bd3fc013d..f3e3b355ba7fd1be9ce8f02ce053516ac904ab93 100644 (file)
@@ -148,13 +148,14 @@ static int send_to_group(struct inode *to_tell, struct vfsmount *mnt,
                         const unsigned char *file_name,
                         struct fsnotify_event **event)
 {
-       struct fsnotify_group *group = inode_mark->group;
+       struct fsnotify_group *group = NULL;
        __u32 inode_test_mask = (mask & ~FS_EVENT_ON_CHILD);
        __u32 vfsmount_test_mask = (mask & ~FS_EVENT_ON_CHILD);
 
-       pr_debug("%s: group=%p to_tell=%p mnt=%p mark=%p mask=%x data=%p"
-                " data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
-                mnt, inode_mark, mask, data, data_is, cookie, *event);
+       if (unlikely(!inode_mark && !vfsmount_mark)) {
+               BUG();
+               return 0;
+       }
 
        /* clear ignored on inode modification */
        if (mask & FS_MODIFY) {
@@ -168,18 +169,24 @@ static int send_to_group(struct inode *to_tell, struct vfsmount *mnt,
 
        /* does the inode mark tell us to do something? */
        if (inode_mark) {
+               group = inode_mark->group;
                inode_test_mask &= inode_mark->mask;
                inode_test_mask &= ~inode_mark->ignored_mask;
        }
 
        /* does the vfsmount_mark tell us to do something? */
        if (vfsmount_mark) {
+               group = vfsmount_mark->group;
                vfsmount_test_mask &= vfsmount_mark->mask;
                vfsmount_test_mask &= ~vfsmount_mark->ignored_mask;
                if (inode_mark)
                        vfsmount_test_mask &= ~inode_mark->ignored_mask;
        }
 
+       pr_debug("%s: group=%p to_tell=%p mnt=%p mark=%p mask=%x data=%p"
+                " data_is=%d cookie=%d event=%p\n", __func__, group, to_tell,
+                mnt, inode_mark, mask, data, data_is, cookie, *event);
+
        if (!inode_test_mask && !vfsmount_test_mask)
                return 0;