From patchwork Tue Sep 18 13:34:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10604333 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 0E1D36CB for ; Tue, 18 Sep 2018 13:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F245F2ABA9 for ; Tue, 18 Sep 2018 13:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4A3F2ABBC; Tue, 18 Sep 2018 13:34:49 +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 9D2E12ABA9 for ; Tue, 18 Sep 2018 13:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729791AbeIRTHZ (ORCPT ); Tue, 18 Sep 2018 15:07:25 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39200 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728575AbeIRTHZ (ORCPT ); Tue, 18 Sep 2018 15:07:25 -0400 Received: by mail-wm1-f65.google.com with SMTP id q8-v6so2829272wmq.4; Tue, 18 Sep 2018 06:34:47 -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:in-reply-to:references; bh=zTavsqr1OFg0MIRSjpyqKsc+XuAFMdysP0g3Gi0Xnkc=; b=ZXqPRlkGWjBUEORwAjN19vH1SHXrqDdWo91N29ju6Atqsj8yaTFI+kSqpBp8axMo25 IFj596z9FYlKM4HjHV+XBnTZ2IyJVCJS932NNOin+F0/2jwmzldBkfpdWFy1qgIWf54v x6Hl/WmacLJIca3xiA476HPMLHb++D4BRxdzhkEZ6pwdYN5daJKZJDRkajGcTqjYk66M oZHbbFNPPCE/VTo0bZ9DuRUA8KAER1otRgiakYiQV+IgYqWmveHVN9l9brSiOmTEte0a gWJJKPrJFve2SecpYbPoE+O1+PuTq34mwD6sgmI0+aHGlJATOXzEie+Z/O/iDDC6bSCo xx0A== 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=zTavsqr1OFg0MIRSjpyqKsc+XuAFMdysP0g3Gi0Xnkc=; b=bOLEzBfcjWTZMmsaMDSLLR180gqDKHVAJHn+IFJFyA+WNOhRu6zF6wkFAudgvUPTbO BW4LnX+Ql6CoPP5TQg3dVPDWfGX1AbshvmQfhwiSvMAPqbl/efLE1QvzZLUlPyD1CHLG YTbj+C0GGhbJY9PJgCXaXhpMiz3B9PqFiLKjwoPuFzoujwJLQtI8omxpWqwY97pFpRKH lq5jVNqcLipPI8vSCyXPafHFUsD8Q161+w1YKAD7OmNQC52EoC6sG0eNjStFdcxDOx8x Cxp8Exrx9oSU5V/BB/fLVklE2qi9WlIjOvh7V8hYvatPbGMIjxkX3bUNzFomgX3wDsxD yP9Q== X-Gm-Message-State: APzg51AIRfDjhMH4Ey9BVXJf+55CiTGW+ot/G33sDI8uF0h+SfYRoHj+ 5D+Dw8h3Al46zVMmHWC8QYs= X-Google-Smtp-Source: ANB0VdZ3hqmPSEI2/Df3L5JPshnmAOvgIK8MNXzrQC/pBiva1U3bvRggRFp/MbAJzp4JBZF6RBAvAg== X-Received: by 2002:a1c:8dc6:: with SMTP id p189-v6mr16449776wmd.3.1537277686346; Tue, 18 Sep 2018 06:34:46 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h7-v6sm16905065wrs.3.2018.09.18.06.34.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 06:34:45 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/4] ovl: fix memory leak on unlink of indexed file Date: Tue, 18 Sep 2018 16:34:31 +0300 Message-Id: <20180918133434.27437-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918133434.27437-1-amir73il@gmail.com> References: <20180918133434.27437-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 Fixes: caf70cb2ba5d ("ovl: cleanup orphan index entries") Cc: # v4.13 Signed-off-by: Amir Goldstein --- fs/overlayfs/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 8cfb62cc8672..ace4fe4c39a9 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -683,7 +683,7 @@ static void ovl_cleanup_index(struct dentry *dentry) struct dentry *upperdentry = ovl_dentry_upper(dentry); struct dentry *index = NULL; struct inode *inode; - struct qstr name; + struct qstr name = { }; int err; err = ovl_get_index_name(lowerdentry, &name); @@ -726,6 +726,7 @@ static void ovl_cleanup_index(struct dentry *dentry) goto fail; out: + kfree(name.name); dput(index); return; From patchwork Tue Sep 18 13:34:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10604335 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 4C3D16CB for ; Tue, 18 Sep 2018 13:34:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B1E32ABB1 for ; Tue, 18 Sep 2018 13:34:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F0112ABBB; Tue, 18 Sep 2018 13:34:51 +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 D1CCB2ABB1 for ; Tue, 18 Sep 2018 13:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729802AbeIRTH1 (ORCPT ); Tue, 18 Sep 2018 15:07:27 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34052 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727207AbeIRTH0 (ORCPT ); Tue, 18 Sep 2018 15:07:26 -0400 Received: by mail-wr1-f66.google.com with SMTP id g33-v6so2150448wrd.1; Tue, 18 Sep 2018 06:34:48 -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:in-reply-to:references; bh=qzthXLonKt8IEuZa9r+RH6BOXWX8PqIg+3E9ouTYLgM=; b=MDkVsavj041KagWt+3riCVtaadZ1y5N+CCtdNqyvlqrLS6f1mU3FQ6e/RI7IcjVt5A UyZ4bqP+bEFh6HNaf0KSoDNt/ZCnAmMr9IrKOIDs4NVd2gsdNDaOZk1LwtrMFylDt3VQ LCMwMJcC4evQQafuIprqgsD0FJc/C84LQIVzy7gA84MyK76xqQHnhidYnPEmnAl2KQ/8 JWoKkcUo6phZ3qoQ0tVJgmVJOwM9JNoFBS2rj9aKng9QUF9lA1l2Th9f5DwCE7u+pxgl HB5VVkIlwJhiP6CrUnup5Ym736ZJLli5OsDggaS2SX0tKP4n7irqWZCDk8EhT6tx3Hle yk/w== 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=qzthXLonKt8IEuZa9r+RH6BOXWX8PqIg+3E9ouTYLgM=; b=k3ixHZ+XMYwH+aaYXcvRVDW51xsdGgJigL7wn0s6fwrnz7jx4IKB7jpP90YEl7EaIJ sdI4e4cy0BDJiIgvH6SC966Ek5FlNyoMt6yBMZ9coJH5T4PqZ0CXwS7R37+fqOSPs/0f /cXzL5imVml/gM4wxm0pKDqvyrVaXZpg/CWaEcxrLh4238/GFbgERUR7+5jwHH8oPhFO ypgNCHJRJ2BiM+WE2XXIvkT463X4larch6lLxEnnzIPjThrDCFEU1dLegiOAjmpEiyjs raNX3OTvSE9JjhYYQgaPiFyqGXVKhoDimT+f658BX+2rdZBsgab4NT1SMib5ZMqj9zoQ btvg== X-Gm-Message-State: APzg51CWfAXMr3xtXLyd2rmhiA374LxAiFr2v/H6AOnb9XyPUaM2UQUF +89Elqm5waP3QpatZZ3CXQU= X-Google-Smtp-Source: ANB0Vdb4+mRHdnU4KdUN/9ujDzTnZcPxMIJ+ZpIlvgv/OaBGVz1wGSMs/daDhdB/pcovXiAsGI+Ymw== X-Received: by 2002:adf:c751:: with SMTP id b17-v6mr24258906wrh.134.1537277687556; Tue, 18 Sep 2018 06:34:47 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h7-v6sm16905065wrs.3.2018.09.18.06.34.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 06:34:47 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/4] ovl: fix freeze protection bypass in ovl_write_iter() Date: Tue, 18 Sep 2018 16:34:32 +0300 Message-Id: <20180918133434.27437-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918133434.27437-1-amir73il@gmail.com> References: <20180918133434.27437-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 Tested by re-writing to an open overlayfs file while upper ext4 is frozen: xfs_io -f /ovl/x xfs_io> pwrite 0 4096 fsfreeze -f /ext4 xfs_io> pwrite 0 4096 WARNING: CPU: 0 PID: 1492 at fs/ext4/ext4_jbd2.c:53 \ ext4_journal_check_start+0x48/0x82 After the fix, the second write blocks in ovl_write_iter() and avoids hitting WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE) in ext4_journal_check_start(). Fixes: 2a92e07edc5e ("ovl: add ovl_write_iter()") Signed-off-by: Amir Goldstein --- fs/overlayfs/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index aeaefd2a551b..986313da0c88 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -240,8 +240,10 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) goto out_unlock; old_cred = ovl_override_creds(file_inode(file)->i_sb); + file_start_write(real.file); ret = vfs_iter_write(real.file, iter, &iocb->ki_pos, ovl_iocb_to_rwf(iocb)); + file_end_write(real.file); revert_creds(old_cred); /* Update size */ From patchwork Tue Sep 18 13:34:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10604337 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 741FA13AD for ; Tue, 18 Sep 2018 13:34:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 645CF2ABB1 for ; Tue, 18 Sep 2018 13:34:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58E892ABBB; Tue, 18 Sep 2018 13:34:52 +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 1517D2ABB1 for ; Tue, 18 Sep 2018 13:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729807AbeIRTH2 (ORCPT ); Tue, 18 Sep 2018 15:07:28 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38338 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728575AbeIRTH2 (ORCPT ); Tue, 18 Sep 2018 15:07:28 -0400 Received: by mail-wm1-f68.google.com with SMTP id t25-v6so2812592wmi.3; Tue, 18 Sep 2018 06:34:49 -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:in-reply-to:references; bh=8AB/jHoZeP+q5PUe4mASYh6f89Fllz8XrUKUvYedphI=; b=MAOwsvdNoLB7Re3VSxgpFXZ6DcCJ5eyHxbbYxUtuaRu2f/ia1Zu9VApcdSo8f39GFy ME3Fy8n8IdHisty2VHs+daIF/EraOlnqCJsSjZeB4AJwOmX2UB5OnSh9xJQInOlkB8zW NtuOQCknXCBJxWNIRZ1lNj8YN0lUyeqAaG53aimmKUrnqB7KOS+XjGg9H2wOVo6nZswE Yffpphuuv+eyQdYuWwKH+fiX3j+g0dnA+BfF2p671++uk8ozdw0wp4Y4r+YJ7IbLUbxn pstgZgoQj144ylW3Kr0gNVRXO04A9FJOpYnrxK5o5RmhHtAUpgqNbZ0H9X4/a0yhi4zO z5eg== 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=8AB/jHoZeP+q5PUe4mASYh6f89Fllz8XrUKUvYedphI=; b=VgWtU0X0hIzaSY1COF19NCcZgwFncXKUh0bRUqdPBN9m8dYQises0qV8uoaHgA7YkZ G8bvZX9x7Za3nZcwa8XZkdi3EcBwvlE5bnMGIG4W7+BnDT/LFVfAo17PPHwqwB3JWo7t ikrElXV3QV5/txx+YAG5cXE+pSyFxcMS2G0+xdMcifLwiNmiuNdXtLuR5+4lh3f5NetS J8S9fc8TUvnckWl3XnVoUvKH099ZNAkV3NJcAHwHBGOqKGDNiKpJfnLq3b4D57niIFrv 0WfKtpOrDlQEC8eNY6ifrGASXWhaTeX2p/xpupNZykNOz/b8yC1fe/Ds4D24dqhR5o1r BrYQ== X-Gm-Message-State: APzg51BoDz9ZkZ+o30Kun4Y0Wmy/gaM0oTaLzOYmIvtMtzDbdXWtPEtV BHdmRY1CmwSYsZ9WYEtwwBc= X-Google-Smtp-Source: ANB0VdYokxWRVW3OH+kSbD2aRQl0L0p7zeC1ppAy0eCx2xud5Faezuy8W2jTuP/n8RDIEXoTfNHd9g== X-Received: by 2002:a1c:9808:: with SMTP id a8-v6mr15358072wme.62.1537277688719; Tue, 18 Sep 2018 06:34:48 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h7-v6sm16905065wrs.3.2018.09.18.06.34.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 06:34:48 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 3/4] ovl: fix freeze protection bypass in ovl_clone_file_range() Date: Tue, 18 Sep 2018 16:34:33 +0300 Message-Id: <20180918133434.27437-4-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918133434.27437-1-amir73il@gmail.com> References: <20180918133434.27437-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 Tested by doing clone on overlayfs while upper xfs+reflink is frozen: xfs_io -f /ovl/y fsfreeze -f /xfs xfs_io> reflink /ovl/x Before the fix xfs_io enters xfs_reflink_remap_range() and blocks in xfs_trans_alloc(). After the fix, xfs_io blocks outside xfs code in ovl_clone_file_range(). Fixes: 8ede205541ff ("ovl: add reflink/copyfile/dedup support") Signed-off-by: Amir Goldstein --- fs/overlayfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 986313da0c88..5d1b4b38f743 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -461,7 +461,7 @@ static ssize_t ovl_copyfile(struct file *file_in, loff_t pos_in, break; case OVL_CLONE: - ret = vfs_clone_file_range(real_in.file, pos_in, + ret = do_clone_file_range(real_in.file, pos_in, real_out.file, pos_out, len); break; From patchwork Tue Sep 18 13:34:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10604339 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 8380713AD for ; Tue, 18 Sep 2018 13:34:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FA602ABA9 for ; Tue, 18 Sep 2018 13:34:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63E422ABBA; Tue, 18 Sep 2018 13:34:55 +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 CF76A2ABA9 for ; Tue, 18 Sep 2018 13:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729823AbeIRTHb (ORCPT ); Tue, 18 Sep 2018 15:07:31 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35124 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727207AbeIRTHb (ORCPT ); Tue, 18 Sep 2018 15:07:31 -0400 Received: by mail-wm1-f65.google.com with SMTP id o18-v6so2838314wmc.0; Tue, 18 Sep 2018 06:34:51 -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:in-reply-to:references; bh=m3XFHCkv1sFaalTmnDUj16ZPMVuMpCQGLpWJFFOdNYA=; b=roKrgjU3tNT4P285bV6j2TsoBftweZII7uEtw2vlN190xgjTDdp6LBGEsl2/2DmYbZ fg5AoFNDP9CJWWqRsY9gqKscLh/Nv+h/I4OPxrD038/md0IQ7+4S/FFrOOGQDnXh6Y7J EUuBiu3lQzYtWHM4Emlt8bU5Mqk+Bd9kmzb7GgZBhmWIIzslnbgsCVorgqkAtKhlzgE9 +ccTJsSqfdaJ7HW3oxJGOvwAtaHR8ZngwTtxoSydpSEnqRWq9hB390mWJhqW9NE3zMAf lyfmX9Ef+ONcGM2JQUIUEA+Sw5Eww7wZznJI4RtnPCnrw08gILhHOF7Pp1R08G9JT9+V 2dIg== 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=m3XFHCkv1sFaalTmnDUj16ZPMVuMpCQGLpWJFFOdNYA=; b=cNlbbeo0c2CoeGsluHlrfgW5mKx2GlwjGl8JnDqG33ClVAK8tVxokwYHHPDXd4D2Cb gO54JVWqNAhssYZmhhmDobBROr6wpqe2H9Jsn+acZWQSjb+h7t5pkptbSIF1xX7HSFxP eYXhmAJTPWHnfZ5uRyR8eKwaxxCCtnwo/Vg9qPfCgdeZfP1D3QaNk52WNqp0VQZOcB2b C5tX226PW44+kShwH3UT87O2ZA3+LKUcuGmwUYAe3+bJ37fz2smD/t7EZew4/82ECjs2 35D8Ck4vIp+RIGYfnDnr2mQzHEHE37e/uhmGUfrbx5P1TKxFZNVJRYnz6HCpGOn/1vom S7xA== X-Gm-Message-State: APzg51CkFMYkEe9LCPllyqeX6NTUPfyGJTUJQ6dYb+ewsazy8tvmG/gg qKvp8KIUNdGZkaQM7x66GpE= X-Google-Smtp-Source: ANB0VdaAVvaUWfbjH22NMFu5gSnKne1RvH0ecIZXLK/M0JeF7Hok4yzNpltjEZh8uzA03gjc0wLOwg== X-Received: by 2002:a1c:4182:: with SMTP id o124-v6mr15908130wma.101.1537277690222; Tue, 18 Sep 2018 06:34:50 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h7-v6sm16905065wrs.3.2018.09.18.06.34.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 06:34:49 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 4/4] vfs: swap names of {do,vfs}_clone_file_range() Date: Tue, 18 Sep 2018 16:34:34 +0300 Message-Id: <20180918133434.27437-5-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918133434.27437-1-amir73il@gmail.com> References: <20180918133434.27437-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 Commit 031a072a0b8a ("vfs: call vfs_clone_file_range() under freeze protection") created a wrapper do_clone_file_range() around vfs_clone_file_range() moving the freeze protection to former, so overlayfs could call the latter. The more common vfs practice is to call do_xxx helpers from vfs_xxx helpers, where freeze protecction is taken in the vfs_xxx helper, so this anomality could be a source of confusion. It seems that commit 8ede205541ff ("ovl: add reflink/copyfile/dedup support") may have fallen a victim to this confusion - ovl_clone_file_range() calls the vfs_clone_file_range() helper in the hope of getting freeze protection on upper fs, but in fact results in overlayfs allowing to bypass upper fs freeze protection. Swap the names of the two helpers to conform to common vfs practice and call the correct helpers from overlayfs and nfsd. Signed-off-by: Amir Goldstein --- fs/ioctl.c | 2 +- fs/nfsd/vfs.c | 3 ++- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/file.c | 2 +- fs/read_write.c | 17 +++++++++++++++-- include/linux/fs.h | 17 +++-------------- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 3212c29235ce..2005529af560 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -230,7 +230,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, ret = -EXDEV; if (src_file.file->f_path.mnt != dst_file->f_path.mnt) goto fdput; - ret = do_clone_file_range(src_file.file, off, dst_file, destoff, olen); + ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen); fdput: fdput(src_file); return ret; diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 55a099e47ba2..b53e76391e52 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -541,7 +541,8 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, u64 dst_pos, u64 count) { - return nfserrno(do_clone_file_range(src, src_pos, dst, dst_pos, count)); + return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos, + count)); } ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst, diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 296037afecdb..1cc797a08a5b 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -141,7 +141,7 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) } /* Try to use clone_file_range to clone up within the same fs */ - error = vfs_clone_file_range(old_file, 0, new_file, 0, len); + error = do_clone_file_range(old_file, 0, new_file, 0, len); if (!error) goto out; /* Couldn't clone, so now we try to copy the data */ diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 5d1b4b38f743..986313da0c88 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -461,7 +461,7 @@ static ssize_t ovl_copyfile(struct file *file_in, loff_t pos_in, break; case OVL_CLONE: - ret = do_clone_file_range(real_in.file, pos_in, + ret = vfs_clone_file_range(real_in.file, pos_in, real_out.file, pos_out, len); break; diff --git a/fs/read_write.c b/fs/read_write.c index 39b4a21dd933..8a2737f0d61d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1818,8 +1818,8 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, } EXPORT_SYMBOL(vfs_clone_file_prep_inodes); -int vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +int do_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, u64 len) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -1866,6 +1866,19 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in, return ret; } +EXPORT_SYMBOL(do_clone_file_range); + +int vfs_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, u64 len) +{ + int ret; + + file_start_write(file_out); + ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len); + file_end_write(file_out); + + return ret; +} EXPORT_SYMBOL(vfs_clone_file_range); /* diff --git a/include/linux/fs.h b/include/linux/fs.h index 4f0a11d0d296..25a449f37bb1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1833,8 +1833,10 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, struct inode *inode_out, loff_t pos_out, u64 *len, bool is_dedupe); +extern int do_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, u64 len); extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len); + struct file *file_out, loff_t pos_out, u64 len); extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same); @@ -2778,19 +2780,6 @@ static inline void file_end_write(struct file *file) __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE); } -static inline int do_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len) -{ - int ret; - - file_start_write(file_out); - ret = vfs_clone_file_range(file_in, pos_in, file_out, pos_out, len); - file_end_write(file_out); - - return ret; -} - /* * get_write_access() gets write permission for a file. * put_write_access() releases this write permission.