From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 A6402369D7B for ; Thu, 28 May 2026 22:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780007012; cv=none; b=g+FvwX3b3iTJ50GY2Tmf0J1A5I97MpUDskVK0Eu/1IXzKrOKbKfCvX7tdQTJdL/klDnxQpIZZsuaHPv+j039RcyzbxGZioENZ7pbnkAMWVRYHOV7cIRO1Km2yPQw/SjyW5znNtQWRYS/SOHCPOb7mZbkpRbvkx+nQj/8nwl67fE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780007012; c=relaxed/simple; bh=2SC0ANVkCKp8E1WQmu3i8e+gSNuNdk0aJRJ5X83hnn8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kpRGyslJrKa/3pLlB7d3XkWGej+FvfqmGxS5BS7W6+sMfuGfirh0QmINWkRaaBOQ0Pm+0gxEENmAcwbbNSfvAVdyF8CX3lkswwqKOVYI/YoRzjGvLp7pLAEmBpyJIa/g6TvXRdREvRdBBpeaDtpCenbvPoTIXUowxIKa4YGpNMs= 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=LYck+3Ya; arc=none smtp.client-ip=209.85.221.50 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="LYck+3Ya" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-45ef14d4200so7083f8f.2 for ; Thu, 28 May 2026 15:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780007008; x=1780611808; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dxyZcyLn2H2/+BqmnLphcOMc8sbPDUQAcX0fDWHLlEw=; b=LYck+3Ya6iHZGzADK96KwBBIdr7U86xXOqlQxzHxNOq5cIeT6h2zhEsPl/lCN42sKC OJrNtF5Rj8uo803ohXJhDM9Z+iyahrNOsXEXPRl5Cp2iOjIyjam3ETNkUA5CQKPUyXMi r2/8TxiWIXkU5A6jIPeFtghSHXNNRDXsaXuHd9EtXZUpfZCbtr92ffOpZc1hNaWKOT0G YNjPg56dhl8Rw5AKscWAqFXfR6niUVDUXRxiibjja8n9ZK9bfuUOcaW8gGQELTV1sHP0 ibVf2rZ3WDeaDJRQs+MwVtCUtwa2W8yTW5cTAdWSat3uwW0OHDpLFzjkXQJvxzm6L4Eg n3xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780007008; x=1780611808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dxyZcyLn2H2/+BqmnLphcOMc8sbPDUQAcX0fDWHLlEw=; b=FSdBQ83qww3/+tc4kkBX1C/xhzXl0jalciW8nVIYcRw0SFNPbJWMTXcjXh57/Y55pP 8y/w6f355HBmC36e34SqB/qOJVbikgxilEmrVNuTnmhcM/PLB9zpdeKT5b96W6TCTKXs C0JKUxCvVigCtXgQrLJ82icMOJ8wFf6aHwswNhjdS2C32YNXRLKsQMM09vBTrTlli4hg CnjkcU6wcuvPuTIvHNJ9nyAU26P+rBpFKnPMskI3EMKdVwRwq/A32jo+WzuTEt1LnbCb q2N9amjR/0YYXQW7nSWIzIA8C8Jumzl97Rgo6XbOaxolDSqYkgsZNeWPYrgtU+Li4Pkj H+cQ== X-Forwarded-Encrypted: i=1; AFNElJ+intmk2xcnM4YVy6sRr4gsKW189EhclV4Pkdb8sZCnwKtT0ECAZ+b48PXm2x1tG/z7Qep9//x+GA+smck=@vger.kernel.org X-Gm-Message-State: AOJu0YxasaYn7CvTIXls2FkA+XkQXcVFZTsnS4gPgWe/YRjwN7vi2e8e xXrFEwRvO9E2+4gdq2jBIzbdErvOwQA3E1Vsjx6fqM2XzXU00NEy+WMXlFmMGg== X-Gm-Gg: Acq92OEHHSTpP5YnKlkzwEXaeS0Vmufdie43tPP3EdKNPOs3U/ZxyfkrtWImZC/grfS 856q95hP2YYZGLEdzsBTeUiy9REB6QF4zZnUFUhqNyI7wJmYLSjEiaavK3ZEjKkU4U6ja68z7I3 JBRHexrizgZB69I+jdQ/p1/3/VSh2XCjwgwSJ2fdCMq+PysVZBEgta+Md6LW3oYZlFkT2PcTsf0 bObKMjUQIyHAm0Meb3+8y6yD+/uPOgmI/3xnN+z0r5jN38ExNkMKwsu68tPj5F2aI+h/5Pzqo6p BcNaNmtW8DZJSzeEwGp4vtqNkjt4A1teLEYXYY+CcwmSECrT/QArpGWsG4i75MhhbDzIl3DZfMs zWm9Xc9xdfo0Q9tE5AZXGqd7LwlV/L4BMAqkE4ycC8VOuyKnu3PuYJcToJ5xwwaShewHcljWaza y6h2RTIS5nCYwrc/ihphRWRKrzVA== X-Received: by 2002:a05:600c:4511:b0:490:6869:e7f5 with SMTP id 5b1f17b1804b1-4909c02bcddmr2412925e9.0.1780007007858; Thu, 28 May 2026 15:23:27 -0700 (PDT) Received: from skbuf ([2a02:2f04:d305:6000:97f9:e596:8819:1468]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909ca6575csm4326545e9.4.2026.05.28.15.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 15:23:27 -0700 (PDT) Date: Fri, 29 May 2026 01:23:25 +0300 From: Vladimir Oltean To: David Yang Cc: netdev@vger.kernel.org, Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: dsa: sja1105: flower: reject cross-chip redirect Message-ID: <20260528222325.swzj77wo7lifymoa@skbuf> References: <20260528203549.1918040-1-mmyangfl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260528203549.1918040-1-mmyangfl@gmail.com> On Fri, May 29, 2026 at 04:35:44AM +0800, David Yang wrote: > The driver silently accepts a destination port on a different switch > chip, then programs its index (on another chip) into the local hardware, > which redirects to the wrong port or possibly crashes if the port index > is out of bound locally. > > Add a check for it and adjust the extack message. > > Signed-off-by: David Yang > --- > 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 fba926f85b47..7547999a113f 100644 > --- a/drivers/net/dsa/sja1105/sja1105_flower.c > +++ b/drivers/net/dsa/sja1105/sja1105_flower.c > @@ -391,9 +391,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 > The problem is more nuanced, but I agree with the patch. If you want to resend to make it more clear in the commit message, fine, if not, oh well. Basically these days we can do better than rejecting the operation, see https://lore.kernel.org/all/20241023135251.1752488-1-vladimir.oltean@nxp.com/ If cls->common.skip_sw is set, sure, but if not, just redirecting to dsa_upstream_port(ds, port) should be fine (but not enough). The problem is that the source user port itself may not belong to a switch directly attached to the conduit, and in this case, redirecting to the CPU implies programming the upstream switch(es) to also redirect that flow to the CPU, for it to be properly processed exclusively in software as opposed to flooded. And then there's a risk that the flow may have been programmed on that switch already with another target, so the operation might fail. This appears to also be a problem with my patch set linked above, so they should be treated together (not necessarily by you, not necessarily now). Reviewed-by: Vladimir Oltean