From patchwork Tue May 29 14:43:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10436051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9857C601E9 for ; Tue, 29 May 2018 15:09:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88D5128767 for ; Tue, 29 May 2018 15:09:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DC5A287DE; Tue, 29 May 2018 15:09:12 +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=-7.9 required=2.0 tests=BAYES_00, 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 2CF3F28767 for ; Tue, 29 May 2018 15:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936649AbeE2PJH (ORCPT ); Tue, 29 May 2018 11:09:07 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53951 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935816AbeE2OoW (ORCPT ); Tue, 29 May 2018 10:44:22 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67-v6so41195379wmf.3 for ; Tue, 29 May 2018 07:44:21 -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:cc:subject:date:message-id:in-reply-to :references; bh=RGIJZSifsy2xeQFppSvaFIOe9Z45/3FzZqM+RWq8UFE=; b=mps6yMXrB9a/X6yu3beX6yfAE0VNPe0NaYt7tRfEx8oU9grZQw09FYcAe+Zlf6CypK pHdAMdvJDR3dR1Z/SluiWOibQvg0MLHLN8a3kI5HdQcIXMZP9EpGaTTVUVexED5wGWDc R8rtRwgFDrZ/wpAo8GKZmLZZkQ97wHRgqHNLw+1ccWBzc4uv3JYwUwEkXg3u54zANgX4 XsWghogQcWlEghldzzhLUe1cNIkvJ+d6c1ExCoCXcVsKRMWqaKTvIicxUsP/g+Zz/MYY UzKibbWFPBgP/G2dPGd3hmHz6C63zunhapfVKa8B5vN/NQT7ukyTAzsgWP1X3InF3rTa 6nsA== X-Gm-Message-State: ALKqPwd9ev03+i443lTha3JZwwhCFUq7G8ExmLmwsIYrSTmsR7+t8JF3 ZufRzJTNyFtWaX/dqq4oNkZikmmVh1s= X-Google-Smtp-Source: ADUXVKIISOBlNycqYriEosiG6vWyVH1ZRUpgbfFyhYdu29BoIX69fYkqfn+GomVOUEZ2lVdjP+1xpQ== X-Received: by 2002:a1c:d1c2:: with SMTP id i185-v6mr12716200wmg.10.1527605060907; Tue, 29 May 2018 07:44:20 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id t198-v6sm18834422wmt.23.2018.05.29.07.44.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:44:20 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 32/39] vfs: fix freeze protection in mnt_want_write_file() for overlayfs Date: Tue, 29 May 2018 16:43:32 +0200 Message-Id: <20180529144339.16538-33-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144339.16538-1-mszeredi@redhat.com> References: <20180529144339.16538-1-mszeredi@redhat.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 The underlying real file used by overlayfs still contains the overlay path. This results in mnt_want_write_file() calls by the filesystem getting freeze protection on the wrong inode (the overlayfs one instead of the real one). Fix by using file_inode(file)->i_sb instead of file->f_path.mnt->mnt_sb. Reported-by: Amir Goldstein Signed-off-by: Miklos Szeredi Reviewed-by: Christoph Hellwig --- fs/namespace.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 5286c5313e67..0d9023a9af4f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -441,10 +441,10 @@ int mnt_want_write_file(struct file *file) { int ret; - sb_start_write(file->f_path.mnt->mnt_sb); + sb_start_write(file_inode(file)->i_sb); ret = __mnt_want_write_file(file); if (ret) - sb_end_write(file->f_path.mnt->mnt_sb); + sb_end_write(file_inode(file)->i_sb); return ret; } EXPORT_SYMBOL_GPL(mnt_want_write_file); @@ -486,7 +486,8 @@ void __mnt_drop_write_file(struct file *file) void mnt_drop_write_file(struct file *file) { - mnt_drop_write(file->f_path.mnt); + __mnt_drop_write_file(file); + sb_end_write(file_inode(file)->i_sb); } EXPORT_SYMBOL(mnt_drop_write_file);