Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FB26377A9F; Sat, 12 Sep 2026 16:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789231862; cv=none; b=nXjh9aoznDj/RZtN0xTlmMGQIx8wvU+aKQQmqz3IUEGwdcZL4XlsT0+QhqKdGq/2Hk4iLCsVLpWHopp7RMIO2mi0+9njPd3GKdo8HMF8Zey1BI8eJIO5G1MTCMAsdd5HptR/2qyuzTS6Fwnenr+ItC5fPSG4gLvFPIDPY54KlDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789231862; c=relaxed/simple; bh=8cGPBXhdBSm/StwyTs7DMKBQDqcQB60awPbi2It9a4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bt37BsLlvgCPUxLdGDrXIZjhX9mt/W3KOuHFWYG4jg0V3SAqs2py5dJEB72Tt9XWKaiCqnbXqj4JzOEVtBQ2NKTDW01z3So15e/U7+oqB/ZjkII+2M4F5X+5VQHJTSurHDWdAJbUPr9Us5WNmvPfvUZJjrlSJrWZr4HNpRm1/3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Mj7MejZ6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Mj7MejZ6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 096F61F000FF; Sat, 12 Sep 2026 16:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789231861; bh=Nkm0bKW3Pf+tTBh0V1Ov7pkLpiX4grKlkqvORE4vXhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Mj7MejZ6jupoK1OpgL1/UvprqfejsmF50SXqVTbFt7BbdrM35sB2srRdAwb9tNtcC 3Pzw1uKyFnftI5CEe7ABpSLnwMu0/YKNR2luWsSBTCRSHj7JofTK5XXlEMC+XzVQVt kc84EL/6ARVBWkgxavs278Vy7qHHi9WfXNw63Iu0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hidayath Khan , Mahanta Jambigi , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 1085/1191] net/smc: free stashed qentry before overwrite in REQ_ADD_LINK to ADD_LINK transition Date: Sat, 12 Sep 2026 09:03:33 +0200 Message-ID: <20260912065612.533621861@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mahanta Jambigi [ Upstream commit 036322025d6e440cb75fc6fecbba9a16b271a2ae ] When smc_llc_event_handler() transitions the local LLC flow from SMC_LLC_FLOW_REQ_ADD_LINK to SMC_LLC_FLOW_ADD_LINK on arrival of an ADD_LINK request, it calls smc_llc_flow_qentry_set() unconditionally: if (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_REQ_ADD_LINK) { lgr->llc_flow_lcl.type = SMC_LLC_FLOW_ADD_LINK; smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, qentry); ... } A CONFIRM_LINK or ADD_LINK_CONT arriving while flow->type is SMC_LLC_FLOW_REQ_ADD_LINK is stashed into flow->qentry via the SMC_LLC_CONFIRM_LINK / SMC_LLC_ADD_LINK_CONT handler (which stores into flow->qentry for any non-NONE flow type). When the subsequent ADD_LINK arrives, the REQ_ADD_LINK branch overwrites flow->qentry with the new pointer without first freeing the stashed allocation, leaking one kmalloc object. The stashed entry has no consumer: smc_llc_wait() is only called from llc_add_link_work, which is not yet scheduled while the flow type remains REQ_ADD_LINK. No waiter is sleeping on llc_msg_waiter at this point. It is safe to unconditionally free any stashed qentry before the overwrite. Call smc_llc_flow_qentry_del() before smc_llc_flow_qentry_set() in the REQ_ADD_LINK branch. smc_llc_flow_qentry_del() already checks flow->qentry before freeing, so the normal path where no entry is stashed is a no-op. Fixes: b4ba4652b3f8 ("net/smc: extend LLC layer for SMC-Rv2") Reviewed-by: Hidayath Khan Signed-off-by: Mahanta Jambigi Link: https://patch.msgid.link/20260818073107.466506-1-mjambigi@linux.ibm.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/smc/smc_llc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c index 761515b590f20..ec2e60b091f30 100644 --- a/net/smc/smc_llc.c +++ b/net/smc/smc_llc.c @@ -1885,6 +1885,8 @@ static void smc_llc_event_handler(struct smc_llc_qentry *qentry) if (lgr->llc_flow_lcl.type == SMC_LLC_FLOW_REQ_ADD_LINK) { /* server started add_link processing */ + /* free any qentry stashed in REQ_ADD_LINK state */ + smc_llc_flow_qentry_del(&lgr->llc_flow_lcl); lgr->llc_flow_lcl.type = SMC_LLC_FLOW_ADD_LINK; smc_llc_flow_qentry_set(&lgr->llc_flow_lcl, qentry); -- 2.53.0