From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lino Sanfilippo Subject: Ensure FMODE_NONOTIFY is not set by userspace Date: Fri, 29 Oct 2010 12:02:17 +0200 Message-ID: <20101029100217.GC26242@lsanfilippo.unix.rd.tt.avira.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: eparis@redhat.com Return-path: Received: from mailout-de.gmx.net ([213.165.64.23]:58596 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1752328Ab0J2KDf (ORCPT ); Fri, 29 Oct 2010 06:03:35 -0400 Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: In fsnotify_open() ensure that FMODE_NONOTIFY is never set by userspace. Also always call fsnotify_parent and fsnotify. Signed-off-by: Lino Sanfilippo --- This patch applies against commit 3970d817558a426cc2f53eaa01182eb9452e0cb1 of branch 'origin/for-next' from git.infradead.org/users/eparis/notify.git diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index ecb43b3..5c185fa 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -235,10 +235,11 @@ static inline void fsnotify_open(struct file *file) if (S_ISDIR(inode->i_mode)) mask |= FS_ISDIR; - if (!(file->f_mode & FMODE_NONOTIFY)) { - fsnotify_parent(path, NULL, mask); - fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); - } + /* FMODE_NONOTIFY must never be set from user */ + file->f_mode &= ~FMODE_NONOTIFY; + + fsnotify_parent(path, NULL, mask); + fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); } /*