Skip to content

Commit 7041101

Browse files
dcarattikuba-moo
authored andcommitted
net/sched: sch_fq: fix integer overflow of "credit"
if sch_fq is configured with "initial quantum" having values greater than INT_MAX, the first assignment of "credit" does signed integer overflow to a very negative value. In this situation, the syzkaller script provided by Cristoph triggers the CPU soft-lockup warning even with few sockets. It's not an infinite loop, but "credit" wasn't probably meant to be minus 2Gb for each new flow. Capping "initial quantum" to INT_MAX proved to fix the issue. v2: validation of "initial quantum" is done in fq_policy, instead of open coding in fq_change() _ suggested by Jakub Kicinski Reported-by: Christoph Paasch <cpaasch@apple.com> Link: multipath-tcp/mptcp_net-next#377 Fixes: afe4fd0 ("pkt_sched: fq: Fair Queue packet scheduler") Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Davide Caratti <dcaratti@redhat.com> Link: https://lore.kernel.org/r/7b3a3c7e36d03068707a021760a194a8eb5ad41a.1682002300.git.dcaratti@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 63cfd21 commit 7041101

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

net/sched/sch_fq.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,17 @@ static int fq_resize(struct Qdisc *sch, u32 log)
779779
return 0;
780780
}
781781

782+
static struct netlink_range_validation iq_range = {
783+
.max = INT_MAX,
784+
};
785+
782786
static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = {
783787
[TCA_FQ_UNSPEC] = { .strict_start_type = TCA_FQ_TIMER_SLACK },
784788

785789
[TCA_FQ_PLIMIT] = { .type = NLA_U32 },
786790
[TCA_FQ_FLOW_PLIMIT] = { .type = NLA_U32 },
787791
[TCA_FQ_QUANTUM] = { .type = NLA_U32 },
788-
[TCA_FQ_INITIAL_QUANTUM] = { .type = NLA_U32 },
792+
[TCA_FQ_INITIAL_QUANTUM] = NLA_POLICY_FULL_RANGE(NLA_U32, &iq_range),
789793
[TCA_FQ_RATE_ENABLE] = { .type = NLA_U32 },
790794
[TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NLA_U32 },
791795
[TCA_FQ_FLOW_MAX_RATE] = { .type = NLA_U32 },

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,28 @@
114114
"$IP link del dev $DUMMY type dummy"
115115
]
116116
},
117+
{
118+
"id": "10f7",
119+
"name": "Create FQ with invalid initial_quantum setting",
120+
"category": [
121+
"qdisc",
122+
"fq"
123+
],
124+
"plugins": {
125+
"requires": "nsPlugin"
126+
},
127+
"setup": [
128+
"$IP link add dev $DUMMY type dummy || /bin/true"
129+
],
130+
"cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root fq initial_quantum 0x80000000",
131+
"expExitCode": "2",
132+
"verifyCmd": "$TC qdisc show dev $DUMMY",
133+
"matchPattern": "qdisc fq 1: root.*initial_quantum 2048Mb",
134+
"matchCount": "0",
135+
"teardown": [
136+
"$IP link del dev $DUMMY type dummy"
137+
]
138+
},
117139
{
118140
"id": "9398",
119141
"name": "Create FQ with maxrate setting",

0 commit comments

Comments
 (0)