From patchwork Thu Nov 22 19:54:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10694777 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 5A2311709 for ; Thu, 22 Nov 2018 19:56:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D6AB2B010 for ; Thu, 22 Nov 2018 19:56:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 418E92B136; Thu, 22 Nov 2018 19:56:17 +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 C02E12B010 for ; Thu, 22 Nov 2018 19:56:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E0766B2CF6; Thu, 22 Nov 2018 14:56:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8912E6B2CF7; Thu, 22 Nov 2018 14:56:15 -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 757D76B2CF8; Thu, 22 Nov 2018 14:56:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 370376B2CF6 for ; Thu, 22 Nov 2018 14:56:15 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id 4so14572653plc.5 for ; Thu, 22 Nov 2018 11:56:15 -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=JneqEw+CGPE7jVMbc6OB15LiQoIX8Fiy0lae51kex8I=; b=i6CUubwVXn9wd4j9IzH8iT1fxZ5Z5gbwcFtAO4eqbCbTzqDSNfXbZCdMDQE4aHyrFT HslTbjAfM20cuwvI66FIDzqPImcMTRtRBMCcbOtW3WFNXe+RlffUAUybMqeQbBCMA3oZ EX/MZXoCUXw9MFDMzsy+90NcjBIWovC0wSbXKkoQsWAlQS15pA+HkR7jhaaQjslTrVUh j/uPJLA0T/qJcu7J0E/ZSuqOmIW/Iu4qOQV6h1AX5Y8QzXvHNR5j1YxYKYI3BfZ/qJbx 8Ij2qdbZQQE67StGkGoRg8k8JrvRRw4Og6HRxeHaDP3DiVRwc+fqT6xNKjPTG4vl1mkn afDQ== X-Gm-Message-State: AA+aEWa+7qJAG33Hmlhd0pZCysW83w0gwDZf5NhG59xHvVnUgl5dXvcI MmhoFsrZtQwrwopTP2wWcnQOfQMruRT3j/4A4gxJJyRZ6hCUvWU3zMPzv53UUrQkxpE4RaHgsgw tnLzSmkuYkoaUuR8LHnGZokMkm5bmYRsiL24p7Z8n0WAG7wFpHmg7QBzm049TGWBRtA== X-Received: by 2002:a63:fc05:: with SMTP id j5mr11433202pgi.434.1542916574846; Thu, 22 Nov 2018 11:56:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/UERgqbq66ftwaKC6ZacSBRCYGjYrLG1YDKYZxOcdc/jEaSWR3l//IlocEu+bfQvyC1scvQ X-Received: by 2002:a63:fc05:: with SMTP id j5mr11433182pgi.434.1542916574296; Thu, 22 Nov 2018 11:56:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542916574; cv=none; d=google.com; s=arc-20160816; b=Bh9P0i6AlSf3dnxMbdiY3LzK/+Q2znozjuTzHctMujfnOChdvklzyxYbb99dGYEG35 trvq1r0L8ochZgmMCWVikfU2Eurx4NX87jzYv+UsjHcbZTLEmSW2zWQ2eFF/P2WZ3T3z lr3kqKXIrTxRKHWwPP0XRzLbiWTyEpUrxDw+zXmg9w9Xrv6MGIfIKD4WvxrRieBRxfAb gLyhEp7RL9d9Mym7avIorIoeyOoIxVhyuo5Jp+pLAp1JB0gCyEKzYPI+Rf+wcw9q7TQQ lEli25hU1VUM4q7LXADbvp55oaDHez2L0YCFnC45r1cKwPACgLhZQFNKmkggslnjYnMd g0eQ== 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=JneqEw+CGPE7jVMbc6OB15LiQoIX8Fiy0lae51kex8I=; b=CG8yONC//A/TsQM38Ic04vihK0dfyEQxirQgvAEeGg19FuD8gt0LK68LIu0oOz9da4 6w65/GT9HeWdR5nGXWd0FMXD6GBGs41JXSbnuJrumPp2PZjtm7xArUQG5oKQfjFGJcgd /XpLDf0RWS99bspObiQU671fDV1ZMQt1qkES4KtHePknVfjOrLgMNW4dxp7idduL70c6 w08PHvMWenz7pDJgrKmHRPzTgpMrWiJXAzO60ApFQSV1kz6/lcI+bGYZCX4qILtIckuX hJUCcvsjicirNT9ILko8ookKmR3/IQbDSRHfbi43fx7xADEh9Mb5DgPQ8SFEsHEd0bnK z2dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sUYDgL1E; 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 z10si37404161pfm.37.2018.11.22.11.56.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 11:56:14 -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=sUYDgL1E; 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 390B120672; Thu, 22 Nov 2018 19:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542916574; bh=S7vU8rSHrCZb3a0fzkTucu2Jn6JD/fp3nZZwX1T/5sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sUYDgL1Ekh56fMazDOnErhYvy5hwvruEbEEuy7UZ53V0KLLelPUz8TeVJGgk5WQwn Sd41JXowZFhhrkJ0xEJtx37Qw5y0NU9dvT3ZfGLZD7t/D87LL9zjOzCJ111g0ykAoe Sdb/evuoj4Q0ppEa57o+BFyaWgl8dPdrdIQRq6V4= 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.14 20/21] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 22 Nov 2018 14:54:51 -0500 Message-Id: <20181122195452.13520-20-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122195452.13520-1-sashal@kernel.org> References: <20181122195452.13520-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 ea786a504e1b..fa08f56fd5e5 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2590,9 +2590,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence) inode_lock(inode); /* 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_SHIFT;