Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Sun, 25 Aug 2019 17:34:21
Message-Id: 1566754438.68b3c0c8413c5ccec635b4d4bf996083d288ba4f.mpagano@gentoo
1 commit: 68b3c0c8413c5ccec635b4d4bf996083d288ba4f
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 25 17:33:58 2019 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 25 17:33:58 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=68b3c0c8
7
8 Linux patch 4.9.190
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1189_linux-4.9.190.patch | 4381 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4385 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 06f5715..9555d77 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -799,6 +799,10 @@ Patch: 1188_linux-4.9.189.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.9.189
23
24 +Patch: 1189_linux-4.9.190.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.9.190
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/1189_linux-4.9.190.patch b/1189_linux-4.9.190.patch
33 new file mode 100644
34 index 0000000..d34ee6d
35 --- /dev/null
36 +++ b/1189_linux-4.9.190.patch
37 @@ -0,0 +1,4381 @@
38 +diff --git a/Documentation/siphash.txt b/Documentation/siphash.txt
39 +new file mode 100644
40 +index 000000000000..908d348ff777
41 +--- /dev/null
42 ++++ b/Documentation/siphash.txt
43 +@@ -0,0 +1,175 @@
44 ++ SipHash - a short input PRF
45 ++-----------------------------------------------
46 ++Written by Jason A. Donenfeld <jason@×××××.com>
47 ++
48 ++SipHash is a cryptographically secure PRF -- a keyed hash function -- that
49 ++performs very well for short inputs, hence the name. It was designed by
50 ++cryptographers Daniel J. Bernstein and Jean-Philippe Aumasson. It is intended
51 ++as a replacement for some uses of: `jhash`, `md5_transform`, `sha_transform`,
52 ++and so forth.
53 ++
54 ++SipHash takes a secret key filled with randomly generated numbers and either
55 ++an input buffer or several input integers. It spits out an integer that is
56 ++indistinguishable from random. You may then use that integer as part of secure
57 ++sequence numbers, secure cookies, or mask it off for use in a hash table.
58 ++
59 ++1. Generating a key
60 ++
61 ++Keys should always be generated from a cryptographically secure source of
62 ++random numbers, either using get_random_bytes or get_random_once:
63 ++
64 ++siphash_key_t key;
65 ++get_random_bytes(&key, sizeof(key));
66 ++
67 ++If you're not deriving your key from here, you're doing it wrong.
68 ++
69 ++2. Using the functions
70 ++
71 ++There are two variants of the function, one that takes a list of integers, and
72 ++one that takes a buffer:
73 ++
74 ++u64 siphash(const void *data, size_t len, const siphash_key_t *key);
75 ++
76 ++And:
77 ++
78 ++u64 siphash_1u64(u64, const siphash_key_t *key);
79 ++u64 siphash_2u64(u64, u64, const siphash_key_t *key);
80 ++u64 siphash_3u64(u64, u64, u64, const siphash_key_t *key);
81 ++u64 siphash_4u64(u64, u64, u64, u64, const siphash_key_t *key);
82 ++u64 siphash_1u32(u32, const siphash_key_t *key);
83 ++u64 siphash_2u32(u32, u32, const siphash_key_t *key);
84 ++u64 siphash_3u32(u32, u32, u32, const siphash_key_t *key);
85 ++u64 siphash_4u32(u32, u32, u32, u32, const siphash_key_t *key);
86 ++
87 ++If you pass the generic siphash function something of a constant length, it
88 ++will constant fold at compile-time and automatically choose one of the
89 ++optimized functions.
90 ++
91 ++3. Hashtable key function usage:
92 ++
93 ++struct some_hashtable {
94 ++ DECLARE_HASHTABLE(hashtable, 8);
95 ++ siphash_key_t key;
96 ++};
97 ++
98 ++void init_hashtable(struct some_hashtable *table)
99 ++{
100 ++ get_random_bytes(&table->key, sizeof(table->key));
101 ++}
102 ++
103 ++static inline hlist_head *some_hashtable_bucket(struct some_hashtable *table, struct interesting_input *input)
104 ++{
105 ++ return &table->hashtable[siphash(input, sizeof(*input), &table->key) & (HASH_SIZE(table->hashtable) - 1)];
106 ++}
107 ++
108 ++You may then iterate like usual over the returned hash bucket.
109 ++
110 ++4. Security
111 ++
112 ++SipHash has a very high security margin, with its 128-bit key. So long as the
113 ++key is kept secret, it is impossible for an attacker to guess the outputs of
114 ++the function, even if being able to observe many outputs, since 2^128 outputs
115 ++is significant.
116 ++
117 ++Linux implements the "2-4" variant of SipHash.
118 ++
119 ++5. Struct-passing Pitfalls
120 ++
121 ++Often times the XuY functions will not be large enough, and instead you'll
122 ++want to pass a pre-filled struct to siphash. When doing this, it's important
123 ++to always ensure the struct has no padding holes. The easiest way to do this
124 ++is to simply arrange the members of the struct in descending order of size,
125 ++and to use offsetendof() instead of sizeof() for getting the size. For
126 ++performance reasons, if possible, it's probably a good thing to align the
127 ++struct to the right boundary. Here's an example:
128 ++
129 ++const struct {
130 ++ struct in6_addr saddr;
131 ++ u32 counter;
132 ++ u16 dport;
133 ++} __aligned(SIPHASH_ALIGNMENT) combined = {
134 ++ .saddr = *(struct in6_addr *)saddr,
135 ++ .counter = counter,
136 ++ .dport = dport
137 ++};
138 ++u64 h = siphash(&combined, offsetofend(typeof(combined), dport), &secret);
139 ++
140 ++6. Resources
141 ++
142 ++Read the SipHash paper if you're interested in learning more:
143 ++https://131002.net/siphash/siphash.pdf
144 ++
145 ++
146 ++~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
147 ++
148 ++HalfSipHash - SipHash's insecure younger cousin
149 ++-----------------------------------------------
150 ++Written by Jason A. Donenfeld <jason@×××××.com>
151 ++
152 ++On the off-chance that SipHash is not fast enough for your needs, you might be
153 ++able to justify using HalfSipHash, a terrifying but potentially useful
154 ++possibility. HalfSipHash cuts SipHash's rounds down from "2-4" to "1-3" and,
155 ++even scarier, uses an easily brute-forcable 64-bit key (with a 32-bit output)
156 ++instead of SipHash's 128-bit key. However, this may appeal to some
157 ++high-performance `jhash` users.
158 ++
159 ++Danger!
160 ++
161 ++Do not ever use HalfSipHash except for as a hashtable key function, and only
162 ++then when you can be absolutely certain that the outputs will never be
163 ++transmitted out of the kernel. This is only remotely useful over `jhash` as a
164 ++means of mitigating hashtable flooding denial of service attacks.
165 ++
166 ++1. Generating a key
167 ++
168 ++Keys should always be generated from a cryptographically secure source of
169 ++random numbers, either using get_random_bytes or get_random_once:
170 ++
171 ++hsiphash_key_t key;
172 ++get_random_bytes(&key, sizeof(key));
173 ++
174 ++If you're not deriving your key from here, you're doing it wrong.
175 ++
176 ++2. Using the functions
177 ++
178 ++There are two variants of the function, one that takes a list of integers, and
179 ++one that takes a buffer:
180 ++
181 ++u32 hsiphash(const void *data, size_t len, const hsiphash_key_t *key);
182 ++
183 ++And:
184 ++
185 ++u32 hsiphash_1u32(u32, const hsiphash_key_t *key);
186 ++u32 hsiphash_2u32(u32, u32, const hsiphash_key_t *key);
187 ++u32 hsiphash_3u32(u32, u32, u32, const hsiphash_key_t *key);
188 ++u32 hsiphash_4u32(u32, u32, u32, u32, const hsiphash_key_t *key);
189 ++
190 ++If you pass the generic hsiphash function something of a constant length, it
191 ++will constant fold at compile-time and automatically choose one of the
192 ++optimized functions.
193 ++
194 ++3. Hashtable key function usage:
195 ++
196 ++struct some_hashtable {
197 ++ DECLARE_HASHTABLE(hashtable, 8);
198 ++ hsiphash_key_t key;
199 ++};
200 ++
201 ++void init_hashtable(struct some_hashtable *table)
202 ++{
203 ++ get_random_bytes(&table->key, sizeof(table->key));
204 ++}
205 ++
206 ++static inline hlist_head *some_hashtable_bucket(struct some_hashtable *table, struct interesting_input *input)
207 ++{
208 ++ return &table->hashtable[hsiphash(input, sizeof(*input), &table->key) & (HASH_SIZE(table->hashtable) - 1)];
209 ++}
210 ++
211 ++You may then iterate like usual over the returned hash bucket.
212 ++
213 ++4. Performance
214 ++
215 ++HalfSipHash is roughly 3 times slower than JenkinsHash. For many replacements,
216 ++this will not be a problem, as the hashtable lookup isn't the bottleneck. And
217 ++in general, this is probably a good sacrifice to make for the security and DoS
218 ++resistance of HalfSipHash.
219 +diff --git a/Documentation/sysctl/net.txt b/Documentation/sysctl/net.txt
220 +index f0480f7ea740..4d5e3b0cab3f 100644
221 +--- a/Documentation/sysctl/net.txt
222 ++++ b/Documentation/sysctl/net.txt
223 +@@ -54,6 +54,14 @@ Values :
224 + 1 - enable JIT hardening for unprivileged users only
225 + 2 - enable JIT hardening for all users
226 +
227 ++bpf_jit_limit
228 ++-------------
229 ++
230 ++This enforces a global limit for memory allocations to the BPF JIT
231 ++compiler in order to reject unprivileged JIT requests once it has
232 ++been surpassed. bpf_jit_limit contains the value of the global limit
233 ++in bytes.
234 ++
235 + dev_weight
236 + --------------
237 +
238 +diff --git a/MAINTAINERS b/MAINTAINERS
239 +index 4f559f5b3a89..98ee40591a9b 100644
240 +--- a/MAINTAINERS
241 ++++ b/MAINTAINERS
242 +@@ -11068,6 +11068,13 @@ F: arch/arm/mach-s3c24xx/mach-bast.c
243 + F: arch/arm/mach-s3c24xx/bast-ide.c
244 + F: arch/arm/mach-s3c24xx/bast-irq.c
245 +
246 ++SIPHASH PRF ROUTINES
247 ++M: Jason A. Donenfeld <Jason@×××××.com>
248 ++S: Maintained
249 ++F: lib/siphash.c
250 ++F: lib/test_siphash.c
251 ++F: include/linux/siphash.h
252 ++
253 + TI DAVINCI MACHINE SUPPORT
254 + M: Sekhar Nori <nsekhar@××.com>
255 + M: Kevin Hilman <khilman@××××××.org>
256 +diff --git a/Makefile b/Makefile
257 +index 4fdc9d984f80..4b6cf4641eba 100644
258 +--- a/Makefile
259 ++++ b/Makefile
260 +@@ -1,6 +1,6 @@
261 + VERSION = 4
262 + PATCHLEVEL = 9
263 +-SUBLEVEL = 189
264 ++SUBLEVEL = 190
265 + EXTRAVERSION =
266 + NAME = Roaring Lionus
267 +
268 +diff --git a/arch/arm/mach-davinci/sleep.S b/arch/arm/mach-davinci/sleep.S
269 +index cd350dee4df3..efcd400b2abb 100644
270 +--- a/arch/arm/mach-davinci/sleep.S
271 ++++ b/arch/arm/mach-davinci/sleep.S
272 +@@ -37,6 +37,7 @@
273 + #define DEEPSLEEP_SLEEPENABLE_BIT BIT(31)
274 +
275 + .text
276 ++ .arch armv5te
277 + /*
278 + * Move DaVinci into deep sleep state
279 + *
280 +diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
281 +index 93d0b6d0b63e..7fd448b23b94 100644
282 +--- a/arch/arm/net/bpf_jit_32.c
283 ++++ b/arch/arm/net/bpf_jit_32.c
284 +@@ -72,8 +72,6 @@ struct jit_ctx {
285 + #endif
286 + };
287 +
288 +-int bpf_jit_enable __read_mostly;
289 +-
290 + static inline int call_neg_helper(struct sk_buff *skb, int offset, void *ret,
291 + unsigned int size)
292 + {
293 +diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
294 +index 65615820155e..65db124a44bf 100644
295 +--- a/arch/arm64/include/asm/efi.h
296 ++++ b/arch/arm64/include/asm/efi.h
297 +@@ -52,7 +52,11 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
298 + #define efi_is_64bit() (true)
299 +
300 + #define alloc_screen_info(x...) &screen_info
301 +-#define free_screen_info(x...)
302 ++
303 ++static inline void free_screen_info(efi_system_table_t *sys_table_arg,
304 ++ struct screen_info *si)
305 ++{
306 ++}
307 +
308 + /* redeclare as 'hidden' so the compiler will generate relative references */
309 + extern struct screen_info screen_info __attribute__((__visibility__("hidden")));
310 +diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
311 +index 73e3718356b0..edb2c359480d 100644
312 +--- a/arch/arm64/include/asm/pgtable.h
313 ++++ b/arch/arm64/include/asm/pgtable.h
314 +@@ -387,8 +387,8 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
315 + PMD_TYPE_SECT)
316 +
317 + #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3
318 +-#define pud_sect(pud) (0)
319 +-#define pud_table(pud) (1)
320 ++static inline bool pud_sect(pud_t pud) { return false; }
321 ++static inline bool pud_table(pud_t pud) { return true; }
322 + #else
323 + #define pud_sect(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \
324 + PUD_TYPE_SECT)
325 +diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
326 +index 0b9e5f6290f9..d168e52ee622 100644
327 +--- a/arch/arm64/kernel/hw_breakpoint.c
328 ++++ b/arch/arm64/kernel/hw_breakpoint.c
329 +@@ -508,13 +508,14 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
330 + /* Aligned */
331 + break;
332 + case 1:
333 +- /* Allow single byte watchpoint. */
334 +- if (info->ctrl.len == ARM_BREAKPOINT_LEN_1)
335 +- break;
336 + case 2:
337 + /* Allow halfword watchpoints and breakpoints. */
338 + if (info->ctrl.len == ARM_BREAKPOINT_LEN_2)
339 + break;
340 ++ case 3:
341 ++ /* Allow single byte watchpoint. */
342 ++ if (info->ctrl.len == ARM_BREAKPOINT_LEN_1)
343 ++ break;
344 + default:
345 + return -EINVAL;
346 + }
347 +diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
348 +index b47a26f4290c..939c607b1376 100644
349 +--- a/arch/arm64/net/bpf_jit_comp.c
350 ++++ b/arch/arm64/net/bpf_jit_comp.c
351 +@@ -30,8 +30,6 @@
352 +
353 + #include "bpf_jit.h"
354 +
355 +-int bpf_jit_enable __read_mostly;
356 +-
357 + #define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
358 + #define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
359 + #define TCALL_CNT (MAX_BPF_JIT_REG + 2)
360 +diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
361 +index 248603739198..bb9f779326d0 100644
362 +--- a/arch/mips/net/bpf_jit.c
363 ++++ b/arch/mips/net/bpf_jit.c
364 +@@ -1194,8 +1194,6 @@ jmp_cmp:
365 + return 0;
366 + }
367 +
368 +-int bpf_jit_enable __read_mostly;
369 +-
370 + void bpf_jit_compile(struct bpf_prog *fp)
371 + {
372 + struct jit_ctx ctx;
373 +diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
374 +index 9c58194c7ea5..158f43008314 100644
375 +--- a/arch/powerpc/net/bpf_jit_comp.c
376 ++++ b/arch/powerpc/net/bpf_jit_comp.c
377 +@@ -18,8 +18,6 @@
378 +
379 + #include "bpf_jit32.h"
380 +
381 +-int bpf_jit_enable __read_mostly;
382 +-
383 + static inline void bpf_flush_icache(void *start, void *end)
384 + {
385 + smp_wmb();
386 +diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
387 +index 9f0810cfe5f3..888ee95340da 100644
388 +--- a/arch/powerpc/net/bpf_jit_comp64.c
389 ++++ b/arch/powerpc/net/bpf_jit_comp64.c
390 +@@ -21,8 +21,6 @@
391 +
392 + #include "bpf_jit64.h"
393 +
394 +-int bpf_jit_enable __read_mostly;
395 +-
396 + static void bpf_jit_fill_ill_insns(void *area, unsigned int size)
397 + {
398 + int *p = area;
399 +diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
400 +index 8bd25aebf488..896344b6e036 100644
401 +--- a/arch/s390/net/bpf_jit_comp.c
402 ++++ b/arch/s390/net/bpf_jit_comp.c
403 +@@ -28,8 +28,6 @@
404 + #include <asm/nospec-branch.h>
405 + #include "bpf_jit.h"
406 +
407 +-int bpf_jit_enable __read_mostly;
408 +-
409 + struct bpf_jit {
410 + u32 seen; /* Flags to remember seen eBPF instructions */
411 + u32 seen_reg[16]; /* Array to remember which registers are used */
412 +diff --git a/arch/sh/kernel/hw_breakpoint.c b/arch/sh/kernel/hw_breakpoint.c
413 +index 2197fc584186..000cc3343867 100644
414 +--- a/arch/sh/kernel/hw_breakpoint.c
415 ++++ b/arch/sh/kernel/hw_breakpoint.c
416 +@@ -160,6 +160,7 @@ int arch_bp_generic_fields(int sh_len, int sh_type,
417 + switch (sh_type) {
418 + case SH_BREAKPOINT_READ:
419 + *gen_type = HW_BREAKPOINT_R;
420 ++ break;
421 + case SH_BREAKPOINT_WRITE:
422 + *gen_type = HW_BREAKPOINT_W;
423 + break;
424 +diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
425 +index a6d9204a6a0b..98a4da3012e3 100644
426 +--- a/arch/sparc/net/bpf_jit_comp.c
427 ++++ b/arch/sparc/net/bpf_jit_comp.c
428 +@@ -10,8 +10,6 @@
429 +
430 + #include "bpf_jit.h"
431 +
432 +-int bpf_jit_enable __read_mostly;
433 +-
434 + static inline bool is_simm13(unsigned int value)
435 + {
436 + return value + 0x1000 < 0x2000;
437 +diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
438 +index c140198d9fa5..7f4b3c59df47 100644
439 +--- a/arch/x86/mm/fault.c
440 ++++ b/arch/x86/mm/fault.c
441 +@@ -273,13 +273,14 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
442 +
443 + pmd = pmd_offset(pud, address);
444 + pmd_k = pmd_offset(pud_k, address);
445 +- if (!pmd_present(*pmd_k))
446 +- return NULL;
447 +
448 +- if (!pmd_present(*pmd))
449 ++ if (pmd_present(*pmd) != pmd_present(*pmd_k))
450 + set_pmd(pmd, *pmd_k);
451 ++
452 ++ if (!pmd_present(*pmd_k))
453 ++ return NULL;
454 + else
455 +- BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
456 ++ BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));
457 +
458 + return pmd_k;
459 + }
460 +@@ -299,17 +300,13 @@ void vmalloc_sync_all(void)
461 + spin_lock(&pgd_lock);
462 + list_for_each_entry(page, &pgd_list, lru) {
463 + spinlock_t *pgt_lock;
464 +- pmd_t *ret;
465 +
466 + /* the pgt_lock only for Xen */
467 + pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
468 +
469 + spin_lock(pgt_lock);
470 +- ret = vmalloc_sync_one(page_address(page), address);
471 ++ vmalloc_sync_one(page_address(page), address);
472 + spin_unlock(pgt_lock);
473 +-
474 +- if (!ret)
475 +- break;
476 + }
477 + spin_unlock(&pgd_lock);
478 + }
479 +diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
480 +index cd9764520851..d9dabd0c31fc 100644
481 +--- a/arch/x86/net/bpf_jit_comp.c
482 ++++ b/arch/x86/net/bpf_jit_comp.c
483 +@@ -15,8 +15,6 @@
484 + #include <asm/nospec-branch.h>
485 + #include <linux/bpf.h>
486 +
487 +-int bpf_jit_enable __read_mostly;
488 +-
489 + /*
490 + * assembly code in arch/x86/net/bpf_jit.S
491 + */
492 +diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
493 +index a45d32abea26..b9beae798d72 100644
494 +--- a/arch/xtensa/kernel/setup.c
495 ++++ b/arch/xtensa/kernel/setup.c
496 +@@ -626,6 +626,7 @@ void cpu_reset(void)
497 + "add %2, %2, %7\n\t"
498 + "addi %0, %0, -1\n\t"
499 + "bnez %0, 1b\n\t"
500 ++ "isync\n\t"
501 + /* Jump to identity mapping */
502 + "jx %3\n"
503 + "2:\n\t"
504 +diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
505 +index 6b81746cd13c..e5b1b3f1c231 100644
506 +--- a/drivers/acpi/arm64/iort.c
507 ++++ b/drivers/acpi/arm64/iort.c
508 +@@ -324,8 +324,8 @@ static int iort_dev_find_its_id(struct device *dev, u32 req_id,
509 +
510 + /* Move to ITS specific data */
511 + its = (struct acpi_iort_its_group *)node->node_data;
512 +- if (idx > its->its_count) {
513 +- dev_err(dev, "requested ITS ID index [%d] is greater than available [%d]\n",
514 ++ if (idx >= its->its_count) {
515 ++ dev_err(dev, "requested ITS ID index [%d] overruns ITS entries [%d]\n",
516 + idx, its->its_count);
517 + return -ENXIO;
518 + }
519 +diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
520 +index cd2eab6aa92e..65371e1befe8 100644
521 +--- a/drivers/ata/libahci_platform.c
522 ++++ b/drivers/ata/libahci_platform.c
523 +@@ -300,6 +300,9 @@ static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port,
524 + hpriv->phys[port] = NULL;
525 + rc = 0;
526 + break;
527 ++ case -EPROBE_DEFER:
528 ++ /* Do not complain yet */
529 ++ break;
530 +
531 + default:
532 + dev_err(dev,
533 +diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c
534 +index 7017a81d53cf..083856272e92 100644
535 +--- a/drivers/ata/libata-zpodd.c
536 ++++ b/drivers/ata/libata-zpodd.c
537 +@@ -55,7 +55,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
538 + unsigned int ret;
539 + struct rm_feature_desc *desc;
540 + struct ata_taskfile tf;
541 +- static const char cdb[] = { GPCMD_GET_CONFIGURATION,
542 ++ static const char cdb[ATAPI_CDB_LEN] = { GPCMD_GET_CONFIGURATION,
543 + 2, /* only 1 feature descriptor requested */
544 + 0, 3, /* 3, removable medium feature */
545 + 0, 0, 0,/* reserved */
546 +diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
547 +index 83957a1e15ed..8e8e4ccb128f 100644
548 +--- a/drivers/block/drbd/drbd_receiver.c
549 ++++ b/drivers/block/drbd/drbd_receiver.c
550 +@@ -5297,7 +5297,7 @@ static int drbd_do_auth(struct drbd_connection *connection)
551 + unsigned int key_len;
552 + char secret[SHARED_SECRET_MAX]; /* 64 byte */
553 + unsigned int resp_size;
554 +- SHASH_DESC_ON_STACK(desc, connection->cram_hmac_tfm);
555 ++ struct shash_desc *desc;
556 + struct packet_info pi;
557 + struct net_conf *nc;
558 + int err, rv;
559 +@@ -5310,6 +5310,13 @@ static int drbd_do_auth(struct drbd_connection *connection)
560 + memcpy(secret, nc->shared_secret, key_len);
561 + rcu_read_unlock();
562 +
563 ++ desc = kmalloc(sizeof(struct shash_desc) +
564 ++ crypto_shash_descsize(connection->cram_hmac_tfm),
565 ++ GFP_KERNEL);
566 ++ if (!desc) {
567 ++ rv = -1;
568 ++ goto fail;
569 ++ }
570 + desc->tfm = connection->cram_hmac_tfm;
571 + desc->flags = 0;
572 +
573 +@@ -5452,7 +5459,10 @@ static int drbd_do_auth(struct drbd_connection *connection)
574 + kfree(peers_ch);
575 + kfree(response);
576 + kfree(right_response);
577 +- shash_desc_zero(desc);
578 ++ if (desc) {
579 ++ shash_desc_zero(desc);
580 ++ kfree(desc);
581 ++ }
582 +
583 + return rv;
584 + }
585 +diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
586 +index 58c933f48300..991b6a3062c4 100644
587 +--- a/drivers/cpufreq/pasemi-cpufreq.c
588 ++++ b/drivers/cpufreq/pasemi-cpufreq.c
589 +@@ -145,10 +145,18 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
590 + int err = -ENODEV;
591 +
592 + cpu = of_get_cpu_node(policy->cpu, NULL);
593 ++ if (!cpu)
594 ++ goto out;
595 +
596 ++ max_freqp = of_get_property(cpu, "clock-frequency", NULL);
597 + of_node_put(cpu);
598 +- if (!cpu)
599 ++ if (!max_freqp) {
600 ++ err = -EINVAL;
601 + goto out;
602 ++ }
603 ++
604 ++ /* we need the freq in kHz */
605 ++ max_freq = *max_freqp / 1000;
606 +
607 + dn = of_find_compatible_node(NULL, NULL, "1682m-sdc");
608 + if (!dn)
609 +@@ -185,16 +193,6 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
610 + }
611 +
612 + pr_debug("init cpufreq on CPU %d\n", policy->cpu);
613 +-
614 +- max_freqp = of_get_property(cpu, "clock-frequency", NULL);
615 +- if (!max_freqp) {
616 +- err = -EINVAL;
617 +- goto out_unmap_sdcpwr;
618 +- }
619 +-
620 +- /* we need the freq in kHz */
621 +- max_freq = *max_freqp / 1000;
622 +-
623 + pr_debug("max clock-frequency is at %u kHz\n", max_freq);
624 + pr_debug("initializing frequency table\n");
625 +
626 +@@ -212,9 +210,6 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
627 +
628 + return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency());
629 +
630 +-out_unmap_sdcpwr:
631 +- iounmap(sdcpwr_mapbase);
632 +-
633 + out_unmap_sdcasr:
634 + iounmap(sdcasr_mapbase);
635 + out:
636 +diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
637 +index bca172d42c74..854df538ae01 100644
638 +--- a/drivers/firmware/Kconfig
639 ++++ b/drivers/firmware/Kconfig
640 +@@ -144,7 +144,7 @@ config DMI_SCAN_MACHINE_NON_EFI_FALLBACK
641 +
642 + config ISCSI_IBFT_FIND
643 + bool "iSCSI Boot Firmware Table Attributes"
644 +- depends on X86 && ACPI
645 ++ depends on X86 && ISCSI_IBFT
646 + default n
647 + help
648 + This option enables the kernel to find the region of memory
649 +@@ -155,7 +155,8 @@ config ISCSI_IBFT_FIND
650 + config ISCSI_IBFT
651 + tristate "iSCSI Boot Firmware Table Attributes module"
652 + select ISCSI_BOOT_SYSFS
653 +- depends on ISCSI_IBFT_FIND && SCSI && SCSI_LOWLEVEL
654 ++ select ISCSI_IBFT_FIND if X86
655 ++ depends on ACPI && SCSI && SCSI_LOWLEVEL
656 + default n
657 + help
658 + This option enables support for detection and exposing of iSCSI
659 +diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
660 +index 132b9bae4b6a..220bbc91cebd 100644
661 +--- a/drivers/firmware/iscsi_ibft.c
662 ++++ b/drivers/firmware/iscsi_ibft.c
663 +@@ -93,6 +93,10 @@ MODULE_DESCRIPTION("sysfs interface to BIOS iBFT information");
664 + MODULE_LICENSE("GPL");
665 + MODULE_VERSION(IBFT_ISCSI_VERSION);
666 +
667 ++#ifndef CONFIG_ISCSI_IBFT_FIND
668 ++struct acpi_table_ibft *ibft_addr;
669 ++#endif
670 ++
671 + struct ibft_hdr {
672 + u8 id;
673 + u8 version;
674 +diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c
675 +index 6e1a4a4fc0c1..ab9da597106f 100644
676 +--- a/drivers/hid/hid-holtek-kbd.c
677 ++++ b/drivers/hid/hid-holtek-kbd.c
678 +@@ -126,9 +126,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
679 +
680 + /* Locate the boot interface, to receive the LED change events */
681 + struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0);
682 ++ struct hid_device *boot_hid;
683 ++ struct hid_input *boot_hid_input;
684 +
685 +- struct hid_device *boot_hid = usb_get_intfdata(boot_interface);
686 +- struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs,
687 ++ if (unlikely(boot_interface == NULL))
688 ++ return -ENODEV;
689 ++
690 ++ boot_hid = usb_get_intfdata(boot_interface);
691 ++ boot_hid_input = list_first_entry(&boot_hid->inputs,
692 + struct hid_input, list);
693 +
694 + return boot_hid_input->input->event(boot_hid_input->input, type, code,
695 +diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
696 +index 308d8432fea3..8903ea09ac58 100644
697 +--- a/drivers/hid/usbhid/hiddev.c
698 ++++ b/drivers/hid/usbhid/hiddev.c
699 +@@ -308,6 +308,14 @@ static int hiddev_open(struct inode *inode, struct file *file)
700 + spin_unlock_irq(&list->hiddev->list_lock);
701 +
702 + mutex_lock(&hiddev->existancelock);
703 ++ /*
704 ++ * recheck exist with existance lock held to
705 ++ * avoid opening a disconnected device
706 ++ */
707 ++ if (!list->hiddev->exist) {
708 ++ res = -ENODEV;
709 ++ goto bail_unlock;
710 ++ }
711 + if (!list->hiddev->open++)
712 + if (list->hiddev->exist) {
713 + struct hid_device *hid = hiddev->hid;
714 +@@ -322,6 +330,10 @@ static int hiddev_open(struct inode *inode, struct file *file)
715 + return 0;
716 + bail_unlock:
717 + mutex_unlock(&hiddev->existancelock);
718 ++
719 ++ spin_lock_irq(&list->hiddev->list_lock);
720 ++ list_del(&list->node);
721 ++ spin_unlock_irq(&list->hiddev->list_lock);
722 + bail:
723 + file->private_data = NULL;
724 + vfree(list);
725 +diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
726 +index 2b31b84d0a5b..006f090c1b0a 100644
727 +--- a/drivers/hwmon/nct6775.c
728 ++++ b/drivers/hwmon/nct6775.c
729 +@@ -698,7 +698,7 @@ static const u16 NCT6106_REG_TARGET[] = { 0x111, 0x121, 0x131 };
730 + static const u16 NCT6106_REG_WEIGHT_TEMP_SEL[] = { 0x168, 0x178, 0x188 };
731 + static const u16 NCT6106_REG_WEIGHT_TEMP_STEP[] = { 0x169, 0x179, 0x189 };
732 + static const u16 NCT6106_REG_WEIGHT_TEMP_STEP_TOL[] = { 0x16a, 0x17a, 0x18a };
733 +-static const u16 NCT6106_REG_WEIGHT_DUTY_STEP[] = { 0x16b, 0x17b, 0x17c };
734 ++static const u16 NCT6106_REG_WEIGHT_DUTY_STEP[] = { 0x16b, 0x17b, 0x18b };
735 + static const u16 NCT6106_REG_WEIGHT_TEMP_BASE[] = { 0x16c, 0x17c, 0x18c };
736 + static const u16 NCT6106_REG_WEIGHT_DUTY_BASE[] = { 0x16d, 0x17d, 0x18d };
737 +
738 +@@ -3481,6 +3481,7 @@ static int nct6775_probe(struct platform_device *pdev)
739 + data->REG_FAN_TIME[0] = NCT6106_REG_FAN_STOP_TIME;
740 + data->REG_FAN_TIME[1] = NCT6106_REG_FAN_STEP_UP_TIME;
741 + data->REG_FAN_TIME[2] = NCT6106_REG_FAN_STEP_DOWN_TIME;
742 ++ data->REG_TOLERANCE_H = NCT6106_REG_TOLERANCE_H;
743 + data->REG_PWM[0] = NCT6106_REG_PWM;
744 + data->REG_PWM[1] = NCT6106_REG_FAN_START_OUTPUT;
745 + data->REG_PWM[2] = NCT6106_REG_FAN_STOP_OUTPUT;
746 +diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
747 +index 12b94b094c0d..7f8738a83cb9 100644
748 +--- a/drivers/hwmon/nct7802.c
749 ++++ b/drivers/hwmon/nct7802.c
750 +@@ -768,7 +768,7 @@ static struct attribute *nct7802_in_attrs[] = {
751 + &sensor_dev_attr_in3_alarm.dev_attr.attr,
752 + &sensor_dev_attr_in3_beep.dev_attr.attr,
753 +
754 +- &sensor_dev_attr_in4_input.dev_attr.attr, /* 17 */
755 ++ &sensor_dev_attr_in4_input.dev_attr.attr, /* 16 */
756 + &sensor_dev_attr_in4_min.dev_attr.attr,
757 + &sensor_dev_attr_in4_max.dev_attr.attr,
758 + &sensor_dev_attr_in4_alarm.dev_attr.attr,
759 +@@ -794,9 +794,9 @@ static umode_t nct7802_in_is_visible(struct kobject *kobj,
760 +
761 + if (index >= 6 && index < 11 && (reg & 0x03) != 0x03) /* VSEN1 */
762 + return 0;
763 +- if (index >= 11 && index < 17 && (reg & 0x0c) != 0x0c) /* VSEN2 */
764 ++ if (index >= 11 && index < 16 && (reg & 0x0c) != 0x0c) /* VSEN2 */
765 + return 0;
766 +- if (index >= 17 && (reg & 0x30) != 0x30) /* VSEN3 */
767 ++ if (index >= 16 && (reg & 0x30) != 0x30) /* VSEN3 */
768 + return 0;
769 +
770 + return attr->mode;
771 +diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
772 +index 3e2ab04201e2..25a28e706072 100644
773 +--- a/drivers/infiniband/core/mad.c
774 ++++ b/drivers/infiniband/core/mad.c
775 +@@ -3155,18 +3155,18 @@ static int ib_mad_port_open(struct ib_device *device,
776 + if (has_smi)
777 + cq_size *= 2;
778 +
779 ++ port_priv->pd = ib_alloc_pd(device, 0);
780 ++ if (IS_ERR(port_priv->pd)) {
781 ++ dev_err(&device->dev, "Couldn't create ib_mad PD\n");
782 ++ ret = PTR_ERR(port_priv->pd);
783 ++ goto error3;
784 ++ }
785 ++
786 + port_priv->cq = ib_alloc_cq(port_priv->device, port_priv, cq_size, 0,
787 + IB_POLL_WORKQUEUE);
788 + if (IS_ERR(port_priv->cq)) {
789 + dev_err(&device->dev, "Couldn't create ib_mad CQ\n");
790 + ret = PTR_ERR(port_priv->cq);
791 +- goto error3;
792 +- }
793 +-
794 +- port_priv->pd = ib_alloc_pd(device, 0);
795 +- if (IS_ERR(port_priv->pd)) {
796 +- dev_err(&device->dev, "Couldn't create ib_mad PD\n");
797 +- ret = PTR_ERR(port_priv->pd);
798 + goto error4;
799 + }
800 +
801 +@@ -3209,11 +3209,11 @@ error8:
802 + error7:
803 + destroy_mad_qp(&port_priv->qp_info[0]);
804 + error6:
805 +- ib_dealloc_pd(port_priv->pd);
806 +-error4:
807 + ib_free_cq(port_priv->cq);
808 + cleanup_recv_queue(&port_priv->qp_info[1]);
809 + cleanup_recv_queue(&port_priv->qp_info[0]);
810 ++error4:
811 ++ ib_dealloc_pd(port_priv->pd);
812 + error3:
813 + kfree(port_priv);
814 +
815 +@@ -3243,8 +3243,8 @@ static int ib_mad_port_close(struct ib_device *device, int port_num)
816 + destroy_workqueue(port_priv->wq);
817 + destroy_mad_qp(&port_priv->qp_info[1]);
818 + destroy_mad_qp(&port_priv->qp_info[0]);
819 +- ib_dealloc_pd(port_priv->pd);
820 + ib_free_cq(port_priv->cq);
821 ++ ib_dealloc_pd(port_priv->pd);
822 + cleanup_recv_queue(&port_priv->qp_info[1]);
823 + cleanup_recv_queue(&port_priv->qp_info[0]);
824 + /* XXX: Handle deallocation of MAD registration tables */
825 +diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
826 +index 415a3185cde7..cf93a96b6324 100644
827 +--- a/drivers/infiniband/core/user_mad.c
828 ++++ b/drivers/infiniband/core/user_mad.c
829 +@@ -49,6 +49,7 @@
830 + #include <linux/sched.h>
831 + #include <linux/semaphore.h>
832 + #include <linux/slab.h>
833 ++#include <linux/nospec.h>
834 +
835 + #include <asm/uaccess.h>
836 +
837 +@@ -843,11 +844,14 @@ static int ib_umad_unreg_agent(struct ib_umad_file *file, u32 __user *arg)
838 +
839 + if (get_user(id, arg))
840 + return -EFAULT;
841 ++ if (id >= IB_UMAD_MAX_AGENTS)
842 ++ return -EINVAL;
843 +
844 + mutex_lock(&file->port->file_mutex);
845 + mutex_lock(&file->mutex);
846 +
847 +- if (id >= IB_UMAD_MAX_AGENTS || !__get_agent(file, id)) {
848 ++ id = array_index_nospec(id, IB_UMAD_MAX_AGENTS);
849 ++ if (!__get_agent(file, id)) {
850 + ret = -EINVAL;
851 + goto out;
852 + }
853 +diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
854 +index db64adfbe1af..3e1ea912b41d 100644
855 +--- a/drivers/input/joystick/iforce/iforce-usb.c
856 ++++ b/drivers/input/joystick/iforce/iforce-usb.c
857 +@@ -145,7 +145,12 @@ static int iforce_usb_probe(struct usb_interface *intf,
858 + return -ENODEV;
859 +
860 + epirq = &interface->endpoint[0].desc;
861 ++ if (!usb_endpoint_is_int_in(epirq))
862 ++ return -ENODEV;
863 ++
864 + epout = &interface->endpoint[1].desc;
865 ++ if (!usb_endpoint_is_int_out(epout))
866 ++ return -ENODEV;
867 +
868 + if (!(iforce = kzalloc(sizeof(struct iforce) + 32, GFP_KERNEL)))
869 + goto fail;
870 +diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h
871 +index 88055755f82e..821b446a85dd 100644
872 +--- a/drivers/input/mouse/trackpoint.h
873 ++++ b/drivers/input/mouse/trackpoint.h
874 +@@ -153,7 +153,8 @@ struct trackpoint_data
875 + #ifdef CONFIG_MOUSE_PS2_TRACKPOINT
876 + int trackpoint_detect(struct psmouse *psmouse, bool set_properties);
877 + #else
878 +-inline int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
879 ++static inline int trackpoint_detect(struct psmouse *psmouse,
880 ++ bool set_properties)
881 + {
882 + return -ENOSYS;
883 + }
884 +diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c
885 +index 4d9d64908b59..b7ea64ec1205 100644
886 +--- a/drivers/input/tablet/kbtab.c
887 ++++ b/drivers/input/tablet/kbtab.c
888 +@@ -125,6 +125,10 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
889 + if (intf->cur_altsetting->desc.bNumEndpoints < 1)
890 + return -ENODEV;
891 +
892 ++ endpoint = &intf->cur_altsetting->endpoint[0].desc;
893 ++ if (!usb_endpoint_is_int_in(endpoint))
894 ++ return -ENODEV;
895 ++
896 + kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
897 + input_dev = input_allocate_device();
898 + if (!kbtab || !input_dev)
899 +@@ -163,8 +167,6 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
900 + input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0);
901 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0);
902 +
903 +- endpoint = &intf->cur_altsetting->endpoint[0].desc;
904 +-
905 + usb_fill_int_urb(kbtab->irq, dev,
906 + usb_rcvintpipe(dev, endpoint->bEndpointAddress),
907 + kbtab->data, 8,
908 +diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
909 +index 13bbe5795e4e..9bb8d64b6f94 100644
910 +--- a/drivers/iommu/amd_iommu_init.c
911 ++++ b/drivers/iommu/amd_iommu_init.c
912 +@@ -1534,7 +1534,7 @@ static const struct attribute_group *amd_iommu_groups[] = {
913 + NULL,
914 + };
915 +
916 +-static int iommu_init_pci(struct amd_iommu *iommu)
917 ++static int __init iommu_init_pci(struct amd_iommu *iommu)
918 + {
919 + int cap_ptr = iommu->cap_ptr;
920 + u32 range, misc, low, high;
921 +diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c
922 +index 2d203b422129..c56da0b13da5 100644
923 +--- a/drivers/irqchip/irq-imx-gpcv2.c
924 ++++ b/drivers/irqchip/irq-imx-gpcv2.c
925 +@@ -145,6 +145,7 @@ static struct irq_chip gpcv2_irqchip_data_chip = {
926 + .irq_unmask = imx_gpcv2_irq_unmask,
927 + .irq_set_wake = imx_gpcv2_irq_set_wake,
928 + .irq_retrigger = irq_chip_retrigger_hierarchy,
929 ++ .irq_set_type = irq_chip_set_type_parent,
930 + #ifdef CONFIG_SMP
931 + .irq_set_affinity = irq_chip_set_affinity_parent,
932 + #endif
933 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
934 +index 5b116ec756b4..d338c319b30e 100644
935 +--- a/drivers/net/bonding/bond_main.c
936 ++++ b/drivers/net/bonding/bond_main.c
937 +@@ -1107,7 +1107,9 @@ static void bond_compute_features(struct bonding *bond)
938 +
939 + done:
940 + bond_dev->vlan_features = vlan_features;
941 +- bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL;
942 ++ bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
943 ++ NETIF_F_HW_VLAN_CTAG_TX |
944 ++ NETIF_F_HW_VLAN_STAG_TX;
945 + bond_dev->hard_header_len = max_hard_header_len;
946 + bond_dev->gso_max_segs = gso_max_segs;
947 + netif_set_gso_max_size(bond_dev, gso_max_size);
948 +diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
949 +index 0b0302af3bd2..54c2354053ac 100644
950 +--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
951 ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
952 +@@ -592,16 +592,16 @@ static int peak_usb_ndo_stop(struct net_device *netdev)
953 + dev->state &= ~PCAN_USB_STATE_STARTED;
954 + netif_stop_queue(netdev);
955 +
956 ++ close_candev(netdev);
957 ++
958 ++ dev->can.state = CAN_STATE_STOPPED;
959 ++
960 + /* unlink all pending urbs and free used memory */
961 + peak_usb_unlink_all_urbs(dev);
962 +
963 + if (dev->adapter->dev_stop)
964 + dev->adapter->dev_stop(dev);
965 +
966 +- close_candev(netdev);
967 +-
968 +- dev->can.state = CAN_STATE_STOPPED;
969 +-
970 + /* can set bus off now */
971 + if (dev->adapter->dev_set_bus) {
972 + int err = dev->adapter->dev_set_bus(dev, 0);
973 +diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
974 +index 7f5ec40e2b4d..40647b837b31 100644
975 +--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
976 ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
977 +@@ -851,7 +851,7 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev)
978 + goto err_out;
979 +
980 + /* allocate command buffer once for all for the interface */
981 +- pdev->cmd_buffer_addr = kmalloc(PCAN_UFD_CMD_BUFFER_SIZE,
982 ++ pdev->cmd_buffer_addr = kzalloc(PCAN_UFD_CMD_BUFFER_SIZE,
983 + GFP_KERNEL);
984 + if (!pdev->cmd_buffer_addr)
985 + goto err_out_1;
986 +diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
987 +index bbdd6058cd2f..d85fdc6949c6 100644
988 +--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
989 ++++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
990 +@@ -500,7 +500,7 @@ static int pcan_usb_pro_drv_loaded(struct peak_usb_device *dev, int loaded)
991 + u8 *buffer;
992 + int err;
993 +
994 +- buffer = kmalloc(PCAN_USBPRO_FCT_DRVLD_REQ_LEN, GFP_KERNEL);
995 ++ buffer = kzalloc(PCAN_USBPRO_FCT_DRVLD_REQ_LEN, GFP_KERNEL);
996 + if (!buffer)
997 + return -ENOMEM;
998 +
999 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
1000 +index 53a71166e784..46a7dcf2ff4a 100644
1001 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
1002 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
1003 +@@ -3062,12 +3062,13 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
1004 + /* if VF indicate to PF this function is going down (PF will delete sp
1005 + * elements and clear initializations
1006 + */
1007 +- if (IS_VF(bp))
1008 ++ if (IS_VF(bp)) {
1009 ++ bnx2x_clear_vlan_info(bp);
1010 + bnx2x_vfpf_close_vf(bp);
1011 +- else if (unload_mode != UNLOAD_RECOVERY)
1012 ++ } else if (unload_mode != UNLOAD_RECOVERY) {
1013 + /* if this is a normal/close unload need to clean up chip*/
1014 + bnx2x_chip_cleanup(bp, unload_mode, keep_link);
1015 +- else {
1016 ++ } else {
1017 + /* Send the UNLOAD_REQUEST to the MCP */
1018 + bnx2x_send_unload_req(bp, unload_mode);
1019 +
1020 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
1021 +index 243cb9748d35..2ec1c43270b7 100644
1022 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
1023 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
1024 +@@ -425,6 +425,8 @@ void bnx2x_set_reset_global(struct bnx2x *bp);
1025 + void bnx2x_disable_close_the_gate(struct bnx2x *bp);
1026 + int bnx2x_init_hw_func_cnic(struct bnx2x *bp);
1027 +
1028 ++void bnx2x_clear_vlan_info(struct bnx2x *bp);
1029 ++
1030 + /**
1031 + * bnx2x_sp_event - handle ramrods completion.
1032 + *
1033 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1034 +index 2ef6012c3dc5..a9681b191304 100644
1035 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1036 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1037 +@@ -8488,11 +8488,21 @@ int bnx2x_set_vlan_one(struct bnx2x *bp, u16 vlan,
1038 + return rc;
1039 + }
1040 +
1041 ++void bnx2x_clear_vlan_info(struct bnx2x *bp)
1042 ++{
1043 ++ struct bnx2x_vlan_entry *vlan;
1044 ++
1045 ++ /* Mark that hw forgot all entries */
1046 ++ list_for_each_entry(vlan, &bp->vlan_reg, link)
1047 ++ vlan->hw = false;
1048 ++
1049 ++ bp->vlan_cnt = 0;
1050 ++}
1051 ++
1052 + static int bnx2x_del_all_vlans(struct bnx2x *bp)
1053 + {
1054 + struct bnx2x_vlan_mac_obj *vlan_obj = &bp->sp_objs[0].vlan_obj;
1055 + unsigned long ramrod_flags = 0, vlan_flags = 0;
1056 +- struct bnx2x_vlan_entry *vlan;
1057 + int rc;
1058 +
1059 + __set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
1060 +@@ -8501,10 +8511,7 @@ static int bnx2x_del_all_vlans(struct bnx2x *bp)
1061 + if (rc)
1062 + return rc;
1063 +
1064 +- /* Mark that hw forgot all entries */
1065 +- list_for_each_entry(vlan, &bp->vlan_reg, link)
1066 +- vlan->hw = false;
1067 +- bp->vlan_cnt = 0;
1068 ++ bnx2x_clear_vlan_info(bp);
1069 +
1070 + return 0;
1071 + }
1072 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
1073 +index 4a51fc6908ad..098a6b56fd54 100644
1074 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
1075 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
1076 +@@ -441,12 +441,6 @@ arfs_hash_bucket(struct arfs_table *arfs_t, __be16 src_port,
1077 + return &arfs_t->rules_hash[bucket_idx];
1078 + }
1079 +
1080 +-static u8 arfs_get_ip_proto(const struct sk_buff *skb)
1081 +-{
1082 +- return (skb->protocol == htons(ETH_P_IP)) ?
1083 +- ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr;
1084 +-}
1085 +-
1086 + static struct arfs_table *arfs_get_table(struct mlx5e_arfs_tables *arfs,
1087 + u8 ip_proto, __be16 etype)
1088 + {
1089 +@@ -605,31 +599,9 @@ out:
1090 + arfs_may_expire_flow(priv);
1091 + }
1092 +
1093 +-/* return L4 destination port from ip4/6 packets */
1094 +-static __be16 arfs_get_dst_port(const struct sk_buff *skb)
1095 +-{
1096 +- char *transport_header;
1097 +-
1098 +- transport_header = skb_transport_header(skb);
1099 +- if (arfs_get_ip_proto(skb) == IPPROTO_TCP)
1100 +- return ((struct tcphdr *)transport_header)->dest;
1101 +- return ((struct udphdr *)transport_header)->dest;
1102 +-}
1103 +-
1104 +-/* return L4 source port from ip4/6 packets */
1105 +-static __be16 arfs_get_src_port(const struct sk_buff *skb)
1106 +-{
1107 +- char *transport_header;
1108 +-
1109 +- transport_header = skb_transport_header(skb);
1110 +- if (arfs_get_ip_proto(skb) == IPPROTO_TCP)
1111 +- return ((struct tcphdr *)transport_header)->source;
1112 +- return ((struct udphdr *)transport_header)->source;
1113 +-}
1114 +-
1115 + static struct arfs_rule *arfs_alloc_rule(struct mlx5e_priv *priv,
1116 + struct arfs_table *arfs_t,
1117 +- const struct sk_buff *skb,
1118 ++ const struct flow_keys *fk,
1119 + u16 rxq, u32 flow_id)
1120 + {
1121 + struct arfs_rule *rule;
1122 +@@ -644,19 +616,19 @@ static struct arfs_rule *arfs_alloc_rule(struct mlx5e_priv *priv,
1123 + INIT_WORK(&rule->arfs_work, arfs_handle_work);
1124 +
1125 + tuple = &rule->tuple;
1126 +- tuple->etype = skb->protocol;
1127 ++ tuple->etype = fk->basic.n_proto;
1128 ++ tuple->ip_proto = fk->basic.ip_proto;
1129 + if (tuple->etype == htons(ETH_P_IP)) {
1130 +- tuple->src_ipv4 = ip_hdr(skb)->saddr;
1131 +- tuple->dst_ipv4 = ip_hdr(skb)->daddr;
1132 ++ tuple->src_ipv4 = fk->addrs.v4addrs.src;
1133 ++ tuple->dst_ipv4 = fk->addrs.v4addrs.dst;
1134 + } else {
1135 +- memcpy(&tuple->src_ipv6, &ipv6_hdr(skb)->saddr,
1136 ++ memcpy(&tuple->src_ipv6, &fk->addrs.v6addrs.src,
1137 + sizeof(struct in6_addr));
1138 +- memcpy(&tuple->dst_ipv6, &ipv6_hdr(skb)->daddr,
1139 ++ memcpy(&tuple->dst_ipv6, &fk->addrs.v6addrs.dst,
1140 + sizeof(struct in6_addr));
1141 + }
1142 +- tuple->ip_proto = arfs_get_ip_proto(skb);
1143 +- tuple->src_port = arfs_get_src_port(skb);
1144 +- tuple->dst_port = arfs_get_dst_port(skb);
1145 ++ tuple->src_port = fk->ports.src;
1146 ++ tuple->dst_port = fk->ports.dst;
1147 +
1148 + rule->flow_id = flow_id;
1149 + rule->filter_id = priv->fs.arfs.last_filter_id++ % RPS_NO_FILTER;
1150 +@@ -667,37 +639,33 @@ static struct arfs_rule *arfs_alloc_rule(struct mlx5e_priv *priv,
1151 + return rule;
1152 + }
1153 +
1154 +-static bool arfs_cmp_ips(struct arfs_tuple *tuple,
1155 +- const struct sk_buff *skb)
1156 ++static bool arfs_cmp(const struct arfs_tuple *tuple, const struct flow_keys *fk)
1157 + {
1158 +- if (tuple->etype == htons(ETH_P_IP) &&
1159 +- tuple->src_ipv4 == ip_hdr(skb)->saddr &&
1160 +- tuple->dst_ipv4 == ip_hdr(skb)->daddr)
1161 +- return true;
1162 +- if (tuple->etype == htons(ETH_P_IPV6) &&
1163 +- (!memcmp(&tuple->src_ipv6, &ipv6_hdr(skb)->saddr,
1164 +- sizeof(struct in6_addr))) &&
1165 +- (!memcmp(&tuple->dst_ipv6, &ipv6_hdr(skb)->daddr,
1166 +- sizeof(struct in6_addr))))
1167 +- return true;
1168 ++ if (tuple->src_port != fk->ports.src || tuple->dst_port != fk->ports.dst)
1169 ++ return false;
1170 ++ if (tuple->etype != fk->basic.n_proto)
1171 ++ return false;
1172 ++ if (tuple->etype == htons(ETH_P_IP))
1173 ++ return tuple->src_ipv4 == fk->addrs.v4addrs.src &&
1174 ++ tuple->dst_ipv4 == fk->addrs.v4addrs.dst;
1175 ++ if (tuple->etype == htons(ETH_P_IPV6))
1176 ++ return !memcmp(&tuple->src_ipv6, &fk->addrs.v6addrs.src,
1177 ++ sizeof(struct in6_addr)) &&
1178 ++ !memcmp(&tuple->dst_ipv6, &fk->addrs.v6addrs.dst,
1179 ++ sizeof(struct in6_addr));
1180 + return false;
1181 + }
1182 +
1183 + static struct arfs_rule *arfs_find_rule(struct arfs_table *arfs_t,
1184 +- const struct sk_buff *skb)
1185 ++ const struct flow_keys *fk)
1186 + {
1187 + struct arfs_rule *arfs_rule;
1188 + struct hlist_head *head;
1189 +- __be16 src_port = arfs_get_src_port(skb);
1190 +- __be16 dst_port = arfs_get_dst_port(skb);
1191 +
1192 +- head = arfs_hash_bucket(arfs_t, src_port, dst_port);
1193 ++ head = arfs_hash_bucket(arfs_t, fk->ports.src, fk->ports.dst);
1194 + hlist_for_each_entry(arfs_rule, head, hlist) {
1195 +- if (arfs_rule->tuple.src_port == src_port &&
1196 +- arfs_rule->tuple.dst_port == dst_port &&
1197 +- arfs_cmp_ips(&arfs_rule->tuple, skb)) {
1198 ++ if (arfs_cmp(&arfs_rule->tuple, fk))
1199 + return arfs_rule;
1200 +- }
1201 + }
1202 +
1203 + return NULL;
1204 +@@ -710,20 +678,24 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1205 + struct mlx5e_arfs_tables *arfs = &priv->fs.arfs;
1206 + struct arfs_table *arfs_t;
1207 + struct arfs_rule *arfs_rule;
1208 ++ struct flow_keys fk;
1209 ++
1210 ++ if (!skb_flow_dissect_flow_keys(skb, &fk, 0))
1211 ++ return -EPROTONOSUPPORT;
1212 +
1213 +- if (skb->protocol != htons(ETH_P_IP) &&
1214 +- skb->protocol != htons(ETH_P_IPV6))
1215 ++ if (fk.basic.n_proto != htons(ETH_P_IP) &&
1216 ++ fk.basic.n_proto != htons(ETH_P_IPV6))
1217 + return -EPROTONOSUPPORT;
1218 +
1219 + if (skb->encapsulation)
1220 + return -EPROTONOSUPPORT;
1221 +
1222 +- arfs_t = arfs_get_table(arfs, arfs_get_ip_proto(skb), skb->protocol);
1223 ++ arfs_t = arfs_get_table(arfs, fk.basic.ip_proto, fk.basic.n_proto);
1224 + if (!arfs_t)
1225 + return -EPROTONOSUPPORT;
1226 +
1227 + spin_lock_bh(&arfs->arfs_lock);
1228 +- arfs_rule = arfs_find_rule(arfs_t, skb);
1229 ++ arfs_rule = arfs_find_rule(arfs_t, &fk);
1230 + if (arfs_rule) {
1231 + if (arfs_rule->rxq == rxq_index) {
1232 + spin_unlock_bh(&arfs->arfs_lock);
1233 +@@ -731,8 +703,7 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1234 + }
1235 + arfs_rule->rxq = rxq_index;
1236 + } else {
1237 +- arfs_rule = arfs_alloc_rule(priv, arfs_t, skb,
1238 +- rxq_index, flow_id);
1239 ++ arfs_rule = arfs_alloc_rule(priv, arfs_t, &fk, rxq_index, flow_id);
1240 + if (!arfs_rule) {
1241 + spin_unlock_bh(&arfs->arfs_lock);
1242 + return -ENOMEM;
1243 +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
1244 +index 54872f8f2f7d..e42ece20cd0b 100644
1245 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
1246 ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
1247 +@@ -1149,6 +1149,9 @@ static int mlx5e_set_pauseparam(struct net_device *netdev,
1248 + struct mlx5_core_dev *mdev = priv->mdev;
1249 + int err;
1250 +
1251 ++ if (!MLX5_CAP_GEN(mdev, vport_group_manager))
1252 ++ return -EOPNOTSUPP;
1253 ++
1254 + if (pauseparam->autoneg)
1255 + return -EINVAL;
1256 +
1257 +diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
1258 +index 0acdf73aa1b0..fd2573cca803 100644
1259 +--- a/drivers/net/team/team.c
1260 ++++ b/drivers/net/team/team.c
1261 +@@ -1014,7 +1014,9 @@ static void ___team_compute_features(struct team *team)
1262 + }
1263 +
1264 + team->dev->vlan_features = vlan_features;
1265 +- team->dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL;
1266 ++ team->dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
1267 ++ NETIF_F_HW_VLAN_CTAG_TX |
1268 ++ NETIF_F_HW_VLAN_STAG_TX;
1269 + team->dev->hard_header_len = max_hard_header_len;
1270 +
1271 + team->dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
1272 +diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
1273 +index ee40ac23507a..5fe9f1273fe2 100644
1274 +--- a/drivers/net/usb/pegasus.c
1275 ++++ b/drivers/net/usb/pegasus.c
1276 +@@ -285,7 +285,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
1277 + static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
1278 + {
1279 + int i;
1280 +- __u8 tmp;
1281 ++ __u8 tmp = 0;
1282 + __le16 retdatai;
1283 + int ret;
1284 +
1285 +diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
1286 +index e1bfc9522cbe..174e45d78c46 100644
1287 +--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
1288 ++++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
1289 +@@ -439,6 +439,8 @@ static void iwl_pcie_tfd_unmap(struct iwl_trans *trans,
1290 + DMA_TO_DEVICE);
1291 + }
1292 +
1293 ++ meta->tbs = 0;
1294 ++
1295 + if (trans->cfg->use_tfh) {
1296 + struct iwl_tfh_tfd *tfd_fh = (void *)tfd;
1297 +
1298 +diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h
1299 +index 26df28f4bfb2..d4e19efb75af 100644
1300 +--- a/drivers/net/wireless/marvell/mwifiex/main.h
1301 ++++ b/drivers/net/wireless/marvell/mwifiex/main.h
1302 +@@ -120,6 +120,7 @@ enum {
1303 +
1304 + #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
1305 +
1306 ++#define WPA_GTK_OUI_OFFSET 2
1307 + #define RSN_GTK_OUI_OFFSET 2
1308 +
1309 + #define MWIFIEX_OUI_NOT_PRESENT 0
1310 +diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
1311 +index 97847eee2dfb..7e96b6a37946 100644
1312 +--- a/drivers/net/wireless/marvell/mwifiex/scan.c
1313 ++++ b/drivers/net/wireless/marvell/mwifiex/scan.c
1314 +@@ -181,7 +181,8 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
1315 + u8 ret = MWIFIEX_OUI_NOT_PRESENT;
1316 +
1317 + if (has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)) {
1318 +- iebody = (struct ie_body *) bss_desc->bcn_wpa_ie->data;
1319 ++ iebody = (struct ie_body *)((u8 *)bss_desc->bcn_wpa_ie->data +
1320 ++ WPA_GTK_OUI_OFFSET);
1321 + oui = &mwifiex_wpa_oui[cipher][0];
1322 + ret = mwifiex_search_oui_in_ie(iebody, oui);
1323 + if (ret)
1324 +diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
1325 +index f57815befc90..a469fbe1abaf 100644
1326 +--- a/drivers/net/xen-netback/netback.c
1327 ++++ b/drivers/net/xen-netback/netback.c
1328 +@@ -927,6 +927,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
1329 + skb_shinfo(skb)->nr_frags = MAX_SKB_FRAGS;
1330 + nskb = xenvif_alloc_skb(0);
1331 + if (unlikely(nskb == NULL)) {
1332 ++ skb_shinfo(skb)->nr_frags = 0;
1333 + kfree_skb(skb);
1334 + xenvif_tx_err(queue, &txreq, extra_count, idx);
1335 + if (net_ratelimit())
1336 +@@ -942,6 +943,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
1337 +
1338 + if (xenvif_set_skb_gso(queue->vif, skb, gso)) {
1339 + /* Failure in xenvif_set_skb_gso is fatal. */
1340 ++ skb_shinfo(skb)->nr_frags = 0;
1341 + kfree_skb(skb);
1342 + kfree_skb(nskb);
1343 + break;
1344 +diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
1345 +index 58cd0e0c9680..b65cab444802 100644
1346 +--- a/drivers/s390/cio/qdio_main.c
1347 ++++ b/drivers/s390/cio/qdio_main.c
1348 +@@ -1576,13 +1576,13 @@ static int handle_outbound(struct qdio_q *q, unsigned int callflags,
1349 + rc = qdio_kick_outbound_q(q, phys_aob);
1350 + } else if (need_siga_sync(q)) {
1351 + rc = qdio_siga_sync_q(q);
1352 ++ } else if (count < QDIO_MAX_BUFFERS_PER_Q &&
1353 ++ get_buf_state(q, prev_buf(bufnr), &state, 0) > 0 &&
1354 ++ state == SLSB_CU_OUTPUT_PRIMED) {
1355 ++ /* The previous buffer is not processed yet, tack on. */
1356 ++ qperf_inc(q, fast_requeue);
1357 + } else {
1358 +- /* try to fast requeue buffers */
1359 +- get_buf_state(q, prev_buf(bufnr), &state, 0);
1360 +- if (state != SLSB_CU_OUTPUT_PRIMED)
1361 +- rc = qdio_kick_outbound_q(q, 0);
1362 +- else
1363 +- qperf_inc(q, fast_requeue);
1364 ++ rc = qdio_kick_outbound_q(q, 0);
1365 + }
1366 +
1367 + /* in case of SIGA errors we must process the error immediately */
1368 +diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
1369 +index d3145799b92f..98787588247b 100644
1370 +--- a/drivers/scsi/device_handler/scsi_dh_alua.c
1371 ++++ b/drivers/scsi/device_handler/scsi_dh_alua.c
1372 +@@ -53,6 +53,7 @@
1373 + #define ALUA_FAILOVER_TIMEOUT 60
1374 + #define ALUA_FAILOVER_RETRIES 5
1375 + #define ALUA_RTPG_DELAY_MSECS 5
1376 ++#define ALUA_RTPG_RETRY_DELAY 2
1377 +
1378 + /* device handler flags */
1379 + #define ALUA_OPTIMIZE_STPG 0x01
1380 +@@ -681,7 +682,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
1381 + case SCSI_ACCESS_STATE_TRANSITIONING:
1382 + if (time_before(jiffies, pg->expiry)) {
1383 + /* State transition, retry */
1384 +- pg->interval = 2;
1385 ++ pg->interval = ALUA_RTPG_RETRY_DELAY;
1386 + err = SCSI_DH_RETRY;
1387 + } else {
1388 + struct alua_dh_data *h;
1389 +@@ -809,6 +810,8 @@ static void alua_rtpg_work(struct work_struct *work)
1390 + spin_lock_irqsave(&pg->lock, flags);
1391 + pg->flags &= ~ALUA_PG_RUNNING;
1392 + pg->flags |= ALUA_PG_RUN_RTPG;
1393 ++ if (!pg->interval)
1394 ++ pg->interval = ALUA_RTPG_RETRY_DELAY;
1395 + spin_unlock_irqrestore(&pg->lock, flags);
1396 + queue_delayed_work(alua_wq, &pg->rtpg_work,
1397 + pg->interval * HZ);
1398 +@@ -820,6 +823,8 @@ static void alua_rtpg_work(struct work_struct *work)
1399 + spin_lock_irqsave(&pg->lock, flags);
1400 + if (err == SCSI_DH_RETRY || pg->flags & ALUA_PG_RUN_RTPG) {
1401 + pg->flags &= ~ALUA_PG_RUNNING;
1402 ++ if (!pg->interval && !(pg->flags & ALUA_PG_RUN_RTPG))
1403 ++ pg->interval = ALUA_RTPG_RETRY_DELAY;
1404 + pg->flags |= ALUA_PG_RUN_RTPG;
1405 + spin_unlock_irqrestore(&pg->lock, flags);
1406 + queue_delayed_work(alua_wq, &pg->rtpg_work,
1407 +diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
1408 +index 9f98c7211ec2..b82df8cdf962 100644
1409 +--- a/drivers/scsi/hpsa.c
1410 ++++ b/drivers/scsi/hpsa.c
1411 +@@ -2236,6 +2236,8 @@ static int handle_ioaccel_mode2_error(struct ctlr_info *h,
1412 + case IOACCEL2_SERV_RESPONSE_COMPLETE:
1413 + switch (c2->error_data.status) {
1414 + case IOACCEL2_STATUS_SR_TASK_COMP_GOOD:
1415 ++ if (cmd)
1416 ++ cmd->result = 0;
1417 + break;
1418 + case IOACCEL2_STATUS_SR_TASK_COMP_CHK_COND:
1419 + cmd->result |= SAM_STAT_CHECK_CONDITION;
1420 +@@ -2423,8 +2425,10 @@ static void process_ioaccel2_completion(struct ctlr_info *h,
1421 +
1422 + /* check for good status */
1423 + if (likely(c2->error_data.serv_response == 0 &&
1424 +- c2->error_data.status == 0))
1425 ++ c2->error_data.status == 0)) {
1426 ++ cmd->result = 0;
1427 + return hpsa_cmd_free_and_done(h, c, cmd);
1428 ++ }
1429 +
1430 + /*
1431 + * Any RAID offload error results in retry which will use
1432 +@@ -5511,6 +5515,12 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
1433 + }
1434 + c = cmd_tagged_alloc(h, cmd);
1435 +
1436 ++ /*
1437 ++ * This is necessary because the SML doesn't zero out this field during
1438 ++ * error recovery.
1439 ++ */
1440 ++ cmd->result = 0;
1441 ++
1442 + /*
1443 + * Call alternate submit routine for I/O accelerated commands.
1444 + * Retries always go down the normal I/O path.
1445 +diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
1446 +index 7e487c78279c..54dea767dfde 100644
1447 +--- a/drivers/scsi/ibmvscsi/ibmvfc.c
1448 ++++ b/drivers/scsi/ibmvscsi/ibmvfc.c
1449 +@@ -4883,8 +4883,8 @@ static int ibmvfc_remove(struct vio_dev *vdev)
1450 +
1451 + spin_lock_irqsave(vhost->host->host_lock, flags);
1452 + ibmvfc_purge_requests(vhost, DID_ERROR);
1453 +- ibmvfc_free_event_pool(vhost);
1454 + spin_unlock_irqrestore(vhost->host->host_lock, flags);
1455 ++ ibmvfc_free_event_pool(vhost);
1456 +
1457 + ibmvfc_free_mem(vhost);
1458 + spin_lock(&ibmvfc_driver_lock);
1459 +diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
1460 +index 5b1c37e3913c..d90693b2767f 100644
1461 +--- a/drivers/scsi/megaraid/megaraid_sas_base.c
1462 ++++ b/drivers/scsi/megaraid/megaraid_sas_base.c
1463 +@@ -2847,6 +2847,7 @@ megasas_fw_crash_buffer_show(struct device *cdev,
1464 + u32 size;
1465 + unsigned long buff_addr;
1466 + unsigned long dmachunk = CRASH_DMA_BUF_SIZE;
1467 ++ unsigned long chunk_left_bytes;
1468 + unsigned long src_addr;
1469 + unsigned long flags;
1470 + u32 buff_offset;
1471 +@@ -2872,6 +2873,8 @@ megasas_fw_crash_buffer_show(struct device *cdev,
1472 + }
1473 +
1474 + size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset;
1475 ++ chunk_left_bytes = dmachunk - (buff_offset % dmachunk);
1476 ++ size = (size > chunk_left_bytes) ? chunk_left_bytes : size;
1477 + size = (size >= PAGE_SIZE) ? (PAGE_SIZE - 1) : size;
1478 +
1479 + src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] +
1480 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
1481 +index a1a5ceb42ce6..6ccde2b41517 100644
1482 +--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
1483 ++++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
1484 +@@ -1707,9 +1707,11 @@ _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev)
1485 + {
1486 + struct sysinfo s;
1487 + u64 consistent_dma_mask;
1488 ++ /* Set 63 bit DMA mask for all SAS3 and SAS35 controllers */
1489 ++ int dma_mask = (ioc->hba_mpi_version_belonged > MPI2_VERSION) ? 63 : 64;
1490 +
1491 + if (ioc->dma_mask)
1492 +- consistent_dma_mask = DMA_BIT_MASK(64);
1493 ++ consistent_dma_mask = DMA_BIT_MASK(dma_mask);
1494 + else
1495 + consistent_dma_mask = DMA_BIT_MASK(32);
1496 +
1497 +@@ -1717,11 +1719,11 @@ _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev)
1498 + const uint64_t required_mask =
1499 + dma_get_required_mask(&pdev->dev);
1500 + if ((required_mask > DMA_BIT_MASK(32)) &&
1501 +- !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
1502 ++ !pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_mask)) &&
1503 + !pci_set_consistent_dma_mask(pdev, consistent_dma_mask)) {
1504 + ioc->base_add_sg_single = &_base_add_sg_single_64;
1505 + ioc->sge_size = sizeof(Mpi2SGESimple64_t);
1506 +- ioc->dma_mask = 64;
1507 ++ ioc->dma_mask = dma_mask;
1508 + goto out;
1509 + }
1510 + }
1511 +@@ -1747,7 +1749,7 @@ static int
1512 + _base_change_consistent_dma_mask(struct MPT3SAS_ADAPTER *ioc,
1513 + struct pci_dev *pdev)
1514 + {
1515 +- if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
1516 ++ if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(ioc->dma_mask))) {
1517 + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)))
1518 + return -ENODEV;
1519 + }
1520 +@@ -3381,7 +3383,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc)
1521 + total_sz += sz;
1522 + } while (ioc->rdpq_array_enable && (++i < ioc->reply_queue_count));
1523 +
1524 +- if (ioc->dma_mask == 64) {
1525 ++ if (ioc->dma_mask > 32) {
1526 + if (_base_change_consistent_dma_mask(ioc, ioc->pdev) != 0) {
1527 + pr_warn(MPT3SAS_FMT
1528 + "no suitable consistent DMA mask for %s\n",
1529 +diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c
1530 +index 19e0b7be8495..917d13abef88 100644
1531 +--- a/drivers/staging/comedi/drivers/dt3000.c
1532 ++++ b/drivers/staging/comedi/drivers/dt3000.c
1533 +@@ -351,9 +351,9 @@ static irqreturn_t dt3k_interrupt(int irq, void *d)
1534 + static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
1535 + unsigned int flags)
1536 + {
1537 +- int divider, base, prescale;
1538 ++ unsigned int divider, base, prescale;
1539 +
1540 +- /* This function needs improvment */
1541 ++ /* This function needs improvement */
1542 + /* Don't know if divider==0 works. */
1543 +
1544 + for (prescale = 0; prescale < 16; prescale++) {
1545 +@@ -367,7 +367,7 @@ static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
1546 + divider = (*nanosec) / base;
1547 + break;
1548 + case CMDF_ROUND_UP:
1549 +- divider = (*nanosec) / base;
1550 ++ divider = DIV_ROUND_UP(*nanosec, base);
1551 + break;
1552 + }
1553 + if (divider < 65536) {
1554 +@@ -377,7 +377,7 @@ static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
1555 + }
1556 +
1557 + prescale = 15;
1558 +- base = timer_base * (1 << prescale);
1559 ++ base = timer_base * (prescale + 1);
1560 + divider = 65535;
1561 + *nanosec = divider * base;
1562 + return (prescale << 16) | (divider);
1563 +diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c
1564 +index dbd7ba32caac..6c5eb99fcfce 100644
1565 +--- a/drivers/tty/tty_ldsem.c
1566 ++++ b/drivers/tty/tty_ldsem.c
1567 +@@ -137,8 +137,7 @@ static void __ldsem_wake_readers(struct ld_semaphore *sem)
1568 +
1569 + list_for_each_entry_safe(waiter, next, &sem->read_wait, list) {
1570 + tsk = waiter->task;
1571 +- smp_mb();
1572 +- waiter->task = NULL;
1573 ++ smp_store_release(&waiter->task, NULL);
1574 + wake_up_process(tsk);
1575 + put_task_struct(tsk);
1576 + }
1577 +@@ -234,7 +233,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout)
1578 + for (;;) {
1579 + set_task_state(tsk, TASK_UNINTERRUPTIBLE);
1580 +
1581 +- if (!waiter.task)
1582 ++ if (!smp_load_acquire(&waiter.task))
1583 + break;
1584 + if (!timeout)
1585 + break;
1586 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1587 +index 8d4d46f3fd16..b2edbd4bf8c4 100644
1588 +--- a/drivers/usb/class/cdc-acm.c
1589 ++++ b/drivers/usb/class/cdc-acm.c
1590 +@@ -1264,10 +1264,6 @@ made_compressed_probe:
1591 + if (acm == NULL)
1592 + goto alloc_fail;
1593 +
1594 +- minor = acm_alloc_minor(acm);
1595 +- if (minor < 0)
1596 +- goto alloc_fail1;
1597 +-
1598 + ctrlsize = usb_endpoint_maxp(epctrl);
1599 + readsize = usb_endpoint_maxp(epread) *
1600 + (quirks == SINGLE_RX_URB ? 1 : 2);
1601 +@@ -1275,6 +1271,13 @@ made_compressed_probe:
1602 + acm->writesize = usb_endpoint_maxp(epwrite) * 20;
1603 + acm->control = control_interface;
1604 + acm->data = data_interface;
1605 ++
1606 ++ usb_get_intf(acm->control); /* undone in destruct() */
1607 ++
1608 ++ minor = acm_alloc_minor(acm);
1609 ++ if (minor < 0)
1610 ++ goto alloc_fail1;
1611 ++
1612 + acm->minor = minor;
1613 + acm->dev = usb_dev;
1614 + if (h.usb_cdc_acm_descriptor)
1615 +@@ -1420,7 +1423,6 @@ skip_countries:
1616 + usb_driver_claim_interface(&acm_driver, data_interface, acm);
1617 + usb_set_intfdata(data_interface, acm);
1618 +
1619 +- usb_get_intf(control_interface);
1620 + tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
1621 + &control_interface->dev);
1622 + if (IS_ERR(tty_dev)) {
1623 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1624 +index 52fc2084b310..06a8f645106b 100644
1625 +--- a/drivers/usb/core/devio.c
1626 ++++ b/drivers/usb/core/devio.c
1627 +@@ -1810,8 +1810,6 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1628 + return 0;
1629 +
1630 + error:
1631 +- if (as && as->usbm)
1632 +- dec_usb_memory_use_count(as->usbm, &as->usbm->urb_use_count);
1633 + kfree(isopkt);
1634 + kfree(dr);
1635 + if (as)
1636 +diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
1637 +index 422ce7b20d73..1626abeca8e8 100644
1638 +--- a/drivers/usb/core/file.c
1639 ++++ b/drivers/usb/core/file.c
1640 +@@ -191,9 +191,10 @@ int usb_register_dev(struct usb_interface *intf,
1641 + intf->minor = minor;
1642 + break;
1643 + }
1644 +- up_write(&minor_rwsem);
1645 +- if (intf->minor < 0)
1646 ++ if (intf->minor < 0) {
1647 ++ up_write(&minor_rwsem);
1648 + return -EXFULL;
1649 ++ }
1650 +
1651 + /* create a usb class device for this usb interface */
1652 + snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
1653 +@@ -201,12 +202,11 @@ int usb_register_dev(struct usb_interface *intf,
1654 + MKDEV(USB_MAJOR, minor), class_driver,
1655 + "%s", kbasename(name));
1656 + if (IS_ERR(intf->usb_dev)) {
1657 +- down_write(&minor_rwsem);
1658 + usb_minors[minor] = NULL;
1659 + intf->minor = -1;
1660 +- up_write(&minor_rwsem);
1661 + retval = PTR_ERR(intf->usb_dev);
1662 + }
1663 ++ up_write(&minor_rwsem);
1664 + return retval;
1665 + }
1666 + EXPORT_SYMBOL_GPL(usb_register_dev);
1667 +@@ -232,12 +232,12 @@ void usb_deregister_dev(struct usb_interface *intf,
1668 + return;
1669 +
1670 + dev_dbg(&intf->dev, "removing %d minor\n", intf->minor);
1671 ++ device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor));
1672 +
1673 + down_write(&minor_rwsem);
1674 + usb_minors[intf->minor] = NULL;
1675 + up_write(&minor_rwsem);
1676 +
1677 +- device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor));
1678 + intf->usb_dev = NULL;
1679 + intf->minor = -1;
1680 + destroy_usb_class();
1681 +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
1682 +index 955cd6552e95..d6075d45e10a 100644
1683 +--- a/drivers/usb/core/message.c
1684 ++++ b/drivers/usb/core/message.c
1685 +@@ -2142,14 +2142,14 @@ int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
1686 + (struct usb_cdc_dmm_desc *)buffer;
1687 + break;
1688 + case USB_CDC_MDLM_TYPE:
1689 +- if (elength < sizeof(struct usb_cdc_mdlm_desc *))
1690 ++ if (elength < sizeof(struct usb_cdc_mdlm_desc))
1691 + goto next_desc;
1692 + if (desc)
1693 + return -EINVAL;
1694 + desc = (struct usb_cdc_mdlm_desc *)buffer;
1695 + break;
1696 + case USB_CDC_MDLM_DETAIL_TYPE:
1697 +- if (elength < sizeof(struct usb_cdc_mdlm_detail_desc *))
1698 ++ if (elength < sizeof(struct usb_cdc_mdlm_detail_desc))
1699 + goto next_desc;
1700 + if (detail)
1701 + return -EINVAL;
1702 +diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
1703 +index 0ef29d202263..318e087f8442 100644
1704 +--- a/drivers/usb/misc/iowarrior.c
1705 ++++ b/drivers/usb/misc/iowarrior.c
1706 +@@ -886,19 +886,20 @@ static void iowarrior_disconnect(struct usb_interface *interface)
1707 + dev = usb_get_intfdata(interface);
1708 + mutex_lock(&iowarrior_open_disc_lock);
1709 + usb_set_intfdata(interface, NULL);
1710 ++ /* prevent device read, write and ioctl */
1711 ++ dev->present = 0;
1712 +
1713 + minor = dev->minor;
1714 ++ mutex_unlock(&iowarrior_open_disc_lock);
1715 ++ /* give back our minor - this will call close() locks need to be dropped at this point*/
1716 +
1717 +- /* give back our minor */
1718 + usb_deregister_dev(interface, &iowarrior_class);
1719 +
1720 + mutex_lock(&dev->mutex);
1721 +
1722 + /* prevent device read, write and ioctl */
1723 +- dev->present = 0;
1724 +
1725 + mutex_unlock(&dev->mutex);
1726 +- mutex_unlock(&iowarrior_open_disc_lock);
1727 +
1728 + if (dev->opened) {
1729 + /* There is a process that holds a filedescriptor to the device ,
1730 +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
1731 +index efa3c86bd262..9744e5f996c1 100644
1732 +--- a/drivers/usb/misc/yurex.c
1733 ++++ b/drivers/usb/misc/yurex.c
1734 +@@ -96,7 +96,6 @@ static void yurex_delete(struct kref *kref)
1735 +
1736 + dev_dbg(&dev->interface->dev, "%s\n", __func__);
1737 +
1738 +- usb_put_dev(dev->udev);
1739 + if (dev->cntl_urb) {
1740 + usb_kill_urb(dev->cntl_urb);
1741 + kfree(dev->cntl_req);
1742 +@@ -112,6 +111,7 @@ static void yurex_delete(struct kref *kref)
1743 + dev->int_buffer, dev->urb->transfer_dma);
1744 + usb_free_urb(dev->urb);
1745 + }
1746 ++ usb_put_dev(dev->udev);
1747 + kfree(dev);
1748 + }
1749 +
1750 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1751 +index d7b31fdce94d..1bceb11f3782 100644
1752 +--- a/drivers/usb/serial/option.c
1753 ++++ b/drivers/usb/serial/option.c
1754 +@@ -967,6 +967,11 @@ static const struct usb_device_id option_ids[] = {
1755 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) },
1756 + { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) },
1757 +
1758 ++ /* Motorola devices */
1759 ++ { USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x2a70, 0xff, 0xff, 0xff) }, /* mdm6600 */
1760 ++ { USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x2e0a, 0xff, 0xff, 0xff) }, /* mdm9600 */
1761 ++ { USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x4281, 0x0a, 0x00, 0xfc) }, /* mdm ram dl */
1762 ++ { USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x900e, 0xff, 0xff, 0xff) }, /* mdm qc dl */
1763 +
1764 + { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) },
1765 + { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V620) },
1766 +@@ -1544,6 +1549,7 @@ static const struct usb_device_id option_ids[] = {
1767 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1428, 0xff, 0xff, 0xff), /* Telewell TW-LTE 4G v2 */
1768 + .driver_info = RSVD(2) },
1769 + { USB_DEVICE_INTERFACE_CLASS(ZTE_VENDOR_ID, 0x1476, 0xff) }, /* GosunCn ZTE WeLink ME3630 (ECM/NCM mode) */
1770 ++ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1481, 0xff, 0x00, 0x00) }, /* ZTE MF871A */
1771 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) },
1772 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) },
1773 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) },
1774 +@@ -1949,11 +1955,15 @@ static const struct usb_device_id option_ids[] = {
1775 + .driver_info = RSVD(4) },
1776 + { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff), /* D-Link DWM-222 */
1777 + .driver_info = RSVD(4) },
1778 ++ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e3d, 0xff), /* D-Link DWM-222 A2 */
1779 ++ .driver_info = RSVD(4) },
1780 + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1781 + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1782 + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
1783 + { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2031, 0xff), /* Olicard 600 */
1784 + .driver_info = RSVD(4) },
1785 ++ { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2060, 0xff), /* BroadMobi BM818 */
1786 ++ .driver_info = RSVD(4) },
1787 + { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
1788 + { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
1789 + { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
1790 +diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
1791 +index 75e1089dfb01..dd8798bf88e7 100644
1792 +--- a/drivers/vhost/net.c
1793 ++++ b/drivers/vhost/net.c
1794 +@@ -39,6 +39,12 @@ MODULE_PARM_DESC(experimental_zcopytx, "Enable Zero Copy TX;"
1795 + * Using this limit prevents one virtqueue from starving others. */
1796 + #define VHOST_NET_WEIGHT 0x80000
1797 +
1798 ++/* Max number of packets transferred before requeueing the job.
1799 ++ * Using this limit prevents one virtqueue from starving others with small
1800 ++ * pkts.
1801 ++ */
1802 ++#define VHOST_NET_PKT_WEIGHT 256
1803 ++
1804 + /* MAX number of TX used buffers for outstanding zerocopy */
1805 + #define VHOST_MAX_PEND 128
1806 + #define VHOST_GOODCOPY_LEN 256
1807 +@@ -372,6 +378,7 @@ static void handle_tx(struct vhost_net *net)
1808 + struct socket *sock;
1809 + struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
1810 + bool zcopy, zcopy_used;
1811 ++ int sent_pkts = 0;
1812 +
1813 + mutex_lock(&vq->mutex);
1814 + sock = vq->private_data;
1815 +@@ -386,7 +393,7 @@ static void handle_tx(struct vhost_net *net)
1816 + hdr_size = nvq->vhost_hlen;
1817 + zcopy = nvq->ubufs;
1818 +
1819 +- for (;;) {
1820 ++ do {
1821 + /* Release DMAs done buffers first */
1822 + if (zcopy)
1823 + vhost_zerocopy_signal_used(net, vq);
1824 +@@ -474,11 +481,7 @@ static void handle_tx(struct vhost_net *net)
1825 + vhost_zerocopy_signal_used(net, vq);
1826 + total_len += len;
1827 + vhost_net_tx_packet(net);
1828 +- if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
1829 +- vhost_poll_queue(&vq->poll);
1830 +- break;
1831 +- }
1832 +- }
1833 ++ } while (likely(!vhost_exceeds_weight(vq, ++sent_pkts, total_len)));
1834 + out:
1835 + mutex_unlock(&vq->mutex);
1836 + }
1837 +@@ -656,6 +659,7 @@ static void handle_rx(struct vhost_net *net)
1838 + struct socket *sock;
1839 + struct iov_iter fixup;
1840 + __virtio16 num_buffers;
1841 ++ int recv_pkts = 0;
1842 +
1843 + mutex_lock_nested(&vq->mutex, 0);
1844 + sock = vq->private_data;
1845 +@@ -675,7 +679,10 @@ static void handle_rx(struct vhost_net *net)
1846 + vq->log : NULL;
1847 + mergeable = vhost_has_feature(vq, VIRTIO_NET_F_MRG_RXBUF);
1848 +
1849 +- while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk))) {
1850 ++ do {
1851 ++ sock_len = vhost_net_rx_peek_head_len(net, sock->sk);
1852 ++ if (!sock_len)
1853 ++ break;
1854 + sock_len += sock_hlen;
1855 + vhost_len = sock_len + vhost_hlen;
1856 + headcount = get_rx_bufs(vq, vq->heads, vhost_len,
1857 +@@ -754,12 +761,10 @@ static void handle_rx(struct vhost_net *net)
1858 + vhost_log_write(vq, vq_log, log, vhost_len,
1859 + vq->iov, in);
1860 + total_len += vhost_len;
1861 +- if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
1862 +- vhost_poll_queue(&vq->poll);
1863 +- goto out;
1864 +- }
1865 +- }
1866 +- vhost_net_enable_vq(net, vq);
1867 ++ } while (likely(!vhost_exceeds_weight(vq, ++recv_pkts, total_len)));
1868 ++
1869 ++ if (!sock_len)
1870 ++ vhost_net_enable_vq(net, vq);
1871 + out:
1872 + mutex_unlock(&vq->mutex);
1873 + }
1874 +@@ -828,7 +833,8 @@ static int vhost_net_open(struct inode *inode, struct file *f)
1875 + n->vqs[i].vhost_hlen = 0;
1876 + n->vqs[i].sock_hlen = 0;
1877 + }
1878 +- vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
1879 ++ vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX,
1880 ++ VHOST_NET_PKT_WEIGHT, VHOST_NET_WEIGHT);
1881 +
1882 + vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
1883 + vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
1884 +diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
1885 +index 17f9ad6fdfa5..dad90f6cc3e1 100644
1886 +--- a/drivers/vhost/scsi.c
1887 ++++ b/drivers/vhost/scsi.c
1888 +@@ -58,6 +58,12 @@
1889 + #define VHOST_SCSI_PREALLOC_UPAGES 2048
1890 + #define VHOST_SCSI_PREALLOC_PROT_SGLS 512
1891 +
1892 ++/* Max number of requests before requeueing the job.
1893 ++ * Using this limit prevents one virtqueue from starving others with
1894 ++ * request.
1895 ++ */
1896 ++#define VHOST_SCSI_WEIGHT 256
1897 ++
1898 + struct vhost_scsi_inflight {
1899 + /* Wait for the flush operation to finish */
1900 + struct completion comp;
1901 +@@ -845,7 +851,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
1902 + u64 tag;
1903 + u32 exp_data_len, data_direction;
1904 + unsigned out, in;
1905 +- int head, ret, prot_bytes;
1906 ++ int head, ret, prot_bytes, c = 0;
1907 + size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp);
1908 + size_t out_size, in_size;
1909 + u16 lun;
1910 +@@ -864,7 +870,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
1911 +
1912 + vhost_disable_notify(&vs->dev, vq);
1913 +
1914 +- for (;;) {
1915 ++ do {
1916 + head = vhost_get_vq_desc(vq, vq->iov,
1917 + ARRAY_SIZE(vq->iov), &out, &in,
1918 + NULL, NULL);
1919 +@@ -1080,7 +1086,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
1920 + */
1921 + INIT_WORK(&cmd->work, vhost_scsi_submission_work);
1922 + queue_work(vhost_scsi_workqueue, &cmd->work);
1923 +- }
1924 ++ } while (likely(!vhost_exceeds_weight(vq, ++c, 0)));
1925 + out:
1926 + mutex_unlock(&vq->mutex);
1927 + }
1928 +@@ -1433,7 +1439,8 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
1929 + vqs[i] = &vs->vqs[i].vq;
1930 + vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
1931 + }
1932 +- vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
1933 ++ vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ,
1934 ++ VHOST_SCSI_WEIGHT, 0);
1935 +
1936 + vhost_scsi_init_inflight(vs, NULL);
1937 +
1938 +diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
1939 +index a54dbfe664cd..8da95d4ac4b7 100644
1940 +--- a/drivers/vhost/vhost.c
1941 ++++ b/drivers/vhost/vhost.c
1942 +@@ -393,8 +393,24 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)
1943 + vhost_vq_free_iovecs(dev->vqs[i]);
1944 + }
1945 +
1946 ++bool vhost_exceeds_weight(struct vhost_virtqueue *vq,
1947 ++ int pkts, int total_len)
1948 ++{
1949 ++ struct vhost_dev *dev = vq->dev;
1950 ++
1951 ++ if ((dev->byte_weight && total_len >= dev->byte_weight) ||
1952 ++ pkts >= dev->weight) {
1953 ++ vhost_poll_queue(&vq->poll);
1954 ++ return true;
1955 ++ }
1956 ++
1957 ++ return false;
1958 ++}
1959 ++EXPORT_SYMBOL_GPL(vhost_exceeds_weight);
1960 ++
1961 + void vhost_dev_init(struct vhost_dev *dev,
1962 +- struct vhost_virtqueue **vqs, int nvqs)
1963 ++ struct vhost_virtqueue **vqs, int nvqs,
1964 ++ int weight, int byte_weight)
1965 + {
1966 + struct vhost_virtqueue *vq;
1967 + int i;
1968 +@@ -408,6 +424,8 @@ void vhost_dev_init(struct vhost_dev *dev,
1969 + dev->iotlb = NULL;
1970 + dev->mm = NULL;
1971 + dev->worker = NULL;
1972 ++ dev->weight = weight;
1973 ++ dev->byte_weight = byte_weight;
1974 + init_llist_head(&dev->work_list);
1975 + init_waitqueue_head(&dev->wait);
1976 + INIT_LIST_HEAD(&dev->read_list);
1977 +diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
1978 +index e8efe1af7487..7932ad8d071a 100644
1979 +--- a/drivers/vhost/vhost.h
1980 ++++ b/drivers/vhost/vhost.h
1981 +@@ -164,9 +164,13 @@ struct vhost_dev {
1982 + struct list_head read_list;
1983 + struct list_head pending_list;
1984 + wait_queue_head_t wait;
1985 ++ int weight;
1986 ++ int byte_weight;
1987 + };
1988 +
1989 +-void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
1990 ++bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
1991 ++void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs,
1992 ++ int nvqs, int weight, int byte_weight);
1993 + long vhost_dev_set_owner(struct vhost_dev *dev);
1994 + bool vhost_dev_has_owner(struct vhost_dev *dev);
1995 + long vhost_dev_check_owner(struct vhost_dev *);
1996 +diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
1997 +index 3cefd602b5b1..a775493b7b67 100644
1998 +--- a/drivers/vhost/vsock.c
1999 ++++ b/drivers/vhost/vsock.c
2000 +@@ -21,6 +21,14 @@
2001 + #include "vhost.h"
2002 +
2003 + #define VHOST_VSOCK_DEFAULT_HOST_CID 2
2004 ++/* Max number of bytes transferred before requeueing the job.
2005 ++ * Using this limit prevents one virtqueue from starving others. */
2006 ++#define VHOST_VSOCK_WEIGHT 0x80000
2007 ++/* Max number of packets transferred before requeueing the job.
2008 ++ * Using this limit prevents one virtqueue from starving others with
2009 ++ * small pkts.
2010 ++ */
2011 ++#define VHOST_VSOCK_PKT_WEIGHT 256
2012 +
2013 + enum {
2014 + VHOST_VSOCK_FEATURES = VHOST_FEATURES,
2015 +@@ -529,7 +537,9 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file)
2016 + vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick;
2017 + vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick;
2018 +
2019 +- vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs));
2020 ++ vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs),
2021 ++ VHOST_VSOCK_PKT_WEIGHT,
2022 ++ VHOST_VSOCK_WEIGHT);
2023 +
2024 + file->private_data = vsock;
2025 + spin_lock_init(&vsock->send_pkt_list_lock);
2026 +diff --git a/drivers/xen/xen-pciback/conf_space_capability.c b/drivers/xen/xen-pciback/conf_space_capability.c
2027 +index 7f83e9083e9d..b1a1d7de0894 100644
2028 +--- a/drivers/xen/xen-pciback/conf_space_capability.c
2029 ++++ b/drivers/xen/xen-pciback/conf_space_capability.c
2030 +@@ -115,13 +115,12 @@ static int pm_ctrl_write(struct pci_dev *dev, int offset, u16 new_value,
2031 + {
2032 + int err;
2033 + u16 old_value;
2034 +- pci_power_t new_state, old_state;
2035 ++ pci_power_t new_state;
2036 +
2037 + err = pci_read_config_word(dev, offset, &old_value);
2038 + if (err)
2039 + goto out;
2040 +
2041 +- old_state = (pci_power_t)(old_value & PCI_PM_CTRL_STATE_MASK);
2042 + new_state = (pci_power_t)(new_value & PCI_PM_CTRL_STATE_MASK);
2043 +
2044 + new_value &= PM_OK_BITS;
2045 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
2046 +index 52b6e4a40748..5255deac86b2 100644
2047 +--- a/fs/cifs/smb2pdu.c
2048 ++++ b/fs/cifs/smb2pdu.c
2049 +@@ -168,7 +168,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
2050 + if (tcon == NULL)
2051 + return 0;
2052 +
2053 +- if (smb2_command == SMB2_TREE_CONNECT)
2054 ++ if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
2055 + return 0;
2056 +
2057 + if (tcon->tidStatus == CifsExiting) {
2058 +@@ -660,7 +660,12 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data)
2059 + else
2060 + req->SecurityMode = 0;
2061 +
2062 ++#ifdef CONFIG_CIFS_DFS_UPCALL
2063 ++ req->Capabilities = cpu_to_le32(SMB2_GLOBAL_CAP_DFS);
2064 ++#else
2065 + req->Capabilities = 0;
2066 ++#endif /* DFS_UPCALL */
2067 ++
2068 + req->Channel = 0; /* MBZ */
2069 +
2070 + sess_data->iov[0].iov_base = (char *)req;
2071 +diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
2072 +index 01932763b4d1..e108c945ac1f 100644
2073 +--- a/fs/ocfs2/xattr.c
2074 ++++ b/fs/ocfs2/xattr.c
2075 +@@ -3832,7 +3832,6 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2076 + u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2077 + int low_bucket = 0, bucket, high_bucket;
2078 + struct ocfs2_xattr_bucket *search;
2079 +- u32 last_hash;
2080 + u64 blkno, lower_blkno = 0;
2081 +
2082 + search = ocfs2_xattr_bucket_new(inode);
2083 +@@ -3876,8 +3875,6 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2084 + if (xh->xh_count)
2085 + xe = &xh->xh_entries[le16_to_cpu(xh->xh_count) - 1];
2086 +
2087 +- last_hash = le32_to_cpu(xe->xe_name_hash);
2088 +-
2089 + /* record lower_blkno which may be the insert place. */
2090 + lower_blkno = blkno;
2091 +
2092 +diff --git a/include/asm-generic/getorder.h b/include/asm-generic/getorder.h
2093 +index 65e4468ac53d..52fbf236a90e 100644
2094 +--- a/include/asm-generic/getorder.h
2095 ++++ b/include/asm-generic/getorder.h
2096 +@@ -6,24 +6,6 @@
2097 + #include <linux/compiler.h>
2098 + #include <linux/log2.h>
2099 +
2100 +-/*
2101 +- * Runtime evaluation of get_order()
2102 +- */
2103 +-static inline __attribute_const__
2104 +-int __get_order(unsigned long size)
2105 +-{
2106 +- int order;
2107 +-
2108 +- size--;
2109 +- size >>= PAGE_SHIFT;
2110 +-#if BITS_PER_LONG == 32
2111 +- order = fls(size);
2112 +-#else
2113 +- order = fls64(size);
2114 +-#endif
2115 +- return order;
2116 +-}
2117 +-
2118 + /**
2119 + * get_order - Determine the allocation order of a memory size
2120 + * @size: The size for which to get the order
2121 +@@ -42,19 +24,27 @@ int __get_order(unsigned long size)
2122 + * to hold an object of the specified size.
2123 + *
2124 + * The result is undefined if the size is 0.
2125 +- *
2126 +- * This function may be used to initialise variables with compile time
2127 +- * evaluations of constants.
2128 + */
2129 +-#define get_order(n) \
2130 +-( \
2131 +- __builtin_constant_p(n) ? ( \
2132 +- ((n) == 0UL) ? BITS_PER_LONG - PAGE_SHIFT : \
2133 +- (((n) < (1UL << PAGE_SHIFT)) ? 0 : \
2134 +- ilog2((n) - 1) - PAGE_SHIFT + 1) \
2135 +- ) : \
2136 +- __get_order(n) \
2137 +-)
2138 ++static inline __attribute_const__ int get_order(unsigned long size)
2139 ++{
2140 ++ if (__builtin_constant_p(size)) {
2141 ++ if (!size)
2142 ++ return BITS_PER_LONG - PAGE_SHIFT;
2143 ++
2144 ++ if (size < (1UL << PAGE_SHIFT))
2145 ++ return 0;
2146 ++
2147 ++ return ilog2((size) - 1) - PAGE_SHIFT + 1;
2148 ++ }
2149 ++
2150 ++ size--;
2151 ++ size >>= PAGE_SHIFT;
2152 ++#if BITS_PER_LONG == 32
2153 ++ return fls(size);
2154 ++#else
2155 ++ return fls64(size);
2156 ++#endif
2157 ++}
2158 +
2159 + #endif /* __ASSEMBLY__ */
2160 +
2161 +diff --git a/include/linux/filter.h b/include/linux/filter.h
2162 +index 1f09c521adfe..0837d904405a 100644
2163 +--- a/include/linux/filter.h
2164 ++++ b/include/linux/filter.h
2165 +@@ -599,6 +599,7 @@ void bpf_warn_invalid_xdp_action(u32 act);
2166 + #ifdef CONFIG_BPF_JIT
2167 + extern int bpf_jit_enable;
2168 + extern int bpf_jit_harden;
2169 ++extern long bpf_jit_limit;
2170 +
2171 + typedef void (*bpf_jit_fill_hole_t)(void *area, unsigned int size);
2172 +
2173 +diff --git a/include/linux/siphash.h b/include/linux/siphash.h
2174 +new file mode 100644
2175 +index 000000000000..bf21591a9e5e
2176 +--- /dev/null
2177 ++++ b/include/linux/siphash.h
2178 +@@ -0,0 +1,145 @@
2179 ++/* Copyright (C) 2016 Jason A. Donenfeld <Jason@×××××.com>. All Rights Reserved.
2180 ++ *
2181 ++ * This file is provided under a dual BSD/GPLv2 license.
2182 ++ *
2183 ++ * SipHash: a fast short-input PRF
2184 ++ * https://131002.net/siphash/
2185 ++ *
2186 ++ * This implementation is specifically for SipHash2-4 for a secure PRF
2187 ++ * and HalfSipHash1-3/SipHash1-3 for an insecure PRF only suitable for
2188 ++ * hashtables.
2189 ++ */
2190 ++
2191 ++#ifndef _LINUX_SIPHASH_H
2192 ++#define _LINUX_SIPHASH_H
2193 ++
2194 ++#include <linux/types.h>
2195 ++#include <linux/kernel.h>
2196 ++
2197 ++#define SIPHASH_ALIGNMENT __alignof__(u64)
2198 ++typedef struct {
2199 ++ u64 key[2];
2200 ++} siphash_key_t;
2201 ++
2202 ++static inline bool siphash_key_is_zero(const siphash_key_t *key)
2203 ++{
2204 ++ return !(key->key[0] | key->key[1]);
2205 ++}
2206 ++
2207 ++u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key);
2208 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2209 ++u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key);
2210 ++#endif
2211 ++
2212 ++u64 siphash_1u64(const u64 a, const siphash_key_t *key);
2213 ++u64 siphash_2u64(const u64 a, const u64 b, const siphash_key_t *key);
2214 ++u64 siphash_3u64(const u64 a, const u64 b, const u64 c,
2215 ++ const siphash_key_t *key);
2216 ++u64 siphash_4u64(const u64 a, const u64 b, const u64 c, const u64 d,
2217 ++ const siphash_key_t *key);
2218 ++u64 siphash_1u32(const u32 a, const siphash_key_t *key);
2219 ++u64 siphash_3u32(const u32 a, const u32 b, const u32 c,
2220 ++ const siphash_key_t *key);
2221 ++
2222 ++static inline u64 siphash_2u32(const u32 a, const u32 b,
2223 ++ const siphash_key_t *key)
2224 ++{
2225 ++ return siphash_1u64((u64)b << 32 | a, key);
2226 ++}
2227 ++static inline u64 siphash_4u32(const u32 a, const u32 b, const u32 c,
2228 ++ const u32 d, const siphash_key_t *key)
2229 ++{
2230 ++ return siphash_2u64((u64)b << 32 | a, (u64)d << 32 | c, key);
2231 ++}
2232 ++
2233 ++
2234 ++static inline u64 ___siphash_aligned(const __le64 *data, size_t len,
2235 ++ const siphash_key_t *key)
2236 ++{
2237 ++ if (__builtin_constant_p(len) && len == 4)
2238 ++ return siphash_1u32(le32_to_cpup((const __le32 *)data), key);
2239 ++ if (__builtin_constant_p(len) && len == 8)
2240 ++ return siphash_1u64(le64_to_cpu(data[0]), key);
2241 ++ if (__builtin_constant_p(len) && len == 16)
2242 ++ return siphash_2u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]),
2243 ++ key);
2244 ++ if (__builtin_constant_p(len) && len == 24)
2245 ++ return siphash_3u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]),
2246 ++ le64_to_cpu(data[2]), key);
2247 ++ if (__builtin_constant_p(len) && len == 32)
2248 ++ return siphash_4u64(le64_to_cpu(data[0]), le64_to_cpu(data[1]),
2249 ++ le64_to_cpu(data[2]), le64_to_cpu(data[3]),
2250 ++ key);
2251 ++ return __siphash_aligned(data, len, key);
2252 ++}
2253 ++
2254 ++/**
2255 ++ * siphash - compute 64-bit siphash PRF value
2256 ++ * @data: buffer to hash
2257 ++ * @size: size of @data
2258 ++ * @key: the siphash key
2259 ++ */
2260 ++static inline u64 siphash(const void *data, size_t len,
2261 ++ const siphash_key_t *key)
2262 ++{
2263 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2264 ++ if (!IS_ALIGNED((unsigned long)data, SIPHASH_ALIGNMENT))
2265 ++ return __siphash_unaligned(data, len, key);
2266 ++#endif
2267 ++ return ___siphash_aligned(data, len, key);
2268 ++}
2269 ++
2270 ++#define HSIPHASH_ALIGNMENT __alignof__(unsigned long)
2271 ++typedef struct {
2272 ++ unsigned long key[2];
2273 ++} hsiphash_key_t;
2274 ++
2275 ++u32 __hsiphash_aligned(const void *data, size_t len,
2276 ++ const hsiphash_key_t *key);
2277 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2278 ++u32 __hsiphash_unaligned(const void *data, size_t len,
2279 ++ const hsiphash_key_t *key);
2280 ++#endif
2281 ++
2282 ++u32 hsiphash_1u32(const u32 a, const hsiphash_key_t *key);
2283 ++u32 hsiphash_2u32(const u32 a, const u32 b, const hsiphash_key_t *key);
2284 ++u32 hsiphash_3u32(const u32 a, const u32 b, const u32 c,
2285 ++ const hsiphash_key_t *key);
2286 ++u32 hsiphash_4u32(const u32 a, const u32 b, const u32 c, const u32 d,
2287 ++ const hsiphash_key_t *key);
2288 ++
2289 ++static inline u32 ___hsiphash_aligned(const __le32 *data, size_t len,
2290 ++ const hsiphash_key_t *key)
2291 ++{
2292 ++ if (__builtin_constant_p(len) && len == 4)
2293 ++ return hsiphash_1u32(le32_to_cpu(data[0]), key);
2294 ++ if (__builtin_constant_p(len) && len == 8)
2295 ++ return hsiphash_2u32(le32_to_cpu(data[0]), le32_to_cpu(data[1]),
2296 ++ key);
2297 ++ if (__builtin_constant_p(len) && len == 12)
2298 ++ return hsiphash_3u32(le32_to_cpu(data[0]), le32_to_cpu(data[1]),
2299 ++ le32_to_cpu(data[2]), key);
2300 ++ if (__builtin_constant_p(len) && len == 16)
2301 ++ return hsiphash_4u32(le32_to_cpu(data[0]), le32_to_cpu(data[1]),
2302 ++ le32_to_cpu(data[2]), le32_to_cpu(data[3]),
2303 ++ key);
2304 ++ return __hsiphash_aligned(data, len, key);
2305 ++}
2306 ++
2307 ++/**
2308 ++ * hsiphash - compute 32-bit hsiphash PRF value
2309 ++ * @data: buffer to hash
2310 ++ * @size: size of @data
2311 ++ * @key: the hsiphash key
2312 ++ */
2313 ++static inline u32 hsiphash(const void *data, size_t len,
2314 ++ const hsiphash_key_t *key)
2315 ++{
2316 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2317 ++ if (!IS_ALIGNED((unsigned long)data, HSIPHASH_ALIGNMENT))
2318 ++ return __hsiphash_unaligned(data, len, key);
2319 ++#endif
2320 ++ return ___hsiphash_aligned(data, len, key);
2321 ++}
2322 ++
2323 ++#endif /* _LINUX_SIPHASH_H */
2324 +diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
2325 +index 9ae819e27940..b57a9f37c297 100644
2326 +--- a/include/net/netfilter/nf_conntrack.h
2327 ++++ b/include/net/netfilter/nf_conntrack.h
2328 +@@ -336,6 +336,8 @@ struct nf_conn *nf_ct_tmpl_alloc(struct net *net,
2329 + gfp_t flags);
2330 + void nf_ct_tmpl_free(struct nf_conn *tmpl);
2331 +
2332 ++u32 nf_ct_get_id(const struct nf_conn *ct);
2333 ++
2334 + #define NF_CT_STAT_INC(net, count) __this_cpu_inc((net)->ct.stat->count)
2335 + #define NF_CT_STAT_INC_ATOMIC(net, count) this_cpu_inc((net)->ct.stat->count)
2336 + #define NF_CT_STAT_ADD_ATOMIC(net, count, v) this_cpu_add((net)->ct.stat->count, (v))
2337 +diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
2338 +index bf619a67ec03..af1c5e7c7e94 100644
2339 +--- a/include/net/netns/ipv4.h
2340 ++++ b/include/net/netns/ipv4.h
2341 +@@ -8,6 +8,7 @@
2342 + #include <linux/uidgid.h>
2343 + #include <net/inet_frag.h>
2344 + #include <linux/rcupdate.h>
2345 ++#include <linux/siphash.h>
2346 +
2347 + struct tcpm_hash_bucket;
2348 + struct ctl_table_header;
2349 +@@ -137,5 +138,6 @@ struct netns_ipv4 {
2350 + int sysctl_fib_multipath_use_neigh;
2351 + #endif
2352 + atomic_t rt_genid;
2353 ++ siphash_key_t ip_id_key;
2354 + };
2355 + #endif
2356 +diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
2357 +index 96bc5acdade3..49482080311a 100644
2358 +--- a/include/sound/compress_driver.h
2359 ++++ b/include/sound/compress_driver.h
2360 +@@ -185,10 +185,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
2361 + if (snd_BUG_ON(!stream))
2362 + return;
2363 +
2364 +- if (stream->direction == SND_COMPRESS_PLAYBACK)
2365 +- stream->runtime->state = SNDRV_PCM_STATE_SETUP;
2366 +- else
2367 +- stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
2368 ++ stream->runtime->state = SNDRV_PCM_STATE_SETUP;
2369 +
2370 + wake_up(&stream->runtime->sleep);
2371 + }
2372 +diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
2373 +index 879ca844ba1d..df2ebce927ec 100644
2374 +--- a/kernel/bpf/core.c
2375 ++++ b/kernel/bpf/core.c
2376 +@@ -208,27 +208,80 @@ struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
2377 + }
2378 +
2379 + #ifdef CONFIG_BPF_JIT
2380 ++/* All BPF JIT sysctl knobs here. */
2381 ++int bpf_jit_enable __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_ALWAYS_ON);
2382 ++int bpf_jit_harden __read_mostly;
2383 ++long bpf_jit_limit __read_mostly;
2384 ++
2385 ++static atomic_long_t bpf_jit_current;
2386 ++
2387 ++/* Can be overridden by an arch's JIT compiler if it has a custom,
2388 ++ * dedicated BPF backend memory area, or if neither of the two
2389 ++ * below apply.
2390 ++ */
2391 ++u64 __weak bpf_jit_alloc_exec_limit(void)
2392 ++{
2393 ++#if defined(MODULES_VADDR)
2394 ++ return MODULES_END - MODULES_VADDR;
2395 ++#else
2396 ++ return VMALLOC_END - VMALLOC_START;
2397 ++#endif
2398 ++}
2399 ++
2400 ++static int __init bpf_jit_charge_init(void)
2401 ++{
2402 ++ /* Only used as heuristic here to derive limit. */
2403 ++ bpf_jit_limit = min_t(u64, round_up(bpf_jit_alloc_exec_limit() >> 2,
2404 ++ PAGE_SIZE), LONG_MAX);
2405 ++ return 0;
2406 ++}
2407 ++pure_initcall(bpf_jit_charge_init);
2408 ++
2409 ++static int bpf_jit_charge_modmem(u32 pages)
2410 ++{
2411 ++ if (atomic_long_add_return(pages, &bpf_jit_current) >
2412 ++ (bpf_jit_limit >> PAGE_SHIFT)) {
2413 ++ if (!capable(CAP_SYS_ADMIN)) {
2414 ++ atomic_long_sub(pages, &bpf_jit_current);
2415 ++ return -EPERM;
2416 ++ }
2417 ++ }
2418 ++
2419 ++ return 0;
2420 ++}
2421 ++
2422 ++static void bpf_jit_uncharge_modmem(u32 pages)
2423 ++{
2424 ++ atomic_long_sub(pages, &bpf_jit_current);
2425 ++}
2426 ++
2427 + struct bpf_binary_header *
2428 + bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
2429 + unsigned int alignment,
2430 + bpf_jit_fill_hole_t bpf_fill_ill_insns)
2431 + {
2432 + struct bpf_binary_header *hdr;
2433 +- unsigned int size, hole, start;
2434 ++ u32 size, hole, start, pages;
2435 +
2436 + /* Most of BPF filters are really small, but if some of them
2437 + * fill a page, allow at least 128 extra bytes to insert a
2438 + * random section of illegal instructions.
2439 + */
2440 + size = round_up(proglen + sizeof(*hdr) + 128, PAGE_SIZE);
2441 ++ pages = size / PAGE_SIZE;
2442 ++
2443 ++ if (bpf_jit_charge_modmem(pages))
2444 ++ return NULL;
2445 + hdr = module_alloc(size);
2446 +- if (hdr == NULL)
2447 ++ if (!hdr) {
2448 ++ bpf_jit_uncharge_modmem(pages);
2449 + return NULL;
2450 ++ }
2451 +
2452 + /* Fill space with illegal/arch-dep instructions. */
2453 + bpf_fill_ill_insns(hdr, size);
2454 +
2455 +- hdr->pages = size / PAGE_SIZE;
2456 ++ hdr->pages = pages;
2457 + hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)),
2458 + PAGE_SIZE - sizeof(*hdr));
2459 + start = (get_random_int() % hole) & ~(alignment - 1);
2460 +@@ -241,11 +294,12 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
2461 +
2462 + void bpf_jit_binary_free(struct bpf_binary_header *hdr)
2463 + {
2464 ++ u32 pages = hdr->pages;
2465 ++
2466 + module_memfree(hdr);
2467 ++ bpf_jit_uncharge_modmem(pages);
2468 + }
2469 +
2470 +-int bpf_jit_harden __read_mostly;
2471 +-
2472 + static int bpf_jit_blind_insn(const struct bpf_insn *from,
2473 + const struct bpf_insn *aux,
2474 + struct bpf_insn *to_buff)
2475 +@@ -925,8 +979,13 @@ load_byte:
2476 + STACK_FRAME_NON_STANDARD(__bpf_prog_run); /* jump table */
2477 +
2478 + #else
2479 +-static unsigned int __bpf_prog_ret0(void *ctx, const struct bpf_insn *insn)
2480 ++static unsigned int __bpf_prog_ret0_warn(void *ctx,
2481 ++ const struct bpf_insn *insn)
2482 + {
2483 ++ /* If this handler ever gets executed, then BPF_JIT_ALWAYS_ON
2484 ++ * is not working properly, so warn about it!
2485 ++ */
2486 ++ WARN_ON_ONCE(1);
2487 + return 0;
2488 + }
2489 + #endif
2490 +@@ -981,7 +1040,7 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)
2491 + #ifndef CONFIG_BPF_JIT_ALWAYS_ON
2492 + fp->bpf_func = (void *) __bpf_prog_run;
2493 + #else
2494 +- fp->bpf_func = (void *) __bpf_prog_ret0;
2495 ++ fp->bpf_func = (void *) __bpf_prog_ret0_warn;
2496 + #endif
2497 +
2498 + /* eBPF JITs can rewrite the program in case constant
2499 +diff --git a/kernel/events/core.c b/kernel/events/core.c
2500 +index 93d7333c64d8..5bbf7537a612 100644
2501 +--- a/kernel/events/core.c
2502 ++++ b/kernel/events/core.c
2503 +@@ -10130,7 +10130,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
2504 + goto err_unlock;
2505 + }
2506 +
2507 +- perf_install_in_context(ctx, event, cpu);
2508 ++ perf_install_in_context(ctx, event, event->cpu);
2509 + perf_unpin_context(ctx);
2510 + mutex_unlock(&ctx->mutex);
2511 +
2512 +diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
2513 +index 58a22ca10f33..4f561860bf41 100644
2514 +--- a/lib/Kconfig.debug
2515 ++++ b/lib/Kconfig.debug
2516 +@@ -1822,9 +1822,9 @@ config TEST_HASH
2517 + tristate "Perform selftest on hash functions"
2518 + default n
2519 + help
2520 +- Enable this option to test the kernel's integer (<linux/hash,h>)
2521 +- and string (<linux/stringhash.h>) hash functions on boot
2522 +- (or module load).
2523 ++ Enable this option to test the kernel's integer (<linux/hash.h>),
2524 ++ string (<linux/stringhash.h>), and siphash (<linux/siphash.h>)
2525 ++ hash functions on boot (or module load).
2526 +
2527 + This is intended to help people writing architecture-specific
2528 + optimized versions. If unsure, say N.
2529 +diff --git a/lib/Makefile b/lib/Makefile
2530 +index 2447a218fff8..452d2956a5a2 100644
2531 +--- a/lib/Makefile
2532 ++++ b/lib/Makefile
2533 +@@ -22,7 +22,8 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
2534 + sha1.o chacha20.o md5.o irq_regs.o argv_split.o \
2535 + flex_proportions.o ratelimit.o show_mem.o \
2536 + is_single_threaded.o plist.o decompress.o kobject_uevent.o \
2537 +- earlycpio.o seq_buf.o nmi_backtrace.o nodemask.o win_minmax.o
2538 ++ earlycpio.o seq_buf.o siphash.o \
2539 ++ nmi_backtrace.o nodemask.o win_minmax.o
2540 +
2541 + lib-$(CONFIG_MMU) += ioremap.o
2542 + lib-$(CONFIG_SMP) += cpumask.o
2543 +@@ -44,7 +45,7 @@ obj-$(CONFIG_TEST_HEXDUMP) += test_hexdump.o
2544 + obj-y += kstrtox.o
2545 + obj-$(CONFIG_TEST_BPF) += test_bpf.o
2546 + obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
2547 +-obj-$(CONFIG_TEST_HASH) += test_hash.o
2548 ++obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o
2549 + obj-$(CONFIG_TEST_KASAN) += test_kasan.o
2550 + CFLAGS_test_kasan.o += -fno-builtin
2551 + obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
2552 +diff --git a/lib/siphash.c b/lib/siphash.c
2553 +new file mode 100644
2554 +index 000000000000..3ae58b4edad6
2555 +--- /dev/null
2556 ++++ b/lib/siphash.c
2557 +@@ -0,0 +1,551 @@
2558 ++/* Copyright (C) 2016 Jason A. Donenfeld <Jason@×××××.com>. All Rights Reserved.
2559 ++ *
2560 ++ * This file is provided under a dual BSD/GPLv2 license.
2561 ++ *
2562 ++ * SipHash: a fast short-input PRF
2563 ++ * https://131002.net/siphash/
2564 ++ *
2565 ++ * This implementation is specifically for SipHash2-4 for a secure PRF
2566 ++ * and HalfSipHash1-3/SipHash1-3 for an insecure PRF only suitable for
2567 ++ * hashtables.
2568 ++ */
2569 ++
2570 ++#include <linux/siphash.h>
2571 ++#include <asm/unaligned.h>
2572 ++
2573 ++#if defined(CONFIG_DCACHE_WORD_ACCESS) && BITS_PER_LONG == 64
2574 ++#include <linux/dcache.h>
2575 ++#include <asm/word-at-a-time.h>
2576 ++#endif
2577 ++
2578 ++#define SIPROUND \
2579 ++ do { \
2580 ++ v0 += v1; v1 = rol64(v1, 13); v1 ^= v0; v0 = rol64(v0, 32); \
2581 ++ v2 += v3; v3 = rol64(v3, 16); v3 ^= v2; \
2582 ++ v0 += v3; v3 = rol64(v3, 21); v3 ^= v0; \
2583 ++ v2 += v1; v1 = rol64(v1, 17); v1 ^= v2; v2 = rol64(v2, 32); \
2584 ++ } while (0)
2585 ++
2586 ++#define PREAMBLE(len) \
2587 ++ u64 v0 = 0x736f6d6570736575ULL; \
2588 ++ u64 v1 = 0x646f72616e646f6dULL; \
2589 ++ u64 v2 = 0x6c7967656e657261ULL; \
2590 ++ u64 v3 = 0x7465646279746573ULL; \
2591 ++ u64 b = ((u64)(len)) << 56; \
2592 ++ v3 ^= key->key[1]; \
2593 ++ v2 ^= key->key[0]; \
2594 ++ v1 ^= key->key[1]; \
2595 ++ v0 ^= key->key[0];
2596 ++
2597 ++#define POSTAMBLE \
2598 ++ v3 ^= b; \
2599 ++ SIPROUND; \
2600 ++ SIPROUND; \
2601 ++ v0 ^= b; \
2602 ++ v2 ^= 0xff; \
2603 ++ SIPROUND; \
2604 ++ SIPROUND; \
2605 ++ SIPROUND; \
2606 ++ SIPROUND; \
2607 ++ return (v0 ^ v1) ^ (v2 ^ v3);
2608 ++
2609 ++u64 __siphash_aligned(const void *data, size_t len, const siphash_key_t *key)
2610 ++{
2611 ++ const u8 *end = data + len - (len % sizeof(u64));
2612 ++ const u8 left = len & (sizeof(u64) - 1);
2613 ++ u64 m;
2614 ++ PREAMBLE(len)
2615 ++ for (; data != end; data += sizeof(u64)) {
2616 ++ m = le64_to_cpup(data);
2617 ++ v3 ^= m;
2618 ++ SIPROUND;
2619 ++ SIPROUND;
2620 ++ v0 ^= m;
2621 ++ }
2622 ++#if defined(CONFIG_DCACHE_WORD_ACCESS) && BITS_PER_LONG == 64
2623 ++ if (left)
2624 ++ b |= le64_to_cpu((__force __le64)(load_unaligned_zeropad(data) &
2625 ++ bytemask_from_count(left)));
2626 ++#else
2627 ++ switch (left) {
2628 ++ case 7: b |= ((u64)end[6]) << 48;
2629 ++ case 6: b |= ((u64)end[5]) << 40;
2630 ++ case 5: b |= ((u64)end[4]) << 32;
2631 ++ case 4: b |= le32_to_cpup(data); break;
2632 ++ case 3: b |= ((u64)end[2]) << 16;
2633 ++ case 2: b |= le16_to_cpup(data); break;
2634 ++ case 1: b |= end[0];
2635 ++ }
2636 ++#endif
2637 ++ POSTAMBLE
2638 ++}
2639 ++EXPORT_SYMBOL(__siphash_aligned);
2640 ++
2641 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2642 ++u64 __siphash_unaligned(const void *data, size_t len, const siphash_key_t *key)
2643 ++{
2644 ++ const u8 *end = data + len - (len % sizeof(u64));
2645 ++ const u8 left = len & (sizeof(u64) - 1);
2646 ++ u64 m;
2647 ++ PREAMBLE(len)
2648 ++ for (; data != end; data += sizeof(u64)) {
2649 ++ m = get_unaligned_le64(data);
2650 ++ v3 ^= m;
2651 ++ SIPROUND;
2652 ++ SIPROUND;
2653 ++ v0 ^= m;
2654 ++ }
2655 ++#if defined(CONFIG_DCACHE_WORD_ACCESS) && BITS_PER_LONG == 64
2656 ++ if (left)
2657 ++ b |= le64_to_cpu((__force __le64)(load_unaligned_zeropad(data) &
2658 ++ bytemask_from_count(left)));
2659 ++#else
2660 ++ switch (left) {
2661 ++ case 7: b |= ((u64)end[6]) << 48;
2662 ++ case 6: b |= ((u64)end[5]) << 40;
2663 ++ case 5: b |= ((u64)end[4]) << 32;
2664 ++ case 4: b |= get_unaligned_le32(end); break;
2665 ++ case 3: b |= ((u64)end[2]) << 16;
2666 ++ case 2: b |= get_unaligned_le16(end); break;
2667 ++ case 1: b |= end[0];
2668 ++ }
2669 ++#endif
2670 ++ POSTAMBLE
2671 ++}
2672 ++EXPORT_SYMBOL(__siphash_unaligned);
2673 ++#endif
2674 ++
2675 ++/**
2676 ++ * siphash_1u64 - compute 64-bit siphash PRF value of a u64
2677 ++ * @first: first u64
2678 ++ * @key: the siphash key
2679 ++ */
2680 ++u64 siphash_1u64(const u64 first, const siphash_key_t *key)
2681 ++{
2682 ++ PREAMBLE(8)
2683 ++ v3 ^= first;
2684 ++ SIPROUND;
2685 ++ SIPROUND;
2686 ++ v0 ^= first;
2687 ++ POSTAMBLE
2688 ++}
2689 ++EXPORT_SYMBOL(siphash_1u64);
2690 ++
2691 ++/**
2692 ++ * siphash_2u64 - compute 64-bit siphash PRF value of 2 u64
2693 ++ * @first: first u64
2694 ++ * @second: second u64
2695 ++ * @key: the siphash key
2696 ++ */
2697 ++u64 siphash_2u64(const u64 first, const u64 second, const siphash_key_t *key)
2698 ++{
2699 ++ PREAMBLE(16)
2700 ++ v3 ^= first;
2701 ++ SIPROUND;
2702 ++ SIPROUND;
2703 ++ v0 ^= first;
2704 ++ v3 ^= second;
2705 ++ SIPROUND;
2706 ++ SIPROUND;
2707 ++ v0 ^= second;
2708 ++ POSTAMBLE
2709 ++}
2710 ++EXPORT_SYMBOL(siphash_2u64);
2711 ++
2712 ++/**
2713 ++ * siphash_3u64 - compute 64-bit siphash PRF value of 3 u64
2714 ++ * @first: first u64
2715 ++ * @second: second u64
2716 ++ * @third: third u64
2717 ++ * @key: the siphash key
2718 ++ */
2719 ++u64 siphash_3u64(const u64 first, const u64 second, const u64 third,
2720 ++ const siphash_key_t *key)
2721 ++{
2722 ++ PREAMBLE(24)
2723 ++ v3 ^= first;
2724 ++ SIPROUND;
2725 ++ SIPROUND;
2726 ++ v0 ^= first;
2727 ++ v3 ^= second;
2728 ++ SIPROUND;
2729 ++ SIPROUND;
2730 ++ v0 ^= second;
2731 ++ v3 ^= third;
2732 ++ SIPROUND;
2733 ++ SIPROUND;
2734 ++ v0 ^= third;
2735 ++ POSTAMBLE
2736 ++}
2737 ++EXPORT_SYMBOL(siphash_3u64);
2738 ++
2739 ++/**
2740 ++ * siphash_4u64 - compute 64-bit siphash PRF value of 4 u64
2741 ++ * @first: first u64
2742 ++ * @second: second u64
2743 ++ * @third: third u64
2744 ++ * @forth: forth u64
2745 ++ * @key: the siphash key
2746 ++ */
2747 ++u64 siphash_4u64(const u64 first, const u64 second, const u64 third,
2748 ++ const u64 forth, const siphash_key_t *key)
2749 ++{
2750 ++ PREAMBLE(32)
2751 ++ v3 ^= first;
2752 ++ SIPROUND;
2753 ++ SIPROUND;
2754 ++ v0 ^= first;
2755 ++ v3 ^= second;
2756 ++ SIPROUND;
2757 ++ SIPROUND;
2758 ++ v0 ^= second;
2759 ++ v3 ^= third;
2760 ++ SIPROUND;
2761 ++ SIPROUND;
2762 ++ v0 ^= third;
2763 ++ v3 ^= forth;
2764 ++ SIPROUND;
2765 ++ SIPROUND;
2766 ++ v0 ^= forth;
2767 ++ POSTAMBLE
2768 ++}
2769 ++EXPORT_SYMBOL(siphash_4u64);
2770 ++
2771 ++u64 siphash_1u32(const u32 first, const siphash_key_t *key)
2772 ++{
2773 ++ PREAMBLE(4)
2774 ++ b |= first;
2775 ++ POSTAMBLE
2776 ++}
2777 ++EXPORT_SYMBOL(siphash_1u32);
2778 ++
2779 ++u64 siphash_3u32(const u32 first, const u32 second, const u32 third,
2780 ++ const siphash_key_t *key)
2781 ++{
2782 ++ u64 combined = (u64)second << 32 | first;
2783 ++ PREAMBLE(12)
2784 ++ v3 ^= combined;
2785 ++ SIPROUND;
2786 ++ SIPROUND;
2787 ++ v0 ^= combined;
2788 ++ b |= third;
2789 ++ POSTAMBLE
2790 ++}
2791 ++EXPORT_SYMBOL(siphash_3u32);
2792 ++
2793 ++#if BITS_PER_LONG == 64
2794 ++/* Note that on 64-bit, we make HalfSipHash1-3 actually be SipHash1-3, for
2795 ++ * performance reasons. On 32-bit, below, we actually implement HalfSipHash1-3.
2796 ++ */
2797 ++
2798 ++#define HSIPROUND SIPROUND
2799 ++#define HPREAMBLE(len) PREAMBLE(len)
2800 ++#define HPOSTAMBLE \
2801 ++ v3 ^= b; \
2802 ++ HSIPROUND; \
2803 ++ v0 ^= b; \
2804 ++ v2 ^= 0xff; \
2805 ++ HSIPROUND; \
2806 ++ HSIPROUND; \
2807 ++ HSIPROUND; \
2808 ++ return (v0 ^ v1) ^ (v2 ^ v3);
2809 ++
2810 ++u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
2811 ++{
2812 ++ const u8 *end = data + len - (len % sizeof(u64));
2813 ++ const u8 left = len & (sizeof(u64) - 1);
2814 ++ u64 m;
2815 ++ HPREAMBLE(len)
2816 ++ for (; data != end; data += sizeof(u64)) {
2817 ++ m = le64_to_cpup(data);
2818 ++ v3 ^= m;
2819 ++ HSIPROUND;
2820 ++ v0 ^= m;
2821 ++ }
2822 ++#if defined(CONFIG_DCACHE_WORD_ACCESS) && BITS_PER_LONG == 64
2823 ++ if (left)
2824 ++ b |= le64_to_cpu((__force __le64)(load_unaligned_zeropad(data) &
2825 ++ bytemask_from_count(left)));
2826 ++#else
2827 ++ switch (left) {
2828 ++ case 7: b |= ((u64)end[6]) << 48;
2829 ++ case 6: b |= ((u64)end[5]) << 40;
2830 ++ case 5: b |= ((u64)end[4]) << 32;
2831 ++ case 4: b |= le32_to_cpup(data); break;
2832 ++ case 3: b |= ((u64)end[2]) << 16;
2833 ++ case 2: b |= le16_to_cpup(data); break;
2834 ++ case 1: b |= end[0];
2835 ++ }
2836 ++#endif
2837 ++ HPOSTAMBLE
2838 ++}
2839 ++EXPORT_SYMBOL(__hsiphash_aligned);
2840 ++
2841 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2842 ++u32 __hsiphash_unaligned(const void *data, size_t len,
2843 ++ const hsiphash_key_t *key)
2844 ++{
2845 ++ const u8 *end = data + len - (len % sizeof(u64));
2846 ++ const u8 left = len & (sizeof(u64) - 1);
2847 ++ u64 m;
2848 ++ HPREAMBLE(len)
2849 ++ for (; data != end; data += sizeof(u64)) {
2850 ++ m = get_unaligned_le64(data);
2851 ++ v3 ^= m;
2852 ++ HSIPROUND;
2853 ++ v0 ^= m;
2854 ++ }
2855 ++#if defined(CONFIG_DCACHE_WORD_ACCESS) && BITS_PER_LONG == 64
2856 ++ if (left)
2857 ++ b |= le64_to_cpu((__force __le64)(load_unaligned_zeropad(data) &
2858 ++ bytemask_from_count(left)));
2859 ++#else
2860 ++ switch (left) {
2861 ++ case 7: b |= ((u64)end[6]) << 48;
2862 ++ case 6: b |= ((u64)end[5]) << 40;
2863 ++ case 5: b |= ((u64)end[4]) << 32;
2864 ++ case 4: b |= get_unaligned_le32(end); break;
2865 ++ case 3: b |= ((u64)end[2]) << 16;
2866 ++ case 2: b |= get_unaligned_le16(end); break;
2867 ++ case 1: b |= end[0];
2868 ++ }
2869 ++#endif
2870 ++ HPOSTAMBLE
2871 ++}
2872 ++EXPORT_SYMBOL(__hsiphash_unaligned);
2873 ++#endif
2874 ++
2875 ++/**
2876 ++ * hsiphash_1u32 - compute 64-bit hsiphash PRF value of a u32
2877 ++ * @first: first u32
2878 ++ * @key: the hsiphash key
2879 ++ */
2880 ++u32 hsiphash_1u32(const u32 first, const hsiphash_key_t *key)
2881 ++{
2882 ++ HPREAMBLE(4)
2883 ++ b |= first;
2884 ++ HPOSTAMBLE
2885 ++}
2886 ++EXPORT_SYMBOL(hsiphash_1u32);
2887 ++
2888 ++/**
2889 ++ * hsiphash_2u32 - compute 32-bit hsiphash PRF value of 2 u32
2890 ++ * @first: first u32
2891 ++ * @second: second u32
2892 ++ * @key: the hsiphash key
2893 ++ */
2894 ++u32 hsiphash_2u32(const u32 first, const u32 second, const hsiphash_key_t *key)
2895 ++{
2896 ++ u64 combined = (u64)second << 32 | first;
2897 ++ HPREAMBLE(8)
2898 ++ v3 ^= combined;
2899 ++ HSIPROUND;
2900 ++ v0 ^= combined;
2901 ++ HPOSTAMBLE
2902 ++}
2903 ++EXPORT_SYMBOL(hsiphash_2u32);
2904 ++
2905 ++/**
2906 ++ * hsiphash_3u32 - compute 32-bit hsiphash PRF value of 3 u32
2907 ++ * @first: first u32
2908 ++ * @second: second u32
2909 ++ * @third: third u32
2910 ++ * @key: the hsiphash key
2911 ++ */
2912 ++u32 hsiphash_3u32(const u32 first, const u32 second, const u32 third,
2913 ++ const hsiphash_key_t *key)
2914 ++{
2915 ++ u64 combined = (u64)second << 32 | first;
2916 ++ HPREAMBLE(12)
2917 ++ v3 ^= combined;
2918 ++ HSIPROUND;
2919 ++ v0 ^= combined;
2920 ++ b |= third;
2921 ++ HPOSTAMBLE
2922 ++}
2923 ++EXPORT_SYMBOL(hsiphash_3u32);
2924 ++
2925 ++/**
2926 ++ * hsiphash_4u32 - compute 32-bit hsiphash PRF value of 4 u32
2927 ++ * @first: first u32
2928 ++ * @second: second u32
2929 ++ * @third: third u32
2930 ++ * @forth: forth u32
2931 ++ * @key: the hsiphash key
2932 ++ */
2933 ++u32 hsiphash_4u32(const u32 first, const u32 second, const u32 third,
2934 ++ const u32 forth, const hsiphash_key_t *key)
2935 ++{
2936 ++ u64 combined = (u64)second << 32 | first;
2937 ++ HPREAMBLE(16)
2938 ++ v3 ^= combined;
2939 ++ HSIPROUND;
2940 ++ v0 ^= combined;
2941 ++ combined = (u64)forth << 32 | third;
2942 ++ v3 ^= combined;
2943 ++ HSIPROUND;
2944 ++ v0 ^= combined;
2945 ++ HPOSTAMBLE
2946 ++}
2947 ++EXPORT_SYMBOL(hsiphash_4u32);
2948 ++#else
2949 ++#define HSIPROUND \
2950 ++ do { \
2951 ++ v0 += v1; v1 = rol32(v1, 5); v1 ^= v0; v0 = rol32(v0, 16); \
2952 ++ v2 += v3; v3 = rol32(v3, 8); v3 ^= v2; \
2953 ++ v0 += v3; v3 = rol32(v3, 7); v3 ^= v0; \
2954 ++ v2 += v1; v1 = rol32(v1, 13); v1 ^= v2; v2 = rol32(v2, 16); \
2955 ++ } while (0)
2956 ++
2957 ++#define HPREAMBLE(len) \
2958 ++ u32 v0 = 0; \
2959 ++ u32 v1 = 0; \
2960 ++ u32 v2 = 0x6c796765U; \
2961 ++ u32 v3 = 0x74656462U; \
2962 ++ u32 b = ((u32)(len)) << 24; \
2963 ++ v3 ^= key->key[1]; \
2964 ++ v2 ^= key->key[0]; \
2965 ++ v1 ^= key->key[1]; \
2966 ++ v0 ^= key->key[0];
2967 ++
2968 ++#define HPOSTAMBLE \
2969 ++ v3 ^= b; \
2970 ++ HSIPROUND; \
2971 ++ v0 ^= b; \
2972 ++ v2 ^= 0xff; \
2973 ++ HSIPROUND; \
2974 ++ HSIPROUND; \
2975 ++ HSIPROUND; \
2976 ++ return v1 ^ v3;
2977 ++
2978 ++u32 __hsiphash_aligned(const void *data, size_t len, const hsiphash_key_t *key)
2979 ++{
2980 ++ const u8 *end = data + len - (len % sizeof(u32));
2981 ++ const u8 left = len & (sizeof(u32) - 1);
2982 ++ u32 m;
2983 ++ HPREAMBLE(len)
2984 ++ for (; data != end; data += sizeof(u32)) {
2985 ++ m = le32_to_cpup(data);
2986 ++ v3 ^= m;
2987 ++ HSIPROUND;
2988 ++ v0 ^= m;
2989 ++ }
2990 ++ switch (left) {
2991 ++ case 3: b |= ((u32)end[2]) << 16;
2992 ++ case 2: b |= le16_to_cpup(data); break;
2993 ++ case 1: b |= end[0];
2994 ++ }
2995 ++ HPOSTAMBLE
2996 ++}
2997 ++EXPORT_SYMBOL(__hsiphash_aligned);
2998 ++
2999 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
3000 ++u32 __hsiphash_unaligned(const void *data, size_t len,
3001 ++ const hsiphash_key_t *key)
3002 ++{
3003 ++ const u8 *end = data + len - (len % sizeof(u32));
3004 ++ const u8 left = len & (sizeof(u32) - 1);
3005 ++ u32 m;
3006 ++ HPREAMBLE(len)
3007 ++ for (; data != end; data += sizeof(u32)) {
3008 ++ m = get_unaligned_le32(data);
3009 ++ v3 ^= m;
3010 ++ HSIPROUND;
3011 ++ v0 ^= m;
3012 ++ }
3013 ++ switch (left) {
3014 ++ case 3: b |= ((u32)end[2]) << 16;
3015 ++ case 2: b |= get_unaligned_le16(end); break;
3016 ++ case 1: b |= end[0];
3017 ++ }
3018 ++ HPOSTAMBLE
3019 ++}
3020 ++EXPORT_SYMBOL(__hsiphash_unaligned);
3021 ++#endif
3022 ++
3023 ++/**
3024 ++ * hsiphash_1u32 - compute 32-bit hsiphash PRF value of a u32
3025 ++ * @first: first u32
3026 ++ * @key: the hsiphash key
3027 ++ */
3028 ++u32 hsiphash_1u32(const u32 first, const hsiphash_key_t *key)
3029 ++{
3030 ++ HPREAMBLE(4)
3031 ++ v3 ^= first;
3032 ++ HSIPROUND;
3033 ++ v0 ^= first;
3034 ++ HPOSTAMBLE
3035 ++}
3036 ++EXPORT_SYMBOL(hsiphash_1u32);
3037 ++
3038 ++/**
3039 ++ * hsiphash_2u32 - compute 32-bit hsiphash PRF value of 2 u32
3040 ++ * @first: first u32
3041 ++ * @second: second u32
3042 ++ * @key: the hsiphash key
3043 ++ */
3044 ++u32 hsiphash_2u32(const u32 first, const u32 second, const hsiphash_key_t *key)
3045 ++{
3046 ++ HPREAMBLE(8)
3047 ++ v3 ^= first;
3048 ++ HSIPROUND;
3049 ++ v0 ^= first;
3050 ++ v3 ^= second;
3051 ++ HSIPROUND;
3052 ++ v0 ^= second;
3053 ++ HPOSTAMBLE
3054 ++}
3055 ++EXPORT_SYMBOL(hsiphash_2u32);
3056 ++
3057 ++/**
3058 ++ * hsiphash_3u32 - compute 32-bit hsiphash PRF value of 3 u32
3059 ++ * @first: first u32
3060 ++ * @second: second u32
3061 ++ * @third: third u32
3062 ++ * @key: the hsiphash key
3063 ++ */
3064 ++u32 hsiphash_3u32(const u32 first, const u32 second, const u32 third,
3065 ++ const hsiphash_key_t *key)
3066 ++{
3067 ++ HPREAMBLE(12)
3068 ++ v3 ^= first;
3069 ++ HSIPROUND;
3070 ++ v0 ^= first;
3071 ++ v3 ^= second;
3072 ++ HSIPROUND;
3073 ++ v0 ^= second;
3074 ++ v3 ^= third;
3075 ++ HSIPROUND;
3076 ++ v0 ^= third;
3077 ++ HPOSTAMBLE
3078 ++}
3079 ++EXPORT_SYMBOL(hsiphash_3u32);
3080 ++
3081 ++/**
3082 ++ * hsiphash_4u32 - compute 32-bit hsiphash PRF value of 4 u32
3083 ++ * @first: first u32
3084 ++ * @second: second u32
3085 ++ * @third: third u32
3086 ++ * @forth: forth u32
3087 ++ * @key: the hsiphash key
3088 ++ */
3089 ++u32 hsiphash_4u32(const u32 first, const u32 second, const u32 third,
3090 ++ const u32 forth, const hsiphash_key_t *key)
3091 ++{
3092 ++ HPREAMBLE(16)
3093 ++ v3 ^= first;
3094 ++ HSIPROUND;
3095 ++ v0 ^= first;
3096 ++ v3 ^= second;
3097 ++ HSIPROUND;
3098 ++ v0 ^= second;
3099 ++ v3 ^= third;
3100 ++ HSIPROUND;
3101 ++ v0 ^= third;
3102 ++ v3 ^= forth;
3103 ++ HSIPROUND;
3104 ++ v0 ^= forth;
3105 ++ HPOSTAMBLE
3106 ++}
3107 ++EXPORT_SYMBOL(hsiphash_4u32);
3108 ++#endif
3109 +diff --git a/lib/test_siphash.c b/lib/test_siphash.c
3110 +new file mode 100644
3111 +index 000000000000..a6d854d933bf
3112 +--- /dev/null
3113 ++++ b/lib/test_siphash.c
3114 +@@ -0,0 +1,223 @@
3115 ++/* Test cases for siphash.c
3116 ++ *
3117 ++ * Copyright (C) 2016 Jason A. Donenfeld <Jason@×××××.com>. All Rights Reserved.
3118 ++ *
3119 ++ * This file is provided under a dual BSD/GPLv2 license.
3120 ++ *
3121 ++ * SipHash: a fast short-input PRF
3122 ++ * https://131002.net/siphash/
3123 ++ *
3124 ++ * This implementation is specifically for SipHash2-4 for a secure PRF
3125 ++ * and HalfSipHash1-3/SipHash1-3 for an insecure PRF only suitable for
3126 ++ * hashtables.
3127 ++ */
3128 ++
3129 ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3130 ++
3131 ++#include <linux/siphash.h>
3132 ++#include <linux/kernel.h>
3133 ++#include <linux/string.h>
3134 ++#include <linux/errno.h>
3135 ++#include <linux/module.h>
3136 ++
3137 ++/* Test vectors taken from reference source available at:
3138 ++ * https://github.com/veorq/SipHash
3139 ++ */
3140 ++
3141 ++static const siphash_key_t test_key_siphash =
3142 ++ {{ 0x0706050403020100ULL, 0x0f0e0d0c0b0a0908ULL }};
3143 ++
3144 ++static const u64 test_vectors_siphash[64] = {
3145 ++ 0x726fdb47dd0e0e31ULL, 0x74f839c593dc67fdULL, 0x0d6c8009d9a94f5aULL,
3146 ++ 0x85676696d7fb7e2dULL, 0xcf2794e0277187b7ULL, 0x18765564cd99a68dULL,
3147 ++ 0xcbc9466e58fee3ceULL, 0xab0200f58b01d137ULL, 0x93f5f5799a932462ULL,
3148 ++ 0x9e0082df0ba9e4b0ULL, 0x7a5dbbc594ddb9f3ULL, 0xf4b32f46226bada7ULL,
3149 ++ 0x751e8fbc860ee5fbULL, 0x14ea5627c0843d90ULL, 0xf723ca908e7af2eeULL,
3150 ++ 0xa129ca6149be45e5ULL, 0x3f2acc7f57c29bdbULL, 0x699ae9f52cbe4794ULL,
3151 ++ 0x4bc1b3f0968dd39cULL, 0xbb6dc91da77961bdULL, 0xbed65cf21aa2ee98ULL,
3152 ++ 0xd0f2cbb02e3b67c7ULL, 0x93536795e3a33e88ULL, 0xa80c038ccd5ccec8ULL,
3153 ++ 0xb8ad50c6f649af94ULL, 0xbce192de8a85b8eaULL, 0x17d835b85bbb15f3ULL,
3154 ++ 0x2f2e6163076bcfadULL, 0xde4daaaca71dc9a5ULL, 0xa6a2506687956571ULL,
3155 ++ 0xad87a3535c49ef28ULL, 0x32d892fad841c342ULL, 0x7127512f72f27cceULL,
3156 ++ 0xa7f32346f95978e3ULL, 0x12e0b01abb051238ULL, 0x15e034d40fa197aeULL,
3157 ++ 0x314dffbe0815a3b4ULL, 0x027990f029623981ULL, 0xcadcd4e59ef40c4dULL,
3158 ++ 0x9abfd8766a33735cULL, 0x0e3ea96b5304a7d0ULL, 0xad0c42d6fc585992ULL,
3159 ++ 0x187306c89bc215a9ULL, 0xd4a60abcf3792b95ULL, 0xf935451de4f21df2ULL,
3160 ++ 0xa9538f0419755787ULL, 0xdb9acddff56ca510ULL, 0xd06c98cd5c0975ebULL,
3161 ++ 0xe612a3cb9ecba951ULL, 0xc766e62cfcadaf96ULL, 0xee64435a9752fe72ULL,
3162 ++ 0xa192d576b245165aULL, 0x0a8787bf8ecb74b2ULL, 0x81b3e73d20b49b6fULL,
3163 ++ 0x7fa8220ba3b2eceaULL, 0x245731c13ca42499ULL, 0xb78dbfaf3a8d83bdULL,
3164 ++ 0xea1ad565322a1a0bULL, 0x60e61c23a3795013ULL, 0x6606d7e446282b93ULL,
3165 ++ 0x6ca4ecb15c5f91e1ULL, 0x9f626da15c9625f3ULL, 0xe51b38608ef25f57ULL,
3166 ++ 0x958a324ceb064572ULL
3167 ++};
3168 ++
3169 ++#if BITS_PER_LONG == 64
3170 ++static const hsiphash_key_t test_key_hsiphash =
3171 ++ {{ 0x0706050403020100ULL, 0x0f0e0d0c0b0a0908ULL }};
3172 ++
3173 ++static const u32 test_vectors_hsiphash[64] = {
3174 ++ 0x050fc4dcU, 0x7d57ca93U, 0x4dc7d44dU,
3175 ++ 0xe7ddf7fbU, 0x88d38328U, 0x49533b67U,
3176 ++ 0xc59f22a7U, 0x9bb11140U, 0x8d299a8eU,
3177 ++ 0x6c063de4U, 0x92ff097fU, 0xf94dc352U,
3178 ++ 0x57b4d9a2U, 0x1229ffa7U, 0xc0f95d34U,
3179 ++ 0x2a519956U, 0x7d908b66U, 0x63dbd80cU,
3180 ++ 0xb473e63eU, 0x8d297d1cU, 0xa6cce040U,
3181 ++ 0x2b45f844U, 0xa320872eU, 0xdae6c123U,
3182 ++ 0x67349c8cU, 0x705b0979U, 0xca9913a5U,
3183 ++ 0x4ade3b35U, 0xef6cd00dU, 0x4ab1e1f4U,
3184 ++ 0x43c5e663U, 0x8c21d1bcU, 0x16a7b60dU,
3185 ++ 0x7a8ff9bfU, 0x1f2a753eU, 0xbf186b91U,
3186 ++ 0xada26206U, 0xa3c33057U, 0xae3a36a1U,
3187 ++ 0x7b108392U, 0x99e41531U, 0x3f1ad944U,
3188 ++ 0xc8138825U, 0xc28949a6U, 0xfaf8876bU,
3189 ++ 0x9f042196U, 0x68b1d623U, 0x8b5114fdU,
3190 ++ 0xdf074c46U, 0x12cc86b3U, 0x0a52098fU,
3191 ++ 0x9d292f9aU, 0xa2f41f12U, 0x43a71ed0U,
3192 ++ 0x73f0bce6U, 0x70a7e980U, 0x243c6d75U,
3193 ++ 0xfdb71513U, 0xa67d8a08U, 0xb7e8f148U,
3194 ++ 0xf7a644eeU, 0x0f1837f2U, 0x4b6694e0U,
3195 ++ 0xb7bbb3a8U
3196 ++};
3197 ++#else
3198 ++static const hsiphash_key_t test_key_hsiphash =
3199 ++ {{ 0x03020100U, 0x07060504U }};
3200 ++
3201 ++static const u32 test_vectors_hsiphash[64] = {
3202 ++ 0x5814c896U, 0xe7e864caU, 0xbc4b0e30U,
3203 ++ 0x01539939U, 0x7e059ea6U, 0x88e3d89bU,
3204 ++ 0xa0080b65U, 0x9d38d9d6U, 0x577999b1U,
3205 ++ 0xc839caedU, 0xe4fa32cfU, 0x959246eeU,
3206 ++ 0x6b28096cU, 0x66dd9cd6U, 0x16658a7cU,
3207 ++ 0xd0257b04U, 0x8b31d501U, 0x2b1cd04bU,
3208 ++ 0x06712339U, 0x522aca67U, 0x911bb605U,
3209 ++ 0x90a65f0eU, 0xf826ef7bU, 0x62512debU,
3210 ++ 0x57150ad7U, 0x5d473507U, 0x1ec47442U,
3211 ++ 0xab64afd3U, 0x0a4100d0U, 0x6d2ce652U,
3212 ++ 0x2331b6a3U, 0x08d8791aU, 0xbc6dda8dU,
3213 ++ 0xe0f6c934U, 0xb0652033U, 0x9b9851ccU,
3214 ++ 0x7c46fb7fU, 0x732ba8cbU, 0xf142997aU,
3215 ++ 0xfcc9aa1bU, 0x05327eb2U, 0xe110131cU,
3216 ++ 0xf9e5e7c0U, 0xa7d708a6U, 0x11795ab1U,
3217 ++ 0x65671619U, 0x9f5fff91U, 0xd89c5267U,
3218 ++ 0x007783ebU, 0x95766243U, 0xab639262U,
3219 ++ 0x9c7e1390U, 0xc368dda6U, 0x38ddc455U,
3220 ++ 0xfa13d379U, 0x979ea4e8U, 0x53ecd77eU,
3221 ++ 0x2ee80657U, 0x33dbb66aU, 0xae3f0577U,
3222 ++ 0x88b4c4ccU, 0x3e7f480bU, 0x74c1ebf8U,
3223 ++ 0x87178304U
3224 ++};
3225 ++#endif
3226 ++
3227 ++static int __init siphash_test_init(void)
3228 ++{
3229 ++ u8 in[64] __aligned(SIPHASH_ALIGNMENT);
3230 ++ u8 in_unaligned[65] __aligned(SIPHASH_ALIGNMENT);
3231 ++ u8 i;
3232 ++ int ret = 0;
3233 ++
3234 ++ for (i = 0; i < 64; ++i) {
3235 ++ in[i] = i;
3236 ++ in_unaligned[i + 1] = i;
3237 ++ if (siphash(in, i, &test_key_siphash) !=
3238 ++ test_vectors_siphash[i]) {
3239 ++ pr_info("siphash self-test aligned %u: FAIL\n", i + 1);
3240 ++ ret = -EINVAL;
3241 ++ }
3242 ++ if (siphash(in_unaligned + 1, i, &test_key_siphash) !=
3243 ++ test_vectors_siphash[i]) {
3244 ++ pr_info("siphash self-test unaligned %u: FAIL\n", i + 1);
3245 ++ ret = -EINVAL;
3246 ++ }
3247 ++ if (hsiphash(in, i, &test_key_hsiphash) !=
3248 ++ test_vectors_hsiphash[i]) {
3249 ++ pr_info("hsiphash self-test aligned %u: FAIL\n", i + 1);
3250 ++ ret = -EINVAL;
3251 ++ }
3252 ++ if (hsiphash(in_unaligned + 1, i, &test_key_hsiphash) !=
3253 ++ test_vectors_hsiphash[i]) {
3254 ++ pr_info("hsiphash self-test unaligned %u: FAIL\n", i + 1);
3255 ++ ret = -EINVAL;
3256 ++ }
3257 ++ }
3258 ++ if (siphash_1u64(0x0706050403020100ULL, &test_key_siphash) !=
3259 ++ test_vectors_siphash[8]) {
3260 ++ pr_info("siphash self-test 1u64: FAIL\n");
3261 ++ ret = -EINVAL;
3262 ++ }
3263 ++ if (siphash_2u64(0x0706050403020100ULL, 0x0f0e0d0c0b0a0908ULL,
3264 ++ &test_key_siphash) != test_vectors_siphash[16]) {
3265 ++ pr_info("siphash self-test 2u64: FAIL\n");
3266 ++ ret = -EINVAL;
3267 ++ }
3268 ++ if (siphash_3u64(0x0706050403020100ULL, 0x0f0e0d0c0b0a0908ULL,
3269 ++ 0x1716151413121110ULL, &test_key_siphash) !=
3270 ++ test_vectors_siphash[24]) {
3271 ++ pr_info("siphash self-test 3u64: FAIL\n");
3272 ++ ret = -EINVAL;
3273 ++ }
3274 ++ if (siphash_4u64(0x0706050403020100ULL, 0x0f0e0d0c0b0a0908ULL,
3275 ++ 0x1716151413121110ULL, 0x1f1e1d1c1b1a1918ULL,
3276 ++ &test_key_siphash) != test_vectors_siphash[32]) {
3277 ++ pr_info("siphash self-test 4u64: FAIL\n");
3278 ++ ret = -EINVAL;
3279 ++ }
3280 ++ if (siphash_1u32(0x03020100U, &test_key_siphash) !=
3281 ++ test_vectors_siphash[4]) {
3282 ++ pr_info("siphash self-test 1u32: FAIL\n");
3283 ++ ret = -EINVAL;
3284 ++ }
3285 ++ if (siphash_2u32(0x03020100U, 0x07060504U, &test_key_siphash) !=
3286 ++ test_vectors_siphash[8]) {
3287 ++ pr_info("siphash self-test 2u32: FAIL\n");
3288 ++ ret = -EINVAL;
3289 ++ }
3290 ++ if (siphash_3u32(0x03020100U, 0x07060504U,
3291 ++ 0x0b0a0908U, &test_key_siphash) !=
3292 ++ test_vectors_siphash[12]) {
3293 ++ pr_info("siphash self-test 3u32: FAIL\n");
3294 ++ ret = -EINVAL;
3295 ++ }
3296 ++ if (siphash_4u32(0x03020100U, 0x07060504U,
3297 ++ 0x0b0a0908U, 0x0f0e0d0cU, &test_key_siphash) !=
3298 ++ test_vectors_siphash[16]) {
3299 ++ pr_info("siphash self-test 4u32: FAIL\n");
3300 ++ ret = -EINVAL;
3301 ++ }
3302 ++ if (hsiphash_1u32(0x03020100U, &test_key_hsiphash) !=
3303 ++ test_vectors_hsiphash[4]) {
3304 ++ pr_info("hsiphash self-test 1u32: FAIL\n");
3305 ++ ret = -EINVAL;
3306 ++ }
3307 ++ if (hsiphash_2u32(0x03020100U, 0x07060504U, &test_key_hsiphash) !=
3308 ++ test_vectors_hsiphash[8]) {
3309 ++ pr_info("hsiphash self-test 2u32: FAIL\n");
3310 ++ ret = -EINVAL;
3311 ++ }
3312 ++ if (hsiphash_3u32(0x03020100U, 0x07060504U,
3313 ++ 0x0b0a0908U, &test_key_hsiphash) !=
3314 ++ test_vectors_hsiphash[12]) {
3315 ++ pr_info("hsiphash self-test 3u32: FAIL\n");
3316 ++ ret = -EINVAL;
3317 ++ }
3318 ++ if (hsiphash_4u32(0x03020100U, 0x07060504U,
3319 ++ 0x0b0a0908U, 0x0f0e0d0cU, &test_key_hsiphash) !=
3320 ++ test_vectors_hsiphash[16]) {
3321 ++ pr_info("hsiphash self-test 4u32: FAIL\n");
3322 ++ ret = -EINVAL;
3323 ++ }
3324 ++ if (!ret)
3325 ++ pr_info("self-tests: pass\n");
3326 ++ return ret;
3327 ++}
3328 ++
3329 ++static void __exit siphash_test_exit(void)
3330 ++{
3331 ++}
3332 ++
3333 ++module_init(siphash_test_init);
3334 ++module_exit(siphash_test_exit);
3335 ++
3336 ++MODULE_AUTHOR("Jason A. Donenfeld <Jason@×××××.com>");
3337 ++MODULE_LICENSE("Dual BSD/GPL");
3338 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
3339 +index 86a6b331b964..cbcbba028c2d 100644
3340 +--- a/mm/memcontrol.c
3341 ++++ b/mm/memcontrol.c
3342 +@@ -887,26 +887,45 @@ void mem_cgroup_iter_break(struct mem_cgroup *root,
3343 + css_put(&prev->css);
3344 + }
3345 +
3346 +-static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)
3347 ++static void __invalidate_reclaim_iterators(struct mem_cgroup *from,
3348 ++ struct mem_cgroup *dead_memcg)
3349 + {
3350 +- struct mem_cgroup *memcg = dead_memcg;
3351 + struct mem_cgroup_reclaim_iter *iter;
3352 + struct mem_cgroup_per_node *mz;
3353 + int nid;
3354 + int i;
3355 +
3356 +- for (; memcg; memcg = parent_mem_cgroup(memcg)) {
3357 +- for_each_node(nid) {
3358 +- mz = mem_cgroup_nodeinfo(memcg, nid);
3359 +- for (i = 0; i <= DEF_PRIORITY; i++) {
3360 +- iter = &mz->iter[i];
3361 +- cmpxchg(&iter->position,
3362 +- dead_memcg, NULL);
3363 +- }
3364 ++ for_each_node(nid) {
3365 ++ mz = mem_cgroup_nodeinfo(from, nid);
3366 ++ for (i = 0; i <= DEF_PRIORITY; i++) {
3367 ++ iter = &mz->iter[i];
3368 ++ cmpxchg(&iter->position,
3369 ++ dead_memcg, NULL);
3370 + }
3371 + }
3372 + }
3373 +
3374 ++static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)
3375 ++{
3376 ++ struct mem_cgroup *memcg = dead_memcg;
3377 ++ struct mem_cgroup *last;
3378 ++
3379 ++ do {
3380 ++ __invalidate_reclaim_iterators(memcg, dead_memcg);
3381 ++ last = memcg;
3382 ++ } while ((memcg = parent_mem_cgroup(memcg)));
3383 ++
3384 ++ /*
3385 ++ * When cgruop1 non-hierarchy mode is used,
3386 ++ * parent_mem_cgroup() does not walk all the way up to the
3387 ++ * cgroup root (root_mem_cgroup). So we have to handle
3388 ++ * dead_memcg from cgroup root separately.
3389 ++ */
3390 ++ if (last != root_mem_cgroup)
3391 ++ __invalidate_reclaim_iterators(root_mem_cgroup,
3392 ++ dead_memcg);
3393 ++}
3394 ++
3395 + /*
3396 + * Iteration constructs for visiting all cgroups (under a tree). If
3397 + * loops are exited prematurely (break), mem_cgroup_iter_break() must
3398 +diff --git a/mm/usercopy.c b/mm/usercopy.c
3399 +index 3c8da0af9695..7683c22551ff 100644
3400 +--- a/mm/usercopy.c
3401 ++++ b/mm/usercopy.c
3402 +@@ -124,7 +124,7 @@ static inline const char *check_kernel_text_object(const void *ptr,
3403 + static inline const char *check_bogus_address(const void *ptr, unsigned long n)
3404 + {
3405 + /* Reject if object wraps past end of memory. */
3406 +- if ((unsigned long)ptr + n < (unsigned long)ptr)
3407 ++ if ((unsigned long)ptr + (n - 1) < (unsigned long)ptr)
3408 + return "<wrapped address>";
3409 +
3410 + /* Reject if NULL or ZERO-allocation. */
3411 +diff --git a/mm/vmalloc.c b/mm/vmalloc.c
3412 +index 73afe460caf0..dd66f1fb3fcf 100644
3413 +--- a/mm/vmalloc.c
3414 ++++ b/mm/vmalloc.c
3415 +@@ -1707,6 +1707,12 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
3416 + if (!addr)
3417 + return NULL;
3418 +
3419 ++ /*
3420 ++ * First make sure the mappings are removed from all page-tables
3421 ++ * before they are freed.
3422 ++ */
3423 ++ vmalloc_sync_all();
3424 ++
3425 + /*
3426 + * In this function, newly allocated vm_struct has VM_UNINITIALIZED
3427 + * flag. It means that vm_struct is not fully initialized.
3428 +@@ -2243,6 +2249,9 @@ EXPORT_SYMBOL(remap_vmalloc_range);
3429 + /*
3430 + * Implement a stub for vmalloc_sync_all() if the architecture chose not to
3431 + * have one.
3432 ++ *
3433 ++ * The purpose of this function is to make sure the vmalloc area
3434 ++ * mappings are identical in all page-tables in the system.
3435 + */
3436 + void __weak vmalloc_sync_all(void)
3437 + {
3438 +diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
3439 +index 546ba76b35a5..a6fc82704f0c 100644
3440 +--- a/net/core/sysctl_net_core.c
3441 ++++ b/net/core/sysctl_net_core.c
3442 +@@ -24,9 +24,12 @@
3443 +
3444 + static int zero = 0;
3445 + static int one = 1;
3446 ++static int two __maybe_unused = 2;
3447 + static int min_sndbuf = SOCK_MIN_SNDBUF;
3448 + static int min_rcvbuf = SOCK_MIN_RCVBUF;
3449 + static int max_skb_frags = MAX_SKB_FRAGS;
3450 ++static long long_one __maybe_unused = 1;
3451 ++static long long_max __maybe_unused = LONG_MAX;
3452 +
3453 + static int net_msg_warn; /* Unused, but still a sysctl */
3454 +
3455 +@@ -231,6 +234,50 @@ static int proc_do_rss_key(struct ctl_table *table, int write,
3456 + return proc_dostring(&fake_table, write, buffer, lenp, ppos);
3457 + }
3458 +
3459 ++#ifdef CONFIG_BPF_JIT
3460 ++static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
3461 ++ void __user *buffer, size_t *lenp,
3462 ++ loff_t *ppos)
3463 ++{
3464 ++ int ret, jit_enable = *(int *)table->data;
3465 ++ struct ctl_table tmp = *table;
3466 ++
3467 ++ if (write && !capable(CAP_SYS_ADMIN))
3468 ++ return -EPERM;
3469 ++
3470 ++ tmp.data = &jit_enable;
3471 ++ ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
3472 ++ if (write && !ret) {
3473 ++ *(int *)table->data = jit_enable;
3474 ++ if (jit_enable == 2)
3475 ++ pr_warn("bpf_jit_enable = 2 was set! NEVER use this in production, only for JIT debugging!\n");
3476 ++ }
3477 ++ return ret;
3478 ++}
3479 ++
3480 ++static int
3481 ++proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
3482 ++ void __user *buffer, size_t *lenp,
3483 ++ loff_t *ppos)
3484 ++{
3485 ++ if (!capable(CAP_SYS_ADMIN))
3486 ++ return -EPERM;
3487 ++
3488 ++ return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
3489 ++}
3490 ++
3491 ++static int
3492 ++proc_dolongvec_minmax_bpf_restricted(struct ctl_table *table, int write,
3493 ++ void __user *buffer, size_t *lenp,
3494 ++ loff_t *ppos)
3495 ++{
3496 ++ if (!capable(CAP_SYS_ADMIN))
3497 ++ return -EPERM;
3498 ++
3499 ++ return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
3500 ++}
3501 ++#endif
3502 ++
3503 + static struct ctl_table net_core_table[] = {
3504 + #ifdef CONFIG_NET
3505 + {
3506 +@@ -292,13 +339,14 @@ static struct ctl_table net_core_table[] = {
3507 + .data = &bpf_jit_enable,
3508 + .maxlen = sizeof(int),
3509 + .mode = 0644,
3510 +-#ifndef CONFIG_BPF_JIT_ALWAYS_ON
3511 +- .proc_handler = proc_dointvec
3512 +-#else
3513 +- .proc_handler = proc_dointvec_minmax,
3514 ++ .proc_handler = proc_dointvec_minmax_bpf_enable,
3515 ++# ifdef CONFIG_BPF_JIT_ALWAYS_ON
3516 + .extra1 = &one,
3517 + .extra2 = &one,
3518 +-#endif
3519 ++# else
3520 ++ .extra1 = &zero,
3521 ++ .extra2 = &two,
3522 ++# endif
3523 + },
3524 + # ifdef CONFIG_HAVE_EBPF_JIT
3525 + {
3526 +@@ -306,9 +354,20 @@ static struct ctl_table net_core_table[] = {
3527 + .data = &bpf_jit_harden,
3528 + .maxlen = sizeof(int),
3529 + .mode = 0600,
3530 +- .proc_handler = proc_dointvec,
3531 ++ .proc_handler = proc_dointvec_minmax_bpf_restricted,
3532 ++ .extra1 = &zero,
3533 ++ .extra2 = &two,
3534 + },
3535 + # endif
3536 ++ {
3537 ++ .procname = "bpf_jit_limit",
3538 ++ .data = &bpf_jit_limit,
3539 ++ .maxlen = sizeof(long),
3540 ++ .mode = 0600,
3541 ++ .proc_handler = proc_dolongvec_minmax_bpf_restricted,
3542 ++ .extra1 = &long_one,
3543 ++ .extra2 = &long_max,
3544 ++ },
3545 + #endif
3546 + {
3547 + .procname = "netdev_tstamp_prequeue",
3548 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
3549 +index 02c49857b5a7..d558dc076577 100644
3550 +--- a/net/ipv4/route.c
3551 ++++ b/net/ipv4/route.c
3552 +@@ -496,15 +496,17 @@ EXPORT_SYMBOL(ip_idents_reserve);
3553 +
3554 + void __ip_select_ident(struct net *net, struct iphdr *iph, int segs)
3555 + {
3556 +- static u32 ip_idents_hashrnd __read_mostly;
3557 + u32 hash, id;
3558 +
3559 +- net_get_random_once(&ip_idents_hashrnd, sizeof(ip_idents_hashrnd));
3560 ++ /* Note the following code is not safe, but this is okay. */
3561 ++ if (unlikely(siphash_key_is_zero(&net->ipv4.ip_id_key)))
3562 ++ get_random_bytes(&net->ipv4.ip_id_key,
3563 ++ sizeof(net->ipv4.ip_id_key));
3564 +
3565 +- hash = jhash_3words((__force u32)iph->daddr,
3566 ++ hash = siphash_3u32((__force u32)iph->daddr,
3567 + (__force u32)iph->saddr,
3568 +- iph->protocol ^ net_hash_mix(net),
3569 +- ip_idents_hashrnd);
3570 ++ iph->protocol,
3571 ++ &net->ipv4.ip_id_key);
3572 + id = ip_idents_reserve(hash, segs);
3573 + iph->id = htons(id);
3574 + }
3575 +diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
3576 +index a338bbc33cf3..6a6d01cb1ace 100644
3577 +--- a/net/ipv6/output_core.c
3578 ++++ b/net/ipv6/output_core.c
3579 +@@ -10,15 +10,25 @@
3580 + #include <net/secure_seq.h>
3581 + #include <linux/netfilter.h>
3582 +
3583 +-static u32 __ipv6_select_ident(struct net *net, u32 hashrnd,
3584 ++static u32 __ipv6_select_ident(struct net *net,
3585 + const struct in6_addr *dst,
3586 + const struct in6_addr *src)
3587 + {
3588 ++ const struct {
3589 ++ struct in6_addr dst;
3590 ++ struct in6_addr src;
3591 ++ } __aligned(SIPHASH_ALIGNMENT) combined = {
3592 ++ .dst = *dst,
3593 ++ .src = *src,
3594 ++ };
3595 + u32 hash, id;
3596 +
3597 +- hash = __ipv6_addr_jhash(dst, hashrnd);
3598 +- hash = __ipv6_addr_jhash(src, hash);
3599 +- hash ^= net_hash_mix(net);
3600 ++ /* Note the following code is not safe, but this is okay. */
3601 ++ if (unlikely(siphash_key_is_zero(&net->ipv4.ip_id_key)))
3602 ++ get_random_bytes(&net->ipv4.ip_id_key,
3603 ++ sizeof(net->ipv4.ip_id_key));
3604 ++
3605 ++ hash = siphash(&combined, sizeof(combined), &net->ipv4.ip_id_key);
3606 +
3607 + /* Treat id of 0 as unset and if we get 0 back from ip_idents_reserve,
3608 + * set the hight order instead thus minimizing possible future
3609 +@@ -41,7 +51,6 @@ static u32 __ipv6_select_ident(struct net *net, u32 hashrnd,
3610 + */
3611 + void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)
3612 + {
3613 +- static u32 ip6_proxy_idents_hashrnd __read_mostly;
3614 + struct in6_addr buf[2];
3615 + struct in6_addr *addrs;
3616 + u32 id;
3617 +@@ -53,11 +62,7 @@ void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)
3618 + if (!addrs)
3619 + return;
3620 +
3621 +- net_get_random_once(&ip6_proxy_idents_hashrnd,
3622 +- sizeof(ip6_proxy_idents_hashrnd));
3623 +-
3624 +- id = __ipv6_select_ident(net, ip6_proxy_idents_hashrnd,
3625 +- &addrs[1], &addrs[0]);
3626 ++ id = __ipv6_select_ident(net, &addrs[1], &addrs[0]);
3627 + skb_shinfo(skb)->ip6_frag_id = htonl(id);
3628 + }
3629 + EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);
3630 +@@ -66,12 +71,9 @@ __be32 ipv6_select_ident(struct net *net,
3631 + const struct in6_addr *daddr,
3632 + const struct in6_addr *saddr)
3633 + {
3634 +- static u32 ip6_idents_hashrnd __read_mostly;
3635 + u32 id;
3636 +
3637 +- net_get_random_once(&ip6_idents_hashrnd, sizeof(ip6_idents_hashrnd));
3638 +-
3639 +- id = __ipv6_select_ident(net, ip6_idents_hashrnd, daddr, saddr);
3640 ++ id = __ipv6_select_ident(net, daddr, saddr);
3641 + return htonl(id);
3642 + }
3643 + EXPORT_SYMBOL(ipv6_select_ident);
3644 +diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c
3645 +index bb886e7db47f..f783d1377d9a 100644
3646 +--- a/net/mac80211/driver-ops.c
3647 ++++ b/net/mac80211/driver-ops.c
3648 +@@ -169,11 +169,16 @@ int drv_conf_tx(struct ieee80211_local *local,
3649 + if (!check_sdata_in_driver(sdata))
3650 + return -EIO;
3651 +
3652 +- if (WARN_ONCE(params->cw_min == 0 ||
3653 +- params->cw_min > params->cw_max,
3654 +- "%s: invalid CW_min/CW_max: %d/%d\n",
3655 +- sdata->name, params->cw_min, params->cw_max))
3656 ++ if (params->cw_min == 0 || params->cw_min > params->cw_max) {
3657 ++ /*
3658 ++ * If we can't configure hardware anyway, don't warn. We may
3659 ++ * never have initialized the CW parameters.
3660 ++ */
3661 ++ WARN_ONCE(local->ops->conf_tx,
3662 ++ "%s: invalid CW_min/CW_max: %d/%d\n",
3663 ++ sdata->name, params->cw_min, params->cw_max);
3664 + return -EINVAL;
3665 ++ }
3666 +
3667 + trace_drv_conf_tx(local, sdata, ac, params);
3668 + if (local->ops->conf_tx)
3669 +diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
3670 +index d787717140e5..f462f026fc6a 100644
3671 +--- a/net/mac80211/mlme.c
3672 ++++ b/net/mac80211/mlme.c
3673 +@@ -1873,6 +1873,16 @@ static bool ieee80211_sta_wmm_params(struct ieee80211_local *local,
3674 + }
3675 + }
3676 +
3677 ++ /* WMM specification requires all 4 ACIs. */
3678 ++ for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3679 ++ if (params[ac].cw_min == 0) {
3680 ++ sdata_info(sdata,
3681 ++ "AP has invalid WMM params (missing AC %d), using defaults\n",
3682 ++ ac);
3683 ++ return false;
3684 ++ }
3685 ++ }
3686 ++
3687 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3688 + mlme_dbg(sdata,
3689 + "WMM AC=%d acm=%d aifs=%d cWmin=%d cWmax=%d txop=%d uapsd=%d, downgraded=%d\n",
3690 +diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
3691 +index df1d5618b008..1bdae8f188e1 100644
3692 +--- a/net/netfilter/nf_conntrack_core.c
3693 ++++ b/net/netfilter/nf_conntrack_core.c
3694 +@@ -25,6 +25,7 @@
3695 + #include <linux/slab.h>
3696 + #include <linux/random.h>
3697 + #include <linux/jhash.h>
3698 ++#include <linux/siphash.h>
3699 + #include <linux/err.h>
3700 + #include <linux/percpu.h>
3701 + #include <linux/moduleparam.h>
3702 +@@ -301,6 +302,40 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
3703 + }
3704 + EXPORT_SYMBOL_GPL(nf_ct_invert_tuple);
3705 +
3706 ++/* Generate a almost-unique pseudo-id for a given conntrack.
3707 ++ *
3708 ++ * intentionally doesn't re-use any of the seeds used for hash
3709 ++ * table location, we assume id gets exposed to userspace.
3710 ++ *
3711 ++ * Following nf_conn items do not change throughout lifetime
3712 ++ * of the nf_conn:
3713 ++ *
3714 ++ * 1. nf_conn address
3715 ++ * 2. nf_conn->master address (normally NULL)
3716 ++ * 3. the associated net namespace
3717 ++ * 4. the original direction tuple
3718 ++ */
3719 ++u32 nf_ct_get_id(const struct nf_conn *ct)
3720 ++{
3721 ++ static __read_mostly siphash_key_t ct_id_seed;
3722 ++ unsigned long a, b, c, d;
3723 ++
3724 ++ net_get_random_once(&ct_id_seed, sizeof(ct_id_seed));
3725 ++
3726 ++ a = (unsigned long)ct;
3727 ++ b = (unsigned long)ct->master;
3728 ++ c = (unsigned long)nf_ct_net(ct);
3729 ++ d = (unsigned long)siphash(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
3730 ++ sizeof(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple),
3731 ++ &ct_id_seed);
3732 ++#ifdef CONFIG_64BIT
3733 ++ return siphash_4u64((u64)a, (u64)b, (u64)c, (u64)d, &ct_id_seed);
3734 ++#else
3735 ++ return siphash_4u32((u32)a, (u32)b, (u32)c, (u32)d, &ct_id_seed);
3736 ++#endif
3737 ++}
3738 ++EXPORT_SYMBOL_GPL(nf_ct_get_id);
3739 ++
3740 + static void
3741 + clean_from_lists(struct nf_conn *ct)
3742 + {
3743 +diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
3744 +index 9e30fd0ab227..deea281ab169 100644
3745 +--- a/net/netfilter/nf_conntrack_netlink.c
3746 ++++ b/net/netfilter/nf_conntrack_netlink.c
3747 +@@ -29,6 +29,7 @@
3748 + #include <linux/spinlock.h>
3749 + #include <linux/interrupt.h>
3750 + #include <linux/slab.h>
3751 ++#include <linux/siphash.h>
3752 +
3753 + #include <linux/netfilter.h>
3754 + #include <net/netlink.h>
3755 +@@ -441,7 +442,9 @@ static int ctnetlink_dump_ct_seq_adj(struct sk_buff *skb,
3756 +
3757 + static int ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct)
3758 + {
3759 +- if (nla_put_be32(skb, CTA_ID, htonl((unsigned long)ct)))
3760 ++ __be32 id = (__force __be32)nf_ct_get_id(ct);
3761 ++
3762 ++ if (nla_put_be32(skb, CTA_ID, id))
3763 + goto nla_put_failure;
3764 + return 0;
3765 +
3766 +@@ -1166,8 +1169,9 @@ static int ctnetlink_del_conntrack(struct net *net, struct sock *ctnl,
3767 + ct = nf_ct_tuplehash_to_ctrack(h);
3768 +
3769 + if (cda[CTA_ID]) {
3770 +- u_int32_t id = ntohl(nla_get_be32(cda[CTA_ID]));
3771 +- if (id != (u32)(unsigned long)ct) {
3772 ++ __be32 id = nla_get_be32(cda[CTA_ID]);
3773 ++
3774 ++ if (id != (__force __be32)nf_ct_get_id(ct)) {
3775 + nf_ct_put(ct);
3776 + return -ENOENT;
3777 + }
3778 +@@ -2472,6 +2476,25 @@ nla_put_failure:
3779 +
3780 + static const union nf_inet_addr any_addr;
3781 +
3782 ++static __be32 nf_expect_get_id(const struct nf_conntrack_expect *exp)
3783 ++{
3784 ++ static __read_mostly siphash_key_t exp_id_seed;
3785 ++ unsigned long a, b, c, d;
3786 ++
3787 ++ net_get_random_once(&exp_id_seed, sizeof(exp_id_seed));
3788 ++
3789 ++ a = (unsigned long)exp;
3790 ++ b = (unsigned long)exp->helper;
3791 ++ c = (unsigned long)exp->master;
3792 ++ d = (unsigned long)siphash(&exp->tuple, sizeof(exp->tuple), &exp_id_seed);
3793 ++
3794 ++#ifdef CONFIG_64BIT
3795 ++ return (__force __be32)siphash_4u64((u64)a, (u64)b, (u64)c, (u64)d, &exp_id_seed);
3796 ++#else
3797 ++ return (__force __be32)siphash_4u32((u32)a, (u32)b, (u32)c, (u32)d, &exp_id_seed);
3798 ++#endif
3799 ++}
3800 ++
3801 + static int
3802 + ctnetlink_exp_dump_expect(struct sk_buff *skb,
3803 + const struct nf_conntrack_expect *exp)
3804 +@@ -2519,7 +2542,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
3805 + }
3806 + #endif
3807 + if (nla_put_be32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout)) ||
3808 +- nla_put_be32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp)) ||
3809 ++ nla_put_be32(skb, CTA_EXPECT_ID, nf_expect_get_id(exp)) ||
3810 + nla_put_be32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags)) ||
3811 + nla_put_be32(skb, CTA_EXPECT_CLASS, htonl(exp->class)))
3812 + goto nla_put_failure;
3813 +@@ -2818,7 +2841,8 @@ static int ctnetlink_get_expect(struct net *net, struct sock *ctnl,
3814 +
3815 + if (cda[CTA_EXPECT_ID]) {
3816 + __be32 id = nla_get_be32(cda[CTA_EXPECT_ID]);
3817 +- if (ntohl(id) != (u32)(unsigned long)exp) {
3818 ++
3819 ++ if (id != nf_expect_get_id(exp)) {
3820 + nf_ct_expect_put(exp);
3821 + return -ENOENT;
3822 + }
3823 +diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
3824 +index 2278d9ab723b..9837a61cb3e3 100644
3825 +--- a/net/netfilter/nfnetlink.c
3826 ++++ b/net/netfilter/nfnetlink.c
3827 +@@ -490,7 +490,7 @@ static int nfnetlink_bind(struct net *net, int group)
3828 + ss = nfnetlink_get_subsys(type << 8);
3829 + rcu_read_unlock();
3830 + if (!ss)
3831 +- request_module("nfnetlink-subsys-%d", type);
3832 ++ request_module_nowait("nfnetlink-subsys-%d", type);
3833 + return 0;
3834 + }
3835 + #endif
3836 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
3837 +index 3578121da79c..b1dbea544d64 100644
3838 +--- a/net/packet/af_packet.c
3839 ++++ b/net/packet/af_packet.c
3840 +@@ -2651,6 +2651,13 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
3841 +
3842 + mutex_lock(&po->pg_vec_lock);
3843 +
3844 ++ /* packet_sendmsg() check on tx_ring.pg_vec was lockless,
3845 ++ * we need to confirm it under protection of pg_vec_lock.
3846 ++ */
3847 ++ if (unlikely(!po->tx_ring.pg_vec)) {
3848 ++ err = -EBUSY;
3849 ++ goto out;
3850 ++ }
3851 + if (likely(saddr == NULL)) {
3852 + dev = packet_cached_dev_get(po);
3853 + proto = po->num;
3854 +diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
3855 +index c345bf153bed..b1ead1776e81 100644
3856 +--- a/net/sctp/sm_sideeffect.c
3857 ++++ b/net/sctp/sm_sideeffect.c
3858 +@@ -508,7 +508,7 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
3859 + */
3860 + if (net->sctp.pf_enable &&
3861 + (transport->state == SCTP_ACTIVE) &&
3862 +- (asoc->pf_retrans < transport->pathmaxrxt) &&
3863 ++ (transport->error_count < transport->pathmaxrxt) &&
3864 + (transport->error_count > asoc->pf_retrans)) {
3865 +
3866 + sctp_assoc_control_transport(asoc, transport,
3867 +diff --git a/net/socket.c b/net/socket.c
3868 +index d9e2989c10c4..bf99bc1fab2c 100644
3869 +--- a/net/socket.c
3870 ++++ b/net/socket.c
3871 +@@ -2550,15 +2550,6 @@ out_fs:
3872 +
3873 + core_initcall(sock_init); /* early initcall */
3874 +
3875 +-static int __init jit_init(void)
3876 +-{
3877 +-#ifdef CONFIG_BPF_JIT_ALWAYS_ON
3878 +- bpf_jit_enable = 1;
3879 +-#endif
3880 +- return 0;
3881 +-}
3882 +-pure_initcall(jit_init);
3883 +-
3884 + #ifdef CONFIG_PROC_FS
3885 + void socket_seq_show(struct seq_file *seq)
3886 + {
3887 +diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
3888 +index 16923ba4b5b1..8cb7971b3f25 100644
3889 +--- a/scripts/Makefile.modpost
3890 ++++ b/scripts/Makefile.modpost
3891 +@@ -74,7 +74,7 @@ modpost = scripts/mod/modpost \
3892 + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
3893 + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
3894 + $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
3895 +- $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \
3896 ++ $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \
3897 + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
3898 + $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
3899 + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
3900 +diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
3901 +index 555df64d46ff..2e2d18468491 100644
3902 +--- a/sound/core/compress_offload.c
3903 ++++ b/sound/core/compress_offload.c
3904 +@@ -575,10 +575,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
3905 + stream->metadata_set = false;
3906 + stream->next_track = false;
3907 +
3908 +- if (stream->direction == SND_COMPRESS_PLAYBACK)
3909 +- stream->runtime->state = SNDRV_PCM_STATE_SETUP;
3910 +- else
3911 +- stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
3912 ++ stream->runtime->state = SNDRV_PCM_STATE_SETUP;
3913 + } else {
3914 + return -EPERM;
3915 + }
3916 +@@ -694,8 +691,17 @@ static int snd_compr_start(struct snd_compr_stream *stream)
3917 + {
3918 + int retval;
3919 +
3920 +- if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED)
3921 ++ switch (stream->runtime->state) {
3922 ++ case SNDRV_PCM_STATE_SETUP:
3923 ++ if (stream->direction != SND_COMPRESS_CAPTURE)
3924 ++ return -EPERM;
3925 ++ break;
3926 ++ case SNDRV_PCM_STATE_PREPARED:
3927 ++ break;
3928 ++ default:
3929 + return -EPERM;
3930 ++ }
3931 ++
3932 + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START);
3933 + if (!retval)
3934 + stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
3935 +@@ -706,9 +712,15 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
3936 + {
3937 + int retval;
3938 +
3939 +- if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
3940 +- stream->runtime->state == SNDRV_PCM_STATE_SETUP)
3941 ++ switch (stream->runtime->state) {
3942 ++ case SNDRV_PCM_STATE_OPEN:
3943 ++ case SNDRV_PCM_STATE_SETUP:
3944 ++ case SNDRV_PCM_STATE_PREPARED:
3945 + return -EPERM;
3946 ++ default:
3947 ++ break;
3948 ++ }
3949 ++
3950 + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
3951 + if (!retval) {
3952 + snd_compr_drain_notify(stream);
3953 +@@ -796,9 +808,17 @@ static int snd_compr_drain(struct snd_compr_stream *stream)
3954 + {
3955 + int retval;
3956 +
3957 +- if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
3958 +- stream->runtime->state == SNDRV_PCM_STATE_SETUP)
3959 ++ switch (stream->runtime->state) {
3960 ++ case SNDRV_PCM_STATE_OPEN:
3961 ++ case SNDRV_PCM_STATE_SETUP:
3962 ++ case SNDRV_PCM_STATE_PREPARED:
3963 ++ case SNDRV_PCM_STATE_PAUSED:
3964 + return -EPERM;
3965 ++ case SNDRV_PCM_STATE_XRUN:
3966 ++ return -EPIPE;
3967 ++ default:
3968 ++ break;
3969 ++ }
3970 +
3971 + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
3972 + if (retval) {
3973 +@@ -818,6 +838,10 @@ static int snd_compr_next_track(struct snd_compr_stream *stream)
3974 + if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
3975 + return -EPERM;
3976 +
3977 ++ /* next track doesn't have any meaning for capture streams */
3978 ++ if (stream->direction == SND_COMPRESS_CAPTURE)
3979 ++ return -EPERM;
3980 ++
3981 + /* you can signal next track if this is intended to be a gapless stream
3982 + * and current track metadata is set
3983 + */
3984 +@@ -835,9 +859,23 @@ static int snd_compr_next_track(struct snd_compr_stream *stream)
3985 + static int snd_compr_partial_drain(struct snd_compr_stream *stream)
3986 + {
3987 + int retval;
3988 +- if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
3989 +- stream->runtime->state == SNDRV_PCM_STATE_SETUP)
3990 ++
3991 ++ switch (stream->runtime->state) {
3992 ++ case SNDRV_PCM_STATE_OPEN:
3993 ++ case SNDRV_PCM_STATE_SETUP:
3994 ++ case SNDRV_PCM_STATE_PREPARED:
3995 ++ case SNDRV_PCM_STATE_PAUSED:
3996 ++ return -EPERM;
3997 ++ case SNDRV_PCM_STATE_XRUN:
3998 ++ return -EPIPE;
3999 ++ default:
4000 ++ break;
4001 ++ }
4002 ++
4003 ++ /* partial drain doesn't have any meaning for capture streams */
4004 ++ if (stream->direction == SND_COMPRESS_CAPTURE)
4005 + return -EPERM;
4006 ++
4007 + /* stream can be drained only when next track has been signalled */
4008 + if (stream->next_track == false)
4009 + return -EPERM;
4010 +diff --git a/sound/firewire/packets-buffer.c b/sound/firewire/packets-buffer.c
4011 +index ea1506679c66..3b09b8ef3a09 100644
4012 +--- a/sound/firewire/packets-buffer.c
4013 ++++ b/sound/firewire/packets-buffer.c
4014 +@@ -37,7 +37,7 @@ int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit,
4015 + packets_per_page = PAGE_SIZE / packet_size;
4016 + if (WARN_ON(!packets_per_page)) {
4017 + err = -EINVAL;
4018 +- goto error;
4019 ++ goto err_packets;
4020 + }
4021 + pages = DIV_ROUND_UP(count, packets_per_page);
4022 +
4023 +diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
4024 +index 56af7308a2fd..85dbe2420248 100644
4025 +--- a/sound/pci/hda/hda_controller.c
4026 ++++ b/sound/pci/hda/hda_controller.c
4027 +@@ -609,11 +609,9 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
4028 + }
4029 + runtime->private_data = azx_dev;
4030 +
4031 +- if (chip->gts_present)
4032 +- azx_pcm_hw.info = azx_pcm_hw.info |
4033 +- SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME;
4034 +-
4035 + runtime->hw = azx_pcm_hw;
4036 ++ if (chip->gts_present)
4037 ++ runtime->hw.info |= SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME;
4038 + runtime->hw.channels_min = hinfo->channels_min;
4039 + runtime->hw.channels_max = hinfo->channels_max;
4040 + runtime->hw.formats = hinfo->formats;
4041 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
4042 +index b0bd29003b5d..98594cbe34c8 100644
4043 +--- a/sound/pci/hda/hda_generic.c
4044 ++++ b/sound/pci/hda/hda_generic.c
4045 +@@ -5849,6 +5849,24 @@ void snd_hda_gen_free(struct hda_codec *codec)
4046 + }
4047 + EXPORT_SYMBOL_GPL(snd_hda_gen_free);
4048 +
4049 ++/**
4050 ++ * snd_hda_gen_reboot_notify - Make codec enter D3 before rebooting
4051 ++ * @codec: the HDA codec
4052 ++ *
4053 ++ * This can be put as patch_ops reboot_notify function.
4054 ++ */
4055 ++void snd_hda_gen_reboot_notify(struct hda_codec *codec)
4056 ++{
4057 ++ /* Make the codec enter D3 to avoid spurious noises from the internal
4058 ++ * speaker during (and after) reboot
4059 ++ */
4060 ++ snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
4061 ++ snd_hda_codec_write(codec, codec->core.afg, 0,
4062 ++ AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4063 ++ msleep(10);
4064 ++}
4065 ++EXPORT_SYMBOL_GPL(snd_hda_gen_reboot_notify);
4066 ++
4067 + #ifdef CONFIG_PM
4068 + /**
4069 + * snd_hda_gen_check_power_status - check the loopback power save state
4070 +@@ -5876,6 +5894,7 @@ static const struct hda_codec_ops generic_patch_ops = {
4071 + .init = snd_hda_gen_init,
4072 + .free = snd_hda_gen_free,
4073 + .unsol_event = snd_hda_jack_unsol_event,
4074 ++ .reboot_notify = snd_hda_gen_reboot_notify,
4075 + #ifdef CONFIG_PM
4076 + .check_power_status = snd_hda_gen_check_power_status,
4077 + #endif
4078 +@@ -5898,7 +5917,7 @@ static int snd_hda_parse_generic_codec(struct hda_codec *codec)
4079 +
4080 + err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
4081 + if (err < 0)
4082 +- return err;
4083 ++ goto error;
4084 +
4085 + err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
4086 + if (err < 0)
4087 +diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
4088 +index f66fc7e25e07..932b533feb48 100644
4089 +--- a/sound/pci/hda/hda_generic.h
4090 ++++ b/sound/pci/hda/hda_generic.h
4091 +@@ -322,6 +322,7 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
4092 + struct auto_pin_cfg *cfg);
4093 + int snd_hda_gen_build_controls(struct hda_codec *codec);
4094 + int snd_hda_gen_build_pcms(struct hda_codec *codec);
4095 ++void snd_hda_gen_reboot_notify(struct hda_codec *codec);
4096 +
4097 + /* standard jack event callbacks */
4098 + void snd_hda_gen_hp_automute(struct hda_codec *codec,
4099 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
4100 +index df66969b124d..8557b94e462c 100644
4101 +--- a/sound/pci/hda/patch_conexant.c
4102 ++++ b/sound/pci/hda/patch_conexant.c
4103 +@@ -204,23 +204,10 @@ static void cx_auto_reboot_notify(struct hda_codec *codec)
4104 + {
4105 + struct conexant_spec *spec = codec->spec;
4106 +
4107 +- switch (codec->core.vendor_id) {
4108 +- case 0x14f12008: /* CX8200 */
4109 +- case 0x14f150f2: /* CX20722 */
4110 +- case 0x14f150f4: /* CX20724 */
4111 +- break;
4112 +- default:
4113 +- return;
4114 +- }
4115 +-
4116 + /* Turn the problematic codec into D3 to avoid spurious noises
4117 + from the internal speaker during (and after) reboot */
4118 + cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
4119 +-
4120 +- snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
4121 +- snd_hda_codec_write(codec, codec->core.afg, 0,
4122 +- AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4123 +- msleep(10);
4124 ++ snd_hda_gen_reboot_notify(codec);
4125 + }
4126 +
4127 + static void cx_auto_free(struct hda_codec *codec)
4128 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4129 +index 04d2dc7097a1..8e995fb27312 100644
4130 +--- a/sound/pci/hda/patch_realtek.c
4131 ++++ b/sound/pci/hda/patch_realtek.c
4132 +@@ -802,15 +802,6 @@ static void alc_reboot_notify(struct hda_codec *codec)
4133 + alc_shutup(codec);
4134 + }
4135 +
4136 +-/* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */
4137 +-static void alc_d3_at_reboot(struct hda_codec *codec)
4138 +-{
4139 +- snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
4140 +- snd_hda_codec_write(codec, codec->core.afg, 0,
4141 +- AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4142 +- msleep(10);
4143 +-}
4144 +-
4145 + #define alc_free snd_hda_gen_free
4146 +
4147 + #ifdef CONFIG_PM
4148 +@@ -4473,7 +4464,7 @@ static void alc_fixup_tpt440_dock(struct hda_codec *codec,
4149 + struct alc_spec *spec = codec->spec;
4150 +
4151 + if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4152 +- spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
4153 ++ spec->reboot_notify = snd_hda_gen_reboot_notify; /* reduce noise */
4154 + spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4155 + codec->power_save_node = 0; /* avoid click noises */
4156 + snd_hda_apply_pincfgs(codec, pincfgs);
4157 +diff --git a/sound/sound_core.c b/sound/sound_core.c
4158 +index 99b73c675743..20d4e2e1bacf 100644
4159 +--- a/sound/sound_core.c
4160 ++++ b/sound/sound_core.c
4161 +@@ -287,7 +287,8 @@ retry:
4162 + goto retry;
4163 + }
4164 + spin_unlock(&sound_loader_lock);
4165 +- return -EBUSY;
4166 ++ r = -EBUSY;
4167 ++ goto fail;
4168 + }
4169 + }
4170 +
4171 +diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
4172 +index d3d1452021d4..f4f8aff8a9bb 100644
4173 +--- a/tools/perf/arch/s390/util/machine.c
4174 ++++ b/tools/perf/arch/s390/util/machine.c
4175 +@@ -6,7 +6,7 @@
4176 + #include "api/fs/fs.h"
4177 + #include "debug.h"
4178 +
4179 +-int arch__fix_module_text_start(u64 *start, const char *name)
4180 ++int arch__fix_module_text_start(u64 *start, u64 *size, const char *name)
4181 + {
4182 + u64 m_start = *start;
4183 + char path[PATH_MAX];
4184 +@@ -16,6 +16,18 @@ int arch__fix_module_text_start(u64 *start, const char *name)
4185 + if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
4186 + pr_debug2("Using module %s start:%#lx\n", path, m_start);
4187 + *start = m_start;
4188 ++ } else {
4189 ++ /* Successful read of the modules segment text start address.
4190 ++ * Calculate difference between module start address
4191 ++ * in memory and module text segment start address.
4192 ++ * For example module load address is 0x3ff8011b000
4193 ++ * (from /proc/modules) and module text segment start
4194 ++ * address is 0x3ff8011b870 (from file above).
4195 ++ *
4196 ++ * Adjust the module size and subtract the GOT table
4197 ++ * size located at the beginning of the module.
4198 ++ */
4199 ++ *size -= (*start - m_start);
4200 + }
4201 +
4202 + return 0;
4203 +diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
4204 +index 9a250c71840e..2b420e7a92c0 100644
4205 +--- a/tools/perf/builtin-probe.c
4206 ++++ b/tools/perf/builtin-probe.c
4207 +@@ -675,6 +675,16 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
4208 +
4209 + ret = perf_add_probe_events(params.events, params.nevents);
4210 + if (ret < 0) {
4211 ++
4212 ++ /*
4213 ++ * When perf_add_probe_events() fails it calls
4214 ++ * cleanup_perf_probe_events(pevs, npevs), i.e.
4215 ++ * cleanup_perf_probe_events(params.events, params.nevents), which
4216 ++ * will call clear_perf_probe_event(), so set nevents to zero
4217 ++ * to avoid cleanup_params() to call clear_perf_probe_event() again
4218 ++ * on the same pevs.
4219 ++ */
4220 ++ params.nevents = 0;
4221 + pr_err_with_code(" Error: Failed to add events.", ret);
4222 + return ret;
4223 + }
4224 +diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
4225 +index 283148104ffb..258b19b251a8 100644
4226 +--- a/tools/perf/util/header.c
4227 ++++ b/tools/perf/util/header.c
4228 +@@ -2854,6 +2854,13 @@ int perf_session__read_header(struct perf_session *session)
4229 + file->path);
4230 + }
4231 +
4232 ++ if (f_header.attr_size == 0) {
4233 ++ pr_err("ERROR: The %s file's attr size field is 0 which is unexpected.\n"
4234 ++ "Was the 'perf record' command properly terminated?\n",
4235 ++ file->path);
4236 ++ return -EINVAL;
4237 ++ }
4238 ++
4239 + nr_attrs = f_header.attrs.size / f_header.attr_size;
4240 + lseek(fd, f_header.attrs.offset, SEEK_SET);
4241 +
4242 +@@ -2936,7 +2943,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool,
4243 + size += sizeof(struct perf_event_header);
4244 + size += ids * sizeof(u64);
4245 +
4246 +- ev = malloc(size);
4247 ++ ev = zalloc(size);
4248 +
4249 + if (ev == NULL)
4250 + return -ENOMEM;
4251 +diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
4252 +index df85b9efd80f..45ea7a8cd818 100644
4253 +--- a/tools/perf/util/machine.c
4254 ++++ b/tools/perf/util/machine.c
4255 +@@ -1074,22 +1074,25 @@ static int machine__set_modules_path(struct machine *machine)
4256 + return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
4257 + }
4258 + int __weak arch__fix_module_text_start(u64 *start __maybe_unused,
4259 ++ u64 *size __maybe_unused,
4260 + const char *name __maybe_unused)
4261 + {
4262 + return 0;
4263 + }
4264 +
4265 +-static int machine__create_module(void *arg, const char *name, u64 start)
4266 ++static int machine__create_module(void *arg, const char *name, u64 start,
4267 ++ u64 size)
4268 + {
4269 + struct machine *machine = arg;
4270 + struct map *map;
4271 +
4272 +- if (arch__fix_module_text_start(&start, name) < 0)
4273 ++ if (arch__fix_module_text_start(&start, &size, name) < 0)
4274 + return -1;
4275 +
4276 + map = machine__findnew_module_map(machine, start, name);
4277 + if (map == NULL)
4278 + return -1;
4279 ++ map->end = start + size;
4280 +
4281 + dso__kernel_module_get_build_id(map->dso, machine->root_dir);
4282 +
4283 +diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
4284 +index 354de6e56109..9b87b8b870ae 100644
4285 +--- a/tools/perf/util/machine.h
4286 ++++ b/tools/perf/util/machine.h
4287 +@@ -205,7 +205,7 @@ struct symbol *machine__find_kernel_function_by_name(struct machine *machine,
4288 +
4289 + struct map *machine__findnew_module_map(struct machine *machine, u64 start,
4290 + const char *filename);
4291 +-int arch__fix_module_text_start(u64 *start, const char *name);
4292 ++int arch__fix_module_text_start(u64 *start, u64 *size, const char *name);
4293 +
4294 + int __machine__load_kallsyms(struct machine *machine, const char *filename,
4295 + enum map_type type, bool no_kcore);
4296 +diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
4297 +index 20ba5a9aeae4..5a50326c8158 100644
4298 +--- a/tools/perf/util/symbol-elf.c
4299 ++++ b/tools/perf/util/symbol-elf.c
4300 +@@ -1478,7 +1478,7 @@ static int kcore_copy__parse_kallsyms(struct kcore_copy_info *kci,
4301 +
4302 + static int kcore_copy__process_modules(void *arg,
4303 + const char *name __maybe_unused,
4304 +- u64 start)
4305 ++ u64 start, u64 size __maybe_unused)
4306 + {
4307 + struct kcore_copy_info *kci = arg;
4308 +
4309 +diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
4310 +index f199d5b11d76..acde8e489352 100644
4311 +--- a/tools/perf/util/symbol.c
4312 ++++ b/tools/perf/util/symbol.c
4313 +@@ -217,7 +217,8 @@ void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
4314 + goto out_unlock;
4315 +
4316 + for (next = map__next(curr); next; next = map__next(curr)) {
4317 +- curr->end = next->start;
4318 ++ if (!curr->end)
4319 ++ curr->end = next->start;
4320 + curr = next;
4321 + }
4322 +
4323 +@@ -225,7 +226,8 @@ void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
4324 + * We still haven't the actual symbols, so guess the
4325 + * last map final address.
4326 + */
4327 +- curr->end = ~0ULL;
4328 ++ if (!curr->end)
4329 ++ curr->end = ~0ULL;
4330 +
4331 + out_unlock:
4332 + pthread_rwlock_unlock(&maps->lock);
4333 +@@ -512,7 +514,7 @@ void dso__sort_by_name(struct dso *dso, enum map_type type)
4334 +
4335 + int modules__parse(const char *filename, void *arg,
4336 + int (*process_module)(void *arg, const char *name,
4337 +- u64 start))
4338 ++ u64 start, u64 size))
4339 + {
4340 + char *line = NULL;
4341 + size_t n;
4342 +@@ -525,8 +527,8 @@ int modules__parse(const char *filename, void *arg,
4343 +
4344 + while (1) {
4345 + char name[PATH_MAX];
4346 +- u64 start;
4347 +- char *sep;
4348 ++ u64 start, size;
4349 ++ char *sep, *endptr;
4350 + ssize_t line_len;
4351 +
4352 + line_len = getline(&line, &n, file);
4353 +@@ -558,7 +560,11 @@ int modules__parse(const char *filename, void *arg,
4354 +
4355 + scnprintf(name, sizeof(name), "[%s]", line);
4356 +
4357 +- err = process_module(arg, name, start);
4358 ++ size = strtoul(sep + 1, &endptr, 0);
4359 ++ if (*endptr != ' ' && *endptr != '\t')
4360 ++ continue;
4361 ++
4362 ++ err = process_module(arg, name, start, size);
4363 + if (err)
4364 + break;
4365 + }
4366 +@@ -905,7 +911,8 @@ static struct module_info *find_module(const char *name,
4367 + return NULL;
4368 + }
4369 +
4370 +-static int __read_proc_modules(void *arg, const char *name, u64 start)
4371 ++static int __read_proc_modules(void *arg, const char *name, u64 start,
4372 ++ u64 size __maybe_unused)
4373 + {
4374 + struct rb_root *modules = arg;
4375 + struct module_info *mi;
4376 +diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
4377 +index d964844eb314..833b1be2fb29 100644
4378 +--- a/tools/perf/util/symbol.h
4379 ++++ b/tools/perf/util/symbol.h
4380 +@@ -268,7 +268,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size);
4381 + int sysfs__read_build_id(const char *filename, void *bf, size_t size);
4382 + int modules__parse(const char *filename, void *arg,
4383 + int (*process_module)(void *arg, const char *name,
4384 +- u64 start));
4385 ++ u64 start, u64 size));
4386 + int filename__read_debuglink(const char *filename, char *debuglink,
4387 + size_t size);
4388 +
4389 +diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
4390 +index f5af87f66663..81aee5adc8a2 100644
4391 +--- a/tools/perf/util/thread.c
4392 ++++ b/tools/perf/util/thread.c
4393 +@@ -114,14 +114,24 @@ struct comm *thread__comm(const struct thread *thread)
4394 +
4395 + struct comm *thread__exec_comm(const struct thread *thread)
4396 + {
4397 +- struct comm *comm, *last = NULL;
4398 ++ struct comm *comm, *last = NULL, *second_last = NULL;
4399 +
4400 + list_for_each_entry(comm, &thread->comm_list, list) {
4401 + if (comm->exec)
4402 + return comm;
4403 ++ second_last = last;
4404 + last = comm;
4405 + }
4406 +
4407 ++ /*
4408 ++ * 'last' with no start time might be the parent's comm of a synthesized
4409 ++ * thread (created by processing a synthesized fork event). For a main
4410 ++ * thread, that is very probably wrong. Prefer a later comm to avoid
4411 ++ * that case.
4412 ++ */
4413 ++ if (second_last && !last->start && thread->pid_ == thread->tid)
4414 ++ return second_last;
4415 ++
4416 + return last;
4417 + }
4418 +