Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6004016pxb; Mon, 14 Feb 2022 12:55:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxriheDc5qdNsbiQWec77lGhY2TJg6ksO9VyJwWM9xElXR61P0uaSZsQOWR8eTMRwMTEFOT X-Received: by 2002:a65:4088:: with SMTP id t8mr700594pgp.241.1644872114332; Mon, 14 Feb 2022 12:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644872114; cv=none; d=google.com; s=arc-20160816; b=WnBFocOcpAO/F+FSZiBgUTF9CK/qKUGtjEEmFZXgFzsO7bHo1iZ3raEIeCyDVtER/m 9BfXTusqlQG9aUvsbyHoyRn8AzKE1jJKW6zmwdKsXijrT+Ceul7khwFjmvF0YHD/0pAP cISNkuM7ciqqI2+ewgbnJYhpqyFEasGTRPbjyuBtyULfYB8yEhVCksGOH8NeA3kk1rjk 092gcpii/MjGcvjEOQJT37hRg/53NJY7VluTeUwiMziU2T3980j1f/a6neD+L6ZG3z75 VgxbrLPxSV60v2p9GZqtA2h1t7X5egRKZ1ksvJNmyBDU8Fhqm4mE6RrVN2WQ8xNHroE4 ueCw== 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=MqtVPJiA6adMHTqayrDncLcAbQ/fTuwgjkiREXccldE=; b=fC1qtESi/Yc7A5VknPyqF7xbaT6pbo/IxQyUMg+vHcYNopTn2Mcm23Dx/W9l1jRiZf 0LfxHusYPqEM+hZgkicf4sjMPOlLjuPl1r6Yu1C2+KcnNZGNRorKi+Gc4+5cpCqbyDkd uSaVdm4/ZiL3X4ps46TznhQaXOhAUtjTQqewHf6Ij93m7oLU2PRhCmo1mW7UUbWCAmzb XmngJji5NJFGHTrGdmrirRTlhK9+/JUBY8AKAiieIecZVf0vav4e9gaJf2C04fUwaEey WOOHqJkkdKAue1OAfSnAz4CtXdl91yGeumNlkR4YtYYEpj6sUIWUPzRMZWh9oB4b0al6 zHfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x+fw2pH4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u6si7931422plf.40.2022.02.14.12.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:55:14 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x+fw2pH4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DAC765420; Mon, 14 Feb 2022 12:19:00 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231805AbiBNJuT (ORCPT + 99 others); Mon, 14 Feb 2022 04:50:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245224AbiBNJpv (ORCPT ); Mon, 14 Feb 2022 04:45:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F378C706DF; Mon, 14 Feb 2022 01:38:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 710EC61193; Mon, 14 Feb 2022 09:38:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F904C340F3; Mon, 14 Feb 2022 09:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831522; bh=JBPKQ49itj41uadUEPuSatkximwIDIrG7Qjp9HSeSXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x+fw2pH4yLAm6KOYAgb0y16uk99r8IxDWgy9meA0lAXnWYKDgS5QOsCj6N4rAGqy9 VS/hwaw8cmc8/5piJTs4tLo2Gpl9+cEOle53fdfHPC7l8V6j8c/DFWKozyxd4d9m10 OjSW3seKRI9ZTr/o23rpJrY+5fZoRBY1rzZDp9y8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever Subject: [PATCH 5.10 010/116] NFSD: Clamp WRITE offsets Date: Mon, 14 Feb 2022 10:25:09 +0100 Message-Id: <20220214092459.036735272@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuck Lever commit 6260d9a56ab352b54891ec66ab0eced57d55abc6 upstream. Ensure that a client cannot specify a WRITE range that falls in a byte range outside what the kernel's internal types (such as loff_t, which is signed) can represent. The kiocb iterators, invoked in nfsd_vfs_write(), should properly limit write operations to within the underlying file system's s_maxbytes. Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs3proc.c | 5 +++++ fs/nfsd/nfs4proc.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -183,6 +183,11 @@ nfsd3_proc_write(struct svc_rqst *rqstp) (unsigned long long) argp->offset, argp->stable? " stable" : ""); + resp->status = nfserr_fbig; + if (argp->offset > (u64)OFFSET_MAX || + argp->offset + argp->len > (u64)OFFSET_MAX) + return rpc_success; + fh_copy(&resp->fh, &argp->fh); resp->committed = argp->stable; nvecs = svc_fill_write_vector(rqstp, rqstp->rq_arg.pages, --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1008,8 +1008,9 @@ nfsd4_write(struct svc_rqst *rqstp, stru unsigned long cnt; int nvecs; - if (write->wr_offset >= OFFSET_MAX) - return nfserr_inval; + if (write->wr_offset > (u64)OFFSET_MAX || + write->wr_offset + write->wr_buflen > (u64)OFFSET_MAX) + return nfserr_fbig; cnt = write->wr_buflen; trace_nfsd_write_start(rqstp, &cstate->current_fh,