Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1416279pxb; Fri, 21 Jan 2022 18:11:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwP1MLQe6IZbDY72EdYKtu1sR8N7YAKVWhVJrHAKJkfk/VYOjaoTCVdtH4o2XQKv4KiS1TJ X-Received: by 2002:a17:902:7597:b0:14a:b4c8:23ce with SMTP id j23-20020a170902759700b0014ab4c823cemr5935291pll.170.1642817485791; Fri, 21 Jan 2022 18:11:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642817485; cv=none; d=google.com; s=arc-20160816; b=llaobIjqkmr2IWjWNEjoaMB73AMvC5z9Whtfezxszkh2+9KWN7fOZnDAHSRcH3K5TE n/KLPbumSsJnKCoIhuoMFH7mXyOgAD4bcVkzFAF2a52eu9wBDsyc8/XDGA1KydtakBL4 4ULY8hVUX9F3t53TtpH3TXVMoFEiLJSF3L5LRISDY1Qvt+3GdFR2jKElwRV7vKPO4fS9 54KKovIZJtYOjXYhcVC11/v0qAA70tPPxXqPCkD9m/zuCGqxGpZjFJE8X8J9gC+Jh28X grURrDX5yp3BWMpFFzWgs8+TjOeLTX07zBaf1BslDs6OThaDenquD5EmqQu5WQGOmaqD WpAA== 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=QzwXz4OCrvfFZ3/TGNeC9Jj5eqEDnWOIs9bPsoJq4X4=; b=m1PpJQV2YkdBIIDP6ft58dZdjGk7AfL7eoBoNaEZoNPZWVOJHN7ms0sP+Z2rsTq0nG ErtrJcmspPoEtsCEZLz4nDLL/EYpVUQyynN0edMQZCHKfEDXBDLsbDJ8c4CoDj2TIPCs ZQDA7uY6noxQCxNgA6D7EnduILJ/hLiCovwgh31peUA1w2MCbsju4a1mzeebns9uMjkb G1ewXpT8s0S9+H9AYc0ohZd1BTiapNZboNc/Hh/FCUSxVMVEs1FaJ5Ub0HXIk1rSk1lr dm2XJBRTG7OFJ97svV1LOVZ9YqDHWNhFM/JkXfRBddzSA9IURckjiXsXSTTn11mQPb13 A/GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vastdata.com header.s=google header.b=f7o2tLUF; 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 d184si7983300pgc.100.2022.01.21.18.11.13; Fri, 21 Jan 2022 18:11:25 -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 header.s=google header.b=f7o2tLUF; 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 S229871AbiAUSuq (ORCPT + 99 others); Fri, 21 Jan 2022 13:50:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbiAUSu3 (ORCPT ); Fri, 21 Jan 2022 13:50:29 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37558C061744 for ; Fri, 21 Jan 2022 10:50:27 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id r187so223325wma.0 for ; Fri, 21 Jan 2022 10:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vastdata.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QzwXz4OCrvfFZ3/TGNeC9Jj5eqEDnWOIs9bPsoJq4X4=; b=f7o2tLUFNZ1FfRj+Nc3Wr4lSyWT3Dupaca9lu5FQYRcmIJQ2Wfuv0SURexlN8f8UjV Rx2qNhPrVK45dgw63jVGUZ+WpOcWpyUqDGqY3Y/DhTZh+Y/7qfaJjWKAw3Gt4FlBu1zp WG1lvLtlxw4yV46SVUSueL95sWVlyffcaapP/S4Fvfy7W80EEFgZftCNaXhKGpWlgm7b IXrpingJAxzMP7cNT75CLyHdfElOUO/3DqyZ4D8roakLefFZmb5Iy6nCF08oYS1nC6La La+mbsJkwADO/12GUIna7eytgZNdHZIDWeUcKVsYKZFmp5yIRMDA6DcAFHFZyGe7nCKt p0rw== 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=QzwXz4OCrvfFZ3/TGNeC9Jj5eqEDnWOIs9bPsoJq4X4=; b=3sm9/+lnQWy2aCvV3rwa1Z0hUKn21TcDg7KuEa1wh2EMkofo43DagaHTvo/zcFLlHQ G+GhQbk8toc/NO+8F8KXUlw9+vumLOYYLf1AaalreGxHzKR/I9OGnxtcO7Xfx4APidty 9EiOjLJB8ubghx2CoHlAqR+HVKsWP87OZsW8RfVONH2C+1QuJ28vgOeocwW3HHXjLK1e g/IVJpinGkwmwEsbuy2rPDebzz2YX9jB1+6Bkhi4hxYAF/rYqPBfCjckOT8MDkIx1SBZ Pja+Ibe588LBUuqevyUD/1lILMQjPqOll5i9p4as24gIvJ8Exvvazl+uombNOO2xjxnl dhww== X-Gm-Message-State: AOAM532H6p7CNE13EdWaG+NP2CQUx/aaNHfIrryV97gffOhiqVXSXNDc 456JtTbDA/3J57Wdl3APGpy9nM4+1YgGag== X-Received: by 2002:a7b:cc13:: with SMTP id f19mr1915548wmh.57.1642791025807; Fri, 21 Jan 2022 10:50:25 -0800 (PST) Received: from jupiter.lan ([77.125.69.23]) by smtp.gmail.com with ESMTPSA id i8sm10536479wry.45.2022.01.21.10.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jan 2022 10:50:25 -0800 (PST) From: Dan Aloni To: trondmy@kernel.org Cc: Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH] NFSD: trim reads past NFS_OFFSET_MAX Date: Fri, 21 Jan 2022 20:50:23 +0200 Message-Id: <20220121185023.260128-1-dan.aloni@vastdata.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: 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 at server side by trimming reads past NFS_OFFSET_MAX. Fixes: 8cfb9015280d ("NFS: Always provide aligned buffers to the RPC read layers") Signed-off-by: Dan Aloni --- fs/nfsd/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 738d564ca4ce..754f4e9ff4a2 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1046,6 +1046,10 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, __be32 err; trace_nfsd_read_start(rqstp, fhp, offset, *count); + + if (unlikely(offset + *count > NFS_OFFSET_MAX)) + *count = NFS_OFFSET_MAX - offset; + err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf); if (err) return err; -- 2.23.0