From patchwork Fri Oct 19 15:28:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10649633 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 68631181D for ; Fri, 19 Oct 2018 15:29:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5670127F91 for ; Fri, 19 Oct 2018 15:29:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A8AB27F94; Fri, 19 Oct 2018 15:29:13 +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 C09D827F92 for ; Fri, 19 Oct 2018 15:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726465AbeJSXfq (ORCPT ); Fri, 19 Oct 2018 19:35:46 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:43079 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbeJSXfq (ORCPT ); Fri, 19 Oct 2018 19:35:46 -0400 Received: by mail-qt1-f194.google.com with SMTP id q41-v6so38695741qtq.10 for ; Fri, 19 Oct 2018 08:29:11 -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=JqSlx0NJttEt8iloB2oDoUtvtoMN/yM9tZtN1x5I2ls=; b=LVhwN7vRPy6T8BSSpR5eDTKQvbxUa+sRl+DgK0Eb41vQ2N9HKC9RX8sIVdWaX26ORX Wv/NmiYl7Zw5bNpwxxWQjLb7KQ9wWZIas8h68kkumcbhBKpC48pTrc8jnUTfOcqAevO8 5SGgC96PUPCG2JiGPTjM2YIrRWBWZHI6eTA1oFInTg7k4vs7NIL+rFul2nKcPKPBAOIa Zp4yAcNWN4iGtF8jCfCcHBHIO45CRthb8gDwjF/WQ7K18wzVkxEkmvO6PG8ijPZ70fLq KgurJqegi7k7XASQTaIcQBOI9aHlwQ7RJR1CGlBSK/yObxmbm0kZ2U2PaJAj6BueOSrj SG6g== 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=JqSlx0NJttEt8iloB2oDoUtvtoMN/yM9tZtN1x5I2ls=; b=SwnFLmovwuf0xAWvHDlmU4TRY95ajLCkaasSSGKp1ho36JX3v9Djak+kTMhIP6JW4J ikYW5miWYw+cOg17s+n6/Wz8zsa50OobP3H4CNoi5yZN+0DJisxPA250qYjVZyCrAcVh sdFPLKGVKUTKi/fmyYVcfEzGsGMphnIdrSI7xUFnRoxCMou8fzj5GmQ2IoyJslfccA4o 4H4vDX9RFXmXzUm+J0UoV18dY5axfCvqav4pNahZKdzmBlaEKz8Hzbi7iOQQMxlP8Cdf FK8gL6qGhMHF5VfHbQ/h+LQ7OqsUvUcT6B5ETBnp97vtXjiPR96toyM2iHMpypV/di8A h3VA== X-Gm-Message-State: ABuFfohLjk4u08DkBDeg2XLuhqGwrjOgFbkFM+2XJDZa6YtJo0nZU5j6 LFFg6YPG5LqymxbmkkvBA+4= X-Google-Smtp-Source: ACcGV61qnqYUmkASvc7DiX6fHfMkAuTLZhaQjUxmT25pjrVY/EKXiWbt1fEjMcqqQBj932zxb9pcyA== X-Received: by 2002:a0c:e70f:: with SMTP id d15mr16216118qvn.221.1539962951010; Fri, 19 Oct 2018 08:29:11 -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 s17-v6sm18126231qtj.31.2018.10.19.08.29.09 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Oct 2018 08:29:10 -0700 (PDT) From: Olga Kornievskaia To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 01/13] fs: Don't copy beyond the end of the file Date: Fri, 19 Oct 2018 11:28:53 -0400 Message-Id: <20181019152905.32418-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181019152905.32418-1-olga.kornievskaia@gmail.com> References: <20181019152905.32418-1-olga.kornievskaia@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anna Schumaker Signed-off-by: Anna Schumaker --- fs/read_write.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 39b4a21..c60790f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1570,6 +1570,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (unlikely(ret)) return ret; + if (pos_in >= i_size_read(inode_in)) + return -EINVAL; + if (!(file_in->f_mode & FMODE_READ) || !(file_out->f_mode & FMODE_WRITE) || (file_out->f_flags & O_APPEND))