net: qede: initialize extack in qede_flow_spec_to_rule()
Subsystems (3)
PATCH 1/1 net: qede: initialize extack in qede_flow_spec_to_rule()
qede_flow_spec_to_rule() declares a netlink_ext_ack on the stack without initializing it. qede_parse_flow_attr() and qede_flow_spec_validate() only set extack._msg on error paths via NL_SET_ERR_MSG_MOD(), so on a successful parse the err_out block reads an uninitialized pointer. If that garbage happens to be non-NULL, DP_NOTICE("%s", extack._msg) dereferences it inside vsnprintf, causing a page fault and kernel panic.
This manifests when configuring ethtool ntuple flow rules (ethtool -U flow-type tcp4/udp4) on kernels built with CONFIG_INIT_STACK_NONE=y. With CONFIG_INIT_STACK_ALL_ZERO=y the bug is masked because the compiler zero-initializes extack, making _msg NULL.
Reproduced on RHEL 9.8 (kernel-5.14.0-687.47.1.el9_8) and mainline (v7.3-rc6) with the following reproducer:
IFACE=ens2f0
ip link set $IFACE up
ethtool -K $IFACE ntuple on
for i in $(seq 1 100); do
ethtool -U $IFACE flow-type udp4 src-ip 192.168.2.$i action -1
doneThe loop panics reliably after 10-15 iterations with:
BUG: unable to handle page fault RIP: string+0x49/0xd0 Call Trace: vsnprintf qede_flow_spec_to_rule+0x2b6/0x4b0 [qede] qede_add_cls_rule ethtool_set_rxnfc
Zero-initialize extack so _msg is NULL unless explicitly set by an error path.
--- drivers/net/ethernet/qlogic/qede/qede_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qede/qede_filter.c +1 -1
@@ -1992,7 +1992,7 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev, {struct ethtool_rx_flow_spec_input input = {};struct ethtool_rx_flow_rule *flow; -struct netlink_ext_ack extack; +struct netlink_ext_ack extack = {};__be16 proto;int err;
Signature · 1 line
2.55.0
Quoted 33 lines · Anirudh Virdi
qede_flow_spec_to_rule()declares anetlink_ext_ackon the stack without initializing it.qede_parse_flow_attr()andqede_flow_spec_validate()only set extack._msg on error paths viaNL_SET_ERR_MSG_MOD(), so on a successful parse theerr_outblock reads an uninitialized pointer. If that garbage happens to be non-NULL,DP_NOTICE("%s", extack._msg)dereferences it inside vsnprintf, causing a page fault and kernel panic.This manifests when configuring ethtool ntuple flow rules (ethtool -U flow-type tcp4/udp4) on kernels built with
CONFIG_INIT_STACK_NONE=y. WithCONFIG_INIT_STACK_ALL_ZERO=ythe bug is masked because the compiler zero-initializes extack, making_msgNULL.Reproduced on RHEL 9.8 (kernel-5.14.0-687.47.1.el9_8) and mainline (v7.3-rc6) with the following reproducer:
IFACE=ens2f0 ip link set $IFACE up ethtool -K $IFACE ntuple on for i in $(seq 1 100); do ethtool -U $IFACE flow-type udp4 src-ip 192.168.2.$i action -1 doneThe loop panics reliably after 10-15 iterations with:
BUG: unable to handle page fault RIP: string+0x49/0xd0 Call Trace: vsnprintf qede_flow_spec_to_rule+0x2b6/0x4b0 [qede] qede_add_cls_rule ethtool_set_rxnfc
Quoted 5 lines
Zero-initialize extack so
_msgis NULL unless explicitly set by an error path.Fixes eb705d734525 ("net: qede: use faked extack in qede_flow_spec_to_rule()")Signed-off-by Anirudh Virdi <[email protected]>
LGTM, thanks.
CC Vadim and Ido:
As stated in the blamed commit message, my implementation was based on mlxsw_env_linecard_modules_power_mode_apply() by commit 06a0fc43bb10 ("mlxsw: core_env: Add interfaces for line card initialization and de-initialization"), so likely that also needs to be fixed. I don't have the hardware to prove/test that it can be triggered.
Quoted 6 lines · Asbjørn Sloth Tønnesen
CC Vadim and Ido:
As stated in the blamed commit message, my implementation was based onmlxsw_env_linecard_modules_power_mode_apply()by commit06a0fc43bb10("mlxsw:core_env: Add interfaces for line card initialization and de-initialization"), so likely that also needs to be fixed. I don't have the hardware to prove/test that it can be triggered.
Unlike qede_flow_spec_to_rule(), mlxsw_env_linecard_modules_power_mode_apply() only prints extack on error and mlxsw_env_set_module_power_mode_apply() sets the extack on all the error paths.
Quoted 47 lines
qede_flow_spec_to_rule()declares anetlink_ext_ackon the stack without initializing it.qede_parse_flow_attr()andqede_flow_spec_validate()only set extack._msg on error paths viaNL_SET_ERR_MSG_MOD(), so on a successful parse theerr_outblock reads an uninitialized pointer. If that garbage happens to be non-NULL,DP_NOTICE("%s", extack._msg)dereferences it inside vsnprintf, causing a page fault and kernel panic.This manifests when configuring ethtool ntuple flow rules (ethtool -U flow-type tcp4/udp4) on kernels built with
CONFIG_INIT_STACK_NONE=y. WithCONFIG_INIT_STACK_ALL_ZERO=ythe bug is masked because the compiler zero-initializes extack, making_msgNULL.Reproduced on RHEL 9.8 (kernel-5.14.0-687.47.1.el9_8) and mainline (v7.3-rc6) with the following reproducer:
IFACE=ens2f0 ip link set $IFACE up ethtool -K $IFACE ntuple on for i in $(seq 1 100); do ethtool -U $IFACE flow-type udp4 src-ip 192.168.2.$i action -1 doneThe loop panics reliably after 10-15 iterations with:
BUG: unable to handle page fault RIP: string+0x49/0xd0 Call Trace: vsnprintf qede_flow_spec_to_rule+0x2b6/0x4b0 [qede] qede_add_cls_rule ethtool_set_rxnfcZero-initialize extack so
_msgis NULL unless explicitly set by an error path.Fixes eb705d734525 ("net: qede: use faked extack in qede_flow_spec_to_rule()")Signed-off-by Anirudh Virdi <[email protected]>--- drivers/net/ethernet/qlogic/qede/qede_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/qlogic/qede/qede_filter.c +0
-0
drivers/net/ethernet/qlogic/qede/qede_filter.c static int qede_flow_spec_to_rule(struct qede_dev *edev, · line 1995
Quoted 5 lines
drivers/net/ethernet/qlogic/qede/qede_filter.c +1
-1@@ -1992,7 +1992,7 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev, {struct ethtool_rx_flow_spec_input input = {};struct ethtool_rx_flow_rule *flow; -struct netlink_ext_ack extack; +struct netlink_ext_ack extack = {};
nit: the fix breaks RXT.
Quoted 6 lines
drivers/net/ethernet/qlogic/qede/qede_filter.c +0
-0__be16 proto;int err;Signature · 1 line
2.55.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 13 Oct 2026 16:24:51 +0530 you wrote:
qede_flow_spec_to_rule()declares anetlink_ext_ackon the stack without initializing it.qede_parse_flow_attr()andqede_flow_spec_validate()only set extack._msg on error paths viaNL_SET_ERR_MSG_MOD(), so on a successful parse theerr_outblock reads an uninitialized pointer. If that garbage happens to be non-NULL,DP_NOTICE("%s", extack._msg)dereferences it inside vsnprintf, causing a page fault and kernel panic.[...]
Here is the summary with links:
- [net] net: qede: initialize extack in qede_flow_spec_to_rule()
https://git.kernel.org/netdev/net/c/106e562966a0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html