From patchwork Sat Sep 1 06:40:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10584625 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 F33CE112B for ; Sat, 1 Sep 2018 06:40:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E021F2B07E for ; Sat, 1 Sep 2018 06:40:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFA362B087; Sat, 1 Sep 2018 06:40:11 +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 62B672B07E for ; Sat, 1 Sep 2018 06:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbeIAKvC (ORCPT ); Sat, 1 Sep 2018 06:51:02 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41895 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbeIAKvC (ORCPT ); Sat, 1 Sep 2018 06:51:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id z96-v6so13017649wrb.8 for ; Fri, 31 Aug 2018 23:40:08 -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; bh=aQgATiZ/CVXx8tb86MH7iz+QGlnp/1Nqcd+UShBgV4M=; b=g20AyaZS/NHIqQ4OdOmovuUDCdwd9bF+KFjmc7JxXeXR4xP0zDergNGAw+K9G0df8j 3SRMbYLm3XmuDvKpjfAt3piTJMCwDGeiuYfjpZ9yFvti/L7rDm95xBQkw5uV1aPubn39 My5hn8FNbBjse+nK2norNHdq+ithxv8N6BmjC6z3jb+HW3OdLyoLZYbfiH60v3jAe5K0 A29Mose3YQn1qQLtrwF7QOMwlI/WYKx3ZtxoaIDGUx0LeMoKalZfDYlWdtvT+TXjxHKa y3P0irq5bcSFRkyichTx8Nk44w7z9nQZKifaX2dPQuMXn5tO+F+txd+Qd6SNmNTVG3Lo XP3Q== 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; bh=aQgATiZ/CVXx8tb86MH7iz+QGlnp/1Nqcd+UShBgV4M=; b=RoJ30nzZOh5bD1jrW1vDIN97DE61EcfDAhqqNOszz52lxpnsVaV2oUJUmt6YoGVDw/ K6VtuUT44E2Go9zNs8brSfirTWBfNQcUQlqWYO+voMLBAxkNRr4Budd2texZQM2K2hGK yU/uySVdcPq7v82B1S1V62XqGhEKNiNfsYFoh/W+70GJsR6RESwYx4kFVHL5cW90eVsO sLEsa0mM3xAkINek3P0F5NPrgPVTixlKpRKwpwqEevodCgU7ce1tPZ/P9fozgEsFrZXi kH20oiVj/Ca7JAsvA6gQZfPMRMYyuEUlLACo5/wjhRx7WlbmFWD5AuLeFon8I83fBJEa brWw== X-Gm-Message-State: APzg51Cncc9YkvRm3c3+Kb9nRrZBG9WyopEOaimq2vQB8s3WmW4T4odL +ST1maI845C2QTmbLFxphmE= X-Google-Smtp-Source: ANB0VdY+c4F3uh+G9HmW3cITPPZXsu82cfVyuuLCpfORzHaDSal5iCPth5o8zZYmAII3lBwdvxBzRA== X-Received: by 2002:a5d:550a:: with SMTP id b10-v6mr13822388wrv.228.1535784008004; Fri, 31 Aug 2018 23:40:08 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id b2-v6sm6136946wmh.3.2018.08.31.23.40.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 23:40:07 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Marko Rauhamaa , linux-fsdevel@vger.kernel.org Subject: [PATCH] fsnotify: fix ignore mask logic in fsnotify() Date: Sat, 1 Sep 2018 09:40:01 +0300 Message-Id: <20180901064001.23430-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 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 Commit 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group()") acknoledges the use case of ignoring an event on an inode mark, because of an ignore mask on a mount mark of the same group (i.e. I want to get all events on this file, except for the events that came from that mount). This change depends on correctly merging the inode marks and mount marks group lists, so that the mount mark ignore mask would be tested in send_to_group(). Alas, the merging of the lists did not take into account the case where event in question is not in the mask of any of the mount marks. To fix this, completely remove the tests for inode and mount event masks from the lists merging code. Fixes: 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group") Signed-off-by: Amir Goldstein --- Jan, Posting this fix independent from the super block mark series, so you can send it in this cycle if you wish. New LTP test fanotify10 from [1] demonstrates the problem and the fix. Note that the test verifies the expected behavior as agreed in this discussion [2]. Thanks, Amir. [1] https://github.com/amir73il/ltp/commits/fanotify_sb [2] https://marc.info/?l=linux-fsdevel&m=152284295703053&w=2 fs/notify/fsnotify.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 775e731d3016..2971803d151c 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -357,16 +357,9 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu); - if ((mask & FS_MODIFY) || - (test_mask & to_tell->i_fsnotify_mask)) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] = - fsnotify_first_mark(&to_tell->i_fsnotify_marks); - } - - if (mnt && ((mask & FS_MODIFY) || - (test_mask & mnt->mnt_fsnotify_mask))) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] = - fsnotify_first_mark(&to_tell->i_fsnotify_marks); + iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] = + fsnotify_first_mark(&to_tell->i_fsnotify_marks); + if (mnt) { iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] = fsnotify_first_mark(&mnt->mnt_fsnotify_marks); }