From patchwork Tue Oct 30 20:56:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661519 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 279951734 for ; Tue, 30 Oct 2018 20:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 176F42AA38 for ; Tue, 30 Oct 2018 20:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B56A2AA40; Tue, 30 Oct 2018 20:56:31 +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 B8E342AA38 for ; Tue, 30 Oct 2018 20:56:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727870AbeJaFvd (ORCPT ); Wed, 31 Oct 2018 01:51:33 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:34487 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbeJaFvd (ORCPT ); Wed, 31 Oct 2018 01:51:33 -0400 Received: by mail-qt1-f196.google.com with SMTP id z2-v6so15313320qts.1; Tue, 30 Oct 2018 13:56:29 -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=nArMGW/INjteRrujdLkp69gM/ZmeUcX82tVQQvtlFnc=; b=RHckd8ROwPWhc3lU4r24zhA1uDj0gmlh5Obpm62kyhO4kFKW6Lcoy6NE1w7fAtlDQS ABnF6VRhn2uQf3ptAYdKdl7HQeum7wa9UAqKRIRoYL/8gH9SUM116UnMxbfpgSivlmna GaXQWGulUMQ+Z/lUVJ8gzhYgrmZM6tScl+UYfMQD/W7q4t05gu5RiM7KYJQ/QPrCX4Ek 2pqVcrs9huckeky1AEVnKpTd5MgXPQji5i16RsT1pdQr0e+0rOcEy5Uu7cIKdc0iHxTz y2g7kQUDYIX39NqeVfvdeg96vIO6ddfMYTSJU/ZUztLJAzO0oOYxYsuYLlm5HFzCs6ky eYcg== 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=nArMGW/INjteRrujdLkp69gM/ZmeUcX82tVQQvtlFnc=; b=QodRhYsWd2QEShAZEXJiTSb/nLs/25eoPfMCPZPVwaAAXw3oZFB9/1QC6OyrSyHLRn qu7IF5eQHRvfLUi/AxCNRyj0FZ4Yp6iRY+cyBZdY13TACRnyiSwkPhUlwwllbE4JJ9Ti TKRNIKn3tzUhtZ0AUfcdHGwHaDochRWeeAF110HUCH9Y8bbpOn+XheCNbTj+AY4OYdA6 S+OC7FPlQBL6PGilgflkDTfocHexZoPOPWHvNRpMyES/z4Sgzs/0m2EnNCi7iB9hkWO8 mZ3snJtkslBO2Kmnh+Fs9UpXaVKLr5RwBcmov4fwZEdIGXPH+PtIGnNjsYEeFb488EGI JOug== X-Gm-Message-State: AGRZ1gLHf4Uf12rA32HUXmHEAqxrZFFc56jSEB+KMMzWGPxqYIg78ADx g5aqx5UwEnVHrp35mlUAx7g= X-Google-Smtp-Source: AJdET5d+i+5we0gVFReH2wFo28seYFUStCjY2KpG7SbefgK5gtzxEF3SeTaetrLufvt5UM5WLzJ6Sg== X-Received: by 2002:a0c:bd15:: with SMTP id m21mr285050qvg.77.1540932988721; Tue, 30 Oct 2018 13:56:28 -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.27 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:28 -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 02/11] NFS: validity check for source offset in copy_file_range Date: Tue, 30 Oct 2018 16:56:05 -0400 Message-Id: <20181030205614.40754-4-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 Input source offset can not be beyond the end of the file. 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 5a73c90..7838bdf 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 (pos_in >= i_size_read(file_inode(file_in))) + return -EINVAL; + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) return -EXDEV;