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=1796382553; b=clizrCzVpJ3wfERTM7Srj2ywyTq6680qwHURKiwaIRF4wvYlBV9861Vql92VDFZXupcQ HtQvQWNEgoMebogqz3tHjPBZo98/MtRho4qt4e4PS4YoHrzBRGHAGgk6MxizTyJ2RqaHG ki/ug+27Y9vFqJUE/DEtDO73AVH7/dn2chGbNT538Wpv8fGeSKot0OekkFQVpalXsp7YB W8dMQsaoiI88ew4GuDlRPZfOVTeVkYZJhhiy2BtlcM4UwZbXTRd9lZTLronNWoJNPx6fJ M3pASRE1gawC/TkuP/5JJj5FodfbN+I+4+9oA8PP+Yh3RWDRkbGXieT1KB3+5RS/iAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382553; 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=16s8xXTA4yOUSAFcS3Nx1eiBlrOTNbIzfAPH41wCXgM=; b=LeQ9/w1s+rT2H9fkkNoZV/nxVt0jRK1yIUZepgIv6kIxg6P7D3aS6GyF9QAmIfGQFo6l AzuQ1On85Wh0a7I4qEfUg1iH8CaktJCV9W43wnesYohH1hPWTSKD9Gmfiv7U7vfpTNTi4 toY5x2th5XEFPqdxuVZSh6XN4VKeigTUeRlyiVeUFnk6FyP2W5hXuAdjCw4bbahP2GIlc Vh/+AZNH1vHdPw84pKHbSppCSUO7yOVrVJdTqqhHVxB+Z8NFqx3X233tn2Hr7bNE1pFUX lII1OyY/mvW1A3viF4AzXSd5ODyipYn62e+tNLEyQx2fJDQFK4QVY8YoVFMjVp7pyOg== 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=oYILiz+e; 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 539A0606A32D; Fri, 4 Dec 2026 11:09:13 +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=oYILiz+e Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0B121F000C2; Fri, 4 Dec 2026 11:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382553; bh=16s8xXTA4yOUSAFcS3Nx1eiBlrOTNbIzfAPH41wCXgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oYILiz+ev60tyikiR08Z/zH2d/ahDsuglsKg6AwKuPNRBOVqSyWfDz7x6qqvPX5Fu Z+QuwolCgOA9EUGVvFwYwQ46/YyYUfilkEXdAaFVc+OxdzXWzWbj+WvYg+HGTXg/bo 1p+WAbj/XrvG2gfFGejjA2PZZwEE5DGwyC1O3cXU= 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.18 504/703] RDMA/srpt: widen the indirect RDMA context counters Date: Fri, 4 Dec 2026 19:06:43 +0900 Message-ID: <20261204100641.208916747@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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]; };