From patchwork Wed Jul 12 17:36:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9837205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7698F602BD for ; Wed, 12 Jul 2017 17:36:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63C95269E2 for ; Wed, 12 Jul 2017 17:36:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5668B28500; Wed, 12 Jul 2017 17:36:58 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, UNPARSEABLE_RELAY 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 08B60269E2 for ; Wed, 12 Jul 2017 17:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750960AbdGLRgz (ORCPT ); Wed, 12 Jul 2017 13:36:55 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:31945 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750869AbdGLRgy (ORCPT ); Wed, 12 Jul 2017 13:36:54 -0400 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v6CHar4i024962 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Jul 2017 17:36:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v6CHarRR018339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Jul 2017 17:36:53 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v6CHapOQ021010; Wed, 12 Jul 2017 17:36:52 GMT Received: from localhost (/73.25.142.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Jul 2017 10:36:51 -0700 Date: Wed, 12 Jul 2017 10:36:50 -0700 From: "Darrick J. Wong" To: linux-fsdevel , xfs , linux-ext4 Subject: [PATCH] vfs: in iomap seek_{hole, data}, return -ENXIO for negative offsets Message-ID: <20170712173650.GC4212@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the iomap implementations of SEEK_HOLE and SEEK_DATA, make sure we return -ENXIO for negative offsets instead of badgering the iomap provider with garbage requests. Inspired-by: Mateusz S Signed-off-by: Darrick J. Wong --- fs/iomap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 432eed8..16f5c074 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -610,8 +610,8 @@ iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops) loff_t length = size - offset; loff_t ret; - /* Nothing to be found beyond the end of the file. */ - if (offset >= size) + /* Nothing to be found before or beyond the end of the file. */ + if (offset < 0 || offset >= size) return -ENXIO; while (length > 0) { @@ -656,8 +656,8 @@ iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops) loff_t length = size - offset; loff_t ret; - /* Nothing to be found beyond the end of the file. */ - if (offset >= size) + /* Nothing to be found before or beyond the end of the file. */ + if (offset < 0 || offset >= size) return -ENXIO; while (length > 0) {