From patchwork Mon May 7 08:37:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10383483 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 7E4BE60353 for ; Mon, 7 May 2018 08:42:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7447928A96 for ; Mon, 7 May 2018 08:42:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 696B028B3E; Mon, 7 May 2018 08:42:10 +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=unavailable 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 2FF3B28A96 for ; Mon, 7 May 2018 08:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752490AbeEGIkx (ORCPT ); Mon, 7 May 2018 04:40:53 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:44557 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752221AbeEGIip (ORCPT ); Mon, 7 May 2018 04:38:45 -0400 Received: by mail-wr0-f196.google.com with SMTP id y15-v6so16122663wrg.11 for ; Mon, 07 May 2018 01:38:44 -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=tZH8ZwmpknNbvvKGO/g6+0F3LKdHzkEqmFmdKohN9ULp/TA+tiTnuw0gdiWfPCLpJW 27G6oxASydviPJ9yL4gexZoJy41EHKjLKWpEp42sVU3RiyePl3ljnjyc67qY4Xkmp2+U iQCrtAH5Y75L9SlZ15ekRTTyo41UxU/nEDyyC/XpXD8HUDbuWM6STbYox7k4fSxLHIqo 9Eb06te6z9PFGcMQheMJ/H/uKVO4mP32dDMP4RdJaUjMbN3rEURHJq6N6kT8j2rpeV0V B+hEfbFpNszV80tJ5n6N7VDWndYGffwnvt5JMKW2kcTq9xsPIegz43PhwTAixJHCIULA 6Bcw== X-Gm-Message-State: ALQs6tBrLnqCdyekby5FUxxjuGQ7EiB9nNj/jEBiXztJMNrzyK7L60jU 70Bczg36rmh14qmEJ/gapIPyTg== X-Google-Smtp-Source: AB8JxZqjC0tnSsbAXMV4obtYSI5ORzPz77tbCvglTLp319TPkUv8i0Zx15LJTChLtFq0QuFsnspFCA== X-Received: by 2002:adf:e78b:: with SMTP id n11-v6mr27645239wrm.192.1525682323300; Mon, 07 May 2018 01:38:43 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id h8-v6sm5908050wmc.16.2018.05.07.01.38.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:38:42 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH v2 27/35] vfs: fix freeze protection in mnt_want_write_file() for overlayfs Date: Mon, 7 May 2018 10:37:59 +0200 Message-Id: <20180507083807.28792-28-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507083807.28792-1-mszeredi@redhat.com> References: <20180507083807.28792-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 --- 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);