From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754312AbbIIWAL (ORCPT ); Wed, 9 Sep 2015 18:00:11 -0400 Received: from www.sr71.net ([198.145.64.142]:60354 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753486AbbIIWAA (ORCPT ); Wed, 9 Sep 2015 18:00:00 -0400 Subject: Re: [PATCH] inotify: actually check for invalid bits in sys_inotify_add_watch() Cc: john@johnmccutchan.com, rlove@rlove.org, eparis@parisplace.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20150630173603.D986EDB7@viggo.jf.intel.com> From: Dave Hansen Message-ID: <55F0ABDB.7040509@sr71.net> Date: Wed, 9 Sep 2015 14:59:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150630173603.D986EDB7@viggo.jf.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/30/2015 10:36 AM, Dave Hansen wrote: > From: Dave Hansen > > 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'. Did anybody have any comments on this patch? Who picks up inotify patches? > 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; > > _ >