[PATCH 1/2] fanotify: fix broken ref count in create_fd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In create_fd(), before we fallback to open a file read-only we should grab dentry
and mount refs again, since they have been put by the former failed call to dentry_open().

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@xxxxxx>
---
 fs/notify/fanotify/fanotify_user.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

 Please apply this against commit 26552d4aa4117cd3ea8cbe13ebf317da652e6bfd of
 branch 'origin/for-next' from git.infradead.org/users/eparis/notify.git

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 2d4925b..e108960 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -92,6 +92,10 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
 		 * in order to at least provide something to the listener.
 		 */
 		if (IS_ERR(new_file) && group->fanotify_data.readonly_fallback) {
+			/* dentry_open() put our refs, so get them again... */
+			dentry = dget(event->path.dentry);
+			mnt = mntget(event->path.mnt);
+
 			flags &= ~O_ACCMODE;
 			flags |= O_RDONLY;
 			new_file = dentry_open(dentry, mnt, flags,
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux