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 35EA0155C94; Mon, 18 Nov 2024 21:23:49 +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=1731965029; cv=none; b=nkcMTjYxxeV5yZWsYb9R88yGExGTHrEn7y3AXhcctPuKMf+3YlwkNZOZL2M4SmQ38zPwsLprE4iS4fwOnfFrxD7+p82rA4IV8ENNTsDAmGwTXxB0Sx/knZPB5P1ZrqEiQ2J/u2k3+hk7yk6dialrZKZfc+a4oE3ite2YrYk1V0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731965029; c=relaxed/simple; bh=L/5WbSn0Hcf4WWyoyklgYacsCyDIHh4RMBF1geAQ6hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cKC/oIzC2QtUygD2uLJnSQ7sLTdID9/nRXrCjh9C5EEmu43fkBut33GRORbH2vHI3UDOYA5uUgSmJdNPRkLimo77w5cDHvxMZG62fa5NNqHjj/xFPeseFDiWZC9Aq0zfIY4dC89igm59FAHR3gRAyl2jlGloF2aIfb8uBMo46IY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FFG9dEM8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FFG9dEM8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ECB8C4CEDB; Mon, 18 Nov 2024 21:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731965029; bh=L/5WbSn0Hcf4WWyoyklgYacsCyDIHh4RMBF1geAQ6hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFG9dEM8I5f5nL7aEdgzMEQzAHCJJtDvomGrLk2w8xdtQbfHVSx187l7gyKPnJmaW sZkbSmofYBv/pbGf+UKgiTiOZ5VOzkufCIjbhH0IR8uDoD/S3BMsgnwCniU8N+2wIK ReyAZ7N+aPRX03xxqPumuhxdWyFeJ8DuIKb6yxxgE3j+sZc8yQ0P7UKFA25OHnE+75 exHiMH7hiSvao/2rzvHBAy/Wv9wg37M9ldTl43gefo1xVSQ6rhOETl4/QoPqIFER6Z lm7fYCi8W0fid8guwyyUcn2+JXrTA202/AFewjvbNvzS5Ny+679NdVLMfgARaHZXus 86q8t1vLwIp+Q== From: cel@kernel.org To: Cc: , Jeff Layton , Chuck Lever , Olga Kornievskaia Subject: [PATCH 5.15 4/5] NFSD: Initialize struct nfsd4_copy earlier Date: Mon, 18 Nov 2024 16:23:42 -0500 Message-ID: <20241118212343.3935-5-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241118212343.3935-1-cel@kernel.org> References: <20241118212343.3935-1-cel@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 54f43501fed9..6267a41092ae 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1787,14 +1787,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.47.0 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 CC4911C4A30 for ; Tue, 19 Nov 2024 12:30:41 +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=1732019441; cv=none; b=JzjlwqbwDDigISOivHuOiiWhJT79J+IaE00WMkuRVCMXVZzuehP5TCjnFDOj4vmO+3n9deu/J6nSiMci5+YQzENVbvV0l0oOSUoYcMZsHJEO/RHI1dNRttRdwKL//gGiljHM8sIzD/5KFMaE5XUgtp+kQUb7fsIpUddsiQ6WBSk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732019441; c=relaxed/simple; bh=UpTdHFkMlsNP9BBZMzfzqzOAOMqx7QLyXjJVfWoxIXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YfVYMyWst0Gb7ZPrUPVsEPF7+jcVEWdoU+TGgPmmYzUAt8v/vmimgJ4o9IRnc7j0ikLAb5PgkHMSSsWCPaZmg551cRUOjxVcw7qJoZer1VV7u6UWOfmTP49P2eS5jWc8ZCNVsjqsWFHo5+t0MXNgqafB3IHvJAZkBJOyZJ/kjA0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bX+/4GNF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bX+/4GNF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E443FC4CECF; Tue, 19 Nov 2024 12:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732019441; bh=UpTdHFkMlsNP9BBZMzfzqzOAOMqx7QLyXjJVfWoxIXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bX+/4GNFMf3/+kqF6IeNJArDHAFsE0np0j8r1qZCGV8j6ZAFv0wk2FucTcYg8T4o3 WqiBLfPWKcKbNOcNaj5qOgNreT18lGUDFGgDeseV8qlo7LUgK8gyDvcbnrTbwcfk5F 4Unm/ybGNPl1XPPr14anf9txZ4jBSwDFNbqDZ4dy6Y9i/FaBFxoNXcmXesyFk+0vWI 8lf0elJh7fdUBSor2Cf1MaqKbpj8LITRdqUKMbSDGCZh7AuiH3MA/MJiha9DWe59DP mpfkPqlp3IcisX1MDTP3pDvodseIwCBToLk5YnHS++PSePiobp5rvCcjLtO/e2R9Ra XZGWZ9GYjddJg== From: Sasha Levin To: stable@vger.kernel.org Cc: cel@kernel.org, Sasha Levin Subject: Re: [PATCH 5.15 4/5] NFSD: Initialize struct nfsd4_copy earlier Date: Tue, 19 Nov 2024 07:30:39 -0500 Message-ID: <20241118212343.3935-5-cel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241118212343.3935-5-cel@kernel.org> References: Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: <20241119123039.5Ts-l4_LvE6DBbIPi9j29xh_dxJN38lrjxwy0OrU7tQ@z> [ Sasha's backport helper bot ] Hi, The upstream commit SHA1 provided is correct: 63fab04cbd0f96191b6e5beedc3b643b01c15889 WARNING: Author mismatch between patch and upstream commit: Backport author: cel@kernel.org Commit author: Chuck Lever Commit in newer trees: |-----------------|----------------------------------------------| | 6.11.y | Present (different SHA1: e30a9a2f69c3) | | 6.6.y | Not found | | 6.1.y | Not found | | 5.15.y | Not found | |-----------------|----------------------------------------------| Note: The patch differs from the upstream commit: --- --- - 2024-11-19 00:47:49.695764940 -0500 +++ /tmp/tmp.R4ErlJ20nR 2024-11-19 00:47:49.689051896 -0500 @@ -1,3 +1,5 @@ +[ 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 @@ -13,10 +15,10 @@ 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c -index b5a6bf4f459fb..5fd1ce3fc8fb7 100644 +index 54f43501fed9..6267a41092ae 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c -@@ -1841,14 +1841,14 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, +@@ -1787,14 +1787,14 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (!async_copy) goto out_err; async_copy->cp_nn = nn; @@ -33,3 +35,6 @@ async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL); if (!async_copy->cp_src) goto out_err; +-- +2.47.0 + --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-5.15.y | Success | Success |