From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F49D494A1E for ; Fri, 21 Aug 2026 16:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787328579; cv=none; b=OLU/d9TV9s7HIOth0Oz+Jz8J4EGbYbxKhtMbfaUjOGNgX2fY3eyX0QK6MjtUkErQWzYcWIeHkLH0Gb+jaT27nqwwJXZD74D+bnzSmCfrxeEkxF+ZMra0KriqEL2+SRYTs4E3G53ySlHNIIIfn5vsQQ80vFwYtD/JLRNo9VeG2Xc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787328579; c=relaxed/simple; bh=UpDuxlJNu+C9IkOy+Gt+iaLqq6SZXac+CbmQAoxtTrk=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=Ax/xES2W5ezjy1tmwENMt5GP63Pvd6UC3ZyOrmHueBguGc3tF+gcMJ5PuPWylq4me+OPZ+3iw4NXsMhxEhbsp8jh5LkpBYEfIxaLdxA5EKVQ4dfYtUfJbOIhCLWtTwW1XpHoA1D24MA0em/9KPTIBeosjfTB2N24chavqLUMQNY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BdnDYJgQ; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BdnDYJgQ" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-92e5c9211d2so94345085a.1 for ; Fri, 21 Aug 2026 09:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787328576; x=1787933376; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=o7FBvi8r0lJa+XUCKtNl5RFOXcEBtuei0j+nR1rFbw0=; b=BdnDYJgQWJymDeNZhYcI7ONBihfvwhwpUtw1L7dVgSPWFz1re4ua/z0yTezAcwGBcZ hqlpSo5FHRm9GoAEezsylZ0+XiyL/2Jg1Py6UU2R8kZIED+FaL6xX+A4UpSDosKMx3+5 ncvZzC2BKPsRr6X2Yk16NeHe4KnJX0vNdHRg1Lxc0UmHTbhW6ddu6Jx+DBExO5hq669x qk2Jrakpma/TmnnH6fEZ5ZoOxjr374LIOCix6BVfRC6yaz89Pj51w7PsVViQei3bO91r IyeFFfl3h+VC8RHY95xqFJ/5jt2KI89Ld4/d4pfsiXPNHVQv8v9AdXoynfC/Z1eASJc1 qnJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787328576; x=1787933376; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=o7FBvi8r0lJa+XUCKtNl5RFOXcEBtuei0j+nR1rFbw0=; b=W0u5Al178qynOmYRaBgCzqvkB2op1Q1IROIYwEb+qLjQU8LkZvt7hqo47nJPr5ysMh Xaxw7bPCw65A14MYQq/kc0P6SuooIKnqBUBx9ISJHOjkXBVCPyMrTFZS8ukwF37qypQO /Itra7IAfJzkfgMn+1nP27cEQeioVuHfkPLGTyFga3hWc5Xe/4beFvbY6/rc0cdpI7JZ 2rd7irR7aJ+ihlaVCG4as+qSIKdukQiRYn4q2GYWMqz/yrca212xK2nQ3j3W6GRKsvxh cslQJ2QPcF0Ncoqs5fO1/QI+tX681YDMkKPBhZ+qHepD36bjMh81L31O9SHiCPP8HRWZ eQfA== X-Forwarded-Encrypted: i=1; AHgh+RotvpTdYHndwni9yVwiJ0IIOA265H60IRA9qWckBk3Z5ZtffJ3/SeMRIzmce3blgGOG2OxOKwsFnprsTRg=@vger.kernel.org X-Gm-Message-State: AOJu0YyUxvKe5dAqWnR0ob0gBZZ69a3lvgMrgnXhIMtuQlqgeW+ijvQs FdHADmNjSEtmxkZj5FLN0vllpd1ppb0aqTDboxrij08jV4qmv2vfYx9j X-Gm-Gg: AR+sD12VcKE3WYiuGFiio+lJyYrdKvPgX9e2OAhPVn5iK2eJucnfwELJsoEky7pfmoQ 9gXikZfs0QLP27Bz6FOgQgyB1jK4aJd7zan3lonaCMOqvuXadhbGC2NTaW/JI+XDeOExEVe4UtD 5E4zSylkvLpKBpT1o05D5D5DHoffduIpnTD9dXJ/XEobok10nwlbqOKJvnXrEPICvc6WGaaetKf 6v7nWm/FVmqVhCM8PVj+U//wl3QGsgEzi/2AMY4aeqfJorsm4jOJiy8H3qqgl5qYTTBAbRI7Q+M mxb3HK6PEz8tDdC7MjWc5LlHUmtQNOm5BbWMAOUMkzNoWAraQ5wByZKFwxNRNXolEML5TOdOPT2 ljNklGGzLBZwjqzDQz07Y34KKb+AriJjNNyzMLrBOX7HAGVn0h9Rn85vSZwhb/VKTh0rumdZ9z/ wGA8+/Y8Mm7Pzs8bc6TrUQOw2AbumZ6jcIReh4qQ6Ftw9fzpoRg6j+AfU2aIRZUZ+VqgCl5V60+ xbTsch5wNWnmkF6Fgd3UCX8Y3HiS8A= X-Received: by 2002:a05:620a:a2c8:10b0:930:f129:1a45 with SMTP id af79cd13be357-93739538e74mr518581085a.30.1787328575641; Fri, 21 Aug 2026 09:09:35 -0700 (PDT) Received: from smtpclient.apple ([2600:1016:b125:e2e1:fd95:4b9f:40d4:e99f]) by smtp.gmail.com with ESMTPSA id af79cd13be357-937205817f1sm626205385a.32.2026.08.21.09.09.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2026 09:09:35 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH] RDMA/siw: Fix CEP reference race in siw_accept() From: Shuangpeng In-Reply-To: <51ecec6f-1a88-44a5-a089-951c757f95f3@linux.dev> Date: Fri, 21 Aug 2026 12:09:03 -0400 Cc: jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20260816061353.4059242-1-shuangpeng.kernel@gmail.com> <51ecec6f-1a88-44a5-a089-951c757f95f3@linux.dev> To: Bernard Metzler X-Mailer: Apple Mail (2.3864.600.51.1.1) Hi Bernard, Thanks for your reply. After carefully rechecking the code path, I realized that I had overlooked synchronization mechanisms: the RDMA core serializes application QP destruction with iw_cm_accept(), while peer-side teardown is serialized by siw_cep_set_inuse() and siw_cep_set_free(). Therefore, the concurrent QP-destroy path described in this follow-up patch is not reachable in the current implementation. Please disregard my follow-up patch. I apologize for the confusion. Thanks again for pointing this out. Best regards, Shuangpeng > On Aug 21, 2026, at 11:34, Bernard Metzler = wrote: >=20 > On 16.08.2026 08:13, Shuangpeng Bai wrote: >> siw_accept() associates a CEP with the selected QP while holding >> qp->state_lock. If the transition to RTS fails, the error path = releases >> the lock before detaching that association. >> The cleanup drops the QP association reference before clearing = qp->cep. >> A concurrent QP destroy can acquire qp->state_lock in between, = observe >> the stale pointer, and drop the same association reference again. = This >> can free the CEP before siw_accept() releases its remaining = reference, >> causing a use-after-free. >=20 > Do we have a stack trace for that use-after-free?> >> Serialize the error-side detachment with qp->state_lock and clear = qp->cep >> before dropping the association reference. This ensures that either = the >> accept cleanup or QP teardown removes the association, but not both. >> This is a follow-up to commit a93949718259 ("RDMA/siw: Fix >> use-after-free in siw_accept()") and addresses a separate race in the >> same error path. >> Fixes: 6c52fdc244b5 ("rdma/siw: connection management") >> Link: = https://patch.msgid.link/20260801213632.1086548-1-shuangpeng.kernel@gmail.= com >> Cc: stable@vger.kernel.org >> Signed-off-by: Shuangpeng Bai >> --- >> drivers/infiniband/sw/siw/siw_cm.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> diff --git a/drivers/infiniband/sw/siw/siw_cm.c = b/drivers/infiniband/sw/siw/siw_cm.c >> index 0245b25e7271..da1b953f3fa3 100644 >> --- a/drivers/infiniband/sw/siw/siw_cm.c >> +++ b/drivers/infiniband/sw/siw/siw_cm.c >> @@ -1751,11 +1751,13 @@ int siw_accept(struct iw_cm_id *id, struct = iw_cm_conn_param *params) >> cep->state =3D SIW_EPSTATE_CLOSED; >> siw_free_cm_id(cep); >=20 > What can destroy the QP at this point? > An appication QP destroy shall be serialized with this > accept call by the RDMA core. >=20 > A concurrent connection drop by peer side would affect > QP state, but is serialized at the cep using > siw_cep_set_inuse()/_free() I don't see other cases > which are not serialized...? >> + down_write(&qp->state_lock); >=20 >> if (qp->cep =3D=3D cep) { >> - siw_cep_put(cep); >> qp->cep =3D NULL; >> + siw_cep_put(cep); >> } >> cep->qp =3D NULL; >> + up_write(&qp->state_lock); >> siw_qp_put(qp); >> free_cep: >> siw_cep_set_free_and_put(cep); >> base-commit: a9394971825933074032794a5feee5211509c774 >=20