netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] net/sched: mqprio: fix stack out-of-bounds write in tc entry parsing
@ 2025-08-02  0:18 Jakub Kicinski
  2025-08-04 10:35 ` Vladimir Oltean
  2025-08-05  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-08-02  0:18 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Maher Azzouzi,
	Jakub Kicinski, jhs, xiyou.wangcong, jiri, vladimir.oltean, fejes

From: Maher Azzouzi <maherazz04@gmail.com>

TCA_MQPRIO_TC_ENTRY_INDEX is validated using
NLA_POLICY_MAX(NLA_U32, TC_QOPT_MAX_QUEUE), which allows the value
TC_QOPT_MAX_QUEUE (16). This leads to a 4-byte out-of-bounds stack
write in the fp[] array, which only has room for 16 elements (0–15).

Fix this by changing the policy to allow only up to TC_QOPT_MAX_QUEUE - 1.

Fixes: f62af20bed2d ("net/sched: mqprio: allow per-TC user input of FP adminStatus")
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Maher Azzouzi <maherazz04@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v3: repost for Maher, email problems..
v2: https://lore.kernel.org/CAFQ-Uc-5ucm+Dyt2s4vV5AyJKjamF=7E_wCWFROYubR5E1PMUg@mail.gmail.com
v2: https://lore.kernel.org/CANn89iJNKR8uBNrRCdqs-M6RspvgSK9+vxzfvXe3xUvDT538Lw@mail.gmail.com
v1: https://lore.kernel.org/20250722155121.440969-1-maherazz04@gmail.com

CC: jhs@mojatatu.com
CC: xiyou.wangcong@gmail.com
CC: jiri@resnulli.us
CC: vladimir.oltean@nxp.com
CC: fejes@inf.elte.hu
---
 net/sched/sch_mqprio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 51d4013b6121..f3e5ef9a9592 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -152,7 +152,7 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
 static const struct
 nla_policy mqprio_tc_entry_policy[TCA_MQPRIO_TC_ENTRY_MAX + 1] = {
 	[TCA_MQPRIO_TC_ENTRY_INDEX]	= NLA_POLICY_MAX(NLA_U32,
-							 TC_QOPT_MAX_QUEUE),
+							 TC_QOPT_MAX_QUEUE - 1),
 	[TCA_MQPRIO_TC_ENTRY_FP]	= NLA_POLICY_RANGE(NLA_U32,
 							   TC_FP_EXPRESS,
 							   TC_FP_PREEMPTIBLE),
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread
[parent not found: <4a000ef11bb148fa8955385155714056@DB9PR10MB6740.EURPRD10.PROD.OUTLOOK.COM>]

end of thread, other threads:[~2025-08-05  0:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02  0:18 [PATCH net v3] net/sched: mqprio: fix stack out-of-bounds write in tc entry parsing Jakub Kicinski
2025-08-04 10:35 ` Vladimir Oltean
2025-08-05  0:30 ` patchwork-bot+netdevbpf
     [not found] <4a000ef11bb148fa8955385155714056@DB9PR10MB6740.EURPRD10.PROD.OUTLOOK.COM>
2025-08-04 12:32 ` Fejes Ferenc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).