Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3036632pxj; Mon, 17 May 2021 16:08:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC0eLRl6KVgqWPuEVfcyne9kvX3ZA2dSCLuD+/SsLLcHxZm26Iwhixz07Jhd+CUP7fnpwD X-Received: by 2002:a05:6402:da:: with SMTP id i26mr3030718edu.379.1621292929814; Mon, 17 May 2021 16:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621292929; cv=none; d=google.com; s=arc-20160816; b=xdm4rB81tfIlfOjbd8UNXqU1ZvG5lhznIFFMMN5wVzv0S0KRu2x2oMWzqjWNMUCMeD vHbpFx8LsSKwP5LVDrUkSSR2A/s2WieUs2IeB/Cs64a/qQUlGuMarAKl5TMLLPutZiFf +iPMuS46cD70Ql2j/q54p6UZOMAfqE3qLHMNtMmZ2cx2SEpoj59UZrCW0HpAPmvE6zgh Lk7jSuozBzPbRrrRLgUQ5xYD0Urj/L265Cw7KZ2uMAjAoT0s5seDuCOAZfRlti1DmBSi k0G4K3O6Fe7uVRWpZKnEdSuELq5V9naIQCjqrzrfhQ/LJdFpu4loJSeQmW8fzQzi/A/I EYWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IvURDJLKkNMfkDHVQla1Ch+kGsYjYFQiwbnxFU0IUyM=; b=JPeodztUXolBp/7nhFfC+jgdQ8pagZjzdsZrwpnYzXdC+tXXtlRkwhUC1JZbxo3L8u MX4Hdo+U7/bySU72WUAKvFQ4LQ/YI2aGZ9jdKCUqBXGbfR/wXiza00y0m1ZByo1GywU5 JWdKDKMKszqAlh6xAM1mT4LFZKb6xrfOQ0WoV4aRiaSmpRQPSRTdf/oFe3LlmSxxqkWY xMuiI2Woxms++6gG5Q5dP6T9RND7cKS0VeYU5/P4FFucKBbkfFnqb/jfiuByqfk6su25 5a3ayheH2Hx7rS9b1Tmt4Ty4ELzIsW16oaaRBt4lBE/W37dJXdhYev3x7nioyGFW3NeB Ad2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A7VKn02F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si1447041ejt.21.2021.05.17.16.08.26; Mon, 17 May 2021 16:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A7VKn02F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239159AbhEQOVE (ORCPT + 99 others); Mon, 17 May 2021 10:21:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:49306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234797AbhEQORh (ORCPT ); Mon, 17 May 2021 10:17:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49191611EE; Mon, 17 May 2021 14:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260609; bh=lOlsJjgaOPtDTbYmbKCrNFRFhoILXqDGkvLtaB4IIV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A7VKn02FGEGsFe7bVOnCNolfBjWf54hXhU6OPN3A8Rny4EPmSDP/R+SWm8tIfCGUL MkKl8NLk42MtBZ9sHlmDJ3XToTIkRN/MFzlLwkoRKe8Nqeb+NPUWOHh2C/A/rKgA62 tVBtwZv2z0LvMKVixFbIM6n3ULoah0fKOGd6mlqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olga Kornievskaia , Trond Myklebust , Sasha Levin Subject: [PATCH 5.12 159/363] NFSv4.2 fix handling of sr_eof in SEEKs reply Date: Mon, 17 May 2021 16:00:25 +0200 Message-Id: <20210517140307.981336756@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Olga Kornievskaia [ Upstream commit 73f5c88f521a630ea1628beb9c2d48a2e777a419 ] Currently the client ignores the value of the sr_eof of the SEEK operation. According to the spec, if the server didn't find the requested extent and reached the end of the file, the server would return sr_eof=true. In case the request for DATA and no data was found (ie in the middle of the hole), then the lseek expects that ENXIO would be returned. Fixes: 1c6dcbe5ceff8 ("NFS: Implement SEEK") Signed-off-by: Olga Kornievskaia Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs42proc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 704a5246ccb5..8d64eb953347 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -667,7 +667,10 @@ static loff_t _nfs42_proc_llseek(struct file *filep, if (status) return status; - return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes); + if (whence == SEEK_DATA && res.sr_eof) + return -NFS4ERR_NXIO; + else + return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes); } loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence) -- 2.30.2