From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383943; b=jJFt9LX0Q1iEt4FtkrfuNfIPbqNOjIcAy2GaX72GeH/ZxwKXZ33Wr2YKZRv+rstdAw0N ydeKV/nEL2eftzbCwy0aZEEY1/7RPApUM+Ayb1S3hFF1/aUy9TI2uPZgw4eX/U6VBioe5 PbFJ4pfo0faobLsioMdpQ4ylR8yC5u/bZNhg5GlGpNBNV0sEPLjt/yfaJt03A0AmgTvfx gJnuBh67h1bYqmKCImJqOP2lc7TKaPqh0MJQxuypTXqO41Al68eBdLgg8hndrU23kH7PG +6WXh6sU5Jn57rxVFZMnjMUgDsQbGqYdBf4/FhLTK7gkhpr4lEn6ryxHDejNXtLEatQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383943; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=J02FfnECX052Z9XksO1XdAfJEQ1QDTF6KtjesnTYH8s=; b=R3d9Gv3Soa8ROSf620nqo/AFApoAw25TR+TFACCrljTZ46KefYfsI0XtU9kjGzi2557l GF0nN+yKaIs+nXkFZbsPGQrN3U/+Hm+KFPWdzF+r9u3IwkCpaRIP9ltkqEw/MR8A8rjGi ZGL7v85MXAfMUhV3atp4RaYS5yLm3biEIghXjVG5r9+Zh3EexJY/cr6DxvF9Pq/7XDVtb gLlqS9WXlzpP8IenlYrLCnSZkWZ1MR7SaZcv1QeUK+wQMYeZgqzMk97kNTcm8dV/2Oy/m oY8Nq2v5pIDaFNEbM/6leGAPevuuC8LPd/79wWv9QunUsyW1adXWuxKyU6MHqPttV7Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yeMEboVr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8B4F606A32C; Fri, 4 Dec 2026 11:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yeMEboVr Received: by smtp.kernel.org (Postfix) with ESMTPSA id A68781F00931; Fri, 4 Dec 2026 11:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383942; bh=J02FfnECX052Z9XksO1XdAfJEQ1QDTF6KtjesnTYH8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yeMEboVr13P7yBeoDyap4v3+TIv1XymeTAJyLqi0Tgi9Il5K982vhqr0BtqnS5X5p KIxonErngX4GmmyqQ8AFQnyegBv8ID9TOulOg1HJVPiV88bC8FFjOKgISrmaxKyR+1 E3iamkYr1IqnDg+fE5Lc7yMjIvaQgfX6x63Iq0FY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bart Van Assche , Yehyeong Lee , Leon Romanovsky Subject: [PATCH 6.12 432/555] RDMA/srpt: widen the indirect RDMA context counters Date: Fri, 4 Dec 2026 19:07:55 +0900 Message-ID: <20261204100626.076931807@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yehyeong Lee commit 013eb66a8ef25ef531bf41d79815948ab4938571 upstream. srpt_send_ioctx::n_rdma and ::n_rw_ctx are u8, and neither of the values stored in them is bounded by 255. n_rw_ctx counts the INDIRECT descriptors a command carries, and the count guard in srpt_get_desc_tbl() admits data_out_desc_cnt plus data_in_desc_cnt, so up to 510. At 256 descriptors n_rw_ctx wraps to zero, and srpt_release_cmd() frees the contexts only when it is non-zero, so every scatterlist and RDMA context the command allocated leaks. n_rdma is not a descriptor count at all. It is the sum of the rdma_rw_ctx_init() return values, which is the number of work requests each context needs, accumulated by ioctx->n_rdma += ret. A handful of descriptors for large transfers can pass 255 on their own, with no unusual descriptor count involved. A wrapped n_rdma is then handed to atomic_sub_return(ioctx->n_rdma, &ch->sq_wr_avail) and tested by WARN_ON(ioctx->n_rdma <= 0), so the send queue work request accounting drifts too. Make both counters int, the type the values they accumulate already have. Fixes: b99f8e4d7bcd ("IB/srpt: convert to the generic RDMA READ/WRITE API") Cc: stable@vger.kernel.org Reviewed-by: Bart Van Assche Signed-off-by: Yehyeong Lee Link: https://patch.msgid.link/20261025013748.3755639-4-yhlee@isslab.korea.ac.kr Signed-off-by: Leon Romanovsky Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +- drivers/infiniband/ulp/srpt/ib_srpt.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -959,7 +959,7 @@ static int srpt_alloc_rw_ctxs(struct srp struct srpt_rdma_ch *ch = ioctx->ch; struct scatterlist *prev = NULL; unsigned prev_nents; - u8 n_rdma, n_rw_ctx; + int n_rdma, n_rw_ctx; int ret, i; if (nbufs == 1) { --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -223,8 +223,8 @@ struct srpt_send_ioctx { struct ib_cqe rdma_cqe; enum srpt_command_state state; struct se_cmd cmd; - u8 n_rdma; - u8 n_rw_ctx; + int n_rdma; + int n_rw_ctx; bool queue_status_only; u8 sense_data[TRANSPORT_SENSE_BUFFER]; };