Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2530387imu; Thu, 29 Nov 2018 06:28:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UvlqnRWKs4ytYNCbAoQDwiNCC9FUCZXPEpHRSR1RyDKEFkdzNjjrVevH6AhSEW38VV+Lwh X-Received: by 2002:a17:902:720c:: with SMTP id ba12mr1681465plb.79.1543501722589; Thu, 29 Nov 2018 06:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501722; cv=none; d=google.com; s=arc-20160816; b=xwaCSH61HR4CQTg/UrYs/WHusjnvf6Q8cx20ffcgwq1tm/s1Um233rMFEhr39XDA6b lmkYnoas2K7g2PZEYumEoxUo6yd0ML8IsPXJzpWHyVTBUoUZHyXkbZ+Hy+c7j4SywD+Z 5AnEnWCC4uEzV/t1JaeRjapTXkIGpFyIVxxo1hQUL3NMIatge3Ut9Zh+zTlM7K7eFKX7 v9CSUjnw983K404pNGKHQ3T17qEooBKD4kZYxbCTrUrxVQ+B8KLQQm0l7H4//Z8JCypr pKaS/Gx5QhNEyYfOt/Jt//mVPKmPOUpCMVkwuvRu/n2iJk0/cwa0H5iAfeHLW6bZ6LM6 G2ZQ== 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=tYGQhOBSp11FYgs+Vvp8XIRG6ohi/+HKsU8rwXETquY=; b=1JCexQzemzhYUrovw4leZg+1cGRyHkNdlpjDLQ/3tMaEQbY9g5HPkaS0aNPhc6lLhb QFbHd4socU6Ggw0n/UMLES9vnGbc+WO+Ev72pTNs9eXnY7vQ2lY/sBtl1aILe5WQVYPX CU/Fva1HgOGZK7Yc9TcqHbQk7wl7EmCaX2KUM8x9qWxkrr3lQKZPAhcx+br1bJFbY/GW ixKurI5TYAVz4Hl1H0k4Rx9WXAh0ILbblUwuCMxYsq289h/YeJrjkPHBOWbSMoJZq5yg s1cVhdAbgLlcQVq2AThAh7ouoaQwEQSCQcvBTf33tsnV+9lq8uYYe7GYfJvtdPqI0th3 1k1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YsfaeM/w"; 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 cd16si2619822plb.47.2018.11.29.06.28.26; Thu, 29 Nov 2018 06:28:42 -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="YsfaeM/w"; 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 S2387426AbeK3BcJ (ORCPT + 99 others); Thu, 29 Nov 2018 20:32:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:60090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387394AbeK3BcI (ORCPT ); Thu, 29 Nov 2018 20:32:08 -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 300F2213A2; Thu, 29 Nov 2018 14:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501596; bh=wDaIS6EgP8AlmaSlXLtu0dpuDdyMJatDuV2UrgezcoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YsfaeM/w1OeXhvYhyQnpKtFyklLmbKmHVXAHn+7NsCA4zjhcP2PKFbsWhbQias+C4 SmOfelRtgdNE5FEUa9pEHrdj8uY2hZ8I4SoxyvOyeVpfllC7CgiKKEgIC4DgmsV7/U EpjJK7pf8W/3TMwtJOa+ZYHCyx48JAjh11Jh1zBU= 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.14 063/100] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 29 Nov 2018 15:12:33 +0100 Message-Id: <20181129140104.433190613@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@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.14-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 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; -- 2.17.1