Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp611470pxb; Thu, 20 Jan 2022 22:02:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNs7kGSnvm5Sp8ZZOglWz1XYdP6ix4vnCy8jeEcWSGAwHiRH8dJvxQITZ4Y5BY5X4oA7Vk X-Received: by 2002:a63:2b03:: with SMTP id r3mr1886412pgr.201.1642744950937; Thu, 20 Jan 2022 22:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642744950; cv=none; d=google.com; s=arc-20160816; b=jzLDMOdNkpqGqd4hL+gzpukX1CKpIC9aj2dqzoTi+6I4hDyRXy0j42g/wi6f/mF4uZ vMvWN8W+JT5UldVkn8rC9KMQeU96dbp3y1PlVr3yedgclN83fuEjsH0OCxvx/77L+4pf rDrG0fjiQLbHW3LQ1NjR60DD9w/e3JpxFU109v8BOJkN1Ux4z5wg09EHRXUinWyO28or Bhx65FKpqvY6NTRf41gumBhiiJ3yxm0pC077HBnDE+0kA6KpSPsOX/Ftggsazf9Of3R9 kTxjnTlOU1YEH2EAlDzry3yTpOyzcTp2aeKqGUxYRjXM2AGhwYpzDWvBw4/nm7A02t4o Y2HQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r4iCyFXHe+bup4K9q9AInOdt5dPxhLGgd0xGPzQvL+w=; b=f7U2PI/Fd+MufnCXRybrluq6DRW+Pwy3lSehh7hgeOrc6gKnMf+OeALwrtv5jQLSRM 2yjNPQKVHq+OIsjqX1eMCyYuEXWEJIikakgZCibF/6EGugtSJU64L2PKBBmRPXiJlF/D Ug2JE2v4sxOmLgAh+Cx1XBs90dwp0I8IrElJYRMZ3DPmi2uQOups6cLjPxHsJuLq3/WV Odnvl4/mCr5MPpm1IOCzf2yi9mA5IAXBAfwBZXjJLZ4V2nBjibzKVq65pDLnKmEzTsoq VvjnqIxKlNWSAHiNVHIO8pck8IXNoG43Fb2wQqYDR3N0cZrQooTPa9vxyfU8U41jj2Lb xW1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vastdata-com.20210112.gappssmtp.com header.s=20210112 header.b="8TJ/vufc"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si5042391pfv.366.2022.01.20.22.02.18; Thu, 20 Jan 2022 22:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@vastdata-com.20210112.gappssmtp.com header.s=20210112 header.b="8TJ/vufc"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348898AbiARTd5 (ORCPT + 99 others); Tue, 18 Jan 2022 14:33:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348737AbiARTdp (ORCPT ); Tue, 18 Jan 2022 14:33:45 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11D9C06173E for ; Tue, 18 Jan 2022 11:33:44 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id e9-20020a05600c4e4900b0034d23cae3f0so726900wmq.2 for ; Tue, 18 Jan 2022 11:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vastdata-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r4iCyFXHe+bup4K9q9AInOdt5dPxhLGgd0xGPzQvL+w=; b=8TJ/vufc5Lv6sW28C8gb3lpzW1UuMM+U4a7wKhPaIh1KeHicwtQ+2Z7T2ghZDuR8Et A00kItLYhkl+2ot7f7cVIz59+q5AD0mSKcByW2T0YEnmfIY//LnH7IFjqYBgq8EuRWTJ 3bfnfSo2cWD5fWahHajcPN01+t4S9Rl5npTj2zsru9yOZ49jBLS1PlBUxJcsSoUcno11 TRtUi5ZK2jqfw/GU//sQpga6g7fADcO7Qh46EkDsgpWL7nJIWLry6W2Lt4U6tfS/8nXA /4/rSvoEE8GNMIM8nA7z48xMKRwbgK7WYRRyJDMJ09tGYWCxvDcWxiCQzHSA0eAIUYO6 bTPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r4iCyFXHe+bup4K9q9AInOdt5dPxhLGgd0xGPzQvL+w=; b=1xHrFLIYNrQRumgK9aJjiJuc+/R2U5csIwhHOyXxlm+yufTUYotJg4D3zoJG/RfgPK G6mkYWkueq0gt+jb77u40X4vnMuKa6ryIGvziQUR18/3ZrWQOEwAOqeFqBpaV2ofdi1y qcmjickbmFh3tiASm1dp9KUzlJlNq7HHBnZgLf/L7iM0myMtfNYP0A4fPyLb+XApRZXe ycI9TdEm/uzP1fNrmgWHQDB8YTKvlxl96kWKUjbovnbKALfsOw/gKrRXs/aRMO4Snazj q1HxwzqGRRBU1Vzzmj1fSJ8DH22/aEh+Opj/Ma6n49x1VSUGQZ3n3oSJq1hj7RTgf8aN q9Sg== X-Gm-Message-State: AOAM533Qv32MOmU0FZ1yGuW6Slx/WadBH0o2T3Isjkahacxm6JzAcF1I VT0uHatwrfjTFv4yxttmLSreEg== X-Received: by 2002:a1c:c915:: with SMTP id f21mr56430wmb.39.1642534423395; Tue, 18 Jan 2022 11:33:43 -0800 (PST) Received: from jupiter.lan ([2a0d:6fc2:4951:4400:aa5e:45ff:fee1:90a8]) by smtp.gmail.com with ESMTPSA id i6sm14145876wrf.21.2022.01.18.11.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 11:33:43 -0800 (PST) From: Dan Aloni To: trondmy@kernel.org Cc: Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH] NFS: fix an infinite request retry in an off-by-one last page read Date: Tue, 18 Jan 2022 21:33:41 +0200 Message-Id: <20220118193341.2684379-1-dan.aloni@vastdata.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220118192627.tg4myc77nmbqm2np@gmail.com> References: <20220118192627.tg4myc77nmbqm2np@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Due to change 8cfb9015280d ("NFS: Always provide aligned buffers to the RPC read layers"), a read of 0xfff is aligned up to server rsize of 0x1000. As a result, in a test where the server has a file of size 0x7fffffffffffffff, and the client tries to read from the offset 0x7ffffffffffff000, the read causes loff_t overflow in the server and it returns an NFS code of EINVAL to the client. The client as a result indefinitely retries the request. This fixes the issue by cancelling the alignment for that case. Fixes: 8cfb9015280d ("NFS: Always provide aligned buffers to the RPC read layers") Signed-off-by: Dan Aloni --- fs/nfs/read.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 08d6cc57cbc3..d6fac5e4d3f4 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -296,16 +296,19 @@ readpage_async_filler(void *data, struct page *page) struct inode *inode = page_file_mapping(page)->host; unsigned int rsize = NFS_SERVER(inode)->rsize; struct nfs_page *new; - unsigned int len, aligned_len; + unsigned int len, request_len; int error; len = nfs_page_length(page); if (len == 0) return nfs_return_empty_page(page); - aligned_len = min_t(unsigned int, ALIGN(len, rsize), PAGE_SIZE); + if (likely(page_index(page) != (LLONG_MAX >> PAGE_SHIFT))) + request_len = min_t(unsigned int, ALIGN(len, rsize), PAGE_SIZE); + else + request_len = len; - new = nfs_create_request(desc->ctx, page, 0, aligned_len); + new = nfs_create_request(desc->ctx, page, 0, request_len); if (IS_ERR(new)) goto out_error; -- 2.23.0