From patchwork Fri Oct 19 15:29:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10649661 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 E23DD109C for ; Fri, 19 Oct 2018 15:29:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D077B27F91 for ; Fri, 19 Oct 2018 15:29:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C024727F93; Fri, 19 Oct 2018 15:29:33 +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 7B9B327F91 for ; Fri, 19 Oct 2018 15:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbeJSXgH (ORCPT ); Fri, 19 Oct 2018 19:36:07 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:41720 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbeJSXgH (ORCPT ); Fri, 19 Oct 2018 19:36:07 -0400 Received: by mail-qk1-f195.google.com with SMTP id g13-v6so1623526qke.8 for ; Fri, 19 Oct 2018 08:29:32 -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=PC8sKXxOUg8U+6Jyop52B5XbKS+h7c4WtuLq6hZPzVE3VlXgq7AJtFHsyKWXZpYMg+ bgI+FBUMrCz4DRk9svoD3Ry6A6CM1B0KrDEmZcdch8ECZNJH0QCtffqVs/g9WqEVTi4h ICL363J8eQ8AdfvntGpgy523MiNd/Wn0nf4/W57rNR4ka48MihceDztpDRNZEfh9LxmV OYp/wB7vbXydVROkwwzjcGS4qq5bdNzIiVTYG7rIHrbqiIBgnumYxQ/qXmp4lOYMmxRx T7vqAn88glBUKfIwDB12Z/Z+noh8VSFvrtKxcTNZJe3FxbZ5F2bwhxCo3YNcgljRo/n9 MCVg== 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=hhuBFQMRHR8mgbGb4Du1bFahmymX9/eygZvFSMOR2eMrEb3pARoAmwIyb6JQww2l7E QTEEvTcoczVPim3b8tSyj99sot7wNb4lRIRVMTYKv6kocD3KnQHLNskzjLGTDle2RNp5 WSfE1KSJ6Hua3EnqkwUNxkprEqhg6o0tkkdqI2yDVz9/2TnRKGpfPuWsUegR7vIjikJE Y5An+jIVr7EgBKS7SEKpUVRU/kvc+h7Kk/3gWs8vsKnB2RigcVJK7F5ZwUNmoHFOCId6 xQLfHohhrnZ3kfeInoEYQuDnfJbEP7+4bcEbbD9+m5LCjEmaAqjXwX/aI+0Twrypx9kG XjVg== X-Gm-Message-State: ABuFfogv5DEForwewIAyDw0yr0g/P2YPGYIQ1Z/DNS2x6gLoRYV3t1R9 n3edzpnmUrDYQt7IqqJ1RPjfaJ0v X-Google-Smtp-Source: ACcGV601T/yZDpmUoe93pVhCr3dmgeAZ2Buw6smkTZNnMmb8Pcovc7RAah09X9UcKoUF5GOXAgajOQ== X-Received: by 2002:a37:5946:: with SMTP id n67-v6mr33270841qkb.202.1539962971929; Fri, 19 Oct 2018 08:29:31 -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 w39-v6sm17358099qtc.84.2018.10.19.08.29.30 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Oct 2018 08:29:31 -0700 (PDT) From: Olga Kornievskaia To: trondmy@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 01/11] fs: Don't copy beyond the end of the file Date: Fri, 19 Oct 2018 11:29:22 -0400 Message-Id: <20181019152932.32462-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181019152932.32462-1-olga.kornievskaia@gmail.com> References: <20181019152932.32462-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))