From patchwork Wed Oct 24 19:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654951 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 E0A4117F3 for ; Wed, 24 Oct 2018 19:58:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1EF428481 for ; Wed, 24 Oct 2018 19:58:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5C2C2B224; Wed, 24 Oct 2018 19:58:50 +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=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 85EA628481 for ; Wed, 24 Oct 2018 19:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbeJYE2O (ORCPT ); Thu, 25 Oct 2018 00:28:14 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40158 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2N (ORCPT ); Thu, 25 Oct 2018 00:28:13 -0400 Received: by mail-qt1-f194.google.com with SMTP id z9-v6so7097058qto.7; Wed, 24 Oct 2018 12:58: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=XkCvx+hgMC4KAXjFXC+q8/hinOBCjkRD+CDTi9Non44=; b=djl1mQAjmlY2jlzKOytCKVVWxSJxcGhGfV4H2GqrFEwONHv+InSHZ1v+KXaGR9/LXg HzB+qwGw12Boms0fEK3JvVh6grEz3jHMdv79QDAtajPUed/u8lgJtmscGYEk8YFjUdE1 H7dJhNqkxjmOYnr6k1IuozT/M603RMQtGD/DlGlSOCAgsHlH3jIf7ujmA4TS6+5WykHz 4+ooUq5IN2F9Jqns77z+HrkNCRaedNS4twn0Ft++J68K+opMY5Ou+uwyWJ4jwVYItBT5 AS/HobcT5enAVxRB0FqiYKkUktL9mKaC6rBVyD2JdSkT3pSAbb1aHSEFLOaELDXXW7Ic dj+Q== 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=XkCvx+hgMC4KAXjFXC+q8/hinOBCjkRD+CDTi9Non44=; b=hjXGXkMcaRvFkguUtWQZ+pf/SmbPLcE2r5usmVfPhQ6/o/hzACq7rAo1gVYZnd5QWr 1BOtbZj/MzMkvvFzutDJvcEJROoGExLsH00nIf9FjuEQsB49i6cjz3GV7bbB+jvxPAot MVZhB+s5lHi3kFed9KMr8/ylab6Ldeggp0rj0XwcJuCGeD5yCC+xKAWPJdcRrtGV/b0M XFvpDpdNCS7uIlBdHjBqOWzMMkG/UL3IHKqQET8OmnISTvQmGnv1SgQHrvQSYCYaDqqz bZrna1M7ecDzVmYiMTnq3CooKrUhXjs52ef9uIzJBuzsZaW/xhoRTZcQxqy+2LOpTd4H i3gg== X-Gm-Message-State: AGRZ1gID0F8e1MW86azQrCvfNmF3s5/Mm8UeCm32JvLfKj5Zy+d20M6G lCIruZa6LW45VH5ablwo+7M= X-Google-Smtp-Source: AJdET5faYI4cJ7ltYOUvpgsxdMUq0VcmiMg4BBZeW5mYa62wsXj0QXikBr0ShL5gH5kbBD0wC6jYIg== X-Received: by 2002:aed:2a0b:: with SMTP id c11-v6mr3824826qtd.147.1540411126914; Wed, 24 Oct 2018 12:58:46 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:46 -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 v2 04/13] NFS: add cross file system check for copy_file_range Date: Wed, 24 Oct 2018 15:58:28 -0400 Message-Id: <20181024195837.35532-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-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 VFS copy_file_range was relaxed to allow for cross-device copy. Add a check to disallow cross file systems copy offload, both files are expected to be of NFS type. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4288a6e..7137e7b 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -135,6 +135,9 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, { ssize_t ret; + if (file_in->f_inode->i_sb->s_type != file_out->f_inode->i_sb->s_type) + return -EXDEV; + if (file_inode(file_in) == file_inode(file_out)) return -EINVAL; retry: