Skip to content

Commit 1e92e82

Browse files
committed
Merge: net/sched: phase-2 backports for rhel-9.5
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4624 JIRA: https://issues.redhat.com/browse/RHEL-44375 JIRA: https://issues.redhat.com/browse/RHEL-45534 CVE: CVE-2024-36244 Upstream Status: All mainline in net.git. Tested: boot-tested only Conflicts: None Signed-off-by: Davide Caratti <dcaratti@redhat.com> Approved-by: Xin Long <lxin@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 7f25d81 + 60d43fd commit 1e92e82

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

net/sched/act_api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,
830830
u32 max;
831831

832832
if (*index) {
833-
again:
834833
rcu_read_lock();
835834
p = idr_find(&idrinfo->action_idr, *index);
836835

@@ -839,7 +838,7 @@ int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,
839838
* index but did not assign the pointer yet.
840839
*/
841840
rcu_read_unlock();
842-
goto again;
841+
return -EAGAIN;
843842
}
844843

845844
if (!p) {

net/sched/sch_taprio.c

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

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

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

11791179
return 0;
@@ -1868,6 +1868,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
18681868

18691869
q->flags = err;
18701870

1871+
/* Needed for length_to_duration() during netlink attribute parsing */
1872+
taprio_set_picos_per_byte(dev, q);
1873+
18711874
err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags);
18721875
if (err < 0)
18731876
return err;
@@ -1927,7 +1930,6 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
19271930
if (err < 0)
19281931
goto free_sched;
19291932

1930-
taprio_set_picos_per_byte(dev, q);
19311933
taprio_update_queue_max_sdu(q, new_admin, stab);
19321934

19331935
if (FULL_OFFLOAD_IS_ENABLED(q->flags))

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,50 @@
132132
"echo \"1\" > /sys/bus/netdevsim/del_device"
133133
]
134134
},
135+
{
136+
"id": "6f62",
137+
"name": "Add taprio Qdisc with too short interval",
138+
"category": [
139+
"qdisc",
140+
"taprio"
141+
],
142+
"plugins": {
143+
"requires": "nsPlugin"
144+
},
145+
"setup": [
146+
"echo \"1 1 8\" > /sys/bus/netdevsim/new_device"
147+
],
148+
"cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: taprio num_tc 2 queues 1@0 1@1 sched-entry S 01 300 sched-entry S 02 1700 clockid CLOCK_TAI",
149+
"expExitCode": "2",
150+
"verifyCmd": "$TC qdisc show dev $ETH",
151+
"matchPattern": "qdisc taprio 1: root refcnt",
152+
"matchCount": "0",
153+
"teardown": [
154+
"echo \"1\" > /sys/bus/netdevsim/del_device"
155+
]
156+
},
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+
},
135179
{
136180
"id": "3e1e",
137181
"name": "Add taprio Qdisc with an invalid cycle-time",

0 commit comments

Comments
 (0)