Skip to content

Commit e7480a4

Browse files
committed
Revert "net: Remove low_thresh in ip defrag"
This reverts commit b2cbac9. We have multiple reports of obvious breakage from this patch. Reported-by: Ido Schimmel <idosch@idosch.org> Link: https://lore.kernel.org/all/ZGIRWjNcfqI8yY8W@shredder/ Link: https://lore.kernel.org/all/CADJHv_sDK=0RrMA2FTZQV5fw7UQ+qY=HG21Wu5qb0V9vvx5w6A@mail.gmail.com/ Reported-by: syzbot+a5e719ac7c268e414c95@syzkaller.appspotmail.com Reported-by: syzbot+a03fd670838d927d9cd8@syzkaller.appspotmail.com Fixes: b2cbac9 ("net: Remove low_thresh in ip defrag") Link: https://lore.kernel.org/r/20230517034112.1261835-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a0e35a6 commit e7480a4

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

Documentation/networking/nf_conntrack-sysctl.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ nf_conntrack_frag6_high_thresh - INTEGER
5555
nf_conntrack_frag6_low_thresh is reached.
5656

5757
nf_conntrack_frag6_low_thresh - INTEGER
58-
(Obsolete since linux-4.17)
5958
default 196608
6059

6160
See nf_conntrack_frag6_low_thresh

include/net/inet_frag.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
struct fqdir {
1414
/* sysctls */
1515
long high_thresh;
16+
long low_thresh;
1617
int timeout;
1718
int max_dist;
1819
struct inet_frags *f;

net/ieee802154/6lowpan/reassembly.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, u8 frag_type)
318318
}
319319

