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=1796381125; b=SUZ/33mUqrtH0lIhGqgf1xURCW6NUlBY1Uj1XnAITYlr8qVBNzG20XgPnHdCiYEO3Rj9 f/CSg4m1gPycCU7evbXVfm/DyoKqLveAxRg4rRBKX1BHfMAo8NKO5FoKaQ+Xk5QKclA2w aiNUs57SaDyAPX7gPAAhoHiGBSXRaOb1tZCFcYlXRSl+aNfoWpcuWNYiEM9EjSrpRhxqI AuQMexxIa5vFh2Tnpw8PXWcSLIN7f+BWee0V/wbD2oGFYI6dp7T+lVxYXA377a3O+Efc7 /OyDM0u3PT0LMn4roOLD8tV7aLFgdjRDFpUuP8G9vS+03Y9VHHW/+gGPkCm8H98yPXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381125; 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=CwGIiTO92xPIGYayNdFYwzjmhzsgR5F3TJ+9hnrUcjA=; b=T50UfMFnB+x6WoWzM/ckjDwHgXuPlNzzhMpxEjiSubXOfQ/+Ccyu1Rny2c6UtVXySFax sAmZ3nGkJK0CY/BhpiMvWzEQ5kaY3d+jP8AJiDwsIaher4vATDaaSbyvyuvLRtg5cWLEJ UUpXIX69C2slLi9CkFSJV+8+a1+WTWX0dF8XY1oQ7ZODFVqLywI7Md8tSeDqFkmBIdZn7 3wvimUtFXPqa2IDD8K7Yrf4igROFix6vrSd4/uFJ5VrBT1LOJhODVgAHbGCSfm/o+Nton 0i0bBZgsZYeb31+wcTxHEaV2DRWx8dizh2xShI4eOlTpvzy84eAMEwSRydSNU9Ktiag== 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=yllyIG0t; 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 48621606A32D; Fri, 4 Dec 2026 10:45:25 +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=yllyIG0t Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B1D1F000CE; Fri, 4 Dec 2026 10:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381125; bh=CwGIiTO92xPIGYayNdFYwzjmhzsgR5F3TJ+9hnrUcjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yllyIG0tUhvZEIjtWVKZdJWk9JfoRic6rQvfVfz81bUrGpOH9du1q5qw4h4B4aHG+ LkhwvnQNGv4kcxGH/yD8iXHFo/DQbUeKof8PzZAAx+QXHOhDywz1Ab+Up+LgEjCPOJ lWBccGg0u9uDP4RGbgHv+gJNepb+3AQ3eNDoOn2c= 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 7.3 567/742] RDMA/srpt: widen the indirect RDMA context counters Date: Fri, 4 Dec 2026 19:07:11 +0900 Message-ID: <20261204100650.207127707@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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]; };