Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2520401imu; Thu, 29 Nov 2018 06:20:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/UD5IAbi58oXJ7t2WLqMdGTP0wtDk9ZERnfBN6fUs0D8s1yOYaW3d/n7RP33er0c5tM1CFX X-Received: by 2002:a17:902:209:: with SMTP id 9mr1679815plc.288.1543501230485; Thu, 29 Nov 2018 06:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501230; cv=none; d=google.com; s=arc-20160816; b=ZVOX0G9oiHrWq3SKmXoAGkA/JZGl+Q7dQyJdLizfEnUvOv/ncpkVMESeKyGmeyhwzV Zo0ETcAxKOwJgvAIA8ZOCr7jMB99h32gKAFPBBLIeiv9hXxz+cOBRIxChwGcaf0j5bqp xT1KMrhpWl6w09lCzFYGsmsWMLQopWtbuKdDhPDGNvasETm+N1IZHuBuhBCSd2txZVQ3 KlFeCaJVdpn2iNBMC4z0PVV3wP3ooKpIMvE3UiwlJ08amuZTn0LykZm+ql1vui/4wWhE lF3tDnfcjXNfdqmN3dGElJfAbQqW1d8H9VPmzdTElCYBJGxO/5CGtL+mTt5TYkstQQkf 8J7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AbqCKylR/U7ANHOtEVRodjyNF9ohHvyrCEjpUgWRfo8=; b=hm3dNvYR9DJkDP/k9PIOUfgNMvr5GsxzK00jpbWrlVM2L/bjUGy3QIXKt+4F8l5IA8 BrH0e1/lYKwAqrK5bZN3SjeoxV4qLYr8TtlRj1Z2aEaNBI0hiC+buQ3zB90BpMuLGjox jGbAofw7C5AWLWOYrAq+zftIGG/UhtKi1FbJ8JfOxszRk/9rTF0U2bNgonI+mN1rYDnv 5K8NgwEkBIKRSoCkQZ3Iyj6TNTdMRPKjV64uhIFELN2+HqzWgxYfeiA/T1vi0e2VgPIE Wo6JBLiOFOzqyNv8cnlSGGZufBAxbHifTPRr6bSNPu6WJdjPN5SoqM1YOwiWAXNpV0HB 12FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zdn3yaZT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si2096772pgb.245.2018.11.29.06.20.15; Thu, 29 Nov 2018 06:20:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zdn3yaZT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730453AbeK3BXH (ORCPT + 99 others); Thu, 29 Nov 2018 20:23:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:45090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728439AbeK3BXG (ORCPT ); Thu, 29 Nov 2018 20:23:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 78D59205C9; Thu, 29 Nov 2018 14:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501055; bh=wVX9TZj5H79gseCgzWtSaInYf7pVlAQI2BNaf4N/Tjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zdn3yaZTFIGSLxJCDHFGfD3kqE0Yg9J7YmOthpLo8k/CYuwGvVTKmNgeGruvP47ZV 4+mT0lTKORWfb8JQ2q555K6CUvt0tOIZP4rM257nXe86Hp1N7bFnbzqULPtW+RtcrY bZt/lDL3GFMSSac5lrgMJM0tAiKFex3dtPfIn5bA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yufen Yu , Andrew Morton , Al Viro , Hugh Dickins , William Kucharski , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 24/86] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 29 Nov 2018 15:11:49 +0100 Message-Id: <20181129140111.807294768@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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; -- 2.17.1