From patchwork Tue Oct 30 20:56:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661559 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 08C8E1734 for ; Tue, 30 Oct 2018 20:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED57A2AA3B for ; Tue, 30 Oct 2018 20:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E155B2AA46; Tue, 30 Oct 2018 20:56:46 +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 968022AA3B for ; Tue, 30 Oct 2018 20:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728075AbeJaFvt (ORCPT ); Wed, 31 Oct 2018 01:51:49 -0400 Received: from mail-qt1-f182.google.com ([209.85.160.182]:36704 "EHLO mail-qt1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbeJaFvs (ORCPT ); Wed, 31 Oct 2018 01:51:48 -0400 Received: by mail-qt1-f182.google.com with SMTP id u34-v6so15269715qth.3; Tue, 30 Oct 2018 13:56:44 -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=vBxFiCMdm9zwB+fNOLFFTK+4s/3BLVSMs2/+B1oAwOg=; b=cgkKa0Q3i+KlnjGiuVy79GFf4RjqUdspiwev4l0bkgi6ZpXbPJWsA1DJcDZzqI82vG 8SvOqklJqWfblfQUq5DhGJAnyuS+VOCvR8oiohe62DGrbVivuQBgnDaAM2eSwdiSOfnC liKDGrhI/MCnS8CqPvz34BwYapnVM2+F4UIPImBJFTFjBNWrudpHH+lGuEb0pYFh+5oP WNyn8DaiquGNJKLj/f/E25Z9BaPloZ1WsqnDNxahzQI/exZiz2QXjHlqa+46aeUemRfN JH/z9Os1wUttFNsdjrPnKVxxjxozXrSl6uRowQWoAcFtuItz6lnlEZR8pqXF2IWJJbkD cvRQ== 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=vBxFiCMdm9zwB+fNOLFFTK+4s/3BLVSMs2/+B1oAwOg=; b=UsTPQczXENjRoKnc4hi1KevTA4MVX+LV3tFmiOoX1Mlz08GtCoRTozIK4/O/M5y7H2 6nyZAxf+Ogprkn7R7AuefuObLHhkI8UeaOAcBSk2xL6ni2/4cQz82ulNlGY4tlYPgJRx YWKm0x2WDzvX1j3WFGDR0Hd2cWJ1HOHxrNs0PS5bXVwpJ+c9YhOfFJ9z0XR+WTspKCjQ l8EcCHomgA95tD4fT7xRanCML8uw3W+PQ+nPMnjfffUoyvyuMsOS45Jh6EH3qL7FySDm iH+0rwsfFjzoQy0Ros14b/yR1LTJNIJAMP5BehICwM6B4mHIAFQE0655ILMpfotBOvi0 08EQ== X-Gm-Message-State: AGRZ1gKVkKDHDhhsSBeJFVjXDMdKQJVjADmq7/Pz7bktQu5mP2pEGl6d 4OO+om/95MJmWNI/YS2RdDIVCTF7 X-Google-Smtp-Source: AJdET5fUpkjHaVVPXUjqzIjTXdnOE/xbHvR4j7xM0d6R8B1xsYh/OgWGwBdkC3ygiedanWCDR4yv/w== X-Received: by 2002:a0c:ec92:: with SMTP id u18mr298903qvo.168.1540933003937; Tue, 30 Oct 2018 13:56:43 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:43 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 11/11] NFS: replace cross device check in copy_file_range Date: Tue, 30 Oct 2018 16:56:14 -0400 Message-Id: <20181030205614.40754-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olga Kornievskaia Add a check to disallow cross file systems copy offload, both files are expected to be of NFS4.2+ type. Reviewed-by: Jeff Layton Reviewed-by: Matthew Wilcox Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 989f174..69e2705 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -142,7 +142,10 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, if (pos_in >= i_size_read(file_inode(file_in))) return -EINVAL; - if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + if (file_in->f_op != &nfs4_file_operations) + return -EXDEV; + + if ((NFS_SERVER(file_inode(file_in)))->nfs_client->cl_minorversion < 2) return -EXDEV; if (file_inode(file_in) == file_inode(file_out))