Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2539456imu; Thu, 29 Nov 2018 06:35:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/VXnCzmibIHaq7S2vcZ90xtkQaV1CwlKsnFfEFdwPuPTSBKDeUvt4DFuc9sBpTsQR4xe7Sm X-Received: by 2002:a17:902:1105:: with SMTP id d5mr1637605pla.47.1543502153551; Thu, 29 Nov 2018 06:35:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502153; cv=none; d=google.com; s=arc-20160816; b=wCytK4tReuhyKl3P35YTDufAEyh6uCjeAMqVE7NwCnbgFHfbl40dOCP0Uz1Hb+Mun0 UhW4uB3IiQkJYXlEBhCG33gkdR6mZ/0eoapA2teHfDo7qKVRfdkRmPJ/Kvm6kMc1f3cH 1mNCalYNkauf/2NBNh12mRREeBMN9q3hxvo1qhgYNC+nEg2qZJ0Wp17/QLVk8LcZnuvt MoGA46FjW8dx8ZKTWD0m0sUj1NoPBxOucLQMAHpo76XEt8XyP9rpEFKYU2OSxZXJbsm5 7918CY47dOEtHFAck9yNZDF2AwMoiPWVP+v6gKwVb16kfYgIWEtu6XRPYsa/rpEsNyGs SyAw== 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=L8i2nAMG0uNCLiRHwWw9lfv9GYV0vY/fzudnP/qq8Kc=; b=Cd7NlvHur9ik9saagX0VqcskQ8UCI8sDH41hRdmRNY8wtBq4SY9h3y4Ssr946zNms8 RV/TBJ6ozdDak+3hxlcFs0uWSWBk59BVbfXpA44OCLkeIHJnzkULvCmq+eB+PTp0lI9z yJ3TC+oAevVGVX+0WyDyIpuL13jLz/Kc8T/EeOBWOC9CMLMgq7rhiaj33EitIIuW9jjv GtsUzFsKiDnpz7da3+uSYHZQiBR348ofO4ZxRg6JDhHt8ChJ+ZJheN25rXWaimt9ccGc hhDDuCOFers7OF2zeicu0Ijc//lQ6ZxOEs3jhtKmsnMuDgy8vWMXF2DZIrDXYFuZl4d5 dE7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I35qwmMw; 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 w32si2095726pga.337.2018.11.29.06.35.38; Thu, 29 Nov 2018 06:35:53 -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=I35qwmMw; 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 S2389601AbeK3BiX (ORCPT + 99 others); Thu, 29 Nov 2018 20:38:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:41908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389583AbeK3BiX (ORCPT ); Thu, 29 Nov 2018 20:38:23 -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 624B92145D; Thu, 29 Nov 2018 14:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501969; bh=GfLQ1z4738EbdXHKsR7q/bIEHz6PBOJ1dNh9nmk4btI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I35qwmMw8tRHg7vZFoP1z9k1AzetYgU1bx+qNOTbvxc7O2qmSUUtkFl41TFug8tmj uJaONJ4mURuIi8OE8ZZL/iDKk2AX7w2cjBhGKDCljKYo310rMoGIc+3OHAlSkESf2z Igz8yVUEK/iC7Wht2OsATjM7c4OXBCtYViwyINkQ= 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.19 097/110] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 29 Nov 2018 15:13:08 +0100 Message-Id: <20181129135925.167058504@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@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.19-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 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; -- 2.17.1