Contents of /trunk/kernel-alx/patches-4.19/0151-4.19.52-all-fixes.patch
Parent Directory | Revision Log
Revision 3430 -
(show annotations)
(download)
Fri Aug 2 11:47:58 2019 UTC (5 years, 1 month ago) by niro
File size: 8956 byte(s)
Fri Aug 2 11:47:58 2019 UTC (5 years, 1 month ago) by niro
File size: 8956 byte(s)
-linux-4.19.52
1 | diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt |
2 | index 2c31208528d5..7eb9366422f5 100644 |
3 | --- a/Documentation/networking/ip-sysctl.txt |
4 | +++ b/Documentation/networking/ip-sysctl.txt |
5 | @@ -250,6 +250,14 @@ tcp_base_mss - INTEGER |
6 | Path MTU discovery (MTU probing). If MTU probing is enabled, |
7 | this is the initial MSS used by the connection. |
8 | |
9 | +tcp_min_snd_mss - INTEGER |
10 | + TCP SYN and SYNACK messages usually advertise an ADVMSS option, |
11 | + as described in RFC 1122 and RFC 6691. |
12 | + If this ADVMSS option is smaller than tcp_min_snd_mss, |
13 | + it is silently capped to tcp_min_snd_mss. |
14 | + |
15 | + Default : 48 (at least 8 bytes of payload per segment) |
16 | + |
17 | tcp_congestion_control - STRING |
18 | Set the congestion control algorithm to be used for new |
19 | connections. The algorithm "reno" is always available, but |
20 | diff --git a/Makefile b/Makefile |
21 | index dd4be2f32b88..c82ee02ad9be 100644 |
22 | --- a/Makefile |
23 | +++ b/Makefile |
24 | @@ -1,7 +1,7 @@ |
25 | # SPDX-License-Identifier: GPL-2.0 |
26 | VERSION = 4 |
27 | PATCHLEVEL = 19 |
28 | -SUBLEVEL = 51 |
29 | +SUBLEVEL = 52 |
30 | EXTRAVERSION = |
31 | NAME = "People's Front" |
32 | |
33 | diff --git a/include/linux/tcp.h b/include/linux/tcp.h |
34 | index d2c8f280e48f..4374196b98ea 100644 |
35 | --- a/include/linux/tcp.h |
36 | +++ b/include/linux/tcp.h |
37 | @@ -485,4 +485,8 @@ static inline u16 tcp_mss_clamp(const struct tcp_sock *tp, u16 mss) |
38 | |
39 | return (user_mss && user_mss < mss) ? user_mss : mss; |
40 | } |
41 | + |
42 | +int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, int pcount, |
43 | + int shiftlen); |
44 | + |
45 | #endif /* _LINUX_TCP_H */ |
46 | diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h |
47 | index 622db6bc2f02..366e2a60010e 100644 |
48 | --- a/include/net/netns/ipv4.h |
49 | +++ b/include/net/netns/ipv4.h |
50 | @@ -114,6 +114,7 @@ struct netns_ipv4 { |
51 | #endif |
52 | int sysctl_tcp_mtu_probing; |
53 | int sysctl_tcp_base_mss; |
54 | + int sysctl_tcp_min_snd_mss; |
55 | int sysctl_tcp_probe_threshold; |
56 | u32 sysctl_tcp_probe_interval; |
57 | |
58 | diff --git a/include/net/tcp.h b/include/net/tcp.h |
59 | index 770917d0caa7..e75661f92daa 100644 |
60 | --- a/include/net/tcp.h |
61 | +++ b/include/net/tcp.h |
62 | @@ -55,6 +55,8 @@ void tcp_time_wait(struct sock *sk, int state, int timeo); |
63 | |
64 | #define MAX_TCP_HEADER (128 + MAX_HEADER) |
65 | #define MAX_TCP_OPTION_SPACE 40 |
66 | +#define TCP_MIN_SND_MSS 48 |
67 | +#define TCP_MIN_GSO_SIZE (TCP_MIN_SND_MSS - MAX_TCP_OPTION_SPACE) |
68 | |
69 | /* |
70 | * Never offer a window over 32767 without using window scaling. Some |
71 | diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h |
72 | index f80135e5feaa..abae27c3001c 100644 |
73 | --- a/include/uapi/linux/snmp.h |
74 | +++ b/include/uapi/linux/snmp.h |
75 | @@ -282,6 +282,7 @@ enum |
76 | LINUX_MIB_TCPACKCOMPRESSED, /* TCPAckCompressed */ |
77 | LINUX_MIB_TCPZEROWINDOWDROP, /* TCPZeroWindowDrop */ |
78 | LINUX_MIB_TCPRCVQDROP, /* TCPRcvQDrop */ |
79 | + LINUX_MIB_TCPWQUEUETOOBIG, /* TCPWqueueTooBig */ |
80 | __LINUX_MIB_MAX |
81 | }; |
82 | |
83 | diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c |
84 | index 70289682a670..eab5c02da8ae 100644 |
85 | --- a/net/ipv4/proc.c |
86 | +++ b/net/ipv4/proc.c |
87 | @@ -290,6 +290,7 @@ static const struct snmp_mib snmp4_net_list[] = { |
88 | SNMP_MIB_ITEM("TCPAckCompressed", LINUX_MIB_TCPACKCOMPRESSED), |
89 | SNMP_MIB_ITEM("TCPZeroWindowDrop", LINUX_MIB_TCPZEROWINDOWDROP), |
90 | SNMP_MIB_ITEM("TCPRcvQDrop", LINUX_MIB_TCPRCVQDROP), |
91 | + SNMP_MIB_ITEM("TCPWqueueTooBig", LINUX_MIB_TCPWQUEUETOOBIG), |
92 | SNMP_MIB_SENTINEL |
93 | }; |
94 | |
95 | diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c |
96 | index ce64453d337d..ad132b6e8cfa 100644 |
97 | --- a/net/ipv4/sysctl_net_ipv4.c |
98 | +++ b/net/ipv4/sysctl_net_ipv4.c |
99 | @@ -39,6 +39,8 @@ static int ip_local_port_range_min[] = { 1, 1 }; |
100 | static int ip_local_port_range_max[] = { 65535, 65535 }; |
101 | static int tcp_adv_win_scale_min = -31; |
102 | static int tcp_adv_win_scale_max = 31; |
103 | +static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS; |
104 | +static int tcp_min_snd_mss_max = 65535; |
105 | static int ip_privileged_port_min; |
106 | static int ip_privileged_port_max = 65535; |
107 | static int ip_ttl_min = 1; |
108 | @@ -737,6 +739,15 @@ static struct ctl_table ipv4_net_table[] = { |
109 | .mode = 0644, |
110 | .proc_handler = proc_dointvec, |
111 | }, |
112 | + { |
113 | + .procname = "tcp_min_snd_mss", |
114 | + .data = &init_net.ipv4.sysctl_tcp_min_snd_mss, |
115 | + .maxlen = sizeof(int), |
116 | + .mode = 0644, |
117 | + .proc_handler = proc_dointvec_minmax, |
118 | + .extra1 = &tcp_min_snd_mss_min, |
119 | + .extra2 = &tcp_min_snd_mss_max, |
120 | + }, |
121 | { |
122 | .procname = "tcp_probe_threshold", |
123 | .data = &init_net.ipv4.sysctl_tcp_probe_threshold, |
124 | diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c |
125 | index 30c6e94b06c4..364e6fdaa38f 100644 |
126 | --- a/net/ipv4/tcp.c |
127 | +++ b/net/ipv4/tcp.c |
128 | @@ -3829,6 +3829,7 @@ void __init tcp_init(void) |
129 | unsigned long limit; |
130 | unsigned int i; |
131 | |
132 | + BUILD_BUG_ON(TCP_MIN_SND_MSS <= MAX_TCP_OPTION_SPACE); |
133 | BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > |
134 | FIELD_SIZEOF(struct sk_buff, cb)); |
135 | |
136 | diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c |
137 | index cfdd70e32755..4a8869d39662 100644 |
138 | --- a/net/ipv4/tcp_input.c |
139 | +++ b/net/ipv4/tcp_input.c |
140 | @@ -1315,7 +1315,7 @@ static bool tcp_shifted_skb(struct sock *sk, struct sk_buff *prev, |
141 | TCP_SKB_CB(skb)->seq += shifted; |
142 | |
143 | tcp_skb_pcount_add(prev, pcount); |
144 | - BUG_ON(tcp_skb_pcount(skb) < pcount); |
145 | + WARN_ON_ONCE(tcp_skb_pcount(skb) < pcount); |
146 | tcp_skb_pcount_add(skb, -pcount); |
147 | |
148 | /* When we're adding to gso_segs == 1, gso_size will be zero, |
149 | @@ -1381,6 +1381,21 @@ static int skb_can_shift(const struct sk_buff *skb) |
150 | return !skb_headlen(skb) && skb_is_nonlinear(skb); |
151 | } |
152 | |
153 | +int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, |
154 | + int pcount, int shiftlen) |
155 | +{ |
156 | + /* TCP min gso_size is 8 bytes (TCP_MIN_GSO_SIZE) |
157 | + * Since TCP_SKB_CB(skb)->tcp_gso_segs is 16 bits, we need |
158 | + * to make sure not storing more than 65535 * 8 bytes per skb, |
159 | + * even if current MSS is bigger. |
160 | + */ |
161 | + if (unlikely(to->len + shiftlen >= 65535 * TCP_MIN_GSO_SIZE)) |
162 | + return 0; |
163 | + if (unlikely(tcp_skb_pcount(to) + pcount > 65535)) |
164 | + return 0; |
165 | + return skb_shift(to, from, shiftlen); |
166 | +} |
167 | + |
168 | /* Try collapsing SACK blocks spanning across multiple skbs to a single |
169 | * skb. |
170 | */ |
171 | @@ -1486,7 +1501,7 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, |
172 | if (!after(TCP_SKB_CB(skb)->seq + len, tp->snd_una)) |
173 | goto fallback; |
174 | |
175 | - if (!skb_shift(prev, skb, len)) |
176 | + if (!tcp_skb_shift(prev, skb, pcount, len)) |
177 | goto fallback; |
178 | if (!tcp_shifted_skb(sk, prev, skb, state, pcount, len, mss, dup_sack)) |
179 | goto out; |
180 | @@ -1504,11 +1519,10 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, |
181 | goto out; |
182 | |
183 | len = skb->len; |
184 | - if (skb_shift(prev, skb, len)) { |
185 | - pcount += tcp_skb_pcount(skb); |
186 | - tcp_shifted_skb(sk, prev, skb, state, tcp_skb_pcount(skb), |
187 | + pcount = tcp_skb_pcount(skb); |
188 | + if (tcp_skb_shift(prev, skb, pcount, len)) |
189 | + tcp_shifted_skb(sk, prev, skb, state, pcount, |
190 | len, mss, 0); |
191 | - } |
192 | |
193 | out: |
194 | return prev; |
195 | diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c |
196 | index 11101cf8693b..b76cf96d5cfe 100644 |
197 | --- a/net/ipv4/tcp_ipv4.c |
198 | +++ b/net/ipv4/tcp_ipv4.c |
199 | @@ -2527,6 +2527,7 @@ static int __net_init tcp_sk_init(struct net *net) |
200 | net->ipv4.sysctl_tcp_ecn_fallback = 1; |
201 | |
202 | net->ipv4.sysctl_tcp_base_mss = TCP_BASE_MSS; |
203 | + net->ipv4.sysctl_tcp_min_snd_mss = TCP_MIN_SND_MSS; |
204 | net->ipv4.sysctl_tcp_probe_threshold = TCP_PROBE_THRESHOLD; |
205 | net->ipv4.sysctl_tcp_probe_interval = TCP_PROBE_INTERVAL; |
206 | |
207 | diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c |
208 | index bd134e3a0473..147ed82b73d3 100644 |
209 | --- a/net/ipv4/tcp_output.c |
210 | +++ b/net/ipv4/tcp_output.c |
211 | @@ -1299,6 +1299,11 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, |
212 | if (nsize < 0) |
213 | nsize = 0; |
214 | |
215 | + if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf)) { |
216 | + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG); |
217 | + return -ENOMEM; |
218 | + } |
219 | + |
220 | if (skb_unclone(skb, gfp)) |
221 | return -ENOMEM; |
222 | |
223 | @@ -1457,8 +1462,7 @@ static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu) |
224 | mss_now -= icsk->icsk_ext_hdr_len; |
225 | |
226 | /* Then reserve room for full set of TCP options and 8 bytes of data */ |
227 | - if (mss_now < 48) |
228 | - mss_now = 48; |
229 | + mss_now = max(mss_now, sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss); |
230 | return mss_now; |
231 | } |
232 | |
233 | @@ -2727,7 +2731,7 @@ static bool tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb) |
234 | if (next_skb_size <= skb_availroom(skb)) |
235 | skb_copy_bits(next_skb, 0, skb_put(skb, next_skb_size), |
236 | next_skb_size); |
237 | - else if (!skb_shift(skb, next_skb, next_skb_size)) |
238 | + else if (!tcp_skb_shift(skb, next_skb, 1, next_skb_size)) |
239 | return false; |
240 | } |
241 | tcp_highest_sack_replace(sk, next_skb, skb); |
242 | diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c |
243 | index b1b5a648def6..17335a370e64 100644 |
244 | --- a/net/ipv4/tcp_timer.c |
245 | +++ b/net/ipv4/tcp_timer.c |
246 | @@ -166,6 +166,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) |
247 | mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; |
248 | mss = min(net->ipv4.sysctl_tcp_base_mss, mss); |
249 | mss = max(mss, 68 - tcp_sk(sk)->tcp_header_len); |
250 | + mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss); |
251 | icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss); |
252 | } |
253 | tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); |