Skip to content

Commit 31ba6cf

Browse files
edumazetSasha Levin
authored andcommitted
net/sched: taprio: always validate TCA_TAPRIO_ATTR_PRIOMAP
[ Upstream commit f921a58 ] 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 <noamr@ssd-disclosure.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://lore.kernel.org/r/20240604181511.769870-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a1919d8 commit 31ba6cf

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
@@ -938,16 +938,13 @@ static int taprio_parse_mqprio_opt(struct net_device *dev,
938938
{
939939
int i, j;
940940

941-
if (!qopt && !dev->num_tc) {
942-
NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary");
943-
return -EINVAL;
944-
}
945-
946-
/* If num_tc is already set, it means that the user already
947-
* configured the mqprio part
948-
*/
949-
if (dev->num_tc)
941+
if (!qopt) {
942+
if (!dev->num_tc) {
943+
NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary");
944+
return -EINVAL;
945+
}
950946
return 0;
947+
}
951948

952949
/* Verify num_tc is not out of max range */
953950
if (qopt->num_tc > TC_MAX_QUEUE) {

0 commit comments

Comments
 (0)