Skip to content

Commit cd8c9d1

Browse files
committed
net/sched: taprio: extend minimum interval restriction to entire cycle too
jira LE-2015 cve CVE-2024-36244 Rebuild_History Non-Buildable kernel-5.14.0-427.42.1.el9_4 commit-author Vladimir Oltean <vladimir.oltean@nxp.com> commit fb66df2 It is possible for syzbot to side-step the restriction imposed by the blamed commit in the Fixes: tag, because the taprio UAPI permits a cycle-time different from (and potentially shorter than) the sum of entry intervals. We need one more restriction, which is that the cycle time itself must be larger than N * ETH_ZLEN bit times, where N is the number of schedule entries. This restriction needs to apply regardless of whether the cycle time came from the user or was the implicit, auto-calculated value, so we move the existing "cycle == 0" check outside the "if "(!new->cycle_time)" branch. This way covers both conditions and scenarios. Add a selftest which illustrates the issue triggered by syzbot. Fixes: b5b73b2 ("taprio: Fix allowing too small intervals") Reported-by: syzbot+a7d2b1d5d1af83035567@syzkaller.appspotmail.com Closes: https://lore.kernel.org/netdev/0000000000007d66bc06196e7c66@google.com/ Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://lore.kernel.org/r/20240527153955.553333-2-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit fb66df2) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 839dd53 commit cd8c9d1

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

net/sched/sch_taprio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,11 +1160,6 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
11601160
list_for_each_entry(entry, &new->entries, list)
11611161
cycle = ktime_add_ns(cycle, entry->interval);
11621162

1163-
if (!cycle) {
1164-
NL_SET_ERR_MSG(extack, "'cycle_time' can never be 0");
1165-
return -EINVAL;
1166-
}
1167-
11681163
if (cycle < 0 || cycle > INT_MAX) {
11691164
NL_SET_ERR_MSG(extack, "'cycle_time' is too big");
11701165
return -EINVAL;
@@ -1173,6 +1168,11 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
11731168
new->cycle_time = cycle;
11741169
}
11751170

1171+
if (new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)) {
1172+
NL_SET_ERR_MSG(extack, "'cycle_time' is too small");
1173+
return -EINVAL;
1174+
}
1175+
11761176
taprio_calculate_gate_durations(q, new);
11771177

11781178
return 0;

tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,28 @@
154154
"echo \"1\" > /sys/bus/netdevsim/del_device"
155155
]
156156
},
157+
{
158+
"id": "831f",
159+
"name": "Add taprio Qdisc with too short cycle-time",
160+
"category": [
161+
"qdisc",
162+
"taprio"
163+
],
164+
"plugins": {
165+
"requires": "nsPlugin"
166+
},
167+
"setup": [
168+
"echo \"1 1 8\" > /sys/bus/netdevsim/new_device"
169+
],
170+
"cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: taprio num_tc 2 queues 1@0 1@1 sched-entry S 01 200000 sched-entry S 02 200000 cycle-time 100 clockid CLOCK_TAI",
171+
"expExitCode": "2",
172+
"verifyCmd": "$TC qdisc show dev $ETH",
173+
"matchPattern": "qdisc taprio 1: root refcnt",
174+
"matchCount": "0",
175+
"teardown": [
176+
"echo \"1\" > /sys/bus/netdevsim/del_device"
177+
]
178+
},
157179
{
158180
"id": "3e1e",
159181
"name": "Add taprio Qdisc with an invalid cycle-time",

0 commit comments

Comments
 (0)