From patchwork Sun Dec 2 11:38:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10707987 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 D117516B1 for ; Sun, 2 Dec 2018 11:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C27C52AEB6 for ; Sun, 2 Dec 2018 11:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6F652AEBF; Sun, 2 Dec 2018 11:38:56 +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 676F92AEB6 for ; Sun, 2 Dec 2018 11:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725870AbeLBLi6 (ORCPT ); Sun, 2 Dec 2018 06:38:58 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33650 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbeLBLi4 (ORCPT ); Sun, 2 Dec 2018 06:38:56 -0500 Received: by mail-wr1-f65.google.com with SMTP id c14so9327020wrr.0 for ; Sun, 02 Dec 2018 03:38:52 -0800 (PST) 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=psHxpwMDXtmhH5mDIMsvGN+vq4zUpYf/PKU4UfjwNEw=; b=HMFPSXfzlxWE6LtXr4iVIID0JXQPz/6m7IKhNCU/5Jm6Mj8OtmqRQsF+ajTJz9G3gG JaCTTrJ79Tfue4FjeaC4lkZdKP9n2mAbXknPSA0wlJOVIxfNJRvrGhkaUPN/3nkmvg7O sL6h9HTbm6PcemlCIY3/zsBJ6cW/1HPzUrNny95nJNsUvw8OA+wWV9U6EapY1qc/eQtA yUduAhZguaFK1eqEfs7xctI+XiKkGH3U4Uv5yeZaIfPsxRCahI3vMMeg2wkkI4haP+OO 0v5PG9GL58Ysucc0ipqrZOhe0beQhuWiOB3HX0IQbZ+GW1ro7H1zbAg3s30ZU5pJ3e4b NvIw== 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=psHxpwMDXtmhH5mDIMsvGN+vq4zUpYf/PKU4UfjwNEw=; b=O5a9sAXD4p8sTNrk+AGBwEIV/OXIvmDvAIfR2c8c3wN1T5gMtAtlj5aC0C5Mi7X1jg NC9B5GLhmnk9rJh/1eWVkJB3XT269v1+lwt0+a0HzT+3Y72mzPjS8MclQvbgzISFHaCm SDmGfCswF5QI3jEDaGKiQIKExME37muRMQy6I/2HKTwLRLKox8LO09/oHtC/jVEg1bHb 5qPlx/P+2wPonDnd64+I6kMiHKa/rB/mAF40lvU3mSrPQMCad4mkIvK1Tzn+k0D36Rsz kGzjCoumL5ALqh1Y4liQD+1RGiHWUdOnmSPS/XJrZTTTG28f0fpRFXe8yJD+zQhGK4em mhWg== X-Gm-Message-State: AA+aEWa5da6ds06RJSmYU8N0KH5Sovh5grdMSrsClnZZAKP00Ihj7GCb XruHKZDhLpx+T1h2IDrOKUU= X-Google-Smtp-Source: AFSGD/U4TltzS/+iXn6KurpeHASlOjpIXDcePbU3nPdDw2br2fwbrZ+cm8ZglVFcEjeSa1YF2vdsag== X-Received: by 2002:a5d:60cc:: with SMTP id x12mr10000172wrt.193.1543750731690; Sun, 02 Dec 2018 03:38:51 -0800 (PST) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id c3-v6sm3448672wmb.46.2018.12.02.03.38.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Dec 2018 03:38:51 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH v4 12/15] fanotify: check FS_ISDIR flag instead of d_is_dir() Date: Sun, 2 Dec 2018 13:38:23 +0200 Message-Id: <20181202113826.32133-13-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181202113826.32133-1-amir73il@gmail.com> References: <20181202113826.32133-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 All fsnotify hooks set the FS_ISDIR flag for events that happen on directory victim inodes except for fsnotify_perm(). Add the missing FS_ISDIR flag in fsnotify_perm() hook and let fanotify_group_event_mask() check the FS_ISDIR flag instead of checking if path argument is a directory. This is needed for fanotify support for event types that do not carry path information. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.c | 2 +- include/linux/fsnotify.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index a5dd8b8d92b7..5a958b1d0cb6 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -144,7 +144,7 @@ static u32 fanotify_group_event_mask(struct fsnotify_iter_info *iter_info, marks_ignored_mask |= mark->ignored_mask; } - if (d_is_dir(path->dentry) && + if (event_mask & FS_ISDIR && !(marks_mask & FS_ISDIR & ~marks_ignored_mask)) return 0; diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 8de8f390cce2..14e1f43c38c9 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -92,6 +92,9 @@ static inline int fsnotify_perm(struct file *file, int mask) fsnotify_mask = FS_ACCESS_PERM; } + if (S_ISDIR(inode->i_mode)) + fsnotify_mask |= FS_ISDIR; + return fsnotify_path(inode, path, fsnotify_mask); }