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 B7E1029B78F; Sat, 12 Sep 2026 13:16:16 +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=1789218977; cv=none; b=RYZcyYDSwJNL5jf8iaUVVEAt6vAZ+sj0KmVPo9bQcYnw12Sh6dwdrh4ZpRptAT17YZyEwdEShG3gLCB7Fgnikt15o5kYvNnCGQ6dD7uF8YwTYR7gm7UKc6ZgVmAkz3+OHovdfoku3t6/JEi9Z+Br+tsWZyxe/ZwDAX2x4CVdo00= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789218977; c=relaxed/simple; bh=4vFAHUrXKjIoAcrIP+hThaKDBiQTa+LJz0hI0gQ48m8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iUNcaTzeUcpiizunIhPNCgfIFBQdVxsVHU5dgCW3Rl7CIK1n1GViEYtHBAEgFwUofxuQeoYGZc55zU00DVMGQyjdC388MgJb1jKhhhYqtwYzKGdqlm+SCf7sWB4XZzZ++siu7LTGlr4gxF+X/ahS/0zTLB+ijAm+VnOCUWGksAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NpBza82o; 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="NpBza82o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B36981F000FF; Sat, 12 Sep 2026 13:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789218976; bh=ioP/fHzSSx7HSl5bs4z9zfghJXX6fdI4LNL6EjWQKBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NpBza82ok/G3X0EqIrykoJHno92K/oD8djiJrF+IPoS/Y5uYfQI7CNT1uuLjWzyxk IutptLLMJvLjm5yAWiBPxA4GoORFmhR7OtIdDeYp0xYPdRFKY1sQvIEjWyRyU1ObJZ OZ4DevgjWDuTmCrAYjAqRIG044ImHxBgqEhUWfC8= 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.12 1257/1376] net/smc: free pending qentry in smc_llc_flow_stop() before memset Date: Sat, 12 Sep 2026 09:01:23 +0200 Message-ID: <20260912065635.555916670@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mahanta Jambigi [ Upstream commit 5ee0ceddc7785c6dcf4a8107fef01f0414a354f4 ] smc_llc_flow_stop() resets a flow struct with a blind memset: spin_lock_bh(&lgr->llc_flow_lock); memset(flow, 0, sizeof(*flow)); flow->type = SMC_LLC_FLOW_NONE; spin_unlock_bh(&lgr->llc_flow_lock); If flow->qentry is non-NULL at this point the pointer is overwritten without the allocation being freed, leaking one kmalloc object. A late-arriving duplicate CONFIRM_LINK or ADD_LINK_CONT message can set flow->qentry after the legitimate message has been consumed by the waiter via smc_llc_flow_qentry_clr() (which NULLs the pointer but leaves flow->type non-zero) but before the flow completes and smc_llc_flow_stop() runs. In that window the duplicate is stashed into flow->qentry, and then lost when smc_llc_flow_stop() zeros the struct. Call smc_llc_flow_qentry_del() inside the lock before the memset. smc_llc_flow_qentry_del() already checks flow->qentry before freeing, so the normal case where no entry is pending is a no-op. Fixes: 555da9af827d ("net/smc: add event-based llc_flow framework") Reviewed-by: Hidayath Khan Signed-off-by: Mahanta Jambigi Link: https://patch.msgid.link/20260818073943.1108383-1-mjambigi@linux.ibm.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/smc/smc_llc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c index 924dbd38e879c..1932983ef7636 100644 --- a/net/smc/smc_llc.c +++ b/net/smc/smc_llc.c @@ -320,6 +320,7 @@ int smc_llc_flow_initiate(struct smc_link_group *lgr, void smc_llc_flow_stop(struct smc_link_group *lgr, struct smc_llc_flow *flow) { spin_lock_bh(&lgr->llc_flow_lock); + smc_llc_flow_qentry_del(flow); memset(flow, 0, sizeof(*flow)); flow->type = SMC_LLC_FLOW_NONE; spin_unlock_bh(&lgr->llc_flow_lock); -- 2.53.0