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=1796483349; b=46ZLoGvDXyKXXUFmYkOCHJ3UUQ5pcWfFzYZWGQ4K0djyHzcbd2eA+Vz/aJUj4M6rC4e5 bHxtYYNJf1VOL5skYUL/lVAplBrDs6FaAg1zJGEKl5I4Lb7CKaO/d3pz2hnuyN3hHTg6r XckodZ4pnHGSjUVFWTL9eZsV704cpdRtwYp62LyBOHeepDq1ygGUaf365e4WUnMqWL94T i2WE6WLXQkOsHP80d/natfNpnFFANxtnPMAyr7Ew5wykkk+xGuGySqACeeahiN1YX2dy3 5xrjMlAFEdVxByAy0YPvQH3Z6g8cTV1pZxrL9CDLhFYHl2mCn/0ZQT+NGmgQ8vubIhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796483349; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zQ9gpEaWNl7hS+g8DqK0WGRWZK5nhCTDMDqe+JPSPfM=; b=ForQ96TLhDAbFVbRdu2PSf+JNOJNQxA0T/QDVyiO7Vy2zYnKAD79BlG9V3+5/LO/XzLd 6gtNbGK1K4vJGyPH57Jbi4OulQI07soCMX0VNgo1TLaUDw/97RU5ToqhUDg3kEvvP0jQr TkOQdZF877xPxs7JFmxCMXnp+uhig7j+/eYFxcuvkAqOk2iAVHFSRh2uRMp3Afd8IwVKN RAFP58470/bHXE1IE6nE+xbxNXpMz3pPBcizbklnlzuF354Wp/RyePYFEXmeoeU/e6Cuy U0LkN2smQEluQczM0P5t6UtgoZtY12JzNyla/983xqJuy5XCg8ve0ME2riciECdbXQg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EVAcLJkz; 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 EB670606A322 for ; Sat, 5 Dec 2026 15:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EVAcLJkz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 668C71F0092B; Sat, 5 Dec 2026 15:09:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796483348; bh=zQ9gpEaWNl7hS+g8DqK0WGRWZK5nhCTDMDqe+JPSPfM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=EVAcLJkzBmsdv2K+J5i2yCQVknzTQTtjKx2IG4tq1Hrh2EKpr3SaRmoj/hulYYvgB 3W26ucFHZsTeP5sJplz8pVIJkSR66EFopco86qicLm5zsVZ1br9ORV+zs/fQxuScmf ZnR+GaEWfyZ4V+736QnsXXhvN/LuAxGjPcyojqMNShUcspFkxy8SsNDKK9+RVYHjmH bejY/rq84EXF0ILw3b0jN7KVMHvdUjUeFB9psFlwodu9jYf92HRlE7BQPD5Rt3z+Yd JS7xjrlxGrwuRp/ed4iMA7r+C95smazIu6/CCD+wVNJwPXc8f3NYg4G0uuJdq3ZA5i Um8xuAsQ050aA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries() Reply-To: sashiko-reviews@lists.linux.dev To: "Yuansheng Yang" <0xbeac@gmail.com> Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261205145247.1712139-1-0xbeac@gmail.com> References: <20261205145247.1712139-1-0xbeac@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 15:09:08 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > In irdma_setup_push_mmap_entries(), iwqp->push_wqe_mmap_entry is stored > upon the first irdma_user_mmap_entry_insert(). If the second > irdma_user_mmap_entry_insert() for iwqp->push_db_mmap_entry fails, > irdma_setup_push_mmap_entries() calls > rdma_user_mmap_entry_remove(iwqp->push_wqe_mmap_entry) -- dropping the > sole kref and freeing the entry -- and returns -ENOMEM without resetting > iwqp->push_wqe_mmap_entry to NULL. >=20 > Crucially, both irdma_modify_qp_roce() and irdma_modify_qp() ignore the > error returned by irdma_setup_push_mmap_entries(). Consequently, either > an immediate ib_respond_udata() failure or a later _irdma_destroy_qp() > after an otherwise successful modify_qp calls > irdma_remove_push_mmap_entries(iwqp) and passes the freed entry to > rdma_user_mmap_entry_remove() a second time, triggering a use-after-free: >=20 > BUG: KASAN: slab-use-after-free in rdma_user_mmap_entry_remove > Call Trace: > rdma_user_mmap_entry_remove > _irdma_destroy_qp > irdma_destroy_qp >=20 > Clear iwqp->push_wqe_mmap_entry to NULL after removing it in > irdma_setup_push_mmap_entries() so subsequent cleanup via > irdma_remove_push_mmap_entries() does not touch the freed entry. >=20 > Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs") > Cc: stable@vger.kernel.org > Signed-off-by: Yuansheng Yang <0xbeac@gmail.com> Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205145247.1712= 139-1-0xbeac@gmail.com?part=3D1