stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] inotify: actually check for invalid bits in sys_inotify_add_watch()
@ 2015-06-30 17:36 Dave Hansen
  2015-09-09 21:59 ` Dave Hansen
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Hansen @ 2015-06-30 17:36 UTC (permalink / raw)
  To: dave; +Cc: dave.hansen, john, rlove, eparis, linux-kernel, stable


From: Dave Hansen <dave.hansen@linux.intel.com>

The comment here says that it is checking for invalid bits.  But,
the mask is *actually* checking to ensure that _any_ valid bit
is set, which is quite different.

Add the actual check which was intended.  Retain the existing
check because it actually does something useful: ensure that some
inotify bits are being added to the watch.  Plus, this is
existing behavior which would be nice to preserve.

I did a quick sniff test that inotify functions and that my
'inotify-tools' package passes 'make check'.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: John McCutchan <john@johnmccutchan.com> (maintainer:INOTIFY)
Cc: Robert Love <rlove@rlove.org> (maintainer:INOTIFY)
Cc: Eric Paris <eparis@parisplace.org> (maintainer:INOTIFY)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: stable@vger.kernel.org
---

 b/fs/notify/inotify/inotify_user.c |    3 +++
 1 file changed, 3 insertions(+)

diff -puN fs/notify/inotify/inotify_user.c~inotify-EINVAL-on-invalid-bit fs/notify/inotify/inotify_user.c
--- a/fs/notify/inotify/inotify_user.c~inotify-EINVAL-on-invalid-bit	2015-06-26 13:33:30.277219285 -0700
+++ b/fs/notify/inotify/inotify_user.c	2015-06-26 13:35:19.026122033 -0700
@@ -707,6 +707,9 @@ SYSCALL_DEFINE3(inotify_add_watch, int,
 	unsigned flags = 0;
 
 	/* don't allow invalid bits: we don't want flags set */
+	if (unlikely(mask & ~ALL_INOTIFY_BITS))
+		return -EINVAL;
+	/* require at least one valid bit set in the mask */
 	if (unlikely(!(mask & ALL_INOTIFY_BITS)))
 		return -EINVAL;
 
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-21 11:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-30 17:36 [PATCH] inotify: actually check for invalid bits in sys_inotify_add_watch() Dave Hansen
2015-09-09 21:59 ` Dave Hansen
2015-09-09 22:37   ` Josh Boyer
2015-09-09 23:16   ` Eric Paris
2015-09-09 23:32     ` Dave Hansen
2015-09-10 20:49       ` Andrew Morton
2015-09-21 11:29         ` Andrey Wagin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).