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 AA8141E7C1A; Mon, 18 Nov 2024 21:14:19 +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=1731964459; cv=none; b=aKsoH8PIffnuDPMYXK+QDbQO/FSgB8onMogVJWxz13nHOOoL3OgripFR2qc6pcD7xAHzlRylmTWR6T1CJaadTgVlOf4NfDwvNW6qFJF6izt30DzmpJG5xqJmXTAuWTuCavfW2o0yD1usfzWC+csoa7AORSeHdO9mysDt20KBhSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731964459; c=relaxed/simple; bh=kudmYckbgBJUAUmnlP964NvQden0S9yrCfqiiDIoS9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tdh6M2QvJOWYSTm+qP2qR7V/d7UX0H5kwqIzBxtewv4Obno7gxjgHzvfoZ2aaDVc3wkUdUDRs8Ok/x0cp4XYMTpDdnATDRvFF7qt8ZtGtGRYbsHNBTaowlI1RjxBqT5p3zMl0Lv++9nweiBqYdrnBrYkH0Vamc9YDujrqqG8fAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LIFy81ov; 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="LIFy81ov" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9177C4CED9; Mon, 18 Nov 2024 21:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731964459; bh=kudmYckbgBJUAUmnlP964NvQden0S9yrCfqiiDIoS9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIFy81ovTS+9sC0ine8sg8oP5UmoFjHgdc0YbZ5Vq2fUDVtcGZY9Td+eV/2eAVUV8 seGTggAFZhoPVkwUghmBHxEXMOwVIKRXhcbr4zaZ3I9DRWmLFUkxyF3VAOA5XtIPxt /fAiN8nMSm08nggYMUkDxX1sF3caA11YJKAOltxuNHg9Wqugc/IhDj6Nr4rNsABFft eI0cYY8v+6ridDCOX9NdDqihI16mx8q9iUsF5PIZmQBfSk8f1YDfkKWR+cZxu0+nXL SAFlACF4eawgR3gxJnIOzwzI94b2/wp+5+Oo+mMKUnX2gqIJZEUEhE6U2o+HEuVQ9v 2PTQgvuXgXIjQ== From: cel@kernel.org To: Cc: , Jeff Layton , Chuck Lever , Olga Kornievskaia Subject: [PATCH 6.6 4/5] NFSD: Initialize struct nfsd4_copy earlier Date: Mon, 18 Nov 2024 16:14:12 -0500 Message-ID: <20241118211413.3756-5-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241118211413.3756-1-cel@kernel.org> References: <20241118211413.3756-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 e74462fb480f..444f68ade80c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1816,14 +1816,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 6172C1C4A30 for ; Tue, 19 Nov 2024 12:30:59 +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=1732019459; cv=none; b=ZuA7OoLFOH+rp1eyGk61+U67+VUKjf66gk3XEbdSryc/cwZAOyXv8mVUEQSMkmYjZTZlxUuteLzRcpwtmMIlFSECU1Ye3PaLi9a0Px0fz8bQGOk0z6Cg13g7gIwr1Kxt3A4EKif/pgbhHg+UJpfu+IY11x6pN8CVzlrKlIC2Jlw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732019459; c=relaxed/simple; bh=eyfiGpZpQXZ2fS0KlEvY5+rCGugv0+c6QD0Uv0zU4Ww=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cAAMFrQg6wKcv82ppgf5htYrQu2vIideG5NdDL2ky+z8GH1XsrgtBU7pyDhJMypIde5bjiBOIbgnAw+6Kclh25MDThhhvob3CkUL5zwa+6ZCoI2Hwjj/RPqcUqeXq4zzf5mgb7SQL8Xk+bLO9pTu2ImfkvC6cPEZKcT55v8PNCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rV4vDxX1; 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="rV4vDxX1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75F55C4CECF; Tue, 19 Nov 2024 12:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732019458; bh=eyfiGpZpQXZ2fS0KlEvY5+rCGugv0+c6QD0Uv0zU4Ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rV4vDxX10U6URz3SYC0CKlzRpmfA4PpNIVbyJNYzEDxiJ3YMF6VSH2rFYiQXzejmU L7t7wXaOgRkBxblf6sz1rcTpDz7T0aJxSIMCp6dRQvRAE6+LEH879oyNMYtT6qoC41 E9h+9UKsr895YIOE9Xt3NhZ1lGCWfNwZ5pJPySyHFRUeNg4BsEHcYlJZK3x9WOJjeZ BQ+BH2YVUvqbo/YDY3qIAFZQ3RJ5d5p/lzl6qCJOqVHvMU14bhhWe4Vnh9JAecnZ4c vukva2j7jf+85VVYkRHNAjkTY7+0Efl6OPagubUzyhCKDm0OUrG6i+Ynrk2m4qddH5 rTIEXkiAWIwjw== From: Sasha Levin To: stable@vger.kernel.org Cc: cel@kernel.org, Sasha Levin Subject: Re: [PATCH 6.6 4/5] NFSD: Initialize struct nfsd4_copy earlier Date: Tue, 19 Nov 2024 07:30:57 -0500 Message-ID: <20241118211413.3756-5-cel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241118211413.3756-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: <20241119123057.Vg_4ZRYKWp2BYGeTsFiOW21GBb7zOkIVHlf8B4Jv_Kk@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 | |-----------------|----------------------------------------------| Note: The patch differs from the upstream commit: --- --- - 2024-11-18 23:54:29.489312431 -0500 +++ /tmp/tmp.oVuvgY7enX 2024-11-18 23:54:29.481985187 -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 e74462fb480f..444f68ade80c 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, +@@ -1816,14 +1816,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-6.6.y | Success | Success |