From patchwork Thu Nov 22 19:57:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10694787 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 D085E14BD for ; Thu, 22 Nov 2018 19:57:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C211A2B2A0 for ; Thu, 22 Nov 2018 19:57:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5C932B4DF; Thu, 22 Nov 2018 19:57:51 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FCCA2B2A0 for ; Thu, 22 Nov 2018 19:57:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F50B6B2CFF; Thu, 22 Nov 2018 14:57:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7A5016B2D00; Thu, 22 Nov 2018 14:57:50 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 694146B2D01; Thu, 22 Nov 2018 14:57:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 2A5426B2CFF for ; Thu, 22 Nov 2018 14:57:50 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id h10so14598806plk.12 for ; Thu, 22 Nov 2018 11:57:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=LCDgvfdiTThPcSkuFTC49zQ5HGv58iYAjjRznvQOzSs=; b=TB+m4b3QR48zuGDeWvHE5VTnASOgoqyOfgGF+b+L2HbBFitZCDm1cKEHKR6AuJOfPL EZfjzVRI3PoYmjVVySYj5wLTifC6sJKuo3s3BAR6zFpphlz2lJjqMUcf45//raEKXJn9 gKmhMosqxJIlkfTBVjIaGz5cTlF7RnWMmFqE3Ff7ZPHy2PUmBvk7Alu5W7NyvqLCExZm PATuvg3wF8c890MMTxt5eFkwilSwuM6nTJzHuyY6FI8G2rwXSwtlbJNyHefMKO4DlkrH gvxl4gmeCISJsyehxHa2qkGUBXWNL1E2PxUOv2VI+nxZohnh5kzUXNjrWP3KUtI8+iuP Gvwg== X-Gm-Message-State: AA+aEWa29uqEaumrDY/HImkJdCg0Jq3Qpxl1BVbQuAGRkO9eAU3uU07j Eig4u6Hqlt5Rllbw2JxajIuEWpJruLD7XXQkZNYOMM/7W5NX6IVrRF5FywZeZF+W67wZjnA9/NX T2l+ZwTulo4X2+fYduCYMQOAM8bZDe9WwqoTXOd6ME0YjbvHJ/D7PWpVWG1jhOEmTUg== X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr12331932pll.33.1542916669859; Thu, 22 Nov 2018 11:57:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/UxF9YJ24PM1EzOt1w73JSMAXWsdKFTA0JrFoBMGZWfUVc0TNuMm4j92BBL7iOirA5nRRuN X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr12331908pll.33.1542916669279; Thu, 22 Nov 2018 11:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542916669; cv=none; d=google.com; s=arc-20160816; b=ZSdaF+rzRMFFEzo3TWQREabyBsf8BYt7of+w3SmaL0f2YBSvYmwvWhmtWauYhLTCE4 NQRD1M7sPO4t05F8bbW93F1wOjO+AmAnc8yJyRpmQfWSUSGzYPcz14O/nUMsZTymd0af hel3mksWfXp767sBMWTCvIFTAdNBBq5KbagDk4GmElfeqo3/yUJKKIVyH1XzmkDcBbO7 wherAvuZ7bitz+pbpwiwpXzG3W1j4DS5q4lOzm/+ClMas6AeDPI/Yjtbu8+KRebidfFB IqVDBNuVvhIUhEp/nVwxbYI4fx+9YnBsoMIiGETY7gFxDeyA98lRR9VRT0IRMXmWwdAG Qwwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LCDgvfdiTThPcSkuFTC49zQ5HGv58iYAjjRznvQOzSs=; b=UAdV8m84yEDDq1bZJEfVJyiIrxHyFvJo64CCjjQ00KtYBebdE2EpD3ITlCnJgAscr1 CTXwsGXDJ6zf7UcPNroq/+iu9ktxDZfMbjNBLwn+RJkEQ/WABBzW+olDXlDpMyQbxW7+ I9kFgc/6EYO9NT09CcJ0EG48UlfeKYz4c2kac4gzN3eXUglsQed7fRVvKPeEybOajTJt tQG3z8jObp7iNaUuM9m8j7YeL3LbRrxQPWwaAJ/LANgjxciwoPTFZgT9yUlJuowP0sqj rvAnzXj+6ARii0dVGQKu0VJ9sGI/IkmiBFouXoE4NAUx/bMf6CPspPLk9Ibvnd9r7BUL Ak1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=arVC2bmd; spf=pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sashal@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id bd4-v6si17632193plb.353.2018.11.22.11.57.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 11:57:49 -0800 (PST) Received-SPF: pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=arVC2bmd; spf=pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sashal@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sasha-vm.mshome.net (unknown [37.142.5.207]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5022720878; Thu, 22 Nov 2018 19:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542916668; bh=HK/JuGrHGiTDtGnxWRxZ7aQR4CN/5PvqmX6Pdix/JN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=arVC2bmdjbL21gscjqadIFtCKojmF/Yj82SYGTSKGIGcB6b/Gy42WjwJ9QEgDRE4K Ansn3BT5XI0KqaMXuOvQ4fvXD6Jtw4fqCGFwzk6sckKZgVWq77ZoYDwLmM9r3d5JZ7 Q3LBexVuEolW6xt5l6mc6sqE83rOavE+qdiyfcBU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yufen Yu , Al Viro , Hugh Dickins , William Kucharski , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 4.4 8/8] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 22 Nov 2018 14:57:15 -0500 Message-Id: <20181122195716.13961-8-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122195716.13961-1-sashal@kernel.org> References: <20181122195716.13961-1-sashal@kernel.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Yufen Yu [ Upstream commit 1a413646931cb14442065cfc17561e50f5b5bb44 ] Other filesystems such as ext4, f2fs and ubifs all return ENXIO when lseek (SEEK_DATA or SEEK_HOLE) requests a negative offset. man 2 lseek says : EINVAL whence is not valid. Or: the resulting file offset would be : negative, or beyond the end of a seekable device. : : ENXIO whence is SEEK_DATA or SEEK_HOLE, and the file offset is beyond : the end of the file. Make tmpfs return ENXIO under these circumstances as well. After this, tmpfs also passes xfstests's generic/448. [akpm@linux-foundation.org: rewrite changelog] Link: http://lkml.kernel.org/r/1540434176-14349-1-git-send-email-yuyufen@huawei.com Signed-off-by: Yufen Yu Reviewed-by: Andrew Morton Cc: Al Viro Cc: Hugh Dickins Cc: William Kucharski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/shmem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 8e506a45a6ef..d902b413941a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1818,9 +1818,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence) mutex_lock(&inode->i_mutex); /* We're holding i_mutex so we can access i_size directly */ - if (offset < 0) - offset = -EINVAL; - else if (offset >= inode->i_size) + if (offset < 0 || offset >= inode->i_size) offset = -ENXIO; else { start = offset >> PAGE_CACHE_SHIFT;