320320
#ifdef CONFIG_SYSCTL
321-
static unsigned long lowpanfrag_low_thresh_unuesd = IPV6_FRAG_LOW_THRESH;
321+
322322
static struct ctl_table lowpan_frags_ns_ctl_table[] = {
323323
{
324324
.procname = "6lowpanfrag_high_thresh",
@@ -374,9 +374,9 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
374374
}
375375

376376
table[0].data = &ieee802154_lowpan->fqdir->high_thresh;
377-
table[0].extra1 = &lowpanfrag_low_thresh_unuesd;
378-
table[1].data = &lowpanfrag_low_thresh_unuesd;
379-
table[1].extra2 = &ieee802154_lowpan->fqdir->high_thresh;
377+
table[0].extra1 = &ieee802154_lowpan->fqdir->low_thresh;
378+
table[1].data = &ieee802154_lowpan->fqdir->low_thresh;
379+
table[1].extra2 = &ieee802154_lowpan->fqdir->high_thresh;
380380
table[2].data = &ieee802154_lowpan->fqdir->timeout;
381381

382382
hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
@@ -451,6 +451,7 @@ static int __net_init lowpan_frags_init_net(struct net *net)
451451
return res;
452452

453453
ieee802154_lowpan->fqdir->high_thresh = IPV6_FRAG_HIGH_THRESH;
454+
ieee802154_lowpan->fqdir->low_thresh = IPV6_FRAG_LOW_THRESH;
454455
ieee802154_lowpan->fqdir->timeout = IPV6_FRAG_TIMEOUT;
455456

456457
res = lowpan_frags_ns_sysctl_register(net);

net/ipv4/ip_fragment.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ EXPORT_SYMBOL(ip_check_defrag);
553553

554554
#ifdef CONFIG_SYSCTL
555555
static int dist_min;
556-
static unsigned long ipfrag_low_thresh_unused;
556+
557557
static struct ctl_table ip4_frags_ns_ctl_table[] = {
558558
{
559559
.procname = "ipfrag_high_thresh",
@@ -609,9 +609,9 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
609609

610610
}
611611
table[0].data = &net->ipv4.fqdir->high_thresh;
612-
table[0].extra1 = &ipfrag_low_thresh_unused;
613-
table[1].data = &ipfrag_low_thresh_unused;
614-
table[1].extra2 = &net->ipv4.fqdir->high_thresh;
612+
table[0].extra1 = &net->ipv4.fqdir->low_thresh;
613+
table[1].data = &net->ipv4.fqdir->low_thresh;
614+
table[1].extra2 = &net->ipv4.fqdir->high_thresh;
615615
table[2].data = &net->ipv4.fqdir->timeout;
616616
table[3].data = &net->ipv4.fqdir->max_dist;
617617

@@ -674,9 +674,12 @@ static int __net_init ipv4_frags_init_net(struct net *net)
674674
* A 64K fragment consumes 129736 bytes (44*2944)+200
675675
* (1500 truesize == 2944, sizeof(struct ipq) == 200)
676676
*
677-
* We will commit 4MB at one time. Should we cross that limit.
677+
* We will commit 4MB at one time. Should we cross that limit
678+
* we will prune down to 3MB, making room for approx 8 big 64K
679+
* fragments 8x128k.
678680
*/
679681
net->ipv4.fqdir->high_thresh = 4 * 1024 * 1024;
682+
net->ipv4.fqdir->low_thresh = 3 * 1024 * 1024;
680683
/*
681684
* Important NOTE! Fragment queue must be destroyed before MSL expires.
682685
* RFC791 is wrong proposing to prolongate timer each fragment arrival

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static struct nft_ct_frag6_pernet *nf_frag_pernet(struct net *net)
4242
}
4343

4444
#ifdef CONFIG_SYSCTL
45-
static unsigned long nf_conntrack_frag6_low_thresh_unused = IPV6_FRAG_LOW_THRESH;
45+
4646
static struct ctl_table nf_ct_frag6_sysctl_table[] = {
4747
{
4848
.procname = "nf_conntrack_frag6_timeout",
@@ -82,10 +82,10 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
8282
nf_frag = nf_frag_pernet(net);
8383

8484
table[0].data = &nf_frag->fqdir->timeout;
85-
table[1].data = &nf_conntrack_frag6_low_thresh_unused;
86-
table[1].extra2 = &nf_frag->fqdir->high_thresh;
85+
table[1].data = &nf_frag->fqdir->low_thresh;
86+
table[1].extra2 = &nf_frag->fqdir->high_thresh;
8787
table[2].data = &nf_frag->fqdir->high_thresh;
88-
table[2].extra1 = &nf_conntrack_frag6_low_thresh_unused;
88+
table[2].extra1 = &nf_frag->fqdir->low_thresh;
8989

9090
hdr = register_net_sysctl(net, "net/netfilter", table);
9191
if (hdr == NULL)
@@ -500,6 +500,7 @@ static int nf_ct_net_init(struct net *net)
500500
return res;
501501

502502
nf_frag->fqdir->high_thresh = IPV6_FRAG_HIGH_THRESH;
503+
nf_frag->fqdir->low_thresh = IPV6_FRAG_LOW_THRESH;
503504
nf_frag->fqdir->timeout = IPV6_FRAG_TIMEOUT;
504505

505506
res = nf_ct_frag6_sysctl_register(net);

net/ipv6/reassembly.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static const struct inet6_protocol frag_protocol = {
416416
};
417417

418418
#ifdef CONFIG_SYSCTL
419-
static unsigned long ip6_frags_low_thresh_unused = IPV6_FRAG_LOW_THRESH;
419+
420420
static struct ctl_table ip6_frags_ns_ctl_table[] = {
421421
{
422422
.procname = "ip6frag_high_thresh",
@@ -465,9 +465,9 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
465465

466466
}
467467
table[0].data = &net->ipv6.fqdir->high_thresh;
468-
table[0].extra1 = &ip6_frags_low_thresh_unused;
469-
table[1].data = &ip6_frags_low_thresh_unused;
470-
table[1].extra2 = &net->ipv6.fqdir->high_thresh;
468+
table[0].extra1 = &net->ipv6.fqdir->low_thresh;
469+
table[1].data = &net->ipv6.fqdir->low_thresh;
470+
table[1].extra2 = &net->ipv6.fqdir->high_thresh;
471471
table[2].data = &net->ipv6.fqdir->timeout;
472472

473473
hdr = register_net_sysctl(net, "net/ipv6", table);
@@ -536,6 +536,7 @@ static int __net_init ipv6_frags_init_net(struct net *net)
536536
return res;
537537

538538
net->ipv6.fqdir->high_thresh = IPV6_FRAG_HIGH_THRESH;
539+
net->ipv6.fqdir->low_thresh = IPV6_FRAG_LOW_THRESH;
539540
net->ipv6.fqdir->timeout = IPV6_FRAG_TIMEOUT;
540541

541542
res = ip6_frags_ns_sysctl_register(net);

0 commit comments

Comments
 (0)