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=1796389410; b=DxXg90rUpaFuzRuWRV7DDNithPdDD1pMdwN2MOVAWmkcDxRX3fGbAaoXUeUzIXxq5Q3O FVhTtPDpoQl/ShBILiQzbPEqh0hxfs6qbpJg8uO8gADXsZXmCG/OYoE81nkjV/WrYgprK eWUQwIqDvYFU0DHpLg08XJ75f9IsNiDhKyUqGOXk9mUIipmporVKsSxGo5WSjoqVOaWxI T57Ju/SyF+EuUFkEEBkqD6eEOQvkf4RJcW48wR1HF7CPJVDKyk+jn2cSzOzyCXOf1NN6c SNVt67cJ1HBMcZxrQrA14DbMXYuvnfcSiK8kc37C0hz8xdcOwA/pIfPEnfB2CJnFAWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389410; 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=hru1UhaPcP8iYaovTcmgKTX7R9xokrZsBHBYJ4cwApw=; b=48TsrhJk96wNlnZUyspnz8kvWoNqqCPuEl9/Tdwl1zk8/qiyPHBJryrxbsmfbRWqE5eT MXNCXHH8tj9iBvWIbXC1+Lu392WV0kKFZVUjtJl7IGX0N3nuR4x60eYgVorMob7gHPO6g m2ZjgRS+hQeSvfwkXiCDToEKYUO4vxGxL8QSk8QYKA3i06nb04BdCv7ghM4VoNHOpJaUV ErwLLMUsqN2a+6G3eoU5WVoZsMvIJP4UINTflrMYVzxUnQV13rvYcQDf4NunxaBmcrzId hL3lC8rdlctgiOErfv4nysRE3SUKmJJNZ+1efZv2lO7P1OelOI+5dSpYhg5gXnY9dIw== 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=teJHV8jI; 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 718DD606A322; Fri, 4 Dec 2026 13:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=teJHV8jI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6377D1F00A07; Fri, 4 Dec 2026 13:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389409; bh=hru1UhaPcP8iYaovTcmgKTX7R9xokrZsBHBYJ4cwApw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=teJHV8jIu7iBWit8YlZsIAv6XHXyN5d0WDKVzrKhOCoW0XyIDZEfDJ+lVGuJnCjOC TIRCypYzNNAC3rFvXbu4NMvozeHWFLwQdC+28qulG1ghlpz3FEHUrZ5ktWcyCgJSK0 Txo/6J1B5SrWIiR3MJjt34G8h28TZlGG++FuxHZE= 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.1 0974/1059] RDMA/srpt: widen the indirect RDMA context counters Date: Fri, 4 Dec 2026 19:08:25 +0900 Message-ID: <20261204100709.239962964@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-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]; };