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=1796389387; b=grYDv4/UweJkCeuXD6sVV0/hu9BXoHZJiBlmTQdjXV75prHCY8FU8RdXSyP1e2PMAQ35 VWN+D+3MlMOf6AT16ClHanxvBLth9sDoZBQkYLEaRmH0xN0is1nlqYTa2Oz/IwBOd8DiV mlUtgLMbOyNYyrH9Z7AavV62BH36b/b/ZiZVjfkPXkti2zL3/g0QJJDQpEmzskYEzh8d2 AAX4L40ASHZb5dv/mV9TzBDd5tArnodO/VtDBdjVXXgsSeTybbtUZc10xEG3vgvHqhqn5 OD8cpRENInBNLe7ANI7vr0pFDHw23vkRodnPJFF1bLheyBK7JHwM+wUawVjQoAxSBlg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389387; 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=QHwLWVswx8JxfrfUMC/U1GBN0LEtUkgM1ORzWlasboM=; b=tUUrJJDjww5orz9EduKKhUNCYLSw9txRQKtmwiSicKgvkjIxUicFkIKL2X0pfHh+OdVA i9Vxb7qDg99kOkkYZWbBVx1tfdAiKKuVnSLdB6adMd9E+iL0lT1gffZu3jSbvmDweeJUW UByoRkaKw0C6LLGGcu7sRfHDDu4B/ZGwS31Lpo23n47YN7d+mLVkCYzcaSms1lOOSXcNV 1IwHBwcSTZ8piCfdJKM3tuwmbCTw0whObhm+wdYkUU30VT8/N4Rsr9J6BTarmJNCCX6NL XUikwtHKFZhN0b0AzWXiTvSy5Wl6nd6WRcLmveJRq38esKQMl+b4JpJ4XegbabllCFw== 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=0frgzA2u; 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 2E6C7606A322; Fri, 4 Dec 2026 13:03:07 +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=0frgzA2u Received: by smtp.kernel.org (Postfix) with ESMTPSA id 270CB1F000CE; Fri, 4 Dec 2026 13:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389386; bh=QHwLWVswx8JxfrfUMC/U1GBN0LEtUkgM1ORzWlasboM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0frgzA2uZ/4vqD2EFKdCga99tmAQADf0vTy1RW8Rf8LF9ugt7daxtZkKvvg1pmRfj MectE1h/V0SXqw89GcVyJ3NFijM9+K6e730U/mAjGKNlGNpBolRMX6mbue0aybVJcF h8T30RceQhc3LmJ7pwgGL7x++vCzBTjgkBZDVtZA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Deep Shah , Leon Romanovsky Subject: [PATCH 6.1 0971/1059] RDMA/siw: Fix use-after-free in siw_mem_id2obj() Date: Fri, 4 Dec 2026 19:08:22 +0900 Message-ID: <20261204100709.166038813@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: 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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Deep Shah commit a70672b9b3ac7d8945f67cd199c1bb680d5d5f64 upstream. siw_mem_id2obj() finds a siw_mem with xa_load() under rcu_read_lock() and then takes a reference with kref_get_unless_zero(). This is only safe if the object stays allocated until RCU readers are done with it. siw_free_mem() frees it with kfree() as soon as the last reference is dropped, so a lookup that races with the final put reads freed memory. This happens when an MR is deregistered while an incoming RDMA WRITE looks up its STag: BUG: KASAN: slab-use-after-free in siw_mem_id2obj+0xe5/0x310 Read of size 4 at addr ff110001042aed88 by task repro-rcu2/90 Call Trace: siw_mem_id2obj+0xe5/0x310 siw_proc_write+0x282/0x430 siw_tcp_rx_data+0x12e/0xbf0 __tcp_read_sock+0x12c/0x440 siw_qp_llp_data_ready+0x147/0x260 Allocated by task 89: siw_mr_add_mem+0xb2/0x2a0 siw_reg_user_mr+0x19f/0x380 ib_uverbs_reg_mr+0x2a7/0x4c0 Freed by task 89: kfree+0x301/0x530 siw_dereg_mr+0x31/0x50 ib_dereg_mr_user+0xb9/0x200 Free siw_mem with kfree_rcu(). A lookup that loses the race then sees a zero refcount and fails. The umem or PBL is still released at the last put, since a failed lookup never touches it. Fixes: 2251334dcac9 ("rdma/siw: application buffer management") Cc: stable@vger.kernel.org Signed-off-by: Deep Shah Link: https://patch.msgid.link/20261102064437.23976-1-deepshah146@gmail.com Signed-off-by: Leon Romanovsky Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/siw/siw.h | 1 + drivers/infiniband/sw/siw/siw_mem.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -160,6 +160,7 @@ struct siw_mem { void *mem_obj; }; struct ib_pd *pd; + struct rcu_head rcu; }; struct siw_mr { --- a/drivers/infiniband/sw/siw/siw_mem.c +++ b/drivers/infiniband/sw/siw/siw_mem.c @@ -149,7 +149,7 @@ void siw_free_mem(struct kref *ref) else kfree(mem->pbl); } - kfree(mem); + kfree_rcu(mem, rcu); } /*