From patchwork Mon Jun 17 11:04:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 1116950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45S7dr4RJdz9sNm; Mon, 17 Jun 2019 21:04:46 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hcpRJ-0004we-0E; Mon, 17 Jun 2019 11:04:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hcpRH-0004w8-J8 for kernel-team@lists.ubuntu.com; Mon, 17 Jun 2019 11:04:39 +0000 Received: from mail-pl1-f198.google.com ([209.85.214.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hcpRH-0006tB-3s for kernel-team@lists.ubuntu.com; Mon, 17 Jun 2019 11:04:39 +0000 Received: by mail-pl1-f198.google.com with SMTP id n1so5799464plk.11 for ; Mon, 17 Jun 2019 04:04:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=/Y5a9m6aUsziTgj6snd/axsz/hz708C5ZZk6VqJbdiY=; b=eEGfePlMhh+aOF/86T+sAvExLXEwts6R/yZRh5ncx4cT7JF69fw5WLr9fpD6yxwSpf c/S4ROtJW9bdJueoDOEcrZzQLFBpGIDlGcN1EpFbUEnO9KI2aVs0ghFqR1UJElPn8nUF /YfrLoKT0NjC2L73lvHlAD/8Q7B7aF1xaK2l5VJeljt7ATIcnQSko8xoFZ4VS0V0Qtz2 FhaLCqTkqMdfBbsJs9GbjxObJEMUdlRpUpcBgegEGvJWjI39ZOitBsNUSoPxwvcZ91ga bPVrcXkakh89mrfVpGVyfUUyxxrQRJIoaTyHgpZdXklXu9A1CYk28kP2OXL4C6eu6GuU lGfw== X-Gm-Message-State: APjAAAV22OZinAtPUvVv3MW6wbg2cX4AWE43iFfOwT+8Fz7DrPY8nfKK zVG8p5zeWL4UqHkYYASwnHUkHKv2Se3DeSO2irre0MMqyD+stw3HVwFV037ijxftzcSC9kN3jB1 9V++zC3fp8eLnxTxFD6zoRSFSpOj0GKtfVXe+4S0y X-Received: by 2002:a63:dc50:: with SMTP id f16mr32750641pgj.447.1560769477592; Mon, 17 Jun 2019 04:04:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0m+4J7mKkoBqSP+VT7zVyEpa66mMg1RXaknPtkJzfRGzNHsh+djLkxhHfnjNx3NZ+0/vbfQ== X-Received: by 2002:a63:dc50:: with SMTP id f16mr32750621pgj.447.1560769477296; Mon, 17 Jun 2019 04:04:37 -0700 (PDT) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id u97sm11972724pjb.26.2019.06.17.04.04.36 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 04:04:36 -0700 (PDT) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [D][SRU][PATCH 1/1] ovl: do not generate duplicate fsnotify events for "fake" path Date: Mon, 17 Jun 2019 19:04:25 +0800 Message-Id: <20190617110425.27689-2-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190617110425.27689-1-po-hsu.lin@canonical.com> References: <20190617110425.27689-1-po-hsu.lin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Amir Goldstein BugLink: https://bugs.launchpad.net/bugs/1833028 Overlayfs "fake" path is used for stacked file operations on underlying files. Operations on files with "fake" path must not generate fsnotify events with path data, because those events have already been generated at overlayfs layer and because the reported event->fd for fanotify marks on underlying inode/filesystem will have the wrong path (the overlayfs path). Link: https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/ Reported-by: Murphy Zhou Fixes: d1d04ef8572b ("ovl: stack file ops") Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi (cherry picked from commit d989903058a83e8536cc7aadf9256a47d5c173fe) Signed-off-by: Po-Hsu Lin Acked-by: Connor Kuehl Acked-by: Stefan Bader --- fs/overlayfs/file.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 84dd957..6f6eb63 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -29,10 +29,11 @@ static struct file *ovl_open_realfile(const struct file *file, struct inode *inode = file_inode(file); struct file *realfile; const struct cred *old_cred; + int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY; old_cred = ovl_override_creds(inode->i_sb); - realfile = open_with_fake_path(&file->f_path, file->f_flags | O_NOATIME, - realinode, current_cred()); + realfile = open_with_fake_path(&file->f_path, flags, realinode, + current_cred()); revert_creds(old_cred); pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n", @@ -50,7 +51,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags) int err; /* No atime modificaton on underlying */ - flags |= O_NOATIME; + flags |= O_NOATIME | FMODE_NONOTIFY; /* If some flag changed that cannot be changed then something's amiss */ if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))