🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Vladimir Oltean Tue, 24 Nov 2026 14:32
Re: [PATCH net] net: dsa: felix: fix NULL pointer dereference in felix_port_enable()
#21852
Author: Vladimir Oltean
Date: Tue, 24 Nov 2026 14:32
48 lines
19268 bytes
On Thu, Nov 19, 2026 at 10:07:10AM +0000, Aristo Chen wrote:
> DSA registers the user ports in dsa_tree_setup_ports() before it sets
> conduit->dsa_ptr in dsa_tree_setup_conduit(). On teardown, it clears
> conduit->dsa_ptr in dsa_tree_teardown_conduit() before
> dsa_tree_teardown_ports() removes the user ports. RTNL is not held
> across either pair of steps, so user space can open a user port while
> conduit->dsa_ptr is NULL.
> 
> In NPI mode, felix_port_enable() calls felix_cpu_port_for_conduit().
> For a physical conduit, that function reads the CPU port index through
> conduit->dsa_ptr without checking for NULL. This caused an oops on an
> LS1028A RDB when systemd-networkd tried to open a user port while the
> switch was being probed again at runtime:
> 
>   [  166.722423] Unable to handle kernel access to user memory outside uaccess routines at virtual address 0000000000000028
>   [  166.816908] Internal error: Oops: 0000000096000004 [#1]  SMP
>   [  166.961766] pc : felix_cpu_port_for_conduit.isra.0+0x90/0xb8 [mscc_felix_dsa_lib]
>   [  166.969289] lr : felix_port_enable+0x120/0x1a0 [mscc_felix_dsa_lib]
> 
> The oops left RTNL locked. Later operations that waited for RTNL hung,
> and the board had to be power cycled.
> 
> NPI mode uses one CPU port for the whole switch. Changing the conduit
> of a user port can move the NPI port to another CPU port, and the check
> in felix_port_enable() keeps user ports that still use the old CPU port
> down.
> 
> For a physical conduit, compare dp->cpu_dp->index with the NPI port
> instead. DSA sets dp->cpu_dp before it registers the user port and
> clears it only after it removes the user port, so the check keeps
> working while conduit->dsa_ptr is NULL. As long as the physical
> conduit is set up, conduit->dsa_ptr and dp->cpu_dp point to the same
> CPU port, so the check gives the same result as before. LAG conduits
> keep using felix_cpu_port_for_conduit(), which does not read dsa_ptr
> for them.
> 
> Fixes: eca70102cfb1 ("net: dsa: felix: add support for changing DSA master")
> Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

As discussed, this is a patch that treats the symptom and not the cause.
It should only be a stopgap for net. The larger problem of
conduit->dsa_ptr being NULL while the user ports are open still remains
unaddressed.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads