From patchwork Wed Oct 3 21:25:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10625325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E851F1515 for ; Wed, 3 Oct 2018 21:25:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D98CB2907A for ; Wed, 3 Oct 2018 21:25:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDBA429080; Wed, 3 Oct 2018 21:25:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DCB52907A for ; Wed, 3 Oct 2018 21:25:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbeJDEQA (ORCPT ); Thu, 4 Oct 2018 00:16:00 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:47077 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbeJDEP7 (ORCPT ); Thu, 4 Oct 2018 00:15:59 -0400 Received: by mail-wr1-f66.google.com with SMTP id a2-v6so605862wrc.13 for ; Wed, 03 Oct 2018 14:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lczJRDZf5gF/P9LPeBol0NCVj9AqNwkjgYSN6nlBwEo=; b=LdspMe0olJC81g4bxrpvykRe1Wft2vTcwjASpzhPfu8WQUW4Fdi774SC49inHM61uS OlueF8fy0E8SANdqKA1WMSNI2UnCaUm+MFGm9ATDRZXCLHiU+Z9j1dfo70Zu95xgEwrz FLiF0ueV5Aj0t6beEwKbf9wKziT/Vj8oS9oAVMjML9GVN8BqKsfwNRhvpMSxo3p03oEu IZYEGVNXTicWMrYbuCX0JxGtHMMX1rQtatYObJtwicMHQu1te2cme2tLG1hMtmtkm1XJ 8v/GO0pXm845XeLlSmkSfw4lviVcXjs55KIpNYYpG/9pzp5ZQvfLw6jIBfMIrRD2yb6n RLLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lczJRDZf5gF/P9LPeBol0NCVj9AqNwkjgYSN6nlBwEo=; b=FOsQ2mbDSsSYnxG/xHpsmhNGC/ppM9isY/MikK4pwOMKwDfqAfN6xnurYvH4/EFc1/ qa8H3h+gyjABW6hWMD2nMs5bCMEcDCnwqHHHdmmq/lXyNSPQ7dRWgTj96oa977ysladC +Bd5mXivFAAPGS4moPayHV/WDwVqSgn7sHXWjXPlaCrT22JGrqYHY5HG6mdY4EwuT4oT g/wmGjPRdU6V7l4m2zIO+aRZpTTDA7rnuOhTRqr1oB8wO5Qf0gs7U76BTtX0WsZuec1B m0vOi9iYDChRqDpTa6YkPe1rJMQaY4C/+C13pevp0WXg+SpuNp7gftCNWVppQRZifeH3 TraQ== X-Gm-Message-State: ABuFfogn9SwENF5tsF+PMpX/4+DjwfMIQqhekCZtN23NUcsX6hDbqSUO BLZk9cxX7i+FXaFbOO7dcKc= X-Google-Smtp-Source: ACcGV62GYwr3C+wLhaTUJIGrMuHbgBhPLgcDsYr1HdwO0oNmQrNzaQKd1FqHPBaD/I1N2B6hCWOYRw== X-Received: by 2002:a5d:6490:: with SMTP id r16-v6mr2422392wru.99.1538601951638; Wed, 03 Oct 2018 14:25:51 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id 193-v6sm4073866wmj.21.2018.10.03.14.25.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 14:25:51 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH v3 3/8] fanotify: simplify handling of FAN_ONDIR Date: Thu, 4 Oct 2018 00:25:34 +0300 Message-Id: <20181003212539.2384-4-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003212539.2384-1-amir73il@gmail.com> References: <20181003212539.2384-1-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fanotify mark add/remove code jumps through hoops to avoid setting the FS_ISDIR in the commulative object mask. That was just papering over a bug in fsnotify() handling of the FS_ISDIR extra flag. This bug is now fixed, so all the hoops can be removed along with the unneeded internal flag FAN_MARK_ONDIR. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify_user.c | 32 +++++------------------------- include/linux/fanotify.h | 3 --- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 15719d4aa4b5..34b511407035 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -506,18 +506,10 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark, spin_lock(&fsn_mark->lock); if (!(flags & FAN_MARK_IGNORED_MASK)) { - __u32 tmask = fsn_mark->mask & ~mask; - - if (flags & FAN_MARK_ONDIR) - tmask &= ~FAN_ONDIR; - oldmask = fsn_mark->mask; - fsn_mark->mask = tmask; + fsn_mark->mask &= ~mask; } else { - __u32 tmask = fsn_mark->ignored_mask & ~mask; - if (flags & FAN_MARK_ONDIR) - tmask &= ~FAN_ONDIR; - fsn_mark->ignored_mask = tmask; + fsn_mark->ignored_mask &= ~mask; } *destroy = !(fsn_mark->mask | fsn_mark->ignored_mask); spin_unlock(&fsn_mark->lock); @@ -586,19 +578,10 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark, spin_lock(&fsn_mark->lock); if (!(flags & FAN_MARK_IGNORED_MASK)) { - __u32 tmask = fsn_mark->mask | mask; - - if (flags & FAN_MARK_ONDIR) - tmask |= FAN_ONDIR; - oldmask = fsn_mark->mask; - fsn_mark->mask = tmask; + fsn_mark->mask |= mask; } else { - __u32 tmask = fsn_mark->ignored_mask | mask; - if (flags & FAN_MARK_ONDIR) - tmask |= FAN_ONDIR; - - fsn_mark->ignored_mask = tmask; + fsn_mark->ignored_mask |= mask; if (flags & FAN_MARK_IGNORED_SURV_MODIFY) fsn_mark->flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY; } @@ -820,7 +803,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, struct fsnotify_group *group; struct fd f; struct path path; - u32 valid_mask = FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD; + u32 valid_mask = FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD | FAN_ONDIR; unsigned int mark_type = flags & FAN_MARK_TYPE_MASK; int ret; @@ -857,11 +840,6 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, return -EINVAL; } - if (mask & FAN_ONDIR) { - flags |= FAN_MARK_ONDIR; - mask &= ~FAN_ONDIR; - } - if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS)) valid_mask |= FAN_ALL_PERM_EVENTS; diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index e70fccc3757e..a8c3fc54276d 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -4,9 +4,6 @@ #include -/* not valid from userspace, only kernel internal */ -#define FAN_MARK_ONDIR 0x80000000 - #define FAN_GROUP_FLAG(group, flag) \ ((group)->fanotify_data.flags & (flag))