From patchwork Fri Oct 19 15:30:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10649683 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 5113A109C for ; Fri, 19 Oct 2018 15:30:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42CD1283FF for ; Fri, 19 Oct 2018 15:30:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C6DC2834A; Fri, 19 Oct 2018 15:30:19 +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 CB0D6281B7 for ; Fri, 19 Oct 2018 15:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbeJSXgw (ORCPT ); Fri, 19 Oct 2018 19:36:52 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:36269 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbeJSXgw (ORCPT ); Fri, 19 Oct 2018 19:36:52 -0400 Received: by mail-qk1-f193.google.com with SMTP id q184-v6so3174125qkd.3; Fri, 19 Oct 2018 08:30:17 -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; bh=JqSlx0NJttEt8iloB2oDoUtvtoMN/yM9tZtN1x5I2ls=; b=hZMcQ6ftCragylAwEU9jC5amr3e6NqjHV7R1HIvdUVbpmpx/8VjEvKr4mVA9dD5Joa bKDWvvkOlLFbECD1lkMkiWjAeqWwR888IORvkRv+UK7nbuVu2Rnyp9mzdjinxDF41eAb y99v+2eWj0hoe72lHHPLRIAP+20ao0XMRkh3buTCfjtHT5EsG4M2/m907sfaQ45iEacd fu3dNFf5N6AnoszPwqwqbDZ6AD1SgcYCWlQIh7dpkr45kj5aFYY3K9ibomGIxQT8N8Kw dc/gvT8JVGtyEA9Ly+NvmDIQr4ugqe9erX14f7s9tMWDii7C/UtNSSexAR77YkKqg8b2 /gqw== 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; bh=JqSlx0NJttEt8iloB2oDoUtvtoMN/yM9tZtN1x5I2ls=; b=Q5zok82UZ893sWPzIY3C2SDipv/rd54Lu20A3d/03onPBEfWCyfuCJcNMC1yjVtyiE LEp0Bajd1nTvCvdnAlz5x34ZHWHUjnyUioZ2eUzL67k1iX+crDZXpEF1YYCNpgABJhgR twt2v0aYd2EJ5pJi8UzxH7jzQbyhpml3eCVxv+H0Cfv1CF1UHz2H6p6SF0P+cg2q9FHE hRCdaqmHLuRPZCINkcMyQ5mFTTs60GUlvhYVyKOgO3jQLztADNayElCIbc8kPcBrW3BE k2Vs7stL6DolSDe7fP0ruAA60eg/9zWqxmfeRY/qAI1WlLxznayIjVq2t5L5kyA/C59g sfkQ== X-Gm-Message-State: ABuFfognqBSlEKxWdpJgj/h8lj1XCpJC8JMwKQET9N4jqbZmnuG9SJ4b eEOK1oIl4sUB5okNqQ0lZa6EaoVB X-Google-Smtp-Source: ACcGV60ve4bS/i2nLXOEbPhkhrlAhJwAq5rQc3NyIIgRIhmKCi3G9PnCHP0vbXhvuErCz63UWgVRXg== X-Received: by 2002:a37:bc03:: with SMTP id m3-v6mr33144239qkf.114.1539963016655; Fri, 19 Oct 2018 08:30:16 -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 m6-v6sm15141324qta.50.2018.10.19.08.30.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Oct 2018 08:30:16 -0700 (PDT) From: Olga Kornievskaia To: linux-fsdevel@vger.kernel.org Cc: linux-nfs@vger.kernel.org, fweimer@redhat.com, smfrench@gmail.com Subject: [PATCH v1 01/11] fs: Don't copy beyond the end of the file Date: Fri, 19 Oct 2018 11:30:17 -0400 Message-Id: <20181019153018.32507-1-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) 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))