Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.3 commit in: /
Date: Sat, 21 Sep 2019 15:53:48
Message-Id: 1569081196.bdd00b553c1319822d9f07df86de47f812b2fbea.mpagano@gentoo
1 commit: bdd00b553c1319822d9f07df86de47f812b2fbea
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 21 15:53:16 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 21 15:53:16 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=bdd00b55
7
8 Linux patch 5.3.1
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1000_linux-5.3.1.patch | 1081 ++++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 1085 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 4403e5a..f9d1f15 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -43,6 +43,10 @@ EXPERIMENTAL
21 Individual Patch Descriptions:
22 --------------------------------------------------------------------------
23
24 +Patch: 1000_linux-5.3.1.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.3.1
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1000_linux-5.3.1.patch b/1000_linux-5.3.1.patch
33 new file mode 100644
34 index 0000000..7d865ae
35 --- /dev/null
36 +++ b/1000_linux-5.3.1.patch
37 @@ -0,0 +1,1081 @@
38 +diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt
39 +index 1da2f1668f08..845d689e0fd7 100644
40 +--- a/Documentation/filesystems/overlayfs.txt
41 ++++ b/Documentation/filesystems/overlayfs.txt
42 +@@ -302,7 +302,7 @@ beneath or above the path of another overlay lower layer path.
43 +
44 + Using an upper layer path and/or a workdir path that are already used by
45 + another overlay mount is not allowed and may fail with EBUSY. Using
46 +-partially overlapping paths is not allowed but will not fail with EBUSY.
47 ++partially overlapping paths is not allowed and may fail with EBUSY.
48 + If files are accessed from two overlayfs mounts which share or overlap the
49 + upper layer and/or workdir path the behavior of the overlay is undefined,
50 + though it will not result in a crash or deadlock.
51 +diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/automarkup.py
52 +index 77e89c1956d7..a8798369e8f7 100644
53 +--- a/Documentation/sphinx/automarkup.py
54 ++++ b/Documentation/sphinx/automarkup.py
55 +@@ -25,7 +25,7 @@ RE_function = re.compile(r'([\w_][\w\d_]+\(\))')
56 + # to the creation of incorrect and confusing cross references. So
57 + # just don't even try with these names.
58 + #
59 +-Skipfuncs = [ 'open', 'close', 'read', 'write', 'fcntl', 'mmap'
60 ++Skipfuncs = [ 'open', 'close', 'read', 'write', 'fcntl', 'mmap',
61 + 'select', 'poll', 'fork', 'execve', 'clone', 'ioctl']
62 +
63 + #
64 +diff --git a/Makefile b/Makefile
65 +index 6886f22902c9..f32e8d2e09c3 100644
66 +--- a/Makefile
67 ++++ b/Makefile
68 +@@ -1,7 +1,7 @@
69 + # SPDX-License-Identifier: GPL-2.0
70 + VERSION = 5
71 + PATCHLEVEL = 3
72 +-SUBLEVEL = 0
73 ++SUBLEVEL = 1
74 + EXTRAVERSION =
75 + NAME = Bobtail Squid
76 +
77 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
78 +index e09760ece844..8eb5c0fbdee6 100644
79 +--- a/arch/arm64/include/asm/pgtable.h
80 ++++ b/arch/arm64/include/asm/pgtable.h
81 +@@ -220,8 +220,10 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
82 + * Only if the new pte is valid and kernel, otherwise TLB maintenance
83 + * or update_mmu_cache() have the necessary barriers.
84 + */
85 +- if (pte_valid_not_user(pte))
86 ++ if (pte_valid_not_user(pte)) {
87 + dsb(ishst);
88 ++ isb();
89 ++ }
90 + }
91 +
92 + extern void __sync_icache_dcache(pte_t pteval);
93 +@@ -484,8 +486,10 @@ static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
94 +
95 + WRITE_ONCE(*pmdp, pmd);
96 +
97 +- if (pmd_valid(pmd))
98 ++ if (pmd_valid(pmd)) {
99 + dsb(ishst);
100 ++ isb();
101 ++ }
102 + }
103 +
104 + static inline void pmd_clear(pmd_t *pmdp)
105 +@@ -543,8 +547,10 @@ static inline void set_pud(pud_t *pudp, pud_t pud)
106 +
107 + WRITE_ONCE(*pudp, pud);
108 +
109 +- if (pud_valid(pud))
110 ++ if (pud_valid(pud)) {
111 + dsb(ishst);
112 ++ isb();
113 ++ }
114 + }
115 +
116 + static inline void pud_clear(pud_t *pudp)
117 +diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
118 +index 0469aceaa230..485865fd0412 100644
119 +--- a/drivers/block/floppy.c
120 ++++ b/drivers/block/floppy.c
121 +@@ -3780,7 +3780,7 @@ static int compat_getdrvprm(int drive,
122 + v.native_format = UDP->native_format;
123 + mutex_unlock(&floppy_mutex);
124 +
125 +- if (copy_from_user(arg, &v, sizeof(struct compat_floppy_drive_params)))
126 ++ if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_params)))
127 + return -EFAULT;
128 + return 0;
129 + }
130 +@@ -3816,7 +3816,7 @@ static int compat_getdrvstat(int drive, bool poll,
131 + v.bufblocks = UDRS->bufblocks;
132 + mutex_unlock(&floppy_mutex);
133 +
134 +- if (copy_from_user(arg, &v, sizeof(struct compat_floppy_drive_struct)))
135 ++ if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_struct)))
136 + return -EFAULT;
137 + return 0;
138 + Eintr:
139 +diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
140 +index 0739f3b70347..db0812263d46 100644
141 +--- a/drivers/firmware/google/vpd.c
142 ++++ b/drivers/firmware/google/vpd.c
143 +@@ -92,8 +92,8 @@ static int vpd_section_check_key_name(const u8 *key, s32 key_len)
144 + return VPD_OK;
145 + }
146 +
147 +-static int vpd_section_attrib_add(const u8 *key, s32 key_len,
148 +- const u8 *value, s32 value_len,
149 ++static int vpd_section_attrib_add(const u8 *key, u32 key_len,
150 ++ const u8 *value, u32 value_len,
151 + void *arg)
152 + {
153 + int ret;
154 +diff --git a/drivers/firmware/google/vpd_decode.c b/drivers/firmware/google/vpd_decode.c
155 +index 92e3258552fc..dda525c0f968 100644
156 +--- a/drivers/firmware/google/vpd_decode.c
157 ++++ b/drivers/firmware/google/vpd_decode.c
158 +@@ -9,8 +9,8 @@
159 +
160 + #include "vpd_decode.h"
161 +
162 +-static int vpd_decode_len(const s32 max_len, const u8 *in,
163 +- s32 *length, s32 *decoded_len)
164 ++static int vpd_decode_len(const u32 max_len, const u8 *in,
165 ++ u32 *length, u32 *decoded_len)
166 + {
167 + u8 more;
168 + int i = 0;
169 +@@ -30,18 +30,39 @@ static int vpd_decode_len(const s32 max_len, const u8 *in,
170 + } while (more);
171 +
172 + *decoded_len = i;
173 ++ return VPD_OK;
174 ++}
175 ++
176 ++static int vpd_decode_entry(const u32 max_len, const u8 *input_buf,
177 ++ u32 *_consumed, const u8 **entry, u32 *entry_len)
178 ++{
179 ++ u32 decoded_len;
180 ++ u32 consumed = *_consumed;
181 ++
182 ++ if (vpd_decode_len(max_len - consumed, &input_buf[consumed],
183 ++ entry_len, &decoded_len) != VPD_OK)
184 ++ return VPD_FAIL;
185 ++ if (max_len - consumed < decoded_len)
186 ++ return VPD_FAIL;
187 ++
188 ++ consumed += decoded_len;
189 ++ *entry = input_buf + consumed;
190 ++
191 ++ /* entry_len is untrusted data and must be checked again. */
192 ++ if (max_len - consumed < *entry_len)
193 ++ return VPD_FAIL;
194 +
195 ++ consumed += decoded_len;
196 ++ *_consumed = consumed;
197 + return VPD_OK;
198 + }
199 +
200 +-int vpd_decode_string(const s32 max_len, const u8 *input_buf, s32 *consumed,
201 ++int vpd_decode_string(const u32 max_len, const u8 *input_buf, u32 *consumed,
202 + vpd_decode_callback callback, void *callback_arg)
203 + {
204 + int type;
205 +- int res;
206 +- s32 key_len;
207 +- s32 value_len;
208 +- s32 decoded_len;
209 ++ u32 key_len;
210 ++ u32 value_len;
211 + const u8 *key;
212 + const u8 *value;
213 +
214 +@@ -56,26 +77,14 @@ int vpd_decode_string(const s32 max_len, const u8 *input_buf, s32 *consumed,
215 + case VPD_TYPE_STRING:
216 + (*consumed)++;
217 +
218 +- /* key */
219 +- res = vpd_decode_len(max_len - *consumed, &input_buf[*consumed],
220 +- &key_len, &decoded_len);
221 +- if (res != VPD_OK || *consumed + decoded_len >= max_len)
222 ++ if (vpd_decode_entry(max_len, input_buf, consumed, &key,
223 ++ &key_len) != VPD_OK)
224 + return VPD_FAIL;
225 +
226 +- *consumed += decoded_len;
227 +- key = &input_buf[*consumed];
228 +- *consumed += key_len;
229 +-
230 +- /* value */
231 +- res = vpd_decode_len(max_len - *consumed, &input_buf[*consumed],
232 +- &value_len, &decoded_len);
233 +- if (res != VPD_OK || *consumed + decoded_len > max_len)
234 ++ if (vpd_decode_entry(max_len, input_buf, consumed, &value,
235 ++ &value_len) != VPD_OK)
236 + return VPD_FAIL;
237 +
238 +- *consumed += decoded_len;
239 +- value = &input_buf[*consumed];
240 +- *consumed += value_len;
241 +-
242 + if (type == VPD_TYPE_STRING)
243 + return callback(key, key_len, value, value_len,
244 + callback_arg);
245 +diff --git a/drivers/firmware/google/vpd_decode.h b/drivers/firmware/google/vpd_decode.h
246 +index cf8c2ace155a..8dbe41cac599 100644
247 +--- a/drivers/firmware/google/vpd_decode.h
248 ++++ b/drivers/firmware/google/vpd_decode.h
249 +@@ -25,8 +25,8 @@ enum {
250 + };
251 +
252 + /* Callback for vpd_decode_string to invoke. */
253 +-typedef int vpd_decode_callback(const u8 *key, s32 key_len,
254 +- const u8 *value, s32 value_len,
255 ++typedef int vpd_decode_callback(const u8 *key, u32 key_len,
256 ++ const u8 *value, u32 value_len,
257 + void *arg);
258 +
259 + /*
260 +@@ -44,7 +44,7 @@ typedef int vpd_decode_callback(const u8 *key, s32 key_len,
261 + * If one entry is successfully decoded, sends it to callback and returns the
262 + * result.
263 + */
264 +-int vpd_decode_string(const s32 max_len, const u8 *input_buf, s32 *consumed,
265 ++int vpd_decode_string(const u32 max_len, const u8 *input_buf, u32 *consumed,
266 + vpd_decode_callback callback, void *callback_arg);
267 +
268 + #endif /* __VPD_DECODE_H */
269 +diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
270 +index c659e18b358b..676d233d46d5 100644
271 +--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
272 ++++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
273 +@@ -608,10 +608,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
274 + static int technisat_usb2_get_ir(struct dvb_usb_device *d)
275 + {
276 + struct technisat_usb2_state *state = d->priv;
277 +- u8 *buf = state->buf;
278 +- u8 *b;
279 +- int ret;
280 + struct ir_raw_event ev;
281 ++ u8 *buf = state->buf;
282 ++ int i, ret;
283 +
284 + buf[0] = GET_IR_DATA_VENDOR_REQUEST;
285 + buf[1] = 0x08;
286 +@@ -647,26 +646,25 @@ unlock:
287 + return 0; /* no key pressed */
288 +
289 + /* decoding */
290 +- b = buf+1;
291 +
292 + #if 0
293 + deb_rc("RC: %d ", ret);
294 +- debug_dump(b, ret, deb_rc);
295 ++ debug_dump(buf + 1, ret, deb_rc);
296 + #endif
297 +
298 + ev.pulse = 0;
299 +- while (1) {
300 +- ev.pulse = !ev.pulse;
301 +- ev.duration = (*b * FIRMWARE_CLOCK_DIVISOR * FIRMWARE_CLOCK_TICK) / 1000;
302 +- ir_raw_event_store(d->rc_dev, &ev);
303 +-
304 +- b++;
305 +- if (*b == 0xff) {
306 ++ for (i = 1; i < ARRAY_SIZE(state->buf); i++) {
307 ++ if (buf[i] == 0xff) {
308 + ev.pulse = 0;
309 + ev.duration = 888888*2;
310 + ir_raw_event_store(d->rc_dev, &ev);
311 + break;
312 + }
313 ++
314 ++ ev.pulse = !ev.pulse;
315 ++ ev.duration = (buf[i] * FIRMWARE_CLOCK_DIVISOR *
316 ++ FIRMWARE_CLOCK_TICK) / 1000;
317 ++ ir_raw_event_store(d->rc_dev, &ev);
318 + }
319 +
320 + ir_raw_event_handle(d->rc_dev);
321 +diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c
322 +index e4d2dcd5cc0f..19c90fa9e443 100644
323 +--- a/drivers/media/usb/tm6000/tm6000-dvb.c
324 ++++ b/drivers/media/usb/tm6000/tm6000-dvb.c
325 +@@ -97,6 +97,7 @@ static void tm6000_urb_received(struct urb *urb)
326 + printk(KERN_ERR "tm6000: error %s\n", __func__);
327 + kfree(urb->transfer_buffer);
328 + usb_free_urb(urb);
329 ++ dev->dvb->bulk_urb = NULL;
330 + }
331 + }
332 + }
333 +@@ -127,6 +128,7 @@ static int tm6000_start_stream(struct tm6000_core *dev)
334 + dvb->bulk_urb->transfer_buffer = kzalloc(size, GFP_KERNEL);
335 + if (!dvb->bulk_urb->transfer_buffer) {
336 + usb_free_urb(dvb->bulk_urb);
337 ++ dvb->bulk_urb = NULL;
338 + return -ENOMEM;
339 + }
340 +
341 +@@ -153,6 +155,7 @@ static int tm6000_start_stream(struct tm6000_core *dev)
342 +
343 + kfree(dvb->bulk_urb->transfer_buffer);
344 + usb_free_urb(dvb->bulk_urb);
345 ++ dvb->bulk_urb = NULL;
346 + return ret;
347 + }
348 +
349 +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
350 +index fd54c7c87485..b19ab09cb18f 100644
351 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
352 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
353 +@@ -4451,10 +4451,12 @@ int stmmac_suspend(struct device *dev)
354 + if (!ndev || !netif_running(ndev))
355 + return 0;
356 +
357 +- phylink_stop(priv->phylink);
358 +-
359 + mutex_lock(&priv->lock);
360 +
361 ++ rtnl_lock();
362 ++ phylink_stop(priv->phylink);
363 ++ rtnl_unlock();
364 ++
365 + netif_device_detach(ndev);
366 + stmmac_stop_all_queues(priv);
367 +
368 +@@ -4558,9 +4560,11 @@ int stmmac_resume(struct device *dev)
369 +
370 + stmmac_start_all_queues(priv);
371 +
372 +- mutex_unlock(&priv->lock);
373 +-
374 ++ rtnl_lock();
375 + phylink_start(priv->phylink);
376 ++ rtnl_unlock();
377 ++
378 ++ mutex_unlock(&priv->lock);
379 +
380 + return 0;
381 + }
382 +diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
383 +index 8d33970a2950..5f5722bf6762 100644
384 +--- a/drivers/net/xen-netfront.c
385 ++++ b/drivers/net/xen-netfront.c
386 +@@ -906,7 +906,7 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
387 + __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
388 + }
389 + if (unlikely(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS)) {
390 +- queue->rx.rsp_cons = ++cons;
391 ++ queue->rx.rsp_cons = ++cons + skb_queue_len(list);
392 + kfree_skb(nskb);
393 + return ~0U;
394 + }
395 +diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c
396 +index 34ff6434da8f..6bb49cc25c63 100644
397 +--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
398 ++++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
399 +@@ -35,7 +35,7 @@
400 + #define PLL_READY_GATE_EN BIT(3)
401 + /* QPHY_PCS_STATUS bit */
402 + #define PHYSTATUS BIT(6)
403 +-/* QPHY_COM_PCS_READY_STATUS bit */
404 ++/* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */
405 + #define PCS_READY BIT(0)
406 +
407 + /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */
408 +@@ -115,6 +115,7 @@ enum qphy_reg_layout {
409 + QPHY_SW_RESET,
410 + QPHY_START_CTRL,
411 + QPHY_PCS_READY_STATUS,
412 ++ QPHY_PCS_STATUS,
413 + QPHY_PCS_AUTONOMOUS_MODE_CTRL,
414 + QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR,
415 + QPHY_PCS_LFPS_RXTERM_IRQ_STATUS,
416 +@@ -133,7 +134,7 @@ static const unsigned int pciephy_regs_layout[] = {
417 + [QPHY_FLL_MAN_CODE] = 0xd4,
418 + [QPHY_SW_RESET] = 0x00,
419 + [QPHY_START_CTRL] = 0x08,
420 +- [QPHY_PCS_READY_STATUS] = 0x174,
421 ++ [QPHY_PCS_STATUS] = 0x174,
422 + };
423 +
424 + static const unsigned int usb3phy_regs_layout[] = {
425 +@@ -144,7 +145,7 @@ static const unsigned int usb3phy_regs_layout[] = {
426 + [QPHY_FLL_MAN_CODE] = 0xd0,
427 + [QPHY_SW_RESET] = 0x00,
428 + [QPHY_START_CTRL] = 0x08,
429 +- [QPHY_PCS_READY_STATUS] = 0x17c,
430 ++ [QPHY_PCS_STATUS] = 0x17c,
431 + [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d4,
432 + [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0d8,
433 + [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x178,
434 +@@ -153,7 +154,7 @@ static const unsigned int usb3phy_regs_layout[] = {
435 + static const unsigned int qmp_v3_usb3phy_regs_layout[] = {
436 + [QPHY_SW_RESET] = 0x00,
437 + [QPHY_START_CTRL] = 0x08,
438 +- [QPHY_PCS_READY_STATUS] = 0x174,
439 ++ [QPHY_PCS_STATUS] = 0x174,
440 + [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d8,
441 + [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0dc,
442 + [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x170,
443 +@@ -911,7 +912,6 @@ struct qmp_phy_cfg {
444 +
445 + unsigned int start_ctrl;
446 + unsigned int pwrdn_ctrl;
447 +- unsigned int mask_pcs_ready;
448 + unsigned int mask_com_pcs_ready;
449 +
450 + /* true, if PHY has a separate PHY_COM control block */
451 +@@ -1074,7 +1074,6 @@ static const struct qmp_phy_cfg msm8996_pciephy_cfg = {
452 +
453 + .start_ctrl = PCS_START | PLL_READY_GATE_EN,
454 + .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL,
455 +- .mask_pcs_ready = PHYSTATUS,
456 + .mask_com_pcs_ready = PCS_READY,
457 +
458 + .has_phy_com_ctrl = true,
459 +@@ -1106,7 +1105,6 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
460 +
461 + .start_ctrl = SERDES_START | PCS_START,
462 + .pwrdn_ctrl = SW_PWRDN,
463 +- .mask_pcs_ready = PHYSTATUS,
464 + };
465 +
466 + /* list of resets */
467 +@@ -1136,7 +1134,6 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
468 +
469 + .start_ctrl = SERDES_START | PCS_START,
470 + .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL,
471 +- .mask_pcs_ready = PHYSTATUS,
472 +
473 + .has_phy_com_ctrl = false,
474 + .has_lane_rst = false,
475 +@@ -1167,7 +1164,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = {
476 +
477 + .start_ctrl = SERDES_START | PCS_START,
478 + .pwrdn_ctrl = SW_PWRDN,
479 +- .mask_pcs_ready = PHYSTATUS,
480 +
481 + .has_pwrdn_delay = true,
482 + .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN,
483 +@@ -1199,7 +1195,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
484 +
485 + .start_ctrl = SERDES_START | PCS_START,
486 + .pwrdn_ctrl = SW_PWRDN,
487 +- .mask_pcs_ready = PHYSTATUS,
488 +
489 + .has_pwrdn_delay = true,
490 + .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN,
491 +@@ -1226,7 +1221,6 @@ static const struct qmp_phy_cfg sdm845_ufsphy_cfg = {
492 +
493 + .start_ctrl = SERDES_START,
494 + .pwrdn_ctrl = SW_PWRDN,
495 +- .mask_pcs_ready = PCS_READY,
496 +
497 + .is_dual_lane_phy = true,
498 + .no_pcs_sw_reset = true,
499 +@@ -1254,7 +1248,6 @@ static const struct qmp_phy_cfg msm8998_pciephy_cfg = {
500 +
501 + .start_ctrl = SERDES_START | PCS_START,
502 + .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL,
503 +- .mask_pcs_ready = PHYSTATUS,
504 + };
505 +
506 + static const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
507 +@@ -1279,7 +1272,6 @@ static const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
508 +
509 + .start_ctrl = SERDES_START | PCS_START,
510 + .pwrdn_ctrl = SW_PWRDN,
511 +- .mask_pcs_ready = PHYSTATUS,
512 +
513 + .is_dual_lane_phy = true,
514 + };
515 +@@ -1457,7 +1449,7 @@ static int qcom_qmp_phy_enable(struct phy *phy)
516 + void __iomem *pcs = qphy->pcs;
517 + void __iomem *dp_com = qmp->dp_com;
518 + void __iomem *status;
519 +- unsigned int mask, val;
520 ++ unsigned int mask, val, ready;
521 + int ret;
522 +
523 + dev_vdbg(qmp->dev, "Initializing QMP phy\n");
524 +@@ -1545,10 +1537,17 @@ static int qcom_qmp_phy_enable(struct phy *phy)
525 + /* start SerDes and Phy-Coding-Sublayer */
526 + qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
527 +
528 +- status = pcs + cfg->regs[QPHY_PCS_READY_STATUS];
529 +- mask = cfg->mask_pcs_ready;
530 ++ if (cfg->type == PHY_TYPE_UFS) {
531 ++ status = pcs + cfg->regs[QPHY_PCS_READY_STATUS];
532 ++ mask = PCS_READY;
533 ++ ready = PCS_READY;
534 ++ } else {
535 ++ status = pcs + cfg->regs[QPHY_PCS_STATUS];
536 ++ mask = PHYSTATUS;
537 ++ ready = 0;
538 ++ }
539 +
540 +- ret = readl_poll_timeout(status, val, val & mask, 10,
541 ++ ret = readl_poll_timeout(status, val, (val & mask) == ready, 10,
542 + PHY_INIT_COMPLETE_TIMEOUT);
543 + if (ret) {
544 + dev_err(qmp->dev, "phy initialization timed-out\n");
545 +diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
546 +index 8ffba67568ec..b7f6b1324395 100644
547 +--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
548 ++++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
549 +@@ -61,6 +61,7 @@
550 + USB2_OBINT_IDDIGCHG)
551 +
552 + /* VBCTRL */
553 ++#define USB2_VBCTRL_OCCLREN BIT(16)
554 + #define USB2_VBCTRL_DRVVBUSSEL BIT(8)
555 +
556 + /* LINECTRL1 */
557 +@@ -374,6 +375,7 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch)
558 + writel(val, usb2_base + USB2_LINECTRL1);
559 +
560 + val = readl(usb2_base + USB2_VBCTRL);
561 ++ val &= ~USB2_VBCTRL_OCCLREN;
562 + writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL);
563 + val = readl(usb2_base + USB2_ADPCTRL);
564 + writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL);
565 +diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
566 +index 0b4f36905321..8e667967928a 100644
567 +--- a/drivers/tty/serial/atmel_serial.c
568 ++++ b/drivers/tty/serial/atmel_serial.c
569 +@@ -1400,7 +1400,6 @@ atmel_handle_transmit(struct uart_port *port, unsigned int pending)
570 +
571 + atmel_port->hd_start_rx = false;
572 + atmel_start_rx(port);
573 +- return;
574 + }
575 +
576 + atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx);
577 +diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
578 +index 73d71a4e6c0c..f49b7d6fbc88 100644
579 +--- a/drivers/tty/serial/sprd_serial.c
580 ++++ b/drivers/tty/serial/sprd_serial.c
581 +@@ -609,7 +609,7 @@ static inline void sprd_rx(struct uart_port *port)
582 +
583 + if (lsr & (SPRD_LSR_BI | SPRD_LSR_PE |
584 + SPRD_LSR_FE | SPRD_LSR_OE))
585 +- if (handle_lsr_errors(port, &lsr, &flag))
586 ++ if (handle_lsr_errors(port, &flag, &lsr))
587 + continue;
588 + if (uart_handle_sysrq_char(port, ch))
589 + continue;
590 +diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
591 +index 9d6cb709ca7b..151a74a54386 100644
592 +--- a/drivers/usb/core/config.c
593 ++++ b/drivers/usb/core/config.c
594 +@@ -921,7 +921,7 @@ int usb_get_bos_descriptor(struct usb_device *dev)
595 + struct usb_bos_descriptor *bos;
596 + struct usb_dev_cap_header *cap;
597 + struct usb_ssp_cap_descriptor *ssp_cap;
598 +- unsigned char *buffer;
599 ++ unsigned char *buffer, *buffer0;
600 + int length, total_len, num, i, ssac;
601 + __u8 cap_type;
602 + int ret;
603 +@@ -966,10 +966,12 @@ int usb_get_bos_descriptor(struct usb_device *dev)
604 + ret = -ENOMSG;
605 + goto err;
606 + }
607 ++
608 ++ buffer0 = buffer;
609 + total_len -= length;
610 ++ buffer += length;
611 +
612 + for (i = 0; i < num; i++) {
613 +- buffer += length;
614 + cap = (struct usb_dev_cap_header *)buffer;
615 +
616 + if (total_len < sizeof(*cap) || total_len < cap->bLength) {
617 +@@ -983,8 +985,6 @@ int usb_get_bos_descriptor(struct usb_device *dev)
618 + break;
619 + }
620 +
621 +- total_len -= length;
622 +-
623 + if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
624 + dev_warn(ddev, "descriptor type invalid, skip\n");
625 + continue;
626 +@@ -1019,7 +1019,11 @@ int usb_get_bos_descriptor(struct usb_device *dev)
627 + default:
628 + break;
629 + }
630 ++
631 ++ total_len -= length;
632 ++ buffer += length;
633 + }
634 ++ dev->bos->desc->wTotalLength = cpu_to_le16(buffer - buffer0);
635 +
636 + return 0;
637 +
638 +diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
639 +index 28a2d12a1029..a8279280e88d 100644
640 +--- a/fs/overlayfs/ovl_entry.h
641 ++++ b/fs/overlayfs/ovl_entry.h
642 +@@ -66,6 +66,7 @@ struct ovl_fs {
643 + bool workdir_locked;
644 + /* Traps in ovl inode cache */
645 + struct inode *upperdir_trap;
646 ++ struct inode *workbasedir_trap;
647 + struct inode *workdir_trap;
648 + struct inode *indexdir_trap;
649 + /* Inode numbers in all layers do not use the high xino_bits */
650 +diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
651 +index b368e2e102fa..afbcb116a7f1 100644
652 +--- a/fs/overlayfs/super.c
653 ++++ b/fs/overlayfs/super.c
654 +@@ -212,6 +212,7 @@ static void ovl_free_fs(struct ovl_fs *ofs)
655 + {
656 + unsigned i;
657 +
658 ++ iput(ofs->workbasedir_trap);
659 + iput(ofs->indexdir_trap);
660 + iput(ofs->workdir_trap);
661 + iput(ofs->upperdir_trap);
662 +@@ -1003,6 +1004,25 @@ static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,
663 + return 0;
664 + }
665 +
666 ++/*
667 ++ * Determine how we treat concurrent use of upperdir/workdir based on the
668 ++ * index feature. This is papering over mount leaks of container runtimes,
669 ++ * for example, an old overlay mount is leaked and now its upperdir is
670 ++ * attempted to be used as a lower layer in a new overlay mount.
671 ++ */
672 ++static int ovl_report_in_use(struct ovl_fs *ofs, const char *name)
673 ++{
674 ++ if (ofs->config.index) {
675 ++ pr_err("overlayfs: %s is in-use as upperdir/workdir of another mount, mount with '-o index=off' to override exclusive upperdir protection.\n",
676 ++ name);
677 ++ return -EBUSY;
678 ++ } else {
679 ++ pr_warn("overlayfs: %s is in-use as upperdir/workdir of another mount, accessing files from both mounts will result in undefined behavior.\n",
680 ++ name);
681 ++ return 0;
682 ++ }
683 ++}
684 ++
685 + static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
686 + struct path *upperpath)
687 + {
688 +@@ -1040,14 +1060,12 @@ static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
689 + upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME);
690 + ofs->upper_mnt = upper_mnt;
691 +
692 +- err = -EBUSY;
693 + if (ovl_inuse_trylock(ofs->upper_mnt->mnt_root)) {
694 + ofs->upperdir_locked = true;
695 +- } else if (ofs->config.index) {
696 +- pr_err("overlayfs: upperdir is in-use by another mount, mount with '-o index=off' to override exclusive upperdir protection.\n");
697 +- goto out;
698 + } else {
699 +- pr_warn("overlayfs: upperdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
700 ++ err = ovl_report_in_use(ofs, "upperdir");
701 ++ if (err)
702 ++ goto out;
703 + }
704 +
705 + err = 0;
706 +@@ -1157,16 +1175,19 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ofs,
707 +
708 + ofs->workbasedir = dget(workpath.dentry);
709 +
710 +- err = -EBUSY;
711 + if (ovl_inuse_trylock(ofs->workbasedir)) {
712 + ofs->workdir_locked = true;
713 +- } else if (ofs->config.index) {
714 +- pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n");
715 +- goto out;
716 + } else {
717 +- pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
718 ++ err = ovl_report_in_use(ofs, "workdir");
719 ++ if (err)
720 ++ goto out;
721 + }
722 +
723 ++ err = ovl_setup_trap(sb, ofs->workbasedir, &ofs->workbasedir_trap,
724 ++ "workdir");
725 ++ if (err)
726 ++ goto out;
727 ++
728 + err = ovl_make_workdir(sb, ofs, &workpath);
729 +
730 + out:
731 +@@ -1313,16 +1334,16 @@ static int ovl_get_lower_layers(struct super_block *sb, struct ovl_fs *ofs,
732 + if (err < 0)
733 + goto out;
734 +
735 +- err = -EBUSY;
736 +- if (ovl_is_inuse(stack[i].dentry)) {
737 +- pr_err("overlayfs: lowerdir is in-use as upperdir/workdir\n");
738 +- goto out;
739 +- }
740 +-
741 + err = ovl_setup_trap(sb, stack[i].dentry, &trap, "lowerdir");
742 + if (err)
743 + goto out;
744 +
745 ++ if (ovl_is_inuse(stack[i].dentry)) {
746 ++ err = ovl_report_in_use(ofs, "lowerdir");
747 ++ if (err)
748 ++ goto out;
749 ++ }
750 ++
751 + mnt = clone_private_mount(&stack[i]);
752 + err = PTR_ERR(mnt);
753 + if (IS_ERR(mnt)) {
754 +@@ -1469,8 +1490,8 @@ out_err:
755 + * - another layer of this overlayfs instance
756 + * - upper/work dir of any overlayfs instance
757 + */
758 +-static int ovl_check_layer(struct super_block *sb, struct dentry *dentry,
759 +- const char *name)
760 ++static int ovl_check_layer(struct super_block *sb, struct ovl_fs *ofs,
761 ++ struct dentry *dentry, const char *name)
762 + {
763 + struct dentry *next = dentry, *parent;
764 + int err = 0;
765 +@@ -1482,13 +1503,11 @@ static int ovl_check_layer(struct super_block *sb, struct dentry *dentry,
766 +
767 + /* Walk back ancestors to root (inclusive) looking for traps */
768 + while (!err && parent != next) {
769 +- if (ovl_is_inuse(parent)) {
770 +- err = -EBUSY;
771 +- pr_err("overlayfs: %s path overlapping in-use upperdir/workdir\n",
772 +- name);
773 +- } else if (ovl_lookup_trap_inode(sb, parent)) {
774 ++ if (ovl_lookup_trap_inode(sb, parent)) {
775 + err = -ELOOP;
776 + pr_err("overlayfs: overlapping %s path\n", name);
777 ++ } else if (ovl_is_inuse(parent)) {
778 ++ err = ovl_report_in_use(ofs, name);
779 + }
780 + next = parent;
781 + parent = dget_parent(next);
782 +@@ -1509,7 +1528,8 @@ static int ovl_check_overlapping_layers(struct super_block *sb,
783 + int i, err;
784 +
785 + if (ofs->upper_mnt) {
786 +- err = ovl_check_layer(sb, ofs->upper_mnt->mnt_root, "upperdir");
787 ++ err = ovl_check_layer(sb, ofs, ofs->upper_mnt->mnt_root,
788 ++ "upperdir");
789 + if (err)
790 + return err;
791 +
792 +@@ -1520,13 +1540,14 @@ static int ovl_check_overlapping_layers(struct super_block *sb,
793 + * workbasedir. In that case, we already have their traps in
794 + * inode cache and we will catch that case on lookup.
795 + */
796 +- err = ovl_check_layer(sb, ofs->workbasedir, "workdir");
797 ++ err = ovl_check_layer(sb, ofs, ofs->workbasedir, "workdir");
798 + if (err)
799 + return err;
800 + }
801 +
802 + for (i = 0; i < ofs->numlower; i++) {
803 +- err = ovl_check_layer(sb, ofs->lower_layers[i].mnt->mnt_root,
804 ++ err = ovl_check_layer(sb, ofs,
805 ++ ofs->lower_layers[i].mnt->mnt_root,
806 + "lowerdir");
807 + if (err)
808 + return err;
809 +diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
810 +index a16fbe9a2a67..aa99c73c3fbd 100644
811 +--- a/include/net/pkt_sched.h
812 ++++ b/include/net/pkt_sched.h
813 +@@ -118,7 +118,12 @@ void __qdisc_run(struct Qdisc *q);
814 + static inline void qdisc_run(struct Qdisc *q)
815 + {
816 + if (qdisc_run_begin(q)) {
817 +- __qdisc_run(q);
818 ++ /* NOLOCK qdisc must check 'state' under the qdisc seqlock
819 ++ * to avoid racing with dev_qdisc_reset()
820 ++ */
821 ++ if (!(q->flags & TCQ_F_NOLOCK) ||
822 ++ likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state)))
823 ++ __qdisc_run(q);
824 + qdisc_run_end(q);
825 + }
826 + }
827 +diff --git a/include/net/sock_reuseport.h b/include/net/sock_reuseport.h
828 +index d9112de85261..43f4a818d88f 100644
829 +--- a/include/net/sock_reuseport.h
830 ++++ b/include/net/sock_reuseport.h
831 +@@ -21,7 +21,8 @@ struct sock_reuseport {
832 + unsigned int synq_overflow_ts;
833 + /* ID stays the same even after the size of socks[] grows. */
834 + unsigned int reuseport_id;
835 +- bool bind_inany;
836 ++ unsigned int bind_inany:1;
837 ++ unsigned int has_conns:1;
838 + struct bpf_prog __rcu *prog; /* optional BPF sock selector */
839 + struct sock *socks[0]; /* array of sock pointers */
840 + };
841 +@@ -37,6 +38,23 @@ extern struct sock *reuseport_select_sock(struct sock *sk,
842 + extern int reuseport_attach_prog(struct sock *sk, struct bpf_prog *prog);
843 + extern int reuseport_detach_prog(struct sock *sk);
844 +
845 ++static inline bool reuseport_has_conns(struct sock *sk, bool set)
846 ++{
847 ++ struct sock_reuseport *reuse;
848 ++ bool ret = false;
849 ++
850 ++ rcu_read_lock();
851 ++ reuse = rcu_dereference(sk->sk_reuseport_cb);
852 ++ if (reuse) {
853 ++ if (set)
854 ++ reuse->has_conns = 1;
855 ++ ret = reuse->has_conns;
856 ++ }
857 ++ rcu_read_unlock();
858 ++
859 ++ return ret;
860 ++}
861 ++
862 + int reuseport_get_id(struct sock_reuseport *reuse);
863 +
864 + #endif /* _SOCK_REUSEPORT_H */
865 +diff --git a/net/core/dev.c b/net/core/dev.c
866 +index 5156c0edebe8..4ed9df74eb8a 100644
867 +--- a/net/core/dev.c
868 ++++ b/net/core/dev.c
869 +@@ -3467,18 +3467,22 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
870 + qdisc_calculate_pkt_len(skb, q);
871 +
872 + if (q->flags & TCQ_F_NOLOCK) {
873 +- if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) {
874 +- __qdisc_drop(skb, &to_free);
875 +- rc = NET_XMIT_DROP;
876 +- } else if ((q->flags & TCQ_F_CAN_BYPASS) && q->empty &&
877 +- qdisc_run_begin(q)) {
878 ++ if ((q->flags & TCQ_F_CAN_BYPASS) && q->empty &&
879 ++ qdisc_run_begin(q)) {
880 ++ if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED,
881 ++ &q->state))) {
882 ++ __qdisc_drop(skb, &to_free);
883 ++ rc = NET_XMIT_DROP;
884 ++ goto end_run;
885 ++ }
886 + qdisc_bstats_cpu_update(q, skb);
887 +
888 ++ rc = NET_XMIT_SUCCESS;
889 + if (sch_direct_xmit(skb, q, dev, txq, NULL, true))
890 + __qdisc_run(q);
891 +
892 ++end_run:
893 + qdisc_run_end(q);
894 +- rc = NET_XMIT_SUCCESS;
895 + } else {
896 + rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK;
897 + qdisc_run(q);
898 +diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
899 +index 9408f9264d05..f3ceec93f392 100644
900 +--- a/net/core/sock_reuseport.c
901 ++++ b/net/core/sock_reuseport.c
902 +@@ -295,8 +295,19 @@ struct sock *reuseport_select_sock(struct sock *sk,
903 +
904 + select_by_hash:
905 + /* no bpf or invalid bpf result: fall back to hash usage */
906 +- if (!sk2)
907 +- sk2 = reuse->socks[reciprocal_scale(hash, socks)];
908 ++ if (!sk2) {
909 ++ int i, j;
910 ++
911 ++ i = j = reciprocal_scale(hash, socks);
912 ++ while (reuse->socks[i]->sk_state == TCP_ESTABLISHED) {
913 ++ i++;
914 ++ if (i >= reuse->num_socks)
915 ++ i = 0;
916 ++ if (i == j)
917 ++ goto out;
918 ++ }
919 ++ sk2 = reuse->socks[i];
920 ++ }
921 + }
922 +
923 + out:
924 +diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
925 +index 3abd173ebacb..96f787cf9b6e 100644
926 +--- a/net/dsa/dsa2.c
927 ++++ b/net/dsa/dsa2.c
928 +@@ -623,6 +623,8 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master)
929 + tag_protocol = ds->ops->get_tag_protocol(ds, dp->index);
930 + tag_ops = dsa_tag_driver_get(tag_protocol);
931 + if (IS_ERR(tag_ops)) {
932 ++ if (PTR_ERR(tag_ops) == -ENOPROTOOPT)
933 ++ return -EPROBE_DEFER;
934 + dev_warn(ds->dev, "No tagger for this switch\n");
935 + return PTR_ERR(tag_ops);
936 + }
937 +diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
938 +index 7bd29e694603..9a0fe0c2fa02 100644
939 +--- a/net/ipv4/datagram.c
940 ++++ b/net/ipv4/datagram.c
941 +@@ -15,6 +15,7 @@
942 + #include <net/sock.h>
943 + #include <net/route.h>
944 + #include <net/tcp_states.h>
945 ++#include <net/sock_reuseport.h>
946 +
947 + int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
948 + {
949 +@@ -69,6 +70,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
950 + }
951 + inet->inet_daddr = fl4->daddr;
952 + inet->inet_dport = usin->sin_port;
953 ++ reuseport_has_conns(sk, true);
954 + sk->sk_state = TCP_ESTABLISHED;
955 + sk_set_txhash(sk);
956 + inet->inet_id = jiffies;
957 +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
958 +index d88821c794fb..16486c8b708b 100644
959 +--- a/net/ipv4/udp.c
960 ++++ b/net/ipv4/udp.c
961 +@@ -423,12 +423,13 @@ static struct sock *udp4_lib_lookup2(struct net *net,
962 + score = compute_score(sk, net, saddr, sport,
963 + daddr, hnum, dif, sdif);
964 + if (score > badness) {
965 +- if (sk->sk_reuseport) {
966 ++ if (sk->sk_reuseport &&
967 ++ sk->sk_state != TCP_ESTABLISHED) {
968 + hash = udp_ehashfn(net, daddr, hnum,
969 + saddr, sport);
970 + result = reuseport_select_sock(sk, hash, skb,
971 + sizeof(struct udphdr));
972 +- if (result)
973 ++ if (result && !reuseport_has_conns(sk, false))
974 + return result;
975 + }
976 + badness = score;
977 +diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
978 +index 9ab897ded4df..96f939248d2f 100644
979 +--- a/net/ipv6/datagram.c
980 ++++ b/net/ipv6/datagram.c
981 +@@ -27,6 +27,7 @@
982 + #include <net/ip6_route.h>
983 + #include <net/tcp_states.h>
984 + #include <net/dsfield.h>
985 ++#include <net/sock_reuseport.h>
986 +
987 + #include <linux/errqueue.h>
988 + #include <linux/uaccess.h>
989 +@@ -254,6 +255,7 @@ ipv4_connected:
990 + goto out;
991 + }
992 +
993 ++ reuseport_has_conns(sk, true);
994 + sk->sk_state = TCP_ESTABLISHED;
995 + sk_set_txhash(sk);
996 + out:
997 +diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
998 +index dd2d0b963260..d5779d6a6065 100644
999 +--- a/net/ipv6/ip6_gre.c
1000 ++++ b/net/ipv6/ip6_gre.c
1001 +@@ -968,7 +968,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
1002 + if (unlikely(!tun_info ||
1003 + !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
1004 + ip_tunnel_info_af(tun_info) != AF_INET6))
1005 +- return -EINVAL;
1006 ++ goto tx_err;
1007 +
1008 + key = &tun_info->key;
1009 + memset(&fl6, 0, sizeof(fl6));
1010 +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
1011 +index 827fe7385078..5995fdc99d3f 100644
1012 +--- a/net/ipv6/udp.c
1013 ++++ b/net/ipv6/udp.c
1014 +@@ -158,13 +158,14 @@ static struct sock *udp6_lib_lookup2(struct net *net,
1015 + score = compute_score(sk, net, saddr, sport,
1016 + daddr, hnum, dif, sdif);
1017 + if (score > badness) {
1018 +- if (sk->sk_reuseport) {
1019 ++ if (sk->sk_reuseport &&
1020 ++ sk->sk_state != TCP_ESTABLISHED) {
1021 + hash = udp6_ehashfn(net, daddr, hnum,
1022 + saddr, sport);
1023 +
1024 + result = reuseport_select_sock(sk, hash, skb,
1025 + sizeof(struct udphdr));
1026 +- if (result)
1027 ++ if (result && !reuseport_has_conns(sk, false))
1028 + return result;
1029 + }
1030 + result = sk;
1031 +diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
1032 +index ac28f6a5d70e..17bd8f539bc7 100644
1033 +--- a/net/sched/sch_generic.c
1034 ++++ b/net/sched/sch_generic.c
1035 +@@ -985,6 +985,9 @@ static void qdisc_destroy(struct Qdisc *qdisc)
1036 +
1037 + void qdisc_put(struct Qdisc *qdisc)
1038 + {
1039 ++ if (!qdisc)
1040 ++ return;
1041 ++
1042 + if (qdisc->flags & TCQ_F_BUILTIN ||
1043 + !refcount_dec_and_test(&qdisc->refcnt))
1044 + return;
1045 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
1046 +index fd05ae1437a9..c9cfc796eccf 100644
1047 +--- a/net/wireless/nl80211.c
1048 ++++ b/net/wireless/nl80211.c
1049 +@@ -10659,9 +10659,11 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
1050 + hyst = wdev->cqm_config->rssi_hyst;
1051 + n = wdev->cqm_config->n_rssi_thresholds;
1052 +
1053 +- for (i = 0; i < n; i++)
1054 ++ for (i = 0; i < n; i++) {
1055 ++ i = array_index_nospec(i, n);
1056 + if (last < wdev->cqm_config->rssi_thresholds[i])
1057 + break;
1058 ++ }
1059 +
1060 + low_index = i - 1;
1061 + if (low_index >= 0) {
1062 +diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
1063 +index 5294abb3f178..8ffd07e2a160 100644
1064 +--- a/virt/kvm/coalesced_mmio.c
1065 ++++ b/virt/kvm/coalesced_mmio.c
1066 +@@ -40,7 +40,7 @@ static int coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev,
1067 + return 1;
1068 + }
1069 +
1070 +-static int coalesced_mmio_has_room(struct kvm_coalesced_mmio_dev *dev)
1071 ++static int coalesced_mmio_has_room(struct kvm_coalesced_mmio_dev *dev, u32 last)
1072 + {
1073 + struct kvm_coalesced_mmio_ring *ring;
1074 + unsigned avail;
1075 +@@ -52,7 +52,7 @@ static int coalesced_mmio_has_room(struct kvm_coalesced_mmio_dev *dev)
1076 + * there is always one unused entry in the buffer
1077 + */
1078 + ring = dev->kvm->coalesced_mmio_ring;
1079 +- avail = (ring->first - ring->last - 1) % KVM_COALESCED_MMIO_MAX;
1080 ++ avail = (ring->first - last - 1) % KVM_COALESCED_MMIO_MAX;
1081 + if (avail == 0) {
1082 + /* full */
1083 + return 0;
1084 +@@ -67,25 +67,28 @@ static int coalesced_mmio_write(struct kvm_vcpu *vcpu,
1085 + {
1086 + struct kvm_coalesced_mmio_dev *dev = to_mmio(this);
1087 + struct kvm_coalesced_mmio_ring *ring = dev->kvm->coalesced_mmio_ring;
1088 ++ __u32 insert;
1089 +
1090 + if (!coalesced_mmio_in_range(dev, addr, len))
1091 + return -EOPNOTSUPP;
1092 +
1093 + spin_lock(&dev->kvm->ring_lock);
1094 +
1095 +- if (!coalesced_mmio_has_room(dev)) {
1096 ++ insert = READ_ONCE(ring->last);
1097 ++ if (!coalesced_mmio_has_room(dev, insert) ||
1098 ++ insert >= KVM_COALESCED_MMIO_MAX) {
1099 + spin_unlock(&dev->kvm->ring_lock);
1100 + return -EOPNOTSUPP;
1101 + }
1102 +
1103 + /* copy data in first free entry of the ring */
1104 +
1105 +- ring->coalesced_mmio[ring->last].phys_addr = addr;
1106 +- ring->coalesced_mmio[ring->last].len = len;
1107 +- memcpy(ring->coalesced_mmio[ring->last].data, val, len);
1108 +- ring->coalesced_mmio[ring->last].pio = dev->zone.pio;
1109 ++ ring->coalesced_mmio[insert].phys_addr = addr;
1110 ++ ring->coalesced_mmio[insert].len = len;
1111 ++ memcpy(ring->coalesced_mmio[insert].data, val, len);
1112 ++ ring->coalesced_mmio[insert].pio = dev->zone.pio;
1113 + smp_wmb();
1114 +- ring->last = (ring->last + 1) % KVM_COALESCED_MMIO_MAX;
1115 ++ ring->last = (insert + 1) % KVM_COALESCED_MMIO_MAX;
1116 + spin_unlock(&dev->kvm->ring_lock);
1117 + return 0;
1118 + }