From patchwork Thu Nov 22 19:52:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10694767 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 505BF14BD for ; Thu, 22 Nov 2018 19:54:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 407A129710 for ; Thu, 22 Nov 2018 19:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 345192AF94; Thu, 22 Nov 2018 19:54:49 +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 BE70B29710 for ; Thu, 22 Nov 2018 19:54:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 845B06B2CED; Thu, 22 Nov 2018 14:54:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7F4CD6B2CEE; Thu, 22 Nov 2018 14:54:47 -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 6BD536B2CEF; Thu, 22 Nov 2018 14:54:47 -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 2C9AD6B2CED for ; Thu, 22 Nov 2018 14:54:47 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id ay11so13963977plb.20 for ; Thu, 22 Nov 2018 11:54:47 -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=QhK0vT8PeYSCCLbTom9RASBxXAca0THq6IpC5RhYar8=; b=Prrpooj8ypg1O7BxWJdOF4By5hmcu1ksKojgJIYIl+OP5LVvlxntuK762gIirYjlPQ +ulaTlbbx9qZI+mVnZmnv1Au22fqRBq1kOmRVwBc5c31Hn2hTwf2tNEotWrSbo46Auwy ypIjffxmQqG2OUhWW00nzCcRUYdwEBmmYST+71SFXEGU0ELCxk8hvleu13PRIh0gTddf AFo1DmLCJInrucfPquuNLUvm+xUG8bDmB0534C+XACuvUQ2kuheaNQk3PTCI92bMrPnl 6du0L/xbbPDsPht2TdqD3fzFiHiHw35DzYPb44V32Yc0m87cAASJPk0t0JX7BxLggLxT /D8A== X-Gm-Message-State: AA+aEWZVWWkwQiY3cQrOfmesGPL1Ap0wCSWBJD0c0srpBblGV+HAlphj mN+IywHG8dyjneeVkdpECbDkO6QdsArWhCQjiTc7OqDXK1+y7CTyCW9VMo7ahAkDuprCdQHV0Ow PZTUXYZGpI/XFfA0M5Vsj0Zkrn04sgt1GBYfwCFSIquIP0e3k1A0Xx3lwpYH9OSBhdw== X-Received: by 2002:a62:5486:: with SMTP id i128mr4714408pfb.215.1542916486840; Thu, 22 Nov 2018 11:54:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/VdKYQ6YAvYpKg8qwS6UwhFry9rKm742IA1Rt5tZR06fTVYJhcPpxAKN0t6OTL1pS3GQvwP X-Received: by 2002:a62:5486:: with SMTP id i128mr4714389pfb.215.1542916486302; Thu, 22 Nov 2018 11:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542916486; cv=none; d=google.com; s=arc-20160816; b=BE1vHTbO1gA+YX45PVFvvzIpBv3def5Jx9YqvPXPRQ21RSn2Jrdz9x89K/MNBk7Gis LiCFQQIBkt3C+vGEecfiOcnxrfSNbsoyZllybpwqYYvDxK50+zFPgsvL1CVA/hImAzXl thepEH5IAC3T2kDJyAt3dfIoqTwA2Aji6+0ofowuTNwqBTZoCqc7XerQbJu+Qxpf1Wpz Fv1fRs900/HIt2duyxggRQpW+tZ3zBLzZm23UeUtWIKOPpWRBZ0jVrvjaaiYzpVpbKc1 bAC6WHchVYDpWBlstn7Ys8q/D8wnpr1MiB3sNYles4pg/GBpuAh0QkjVE2Hh4aZFlA+k CDZA== 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=QhK0vT8PeYSCCLbTom9RASBxXAca0THq6IpC5RhYar8=; b=Q3h26jHOz8n3X5IpqxJJuKzlgzRzzx7QOH385G32pgntD6CvECvWnAlk6PVhWMauab EUDUrdJ0FZuYPINmXHg73NJnDlAPRbW/GlvX2smh42syr7vFhqXJbRA3RXgHj7/h/T2+ mvBtGfgHvePEcx8pJDSUm8vZGJ3TQ/R2DWugUAh9XP0w+yA1nJkF0BjwSvQ57hg/yXpk +Ktnd3qSv+EOLpR5buy9EFT/aIIBUYZke5ciqFrSkqsz1ktbN2WE5/eQ7aCqpG7Q+Q/Z g76/vCXYT2Bm+5+QA5AkR+nv5i76DbzmCN+KTEfuaYL2KaPYqLNDv2vJtg8Ce6Dw0Ojs Vpbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A1bdREAS; 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 j28si49463654pgm.160.2018.11.22.11.54.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 11:54:46 -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=A1bdREAS; 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 5E47120645; Thu, 22 Nov 2018 19:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542916486; bh=X7gUEgCCkxL0A2Ds0/+fdp3ZX3Sjdi5FsJEcYoVFCzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1bdREAScheuDHtrlQIHD/LKoksCL1uZYs+Pe+Zb6CYFH9Me8n53wlAwNeImDd5By /K6cuqmPEDUP7IMaHc6i5Vjo24Qh4ZPuFLuI4PT3Lb8GTGcMIq0Z/2Mzibb3R38v93 5FBZrtdgcxCgn4Z9MSyIf42pgtxIiZnbl++bE7Pk= 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.19 35/36] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 22 Nov 2018 14:52:39 -0500 Message-Id: <20181122195240.13123-35-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122195240.13123-1-sashal@kernel.org> References: <20181122195240.13123-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 446942677cd4..38d228a30fdc 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2610,9 +2610,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;