Skip to content

Commit f921a58

Browse files
edumazetkuba-moo
authored andcommitted
net/sched: taprio: always validate TCA_TAPRIO_ATTR_PRIOMAP
If one TCA_TAPRIO_ATTR_PRIOMAP attribute has been provided, taprio_parse_mqprio_opt() must validate it, or userspace can inject arbitrary data to the kernel, the second time taprio_change() is called. First call (with valid attributes) sets dev->num_tc to a non zero value. Second call (with arbitrary mqprio attributes) returns early from taprio_parse_mqprio_opt() and bad things can happen. Fixes: a3d43c0 ("taprio: Add support adding an admin schedule") Reported-by: Noam Rathaus <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Vinicius Costa Gomes <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 229bedb commit f921a58

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

net/sched/sch_taprio.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,16 +1176,13 @@ static int taprio_parse_mqprio_opt(struct net_device *dev,
11761176
{
11771177
bool allow_overlapping_txqs = TXTIME_ASSIST_IS_ENABLED(taprio_flags);
11781178

1179-
if (!qopt && !dev->num_tc) {
1180-
NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary");
1181-
return -EINVAL;
1182-
}
1183-
1184-
/* If num_tc is already set, it means that the user already
1185-
* configured the mqprio part
1186-
*/
1187-
if (dev->num_tc)
1179+
if (!qopt) {
1180+
if (!dev->num_tc) {
1181+
NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary");
1182+
return -EINVAL;
1183+
}
11881184
return 0;
1185+
}
11891186

11901187
/* taprio imposes that traffic classes map 1:n to tx queues */
11911188
if (qopt->num_tc > dev->num_tx_queues) {

0 commit comments

Comments
 (0)