From: Sasha Levin Date: Sat, 10 Sep 2022 23:50:48 +0000 (-0400) Subject: Fixes for 4.14 X-Git-Tag: v5.19.9~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a02542c74e515f6597e32742b2d0d6140f0029bf;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/ipv6-sr-fix-out-of-bounds-read-when-setting-hmac-dat.patch b/queue-4.14/ipv6-sr-fix-out-of-bounds-read-when-setting-hmac-dat.patch new file mode 100644 index 00000000000..4974e855cb2 --- /dev/null +++ b/queue-4.14/ipv6-sr-fix-out-of-bounds-read-when-setting-hmac-dat.patch @@ -0,0 +1,78 @@ +From 57792a6618c3c8088a932c1d0c4c27553365ddf9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 2 Sep 2022 10:45:06 +0100 +Subject: ipv6: sr: fix out-of-bounds read when setting HMAC data. + +From: David Lebrun + +[ Upstream commit 84a53580c5d2138c7361c7c3eea5b31827e63b35 ] + +The SRv6 layer allows defining HMAC data that can later be used to sign IPv6 +Segment Routing Headers. This configuration is realised via netlink through +four attributes: SEG6_ATTR_HMACKEYID, SEG6_ATTR_SECRET, SEG6_ATTR_SECRETLEN and +SEG6_ATTR_ALGID. Because the SECRETLEN attribute is decoupled from the actual +length of the SECRET attribute, it is possible to provide invalid combinations +(e.g., secret = "", secretlen = 64). This case is not checked in the code and +with an appropriately crafted netlink message, an out-of-bounds read of up +to 64 bytes (max secret length) can occur past the skb end pointer and into +skb_shared_info: + +Breakpoint 1, seg6_genl_sethmac (skb=, info=) at net/ipv6/seg6.c:208 +208 memcpy(hinfo->secret, secret, slen); +(gdb) bt + #0 seg6_genl_sethmac (skb=, info=) at net/ipv6/seg6.c:208 + #1 0xffffffff81e012e9 in genl_family_rcv_msg_doit (skb=skb@entry=0xffff88800b1f9f00, nlh=nlh@entry=0xffff88800b1b7600, + extack=extack@entry=0xffffc90000ba7af0, ops=ops@entry=0xffffc90000ba7a80, hdrlen=4, net=0xffffffff84237580 , family=, + family=) at net/netlink/genetlink.c:731 + #2 0xffffffff81e01435 in genl_family_rcv_msg (extack=0xffffc90000ba7af0, nlh=0xffff88800b1b7600, skb=0xffff88800b1f9f00, + family=0xffffffff82fef6c0 ) at net/netlink/genetlink.c:775 + #3 genl_rcv_msg (skb=0xffff88800b1f9f00, nlh=0xffff88800b1b7600, extack=0xffffc90000ba7af0) at net/netlink/genetlink.c:792 + #4 0xffffffff81dfffc3 in netlink_rcv_skb (skb=skb@entry=0xffff88800b1f9f00, cb=cb@entry=0xffffffff81e01350 ) + at net/netlink/af_netlink.c:2501 + #5 0xffffffff81e00919 in genl_rcv (skb=0xffff88800b1f9f00) at net/netlink/genetlink.c:803 + #6 0xffffffff81dff6ae in netlink_unicast_kernel (ssk=0xffff888010eec800, skb=0xffff88800b1f9f00, sk=0xffff888004aed000) + at net/netlink/af_netlink.c:1319 + #7 netlink_unicast (ssk=ssk@entry=0xffff888010eec800, skb=skb@entry=0xffff88800b1f9f00, portid=portid@entry=0, nonblock=) + at net/netlink/af_netlink.c:1345 + #8 0xffffffff81dff9a4 in netlink_sendmsg (sock=, msg=0xffffc90000ba7e48, len=) at net/netlink/af_netlink.c:1921 +... +(gdb) p/x ((struct sk_buff *)0xffff88800b1f9f00)->head + ((struct sk_buff *)0xffff88800b1f9f00)->end +$1 = 0xffff88800b1b76c0 +(gdb) p/x secret +$2 = 0xffff88800b1b76c0 +(gdb) p slen +$3 = 64 '@' + +The OOB data can then be read back from userspace by dumping HMAC state. This +commit fixes this by ensuring SECRETLEN cannot exceed the actual length of +SECRET. + +Reported-by: Lucas Leong +Tested: verified that EINVAL is correctly returned when secretlen > len(secret) +Fixes: 4f4853dc1c9c1 ("ipv6: sr: implement API to control SR HMAC structure") +Signed-off-by: David Lebrun +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/ipv6/seg6.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c +index fdeb90dd1c824..9c45165fe79bb 100644 +--- a/net/ipv6/seg6.c ++++ b/net/ipv6/seg6.c +@@ -129,6 +129,11 @@ static int seg6_genl_sethmac(struct sk_buff *skb, struct genl_info *info) + goto out_unlock; + } + ++ if (slen > nla_len(info->attrs[SEG6_ATTR_SECRET])) { ++ err = -EINVAL; ++ goto out_unlock; ++ } ++ + if (hinfo) { + err = seg6_hmac_info_del(net, hmackeyid); + if (err) +-- +2.35.1 + diff --git a/queue-4.14/netfilter-br_netfilter-drop-dst-references-before-se.patch b/queue-4.14/netfilter-br_netfilter-drop-dst-references-before-se.patch new file mode 100644 index 00000000000..a0d2cdc0293 --- /dev/null +++ b/queue-4.14/netfilter-br_netfilter-drop-dst-references-before-se.patch @@ -0,0 +1,96 @@ +From ef880a9df8f5c61bbc99bc159391bac811e083a0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 30 Aug 2022 22:36:03 -0700 +Subject: netfilter: br_netfilter: Drop dst references before setting. + +From: Harsh Modi + +[ Upstream commit d047283a7034140ea5da759a494fd2274affdd46 ] + +The IPv6 path already drops dst in the daddr changed case, but the IPv4 +path does not. This change makes the two code paths consistent. + +Further, it is possible that there is already a metadata_dst allocated from +ingress that might already be attached to skbuff->dst while following +the bridge path. If it is not released before setting a new +metadata_dst, it will be leaked. This is similar to what is done in +bpf_set_tunnel_key() or ip6_route_input(). + +It is important to note that the memory being leaked is not the dst +being set in the bridge code, but rather memory allocated from some +other code path that is not being freed correctly before the skb dst is +overwritten. + +An example of the leakage fixed by this commit found using kmemleak: + +unreferenced object 0xffff888010112b00 (size 256): + comm "softirq", pid 0, jiffies 4294762496 (age 32.012s) + hex dump (first 32 bytes): + 00 00 00 00 00 00 00 00 80 16 f1 83 ff ff ff ff ................ + e1 4e f6 82 ff ff ff ff 00 00 00 00 00 00 00 00 .N.............. + backtrace: + [<00000000d79567ea>] metadata_dst_alloc+0x1b/0xe0 + [<00000000be113e13>] udp_tun_rx_dst+0x174/0x1f0 + [<00000000a36848f4>] geneve_udp_encap_recv+0x350/0x7b0 + [<00000000d4afb476>] udp_queue_rcv_one_skb+0x380/0x560 + [<00000000ac064aea>] udp_unicast_rcv_skb+0x75/0x90 + [<000000009a8ee8c5>] ip_protocol_deliver_rcu+0xd8/0x230 + [<00000000ef4980bb>] ip_local_deliver_finish+0x7a/0xa0 + [<00000000d7533c8c>] __netif_receive_skb_one_core+0x89/0xa0 + [<00000000a879497d>] process_backlog+0x93/0x190 + [<00000000e41ade9f>] __napi_poll+0x28/0x170 + [<00000000b4c0906b>] net_rx_action+0x14f/0x2a0 + [<00000000b20dd5d4>] __do_softirq+0xf4/0x305 + [<000000003a7d7e15>] __irq_exit_rcu+0xc3/0x140 + [<00000000968d39a2>] sysvec_apic_timer_interrupt+0x9e/0xc0 + [<000000009e920794>] asm_sysvec_apic_timer_interrupt+0x16/0x20 + [<000000008942add0>] native_safe_halt+0x13/0x20 + +Florian Westphal says: "Original code was likely fine because nothing +ever did set a skb->dst entry earlier than bridge in those days." + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Harsh Modi +Acked-by: Florian Westphal +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/bridge/br_netfilter_hooks.c | 2 ++ + net/bridge/br_netfilter_ipv6.c | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c +index ee7a03ff89f3a..d229bfaaaba72 100644 +--- a/net/bridge/br_netfilter_hooks.c ++++ b/net/bridge/br_netfilter_hooks.c +@@ -382,6 +382,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_ + /* - Bridged-and-DNAT'ed traffic doesn't + * require ip_forwarding. */ + if (rt->dst.dev == dev) { ++ skb_dst_drop(skb); + skb_dst_set(skb, &rt->dst); + goto bridged_dnat; + } +@@ -411,6 +412,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_ + kfree_skb(skb); + return 0; + } ++ skb_dst_drop(skb); + skb_dst_set_noref(skb, &rt->dst); + } + +diff --git a/net/bridge/br_netfilter_ipv6.c b/net/bridge/br_netfilter_ipv6.c +index 09d5e0c7b3ba4..995d86777e7cb 100644 +--- a/net/bridge/br_netfilter_ipv6.c ++++ b/net/bridge/br_netfilter_ipv6.c +@@ -201,6 +201,7 @@ static int br_nf_pre_routing_finish_ipv6(struct net *net, struct sock *sk, struc + kfree_skb(skb); + return 0; + } ++ skb_dst_drop(skb); + skb_dst_set_noref(skb, &rt->dst); + } + +-- +2.35.1 + diff --git a/queue-4.14/netfilter-nf_conntrack_irc-fix-forged-ip-logic.patch b/queue-4.14/netfilter-nf_conntrack_irc-fix-forged-ip-logic.patch new file mode 100644 index 00000000000..20371b47c1f --- /dev/null +++ b/queue-4.14/netfilter-nf_conntrack_irc-fix-forged-ip-logic.patch @@ -0,0 +1,43 @@ +From ff23a63abda39fa3787965570ec90d400cb72430 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 26 Aug 2022 14:56:58 +1000 +Subject: netfilter: nf_conntrack_irc: Fix forged IP logic + +From: David Leadbeater + +[ Upstream commit 0efe125cfb99e6773a7434f3463f7c2fa28f3a43 ] + +Ensure the match happens in the right direction, previously the +destination used was the server, not the NAT host, as the comment +shows the code intended. + +Additionally nf_nat_irc uses port 0 as a signal and there's no valid way +it can appear in a DCC message, so consider port 0 also forged. + +Fixes: 869f37d8e48f ("[NETFILTER]: nf_conntrack/nf_nat: add IRC helper port") +Signed-off-by: David Leadbeater +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nf_conntrack_irc.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c +index 5523acce9d699..814220f7be676 100644 +--- a/net/netfilter/nf_conntrack_irc.c ++++ b/net/netfilter/nf_conntrack_irc.c +@@ -187,8 +187,9 @@ static int help(struct sk_buff *skb, unsigned int protoff, + + /* dcc_ip can be the internal OR external (NAT'ed) IP */ + tuple = &ct->tuplehash[dir].tuple; +- if (tuple->src.u3.ip != dcc_ip && +- tuple->dst.u3.ip != dcc_ip) { ++ if ((tuple->src.u3.ip != dcc_ip && ++ ct->tuplehash[!dir].tuple.dst.u3.ip != dcc_ip) || ++ dcc_port == 0) { + net_warn_ratelimited("Forged DCC command from %pI4: %pI4:%u\n", + &tuple->src.u3.ip, + &dcc_ip, dcc_port); +-- +2.35.1 + diff --git a/queue-4.14/sch_sfb-also-store-skb-len-before-calling-child-enqu.patch b/queue-4.14/sch_sfb-also-store-skb-len-before-calling-child-enqu.patch new file mode 100644 index 00000000000..2692f849c62 --- /dev/null +++ b/queue-4.14/sch_sfb-also-store-skb-len-before-calling-child-enqu.patch @@ -0,0 +1,52 @@ +From 9871a7c8c9b1118a1b38529371aef97c3d2e0eac Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 5 Sep 2022 21:21:36 +0200 +Subject: sch_sfb: Also store skb len before calling child enqueue +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Toke Høiland-Jørgensen + +[ Upstream commit 2f09707d0c972120bf794cfe0f0c67e2c2ddb252 ] + +Cong Wang noticed that the previous fix for sch_sfb accessing the queued +skb after enqueueing it to a child qdisc was incomplete: the SFB enqueue +function was also calling qdisc_qstats_backlog_inc() after enqueue, which +reads the pkt len from the skb cb field. Fix this by also storing the skb +len, and using the stored value to increment the backlog after enqueueing. + +Fixes: 9efd23297cca ("sch_sfb: Don't assume the skb is still around after enqueueing to child") +Signed-off-by: Toke Høiland-Jørgensen +Acked-by: Cong Wang +Link: https://lore.kernel.org/r/20220905192137.965549-1-toke@toke.dk +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + net/sched/sch_sfb.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c +index 8f924defa98d0..9962a49989938 100644 +--- a/net/sched/sch_sfb.c ++++ b/net/sched/sch_sfb.c +@@ -284,6 +284,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, + { + + struct sfb_sched_data *q = qdisc_priv(sch); ++ unsigned int len = qdisc_pkt_len(skb); + struct Qdisc *child = q->qdisc; + struct tcf_proto *fl; + struct sfb_skb_cb cb; +@@ -406,7 +407,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, + memcpy(&cb, sfb_skb_cb(skb), sizeof(cb)); + ret = qdisc_enqueue(skb, child, to_free); + if (likely(ret == NET_XMIT_SUCCESS)) { +- qdisc_qstats_backlog_inc(sch, skb); ++ sch->qstats.backlog += len; + sch->q.qlen++; + increment_qlen(&cb, q); + } else if (net_xmit_drop_count(ret)) { +-- +2.35.1 + diff --git a/queue-4.14/sch_sfb-don-t-assume-the-skb-is-still-around-after-e.patch b/queue-4.14/sch_sfb-don-t-assume-the-skb-is-still-around-after-e.patch new file mode 100644 index 00000000000..78f6ed2d143 --- /dev/null +++ b/queue-4.14/sch_sfb-don-t-assume-the-skb-is-still-around-after-e.patch @@ -0,0 +1,82 @@ +From e4b37aba800e30067beaed3771449ddbc6818b1e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 31 Aug 2022 23:52:18 +0200 +Subject: sch_sfb: Don't assume the skb is still around after enqueueing to + child +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Toke Høiland-Jørgensen + +[ Upstream commit 9efd23297cca530bb35e1848665805d3fcdd7889 ] + +The sch_sfb enqueue() routine assumes the skb is still alive after it has +been enqueued into a child qdisc, using the data in the skb cb field in the +increment_qlen() routine after enqueue. However, the skb may in fact have +been freed, causing a use-after-free in this case. In particular, this +happens if sch_cake is used as a child of sfb, and the GSO splitting mode +of CAKE is enabled (in which case the skb will be split into segments and +the original skb freed). + +Fix this by copying the sfb cb data to the stack before enqueueing the skb, +and using this stack copy in increment_qlen() instead of the skb pointer +itself. + +Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-18231 +Fixes: e13e02a3c68d ("net_sched: SFB flow scheduler") +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/sched/sch_sfb.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c +index 04f15e0aeaa8b..8f924defa98d0 100644 +--- a/net/sched/sch_sfb.c ++++ b/net/sched/sch_sfb.c +@@ -139,15 +139,15 @@ static void increment_one_qlen(u32 sfbhash, u32 slot, struct sfb_sched_data *q) + } + } + +-static void increment_qlen(const struct sk_buff *skb, struct sfb_sched_data *q) ++static void increment_qlen(const struct sfb_skb_cb *cb, struct sfb_sched_data *q) + { + u32 sfbhash; + +- sfbhash = sfb_hash(skb, 0); ++ sfbhash = cb->hashes[0]; + if (sfbhash) + increment_one_qlen(sfbhash, 0, q); + +- sfbhash = sfb_hash(skb, 1); ++ sfbhash = cb->hashes[1]; + if (sfbhash) + increment_one_qlen(sfbhash, 1, q); + } +@@ -286,6 +286,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, + struct sfb_sched_data *q = qdisc_priv(sch); + struct Qdisc *child = q->qdisc; + struct tcf_proto *fl; ++ struct sfb_skb_cb cb; + int i; + u32 p_min = ~0; + u32 minqlen = ~0; +@@ -402,11 +403,12 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch, + } + + enqueue: ++ memcpy(&cb, sfb_skb_cb(skb), sizeof(cb)); + ret = qdisc_enqueue(skb, child, to_free); + if (likely(ret == NET_XMIT_SUCCESS)) { + qdisc_qstats_backlog_inc(sch, skb); + sch->q.qlen++; +- increment_qlen(skb, q); ++ increment_qlen(&cb, q); + } else if (net_xmit_drop_count(ret)) { + q->stats.childdrop++; + qdisc_qstats_drop(sch); +-- +2.35.1 + diff --git a/queue-4.14/series b/queue-4.14/series index b59aab6b823..d064d072b63 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -47,3 +47,10 @@ alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch kprobes-prohibit-probes-in-gate-area.patch scsi-mpt3sas-fix-use-after-free-warning.patch driver-core-don-t-probe-devices-after-bus_type.match-probe-deferral.patch +netfilter-br_netfilter-drop-dst-references-before-se.patch +netfilter-nf_conntrack_irc-fix-forged-ip-logic.patch +sch_sfb-don-t-assume-the-skb-is-still-around-after-e.patch +tipc-fix-shift-wrapping-bug-in-map_get.patch +ipv6-sr-fix-out-of-bounds-read-when-setting-hmac-dat.patch +tcp-fix-early-etimedout-after-spurious-non-sack-rto.patch +sch_sfb-also-store-skb-len-before-calling-child-enqu.patch diff --git a/queue-4.14/tcp-fix-early-etimedout-after-spurious-non-sack-rto.patch b/queue-4.14/tcp-fix-early-etimedout-after-spurious-non-sack-rto.patch new file mode 100644 index 00000000000..009696ffeeb --- /dev/null +++ b/queue-4.14/tcp-fix-early-etimedout-after-spurious-non-sack-rto.patch @@ -0,0 +1,129 @@ +From 38ec5cd19f19c1eff0a624f6c29d7d6a8254056b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Sep 2022 08:10:23 -0400 +Subject: tcp: fix early ETIMEDOUT after spurious non-SACK RTO + +From: Neal Cardwell + +[ Upstream commit 686dc2db2a0fdc1d34b424ec2c0a735becd8d62b ] + +Fix a bug reported and analyzed by Nagaraj Arankal, where the handling +of a spurious non-SACK RTO could cause a connection to fail to clear +retrans_stamp, causing a later RTO to very prematurely time out the +connection with ETIMEDOUT. + +Here is the buggy scenario, expanding upon Nagaraj Arankal's excellent +report: + +(*1) Send one data packet on a non-SACK connection + +(*2) Because no ACK packet is received, the packet is retransmitted + and we enter CA_Loss; but this retransmission is spurious. + +(*3) The ACK for the original data is received. The transmitted packet + is acknowledged. The TCP timestamp is before the retrans_stamp, + so tcp_may_undo() returns true, and tcp_try_undo_loss() returns + true without changing state to Open (because tcp_is_sack() is + false), and tcp_process_loss() returns without calling + tcp_try_undo_recovery(). Normally after undoing a CA_Loss + episode, tcp_fastretrans_alert() would see that the connection + has returned to CA_Open and fall through and call + tcp_try_to_open(), which would set retrans_stamp to 0. However, + for non-SACK connections we hold the connection in CA_Loss, so do + not fall through to call tcp_try_to_open() and do not set + retrans_stamp to 0. So retrans_stamp is (erroneously) still + non-zero. + + At this point the first "retransmission event" has passed and + been recovered from. Any future retransmission is a completely + new "event". However, retrans_stamp is erroneously still + set. (And we are still in CA_Loss, which is correct.) + +(*4) After 16 minutes (to correspond with tcp_retries2=15), a new data + packet is sent. Note: No data is transmitted between (*3) and + (*4) and we disabled keep alives. + + The socket's timeout SHOULD be calculated from this point in + time, but instead it's calculated from the prior "event" 16 + minutes ago (step (*2)). + +(*5) Because no ACK packet is received, the packet is retransmitted. + +(*6) At the time of the 2nd retransmission, the socket returns + ETIMEDOUT, prematurely, because retrans_stamp is (erroneously) + too far in the past (set at the time of (*2)). + +This commit fixes this bug by ensuring that we reuse in +tcp_try_undo_loss() the same careful logic for non-SACK connections +that we have in tcp_try_undo_recovery(). To avoid duplicating logic, +we factor out that logic into a new +tcp_is_non_sack_preventing_reopen() helper and call that helper from +both undo functions. + +Fixes: da34ac7626b5 ("tcp: only undo on partial ACKs in CA_Loss") +Reported-by: Nagaraj Arankal +Link: https://lore.kernel.org/all/SJ0PR84MB1847BE6C24D274C46A1B9B0EB27A9@SJ0PR84MB1847.NAMPRD84.PROD.OUTLOOK.COM/ +Signed-off-by: Neal Cardwell +Signed-off-by: Yuchung Cheng +Reviewed-by: Eric Dumazet +Link: https://lore.kernel.org/r/20220903121023.866900-1-ncardwell.kernel@gmail.com +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + net/ipv4/tcp_input.c | 25 ++++++++++++++++++------- + 1 file changed, 18 insertions(+), 7 deletions(-) + +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c +index 906d26794d007..c6d49ec38a56a 100644 +--- a/net/ipv4/tcp_input.c ++++ b/net/ipv4/tcp_input.c +@@ -2425,6 +2425,21 @@ static inline bool tcp_may_undo(const struct tcp_sock *tp) + return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp)); + } + ++static bool tcp_is_non_sack_preventing_reopen(struct sock *sk) ++{ ++ struct tcp_sock *tp = tcp_sk(sk); ++ ++ if (tp->snd_una == tp->high_seq && tcp_is_reno(tp)) { ++ /* Hold old state until something *above* high_seq ++ * is ACKed. For Reno it is MUST to prevent false ++ * fast retransmits (RFC2582). SACK TCP is safe. */ ++ if (!tcp_any_retrans_done(sk)) ++ tp->retrans_stamp = 0; ++ return true; ++ } ++ return false; ++} ++ + /* People celebrate: "We love our President!" */ + static bool tcp_try_undo_recovery(struct sock *sk) + { +@@ -2445,14 +2460,8 @@ static bool tcp_try_undo_recovery(struct sock *sk) + + NET_INC_STATS(sock_net(sk), mib_idx); + } +- if (tp->snd_una == tp->high_seq && tcp_is_reno(tp)) { +- /* Hold old state until something *above* high_seq +- * is ACKed. For Reno it is MUST to prevent false +- * fast retransmits (RFC2582). SACK TCP is safe. */ +- if (!tcp_any_retrans_done(sk)) +- tp->retrans_stamp = 0; ++ if (tcp_is_non_sack_preventing_reopen(sk)) + return true; +- } + tcp_set_ca_state(sk, TCP_CA_Open); + tp->is_sack_reneg = 0; + return false; +@@ -2486,6 +2495,8 @@ static bool tcp_try_undo_loss(struct sock *sk, bool frto_undo) + NET_INC_STATS(sock_net(sk), + LINUX_MIB_TCPSPURIOUSRTOS); + inet_csk(sk)->icsk_retransmits = 0; ++ if (tcp_is_non_sack_preventing_reopen(sk)) ++ return true; + if (frto_undo || tcp_is_sack(tp)) { + tcp_set_ca_state(sk, TCP_CA_Open); + tp->is_sack_reneg = 0; +-- +2.35.1 + diff --git a/queue-4.14/tipc-fix-shift-wrapping-bug-in-map_get.patch b/queue-4.14/tipc-fix-shift-wrapping-bug-in-map_get.patch new file mode 100644 index 00000000000..009c6c5a770 --- /dev/null +++ b/queue-4.14/tipc-fix-shift-wrapping-bug-in-map_get.patch @@ -0,0 +1,36 @@ +From f22e17c674bbd594f8ea0b89ff75ba062aae0f51 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 31 Aug 2022 17:47:56 +0300 +Subject: tipc: fix shift wrapping bug in map_get() + +From: Dan Carpenter + +[ Upstream commit e2b224abd9bf45dcb55750479fc35970725a430b ] + +There is a shift wrapping bug in this code so anything thing above +31 will return false. + +Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework") +Signed-off-by: Dan Carpenter +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/tipc/monitor.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c +index c6496da9392d7..cf6dd3546c53c 100644 +--- a/net/tipc/monitor.c ++++ b/net/tipc/monitor.c +@@ -130,7 +130,7 @@ static void map_set(u64 *up_map, int i, unsigned int v) + + static int map_get(u64 up_map, int i) + { +- return (up_map & (1 << i)) >> i; ++ return (up_map & (1ULL << i)) >> i; + } + + static struct tipc_peer *peer_prev(struct tipc_peer *peer) +-- +2.35.1 +