From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 946D918C00E; Wed, 6 Nov 2024 12:28:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730896138; cv=none; b=g84uzGo4rH01M6/M5NyO+yXDggob/Hmh6+qXh/3E0edeMGCLgzimVXkLMGsPzfwSoDVcIDtMYTw2QpjAcqsaK9EeT02rmeTvtTauq7+q4orp3nGY++8KzC18KQK30SdRkwjIv1UcpkPSNpVRG+QXtcvufRoXiizJph2jaHvRXgo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730896138; c=relaxed/simple; bh=tMRnWglhvRkuWySe2zFEGqBqftBIRiLEnqbHdQgDfO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SDZaNAhf5BwKnPx51WqLW/Q8OwjKQ8Duf2SCsPTBfIyLrg1fLfkS6bGjYD+PgxiDRagXSaR+8PE+vBld507qE2j3vmdJnKH+VT7+2qJpSxWhqcsExKR7B8173UMVWhx5vsapR0yNGSWe+rJ5NBqppe0wHqCSoXUMlriyHIFnHoo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iVV/jlFF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="iVV/jlFF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CF39C4CECD; Wed, 6 Nov 2024 12:28:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730896138; bh=tMRnWglhvRkuWySe2zFEGqBqftBIRiLEnqbHdQgDfO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iVV/jlFFlpisozSd2G8QztoTXfNm4NXrw6vwDb0L3kbYTJXSHX7xbgAfVHGO3RR2A OLsqv2u15P1B43FzIDrLgiZ39ta+7Rkr4PMlKb7HC19Tveh9yHV1ervJ2uCLKpYgDR XEWPrbjR9iViGDCc7H9jciKtwATzT0Kkbbk3dkDo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Olga Kornievskaia , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 6.11 102/245] NFSD: Initialize struct nfsd4_copy earlier Date: Wed, 6 Nov 2024 13:02:35 +0100 Message-ID: <20241106120321.725587229@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120319.234238499@linuxfoundation.org> References: <20241106120319.234238499@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever [ Upstream commit 63fab04cbd0f96191b6e5beedc3b643b01c15889 ] Ensure the refcount and async_copies fields are initialized early. cleanup_async_copy() will reference these fields if an error occurs in nfsd4_copy(). If they are not correctly initialized, at the very least, a refcount underflow occurs. Reported-by: Olga Kornievskaia Fixes: aadc3bbea163 ("NFSD: Limit the number of concurrent async COPY operations") Reviewed-by: Jeff Layton Tested-by: Olga Kornievskaia Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 5768b2ff1d1d1..81a1e3bf06b97 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1838,14 +1838,14 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (!async_copy) goto out_err; async_copy->cp_nn = nn; + INIT_LIST_HEAD(&async_copy->copies); + refcount_set(&async_copy->refcount, 1); /* Arbitrary cap on number of pending async copy operations */ if (atomic_inc_return(&nn->pending_async_copies) > (int)rqstp->rq_pool->sp_nrthreads) { atomic_dec(&nn->pending_async_copies); goto out_err; } - INIT_LIST_HEAD(&async_copy->copies); - refcount_set(&async_copy->refcount, 1); async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL); if (!async_copy->cp_src) goto out_err; -- 2.43.0