From patchwork Thu Nov 22 19:56:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10694785 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 1CDE41709 for ; Thu, 22 Nov 2018 19:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EB042B010 for ; Thu, 22 Nov 2018 19:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 028A32B2A0; Thu, 22 Nov 2018 19:57: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 81CA72CE6C for ; Thu, 22 Nov 2018 19:57:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A18716B2CFD; Thu, 22 Nov 2018 14:57:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9C9116B2CFE; Thu, 22 Nov 2018 14:57:16 -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 8B6A86B2CFF; Thu, 22 Nov 2018 14:57:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 4BB746B2CFD for ; Thu, 22 Nov 2018 14:57:16 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id x21-v6so7140405pln.10 for ; Thu, 22 Nov 2018 11:57:16 -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=OipsbXVsfm3qBfbQ9iApZInLZW5NS15W8Sm1cwmbsis=; b=uKkGDynQthPymceNUlgf6FxTMm9dXv8fw5A9xahPgL6Ou/huyLen4LgdUeaATjz7ll 9FjkdG0TuX4NHcpp+tFsX+Ow2SaHG4yvkL3yIQrpQSAO6eMDchONBeTvTq7f3VgDyhUY uvuCr37R1g5KvA2hV59EYzUmgdtxa8x1L17+0dk/Lv2fiELGBoSFWaMSIGqoQUgd6PBm qZ/LJeUJAz9QAh2spn9wPh/S2n+2ueGH3VKFlygzcXMXrPnAQeatU/c7tQ+ll+OgAmt4 Kk+qmou6VLqAfNzal4OflEiSiYb9xskXDVysEsneYxgJ7PQawmqTlEHzldxPr7YtasxD PgAw== X-Gm-Message-State: AA+aEWZwSd0RhuMfNzJk047Ehfba8ycQd+IxMuMXbn5yU0lrcnKBWhNr leJoSqqeNuCsZgV/pM1RaE3Z1i2CtrvyG5g6/c0KllVT5t0lGCM1lF9MZHcie2gQTDIO1qC2E2G 4b3QYPSdBPNustVKJUWysJBH0bWEzvlNk9fRLWk/D1NVsq0b64oyU+n+4UcxGzyN8rA== X-Received: by 2002:a17:902:714c:: with SMTP id u12mr12415989plm.234.1542916635986; Thu, 22 Nov 2018 11:57:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/WiHlSFmSLMxXdApPYSxlj3MZ6vYBaopU9u4RwuDgeB+WQIbuvtW+IobGnKn1vJKZVrf9Ke X-Received: by 2002:a17:902:714c:: with SMTP id u12mr12415965plm.234.1542916635461; Thu, 22 Nov 2018 11:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542916635; cv=none; d=google.com; s=arc-20160816; b=vnuUA/NuTmviLl3YS+j/Mwt00Fk/GA6meZZ6OP1WLZR8PvDI+UaDTOjEI2A9bnRh9C 5SSZILJ3qYA8f0mjCmHVFl36zFQHMnDlhb3ylhoHWiunsfcop+CZPjxpRWbrbwmypoM4 8C7I9g5MRMf/QbSvDnc7oaBLuQXuH9Gf14D59M+r6pnD4WL+K7qy4LPa5gqC5yFjsqQf JINoGB6kARBOgDgzJF18MV2gN1fxxcBgOcezwAEWEL2BQlfr664yWe8oAdArfT+3ggHK tUhTfxlrUkn+e6i4UGJvTcsRKIUfa/vUHCNMVMxZJOc4yH2zmAnV9RkPHFlpoWD4npBn B+oQ== 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=OipsbXVsfm3qBfbQ9iApZInLZW5NS15W8Sm1cwmbsis=; b=QUqAAplTZCHJ9PAnOgxuUsY5SMB16Ye/K3XIWPdk7cLq6tJwi3a9MO20d+eaQWl9dl SRbqtZgzARlhoyBxixL6JbXRPhi81pQDYZShsEtWNjnFW2ElNwr24libU1MahkTjjjm4 XQtcMpyef2cAAL8VdOFkb9Ru5z4mL4B45uSNLmZ3uBdZhchLdxmvTD6mQjVCV2DqCbf1 banGUl9xbE0D+qFcy/Y1yR3MnGkH/kPJGimFtpauJh4jQ5RWZMPoEZgZOGDzmsjTzGNV p7lvRWREwSXwQJTojBNgNyny/Z/zyVd6D/vPEl3GJeCb/M+aiH2p2Tb21jaXgK6g9lS+ 9otg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kYYEW3i+; 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 cd16si24508687plb.47.2018.11.22.11.57.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 11:57:15 -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=kYYEW3i+; 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 4716820864; Thu, 22 Nov 2018 19:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542916635; bh=D7lVgAjF7h4m1elLmSI9Xu9HGyU9iX40zBv6A43c6bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kYYEW3i+3E7qJXJUhThAAcdHBAP54v3MiFyl3HS0MGS4W4ethhI770LEtdLHoRid0 jg82xtnkTnxxbQU1S72QhWHt+R5Rh5RIIzj6oN6/HOKGPDf5D658C+nGVwqTeHHlsi DMAe42EM8zCK7UfMXwtkov8abjuCGeqUjOV22YtM= 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.9 15/15] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Date: Thu, 22 Nov 2018 14:56:21 -0500 Message-Id: <20181122195621.13776-15-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122195621.13776-1-sashal@kernel.org> References: <20181122195621.13776-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 4b5cca167baf..358a92be43eb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2414,9 +2414,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;