From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757237Ab3ERCS3 (ORCPT ); Fri, 17 May 2013 22:18:29 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.122]:14912 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756801Ab3ERCQ7 (ORCPT ); Fri, 17 May 2013 22:16:59 -0400 X-Authority-Analysis: v=2.0 cv=UO1f7Vjy c=1 sm=0 a=rXTBtCOcEpjy1lPqhTCpEQ==:17 a=mNMOxpOpBa8A:10 a=Ciwy3NGCPMMA:10 a=EkHcsc4YyhkA:10 a=5SG0PmZfjMsA:10 a=bbbx4UPp9XUA:10 a=meVymXHHAAAA:8 a=iT4wd3fUEwIA:10 a=i0EeH86SAAAA:8 a=Z4Rwk6OoAAAA:8 a=t7CeM3EgAAAA:8 a=20KFwNOVAAAA:8 a=77d_1CzMAAAA:8 a=VwQbUJbxAAAA:8 a=Nc5lta3nJawr1F_pDB8A:9 a=hPjdaMEvmhQA:10 a=jbrJJM5MRmoA:10 a=2e6ZYRoF4I4A:10 a=jEp0ucaQiEUA:10 a=w2G1Yk43JnIA:10 a=jeBq3FmKZ4MA:10 a=UxyJTjye8zGWrGUJ:21 a=7cHGK3AtX-GkLJQe:21 a=rXTBtCOcEpjy1lPqhTCpEQ==:117 X-Cloudmark-Score: 0 X-Authenticated-User: X-Originating-IP: 74.67.115.198 Message-Id: <20130518021651.427121663@goodmis.org> User-Agent: quilt/0.60-1 Date: Fri, 17 May 2013 22:16:57 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhao Hongjiang , Jim Somerville , Paul Gortmaker , Jerome Marchand , Eric Paris , Andrew Morton Subject: [ 060/136 ] inotify: invalid mask should return a error number but not set it References: <20130518021557.139113314@goodmis.org> Content-Disposition: inline; filename=0060-inotify-invalid-mask-should-return-a-error-number-bu.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.6.11.4 stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhao Hongjiang [ Upstream commit 04df32fa10ab9a6f0643db2949d42efc966bc844 ] When we run the crackerjack testsuite, the inotify_add_watch test is stalled. This is caused by the invalid mask 0 - the task is waiting for the event but it never comes. inotify_add_watch() should return -EINVAL as it did before commit 676a0675cf92 ("inotify: remove broken mask checks causing unmount to be EINVAL"). That commit removes the invalid mask check, but that check is needed. Check the mask's ALL_INOTIFY_BITS before the inotify_arg_to_mask() call. If none are set, just return -EINVAL. Because IN_UNMOUNT is in ALL_INOTIFY_BITS, this change will not trigger the problem that above commit fixed. [akpm@linux-foundation.org: fix build] Signed-off-by: Zhao Hongjiang Acked-by: Jim Somerville Cc: Paul Gortmaker Cc: Jerome Marchand Cc: Eric Paris Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Steven Rostedt --- fs/notify/inotify/inotify_user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 8445fbc..7e15ab0 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -577,7 +577,6 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, int add = (arg & IN_MASK_ADD); int ret; - /* don't allow invalid bits: we don't want flags set */ mask = inotify_arg_to_mask(arg); if (unlikely(!(mask & IN_ALL_EVENTS))) return -EINVAL; @@ -630,7 +629,6 @@ static int inotify_new_watch(struct fsnotify_group *group, struct idr *idr = &group->inotify_data.idr; spinlock_t *idr_lock = &group->inotify_data.idr_lock; - /* don't allow invalid bits: we don't want flags set */ mask = inotify_arg_to_mask(arg); if (unlikely(!(mask & IN_ALL_EVENTS))) return -EINVAL; @@ -761,6 +759,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, int ret, fput_needed; unsigned flags = 0; + /* don't allow invalid bits: we don't want flags set */ + if (unlikely(!(mask & ALL_INOTIFY_BITS))) + return -EINVAL; + filp = fget_light(fd, &fput_needed); if (unlikely(!filp)) return -EBADF; -- 1.7.10.4