From mboxrd@z Thu Jan 1 00:00:00 1970 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 27FA351FCC0; Wed, 30 Sep 2026 17:55: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=1790790902; cv=none; b=XKyPyoKLgWNF3YXyKrA8tukzBj5GEBbCFI8Alx3ijxNO7FXNbcEmtG4x3JqRk1C95XfTk8Ln4F8YTl8xDkMwPb5M8ncWcmlHmjXEN8IRjgB51EEvHiVQX6xb3KfgO7uNr2CYmaWQzoIOxhmHS1FFXZg6Cj3ET5fxgR5YJK+wMQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790790902; c=relaxed/simple; bh=LTclkzLvH18+ps7OtAEhsRQndxwkLcyqMa9bhwiK/oI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X4ZAEoX8jS84tsLt0o7OsAz7HJvErGMnrZC8OXPT/nilCnHjfEq8TQq9EpruMRmUjBofSF2QlRyPSa9UQuNu7CCNqZvg1+KaoL5GeKO9OKYkxsl+dt2X9KXPsHXMHTiQmp6MqhSb15DTqhNmfNt/bwwCrEwlsCmGWys6fl4D0Bw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=L4P4pVl8; 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="L4P4pVl8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC5AD1F000FF; Wed, 30 Sep 2026 17:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790790901; bh=Zr7jxonlqTOeSVWRNnol8LQxMPlQRxUEhGiyHlIQu8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L4P4pVl8gnfV6aUoB3pLscq70mh/Ruv0Zl2ZqMBCFtEO1IapLuha1O5kEAOmQlCI8 0aSGOgxPc4bblZ4SrsmHy5NzQbYzNZT2KHyw8i4HdXcUoNdagpnC7q/e7OO0kkkPTP +8flLrLBbbuSWXDNXAldCO+ASreSll530udpAPhk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Yang , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 113/752] net: dsa: sja1105: flower: reject cross-chip redirect Date: Wed, 30 Sep 2026 17:19:43 +0200 Message-ID: <20260930152400.615991523@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Yang [ Upstream commit cfa5274a5dc2a23b957da5dc806d2ac0c7a66af0 ] dsa_port_from_netdev() may return a valid port from a different switch chip. Programming another chip's port index into the local hardware causes redirection to the wrong port, or an out-of-bounds access if the index exceeds the local chip's port count. Apply a minimal fix that adds a check to catch this case and adjusts the extack message. When cls->common.skip_sw is not set, the operation could instead redirect to the upstream port and let the software or upstream switch(es) handle the forward, but that is not addressed here. Signed-off-by: David Yang Reviewed-by: Vladimir Oltean Link: https://patch.msgid.link/20260530003940.2000994-1-mmyangfl@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/dsa/sja1105/sja1105_flower.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_flower.c b/drivers/net/dsa/sja1105/sja1105_flower.c index 72b9b39b0989d..82ca90e01d384 100644 --- a/drivers/net/dsa/sja1105/sja1105_flower.c +++ b/drivers/net/dsa/sja1105/sja1105_flower.c @@ -351,9 +351,9 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port, struct dsa_port *to_dp; to_dp = dsa_port_from_netdev(act->dev); - if (IS_ERR(to_dp)) { + if (IS_ERR(to_dp) || to_dp->ds != ds) { NL_SET_ERR_MSG_MOD(extack, - "Destination not a switch port"); + "Destination not a local switch port"); return -EOPNOTSUPP; } -- 2.53.0