Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Sat, 01 Dec 2018 15:06:20
Message-Id: 1543676755.a0335979bdabd1a61a12b25e022f8b08e86139db.mpagano@gentoo
1 commit: a0335979bdabd1a61a12b25e022f8b08e86139db
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 1 15:05:55 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 1 15:05:55 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=a0335979
7
8 proj/linux-patches: Linux patch 4.14.85
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1084_linux-4.14.85.patch | 4286 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 4290 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index b8625f0..b328a3b 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -379,6 +379,10 @@ Patch: 1083-4.14.84.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.14.84
23
24 +Patch: 1084-4.14.85.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.14.85
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/1084_linux-4.14.85.patch b/1084_linux-4.14.85.patch
33 new file mode 100644
34 index 0000000..ce3192e
35 --- /dev/null
36 +++ b/1084_linux-4.14.85.patch
37 @@ -0,0 +1,4286 @@
38 +diff --git a/Documentation/devicetree/bindings/net/can/holt_hi311x.txt b/Documentation/devicetree/bindings/net/can/holt_hi311x.txt
39 +index 23aa94eab207..4e0ec14f7abf 100644
40 +--- a/Documentation/devicetree/bindings/net/can/holt_hi311x.txt
41 ++++ b/Documentation/devicetree/bindings/net/can/holt_hi311x.txt
42 +@@ -18,7 +18,7 @@ Example:
43 + reg = <1>;
44 + clocks = <&clk32m>;
45 + interrupt-parent = <&gpio4>;
46 +- interrupts = <13 IRQ_TYPE_EDGE_RISING>;
47 ++ interrupts = <13 IRQ_TYPE_LEVEL_HIGH>;
48 + vdd-supply = <&reg5v0>;
49 + xceiver-supply = <&reg5v0>;
50 + };
51 +diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt
52 +index 35e17f748ca7..af5859b2d0f9 100644
53 +--- a/Documentation/sysctl/fs.txt
54 ++++ b/Documentation/sysctl/fs.txt
55 +@@ -34,7 +34,9 @@ Currently, these files are in /proc/sys/fs:
56 + - overflowgid
57 + - pipe-user-pages-hard
58 + - pipe-user-pages-soft
59 ++- protected_fifos
60 + - protected_hardlinks
61 ++- protected_regular
62 + - protected_symlinks
63 + - suid_dumpable
64 + - super-max
65 +@@ -182,6 +184,24 @@ applied.
66 +
67 + ==============================================================
68 +
69 ++protected_fifos:
70 ++
71 ++The intent of this protection is to avoid unintentional writes to
72 ++an attacker-controlled FIFO, where a program expected to create a regular
73 ++file.
74 ++
75 ++When set to "0", writing to FIFOs is unrestricted.
76 ++
77 ++When set to "1" don't allow O_CREAT open on FIFOs that we don't own
78 ++in world writable sticky directories, unless they are owned by the
79 ++owner of the directory.
80 ++
81 ++When set to "2" it also applies to group writable sticky directories.
82 ++
83 ++This protection is based on the restrictions in Openwall.
84 ++
85 ++==============================================================
86 ++
87 + protected_hardlinks:
88 +
89 + A long-standing class of security issues is the hardlink-based
90 +@@ -202,6 +222,22 @@ This protection is based on the restrictions in Openwall and grsecurity.
91 +
92 + ==============================================================
93 +
94 ++protected_regular:
95 ++
96 ++This protection is similar to protected_fifos, but it
97 ++avoids writes to an attacker-controlled regular file, where a program
98 ++expected to create one.
99 ++
100 ++When set to "0", writing to regular files is unrestricted.
101 ++
102 ++When set to "1" don't allow O_CREAT open on regular files that we
103 ++don't own in world writable sticky directories, unless they are
104 ++owned by the owner of the directory.
105 ++
106 ++When set to "2" it also applies to group writable sticky directories.
107 ++
108 ++==============================================================
109 ++
110 + protected_symlinks:
111 +
112 + A long-standing class of security issues is the symlink-based
113 +diff --git a/MAINTAINERS b/MAINTAINERS
114 +index 546beb6b0176..6cb70b853323 100644
115 +--- a/MAINTAINERS
116 ++++ b/MAINTAINERS
117 +@@ -12662,6 +12662,7 @@ F: arch/alpha/kernel/srm_env.c
118 +
119 + STABLE BRANCH
120 + M: Greg Kroah-Hartman <gregkh@×××××××××××××××.org>
121 ++M: Sasha Levin <sashal@××××××.org>
122 + L: stable@×××××××××××.org
123 + S: Supported
124 + F: Documentation/process/stable-kernel-rules.rst
125 +diff --git a/Makefile b/Makefile
126 +index 874d72a3e6a7..58a248264090 100644
127 +--- a/Makefile
128 ++++ b/Makefile
129 +@@ -1,7 +1,7 @@
130 + # SPDX-License-Identifier: GPL-2.0
131 + VERSION = 4
132 + PATCHLEVEL = 14
133 +-SUBLEVEL = 84
134 ++SUBLEVEL = 85
135 + EXTRAVERSION =
136 + NAME = Petit Gorille
137 +
138 +@@ -480,13 +480,15 @@ endif
139 + ifeq ($(cc-name),clang)
140 + ifneq ($(CROSS_COMPILE),)
141 + CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
142 +-GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
143 ++GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
144 ++CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)
145 ++GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
146 + endif
147 + ifneq ($(GCC_TOOLCHAIN),)
148 + CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
149 + endif
150 +-KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
151 +-KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
152 ++KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
153 ++KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
154 + KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
155 + KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
156 + endif
157 +diff --git a/arch/arm/Makefile b/arch/arm/Makefile
158 +index 36ae4454554c..17e80f483281 100644
159 +--- a/arch/arm/Makefile
160 ++++ b/arch/arm/Makefile
161 +@@ -106,7 +106,7 @@ tune-$(CONFIG_CPU_V6K) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
162 + tune-y := $(tune-y)
163 +
164 + ifeq ($(CONFIG_AEABI),y)
165 +-CFLAGS_ABI :=-mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp
166 ++CFLAGS_ABI :=-mabi=aapcs-linux -mfpu=vfp
167 + else
168 + CFLAGS_ABI :=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
169 + endif
170 +diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
171 +index a5889238fc9f..746c8c575f98 100644
172 +--- a/arch/arm/boot/compressed/Makefile
173 ++++ b/arch/arm/boot/compressed/Makefile
174 +@@ -113,7 +113,7 @@ CFLAGS_fdt_ro.o := $(nossp_flags)
175 + CFLAGS_fdt_rw.o := $(nossp_flags)
176 + CFLAGS_fdt_wip.o := $(nossp_flags)
177 +
178 +-ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
179 ++ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin -I$(obj)
180 + asflags-y := -DZIMAGE
181 +
182 + # Supply kernel BSS size to the decompressor via a linker symbol.
183 +diff --git a/arch/arm/boot/dts/exynos5420-peach-pit.dts b/arch/arm/boot/dts/exynos5420-peach-pit.dts
184 +index 683a4cfb4a23..c91eff8475a8 100644
185 +--- a/arch/arm/boot/dts/exynos5420-peach-pit.dts
186 ++++ b/arch/arm/boot/dts/exynos5420-peach-pit.dts
187 +@@ -31,7 +31,7 @@
188 +
189 + aliases {
190 + /* Assign 20 so we don't get confused w/ builtin ones */
191 +- i2c20 = "/spi@12d40000/cros-ec@0/i2c-tunnel";
192 ++ i2c20 = &i2c_tunnel;
193 + };
194 +
195 + backlight: backlight {
196 +@@ -952,7 +952,7 @@
197 + samsung,spi-feedback-delay = <1>;
198 + };
199 +
200 +- i2c-tunnel {
201 ++ i2c_tunnel: i2c-tunnel {
202 + compatible = "google,cros-ec-i2c-tunnel";
203 + #address-cells = <1>;
204 + #size-cells = <0>;
205 +diff --git a/arch/arm/boot/dts/exynos5800-peach-pi.dts b/arch/arm/boot/dts/exynos5800-peach-pi.dts
206 +index b2b95ff205e8..daad5d425cf5 100644
207 +--- a/arch/arm/boot/dts/exynos5800-peach-pi.dts
208 ++++ b/arch/arm/boot/dts/exynos5800-peach-pi.dts
209 +@@ -29,7 +29,7 @@
210 +
211 + aliases {
212 + /* Assign 20 so we don't get confused w/ builtin ones */
213 +- i2c20 = "/spi@12d40000/cros-ec@0/i2c-tunnel";
214 ++ i2c20 = &i2c_tunnel;
215 + };
216 +
217 + backlight: backlight {
218 +@@ -921,7 +921,7 @@
219 + samsung,spi-feedback-delay = <1>;
220 + };
221 +
222 +- i2c-tunnel {
223 ++ i2c_tunnel: i2c-tunnel {
224 + compatible = "google,cros-ec-i2c-tunnel";
225 + #address-cells = <1>;
226 + #size-cells = <0>;
227 +diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c
228 +index 3fb1b5a1dce9..689e6565abfc 100644
229 +--- a/arch/arm/firmware/trusted_foundations.c
230 ++++ b/arch/arm/firmware/trusted_foundations.c
231 +@@ -31,21 +31,25 @@
232 +
233 + static unsigned long cpu_boot_addr;
234 +
235 +-static void __naked tf_generic_smc(u32 type, u32 arg1, u32 arg2)
236 ++static void tf_generic_smc(u32 type, u32 arg1, u32 arg2)
237 + {
238 ++ register u32 r0 asm("r0") = type;
239 ++ register u32 r1 asm("r1") = arg1;
240 ++ register u32 r2 asm("r2") = arg2;
241 ++
242 + asm volatile(
243 + ".arch_extension sec\n\t"
244 +- "stmfd sp!, {r4 - r11, lr}\n\t"
245 ++ "stmfd sp!, {r4 - r11}\n\t"
246 + __asmeq("%0", "r0")
247 + __asmeq("%1", "r1")
248 + __asmeq("%2", "r2")
249 + "mov r3, #0\n\t"
250 + "mov r4, #0\n\t"
251 + "smc #0\n\t"
252 +- "ldmfd sp!, {r4 - r11, pc}"
253 ++ "ldmfd sp!, {r4 - r11}\n\t"
254 + :
255 +- : "r" (type), "r" (arg1), "r" (arg2)
256 +- : "memory");
257 ++ : "r" (r0), "r" (r1), "r" (r2)
258 ++ : "memory", "r3", "r12", "lr");
259 + }
260 +
261 + static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
262 +diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
263 +index 7318165cfc90..48f2b3657507 100644
264 +--- a/arch/arm64/Makefile
265 ++++ b/arch/arm64/Makefile
266 +@@ -10,7 +10,7 @@
267 + #
268 + # Copyright (C) 1995-2001 by Russell King
269 +
270 +-LDFLAGS_vmlinux :=-p --no-undefined -X
271 ++LDFLAGS_vmlinux :=--no-undefined -X
272 + CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
273 + GZFLAGS :=-9
274 +
275 +diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
276 +index 422f99cf9924..e6d33eed8202 100644
277 +--- a/arch/powerpc/include/asm/io.h
278 ++++ b/arch/powerpc/include/asm/io.h
279 +@@ -287,19 +287,13 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
280 + * their hooks, a bitfield is reserved for use by the platform near the
281 + * top of MMIO addresses (not PIO, those have to cope the hard way).
282 + *
283 +- * This bit field is 12 bits and is at the top of the IO virtual
284 +- * addresses PCI_IO_INDIRECT_TOKEN_MASK.
285 ++ * The highest address in the kernel virtual space are:
286 + *
287 +- * The kernel virtual space is thus:
288 ++ * d0003fffffffffff # with Hash MMU
289 ++ * c00fffffffffffff # with Radix MMU
290 + *
291 +- * 0xD000000000000000 : vmalloc
292 +- * 0xD000080000000000 : PCI PHB IO space
293 +- * 0xD000080080000000 : ioremap
294 +- * 0xD0000fffffffffff : end of ioremap region
295 +- *
296 +- * Since the top 4 bits are reserved as the region ID, we use thus
297 +- * the next 12 bits and keep 4 bits available for the future if the
298 +- * virtual address space is ever to be extended.
299 ++ * The top 4 bits are reserved as the region ID on hash, leaving us 8 bits
300 ++ * that can be used for the field.
301 + *
302 + * The direct IO mapping operations will then mask off those bits
303 + * before doing the actual access, though that only happen when
304 +@@ -311,8 +305,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
305 + */
306 +
307 + #ifdef CONFIG_PPC_INDIRECT_MMIO
308 +-#define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul
309 +-#define PCI_IO_IND_TOKEN_SHIFT 48
310 ++#define PCI_IO_IND_TOKEN_SHIFT 52
311 ++#define PCI_IO_IND_TOKEN_MASK (0xfful << PCI_IO_IND_TOKEN_SHIFT)
312 + #define PCI_FIX_ADDR(addr) \
313 + ((PCI_IO_ADDR)(((unsigned long)(addr)) & ~PCI_IO_IND_TOKEN_MASK))
314 + #define PCI_GET_ADDR_TOKEN(addr) \
315 +diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h
316 +index 491b0f715d6b..ea1d7c808319 100644
317 +--- a/arch/powerpc/kvm/trace.h
318 ++++ b/arch/powerpc/kvm/trace.h
319 +@@ -6,8 +6,6 @@
320 +
321 + #undef TRACE_SYSTEM
322 + #define TRACE_SYSTEM kvm
323 +-#define TRACE_INCLUDE_PATH .
324 +-#define TRACE_INCLUDE_FILE trace
325 +
326 + /*
327 + * Tracepoint for guest mode entry.
328 +@@ -120,4 +118,10 @@ TRACE_EVENT(kvm_check_requests,
329 + #endif /* _TRACE_KVM_H */
330 +
331 + /* This part must be outside protection */
332 ++#undef TRACE_INCLUDE_PATH
333 ++#undef TRACE_INCLUDE_FILE
334 ++
335 ++#define TRACE_INCLUDE_PATH .
336 ++#define TRACE_INCLUDE_FILE trace
337 ++
338 + #include <trace/define_trace.h>
339 +diff --git a/arch/powerpc/kvm/trace_booke.h b/arch/powerpc/kvm/trace_booke.h
340 +index ac640e81fdc5..3837842986aa 100644
341 +--- a/arch/powerpc/kvm/trace_booke.h
342 ++++ b/arch/powerpc/kvm/trace_booke.h
343 +@@ -6,8 +6,6 @@
344 +
345 + #undef TRACE_SYSTEM
346 + #define TRACE_SYSTEM kvm_booke
347 +-#define TRACE_INCLUDE_PATH .
348 +-#define TRACE_INCLUDE_FILE trace_booke
349 +
350 + #define kvm_trace_symbol_exit \
351 + {0, "CRITICAL"}, \
352 +@@ -218,4 +216,11 @@ TRACE_EVENT(kvm_booke_queue_irqprio,
353 + #endif
354 +
355 + /* This part must be outside protection */
356 ++
357 ++#undef TRACE_INCLUDE_PATH
358 ++#undef TRACE_INCLUDE_FILE
359 ++
360 ++#define TRACE_INCLUDE_PATH .
361 ++#define TRACE_INCLUDE_FILE trace_booke
362 ++
363 + #include <trace/define_trace.h>
364 +diff --git a/arch/powerpc/kvm/trace_hv.h b/arch/powerpc/kvm/trace_hv.h
365 +index bcfe8a987f6a..8a1e3b0047f1 100644
366 +--- a/arch/powerpc/kvm/trace_hv.h
367 ++++ b/arch/powerpc/kvm/trace_hv.h
368 +@@ -9,8 +9,6 @@
369 +
370 + #undef TRACE_SYSTEM
371 + #define TRACE_SYSTEM kvm_hv
372 +-#define TRACE_INCLUDE_PATH .
373 +-#define TRACE_INCLUDE_FILE trace_hv
374 +
375 + #define kvm_trace_symbol_hcall \
376 + {H_REMOVE, "H_REMOVE"}, \
377 +@@ -497,4 +495,11 @@ TRACE_EVENT(kvmppc_run_vcpu_exit,
378 + #endif /* _TRACE_KVM_HV_H */
379 +
380 + /* This part must be outside protection */
381 ++
382 ++#undef TRACE_INCLUDE_PATH
383 ++#undef TRACE_INCLUDE_FILE
384 ++
385 ++#define TRACE_INCLUDE_PATH .
386 ++#define TRACE_INCLUDE_FILE trace_hv
387 ++
388 + #include <trace/define_trace.h>
389 +diff --git a/arch/powerpc/kvm/trace_pr.h b/arch/powerpc/kvm/trace_pr.h
390 +index 85785a370c0e..256530eb1354 100644
391 +--- a/arch/powerpc/kvm/trace_pr.h
392 ++++ b/arch/powerpc/kvm/trace_pr.h
393 +@@ -8,8 +8,6 @@
394 +
395 + #undef TRACE_SYSTEM
396 + #define TRACE_SYSTEM kvm_pr
397 +-#define TRACE_INCLUDE_PATH .
398 +-#define TRACE_INCLUDE_FILE trace_pr
399 +
400 + TRACE_EVENT(kvm_book3s_reenter,
401 + TP_PROTO(int r, struct kvm_vcpu *vcpu),
402 +@@ -272,4 +270,11 @@ TRACE_EVENT(kvm_unmap_hva,
403 + #endif /* _TRACE_KVM_H */
404 +
405 + /* This part must be outside protection */
406 ++
407 ++#undef TRACE_INCLUDE_PATH
408 ++#undef TRACE_INCLUDE_FILE
409 ++
410 ++#define TRACE_INCLUDE_PATH .
411 ++#define TRACE_INCLUDE_FILE trace_pr
412 ++
413 + #include <trace/define_trace.h>
414 +diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
415 +index 9fead0796364..40fb9a8835fe 100644
416 +--- a/arch/powerpc/mm/numa.c
417 ++++ b/arch/powerpc/mm/numa.c
418 +@@ -1261,7 +1261,7 @@ static long vphn_get_associativity(unsigned long cpu,
419 +
420 + switch (rc) {
421 + case H_FUNCTION:
422 +- printk(KERN_INFO
423 ++ printk_once(KERN_INFO
424 + "VPHN is not supported. Disabling polling...\n");
425 + stop_topology_update();
426 + break;
427 +diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
428 +index 2f66290c9b92..ec9292917d3f 100644
429 +--- a/arch/s390/mm/gmap.c
430 ++++ b/arch/s390/mm/gmap.c
431 +@@ -689,6 +689,8 @@ void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to)
432 + vmaddr |= gaddr & ~PMD_MASK;
433 + /* Find vma in the parent mm */
434 + vma = find_vma(gmap->mm, vmaddr);
435 ++ if (!vma)
436 ++ continue;
437 + size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK));
438 + zap_page_range(vma, vmaddr, size);
439 + }
440 +diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c
441 +index aee5e8496be4..aa4e6f4e6a01 100644
442 +--- a/arch/x86/events/intel/uncore_snb.c
443 ++++ b/arch/x86/events/intel/uncore_snb.c
444 +@@ -15,6 +15,25 @@
445 + #define PCI_DEVICE_ID_INTEL_SKL_HQ_IMC 0x1910
446 + #define PCI_DEVICE_ID_INTEL_SKL_SD_IMC 0x190f
447 + #define PCI_DEVICE_ID_INTEL_SKL_SQ_IMC 0x191f
448 ++#define PCI_DEVICE_ID_INTEL_KBL_Y_IMC 0x590c
449 ++#define PCI_DEVICE_ID_INTEL_KBL_U_IMC 0x5904
450 ++#define PCI_DEVICE_ID_INTEL_KBL_UQ_IMC 0x5914
451 ++#define PCI_DEVICE_ID_INTEL_KBL_SD_IMC 0x590f
452 ++#define PCI_DEVICE_ID_INTEL_KBL_SQ_IMC 0x591f
453 ++#define PCI_DEVICE_ID_INTEL_CFL_2U_IMC 0x3ecc
454 ++#define PCI_DEVICE_ID_INTEL_CFL_4U_IMC 0x3ed0
455 ++#define PCI_DEVICE_ID_INTEL_CFL_4H_IMC 0x3e10
456 ++#define PCI_DEVICE_ID_INTEL_CFL_6H_IMC 0x3ec4
457 ++#define PCI_DEVICE_ID_INTEL_CFL_2S_D_IMC 0x3e0f
458 ++#define PCI_DEVICE_ID_INTEL_CFL_4S_D_IMC 0x3e1f
459 ++#define PCI_DEVICE_ID_INTEL_CFL_6S_D_IMC 0x3ec2
460 ++#define PCI_DEVICE_ID_INTEL_CFL_8S_D_IMC 0x3e30
461 ++#define PCI_DEVICE_ID_INTEL_CFL_4S_W_IMC 0x3e18
462 ++#define PCI_DEVICE_ID_INTEL_CFL_6S_W_IMC 0x3ec6
463 ++#define PCI_DEVICE_ID_INTEL_CFL_8S_W_IMC 0x3e31
464 ++#define PCI_DEVICE_ID_INTEL_CFL_4S_S_IMC 0x3e33
465 ++#define PCI_DEVICE_ID_INTEL_CFL_6S_S_IMC 0x3eca
466 ++#define PCI_DEVICE_ID_INTEL_CFL_8S_S_IMC 0x3e32
467 +
468 + /* SNB event control */
469 + #define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff
470 +@@ -632,7 +651,82 @@ static const struct pci_device_id skl_uncore_pci_ids[] = {
471 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_SQ_IMC),
472 + .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
473 + },
474 +-
475 ++ { /* IMC */
476 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_Y_IMC),
477 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
478 ++ },
479 ++ { /* IMC */
480 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_U_IMC),
481 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
482 ++ },
483 ++ { /* IMC */
484 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_UQ_IMC),
485 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
486 ++ },
487 ++ { /* IMC */
488 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_SD_IMC),
489 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
490 ++ },
491 ++ { /* IMC */
492 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBL_SQ_IMC),
493 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
494 ++ },
495 ++ { /* IMC */
496 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_2U_IMC),
497 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
498 ++ },
499 ++ { /* IMC */
500 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4U_IMC),
501 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
502 ++ },
503 ++ { /* IMC */
504 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4H_IMC),
505 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
506 ++ },
507 ++ { /* IMC */
508 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6H_IMC),
509 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
510 ++ },
511 ++ { /* IMC */
512 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_2S_D_IMC),
513 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
514 ++ },
515 ++ { /* IMC */
516 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4S_D_IMC),
517 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
518 ++ },
519 ++ { /* IMC */
520 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6S_D_IMC),
521 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
522 ++ },
523 ++ { /* IMC */
524 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_8S_D_IMC),
525 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
526 ++ },
527 ++ { /* IMC */
528 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4S_W_IMC),
529 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
530 ++ },
531 ++ { /* IMC */
532 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6S_W_IMC),
533 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
534 ++ },
535 ++ { /* IMC */
536 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_8S_W_IMC),
537 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
538 ++ },
539 ++ { /* IMC */
540 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_4S_S_IMC),
541 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
542 ++ },
543 ++ { /* IMC */
544 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_6S_S_IMC),
545 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
546 ++ },
547 ++ { /* IMC */
548 ++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CFL_8S_S_IMC),
549 ++ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
550 ++ },
551 + { /* end: all zeroes */ },
552 + };
553 +
554 +@@ -681,6 +775,25 @@ static const struct imc_uncore_pci_dev desktop_imc_pci_ids[] = {
555 + IMC_DEV(SKL_HQ_IMC, &skl_uncore_pci_driver), /* 6th Gen Core H Quad Core */
556 + IMC_DEV(SKL_SD_IMC, &skl_uncore_pci_driver), /* 6th Gen Core S Dual Core */
557 + IMC_DEV(SKL_SQ_IMC, &skl_uncore_pci_driver), /* 6th Gen Core S Quad Core */
558 ++ IMC_DEV(KBL_Y_IMC, &skl_uncore_pci_driver), /* 7th Gen Core Y */
559 ++ IMC_DEV(KBL_U_IMC, &skl_uncore_pci_driver), /* 7th Gen Core U */
560 ++ IMC_DEV(KBL_UQ_IMC, &skl_uncore_pci_driver), /* 7th Gen Core U Quad Core */
561 ++ IMC_DEV(KBL_SD_IMC, &skl_uncore_pci_driver), /* 7th Gen Core S Dual Core */
562 ++ IMC_DEV(KBL_SQ_IMC, &skl_uncore_pci_driver), /* 7th Gen Core S Quad Core */
563 ++ IMC_DEV(CFL_2U_IMC, &skl_uncore_pci_driver), /* 8th Gen Core U 2 Cores */
564 ++ IMC_DEV(CFL_4U_IMC, &skl_uncore_pci_driver), /* 8th Gen Core U 4 Cores */
565 ++ IMC_DEV(CFL_4H_IMC, &skl_uncore_pci_driver), /* 8th Gen Core H 4 Cores */
566 ++ IMC_DEV(CFL_6H_IMC, &skl_uncore_pci_driver), /* 8th Gen Core H 6 Cores */
567 ++ IMC_DEV(CFL_2S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 2 Cores Desktop */
568 ++ IMC_DEV(CFL_4S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 4 Cores Desktop */
569 ++ IMC_DEV(CFL_6S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 6 Cores Desktop */
570 ++ IMC_DEV(CFL_8S_D_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 8 Cores Desktop */
571 ++ IMC_DEV(CFL_4S_W_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 4 Cores Work Station */
572 ++ IMC_DEV(CFL_6S_W_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 6 Cores Work Station */
573 ++ IMC_DEV(CFL_8S_W_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 8 Cores Work Station */
574 ++ IMC_DEV(CFL_4S_S_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 4 Cores Server */
575 ++ IMC_DEV(CFL_6S_S_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 6 Cores Server */
576 ++ IMC_DEV(CFL_8S_S_IMC, &skl_uncore_pci_driver), /* 8th Gen Core S 8 Cores Server */
577 + { /* end marker */ }
578 + };
579 +
580 +diff --git a/crypto/simd.c b/crypto/simd.c
581 +index 88203370a62f..894c62944106 100644
582 +--- a/crypto/simd.c
583 ++++ b/crypto/simd.c
584 +@@ -126,8 +126,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
585 +
586 + ctx->cryptd_tfm = cryptd_tfm;
587 +
588 +- reqsize = sizeof(struct skcipher_request);
589 +- reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
590 ++ reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
591 ++ reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base));
592 ++ reqsize += sizeof(struct skcipher_request);
593 +
594 + crypto_skcipher_set_reqsize(tfm, reqsize);
595 +
596 +diff --git a/drivers/base/core.c b/drivers/base/core.c
597 +index eb066cc827ef..3f463a61f8cf 100644
598 +--- a/drivers/base/core.c
599 ++++ b/drivers/base/core.c
600 +@@ -1973,7 +1973,6 @@ void device_del(struct device *dev)
601 + blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
602 + BUS_NOTIFY_DEL_DEVICE, dev);
603 +
604 +- device_links_purge(dev);
605 + dpm_sysfs_remove(dev);
606 + if (parent)
607 + klist_del(&dev->p->knode_parent);
608 +@@ -2001,6 +2000,7 @@ void device_del(struct device *dev)
609 + device_pm_remove(dev);
610 + driver_deferred_probe_del(dev);
611 + device_remove_properties(dev);
612 ++ device_links_purge(dev);
613 +
614 + /* Notify the platform of the removal, in case they
615 + * need to do anything...
616 +diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
617 +index 3d0287e212fe..a7f212ea17bf 100644
618 +--- a/drivers/block/floppy.c
619 ++++ b/drivers/block/floppy.c
620 +@@ -4146,10 +4146,11 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)
621 + bio.bi_end_io = floppy_rb0_cb;
622 + bio_set_op_attrs(&bio, REQ_OP_READ, 0);
623 +
624 ++ init_completion(&cbdata.complete);
625 ++
626 + submit_bio(&bio);
627 + process_fd_request();
628 +
629 +- init_completion(&cbdata.complete);
630 + wait_for_completion(&cbdata.complete);
631 +
632 + __free_page(page);
633 +diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
634 +index 5426c04fe24b..fc2da3a617ac 100644
635 +--- a/drivers/bus/arm-cci.c
636 ++++ b/drivers/bus/arm-cci.c
637 +@@ -2103,8 +2103,6 @@ asmlinkage void __naked cci_enable_port_for_self(void)
638 + [sizeof_struct_cpu_port] "i" (sizeof(struct cpu_port)),
639 + [sizeof_struct_ace_port] "i" (sizeof(struct cci_ace_port)),
640 + [offsetof_port_phys] "i" (offsetof(struct cci_ace_port, phys)) );
641 +-
642 +- unreachable();
643 + }
644 +
645 + /**
646 +diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c
647 +index 6a0cb8a515e8..b609219c802b 100644
648 +--- a/drivers/clk/samsung/clk-exynos5250.c
649 ++++ b/drivers/clk/samsung/clk-exynos5250.c
650 +@@ -560,6 +560,8 @@ static const struct samsung_gate_clock exynos5250_gate_clks[] __initconst = {
651 + 0),
652 + GATE(CLK_GSCL3, "gscl3", "mout_aclk266_gscl_sub", GATE_IP_GSCL, 3, 0,
653 + 0),
654 ++ GATE(CLK_CAMIF_TOP, "camif_top", "mout_aclk266_gscl_sub",
655 ++ GATE_IP_GSCL, 4, 0, 0),
656 + GATE(CLK_GSCL_WA, "gscl_wa", "div_gscl_wa", GATE_IP_GSCL, 5, 0, 0),
657 + GATE(CLK_GSCL_WB, "gscl_wb", "div_gscl_wb", GATE_IP_GSCL, 6, 0, 0),
658 + GATE(CLK_SMMU_GSCL0, "smmu_gscl0", "mout_aclk266_gscl_sub",
659 +@@ -570,6 +572,10 @@ static const struct samsung_gate_clock exynos5250_gate_clks[] __initconst = {
660 + GATE_IP_GSCL, 9, 0, 0),
661 + GATE(CLK_SMMU_GSCL3, "smmu_gscl3", "mout_aclk266_gscl_sub",
662 + GATE_IP_GSCL, 10, 0, 0),
663 ++ GATE(CLK_SMMU_FIMC_LITE0, "smmu_fimc_lite0", "mout_aclk266_gscl_sub",
664 ++ GATE_IP_GSCL, 11, 0, 0),
665 ++ GATE(CLK_SMMU_FIMC_LITE1, "smmu_fimc_lite1", "mout_aclk266_gscl_sub",
666 ++ GATE_IP_GSCL, 12, 0, 0),
667 +
668 + GATE(CLK_FIMD1, "fimd1", "mout_aclk200_disp1_sub", GATE_IP_DISP1, 0, 0,
669 + 0),
670 +diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
671 +index 14466a9b01c0..63d28323a29c 100644
672 +--- a/drivers/cpufreq/imx6q-cpufreq.c
673 ++++ b/drivers/cpufreq/imx6q-cpufreq.c
674 +@@ -135,8 +135,13 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
675 + /* Ensure the arm clock divider is what we expect */
676 + ret = clk_set_rate(arm_clk, new_freq * 1000);
677 + if (ret) {
678 ++ int ret1;
679 ++
680 + dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
681 +- regulator_set_voltage_tol(arm_reg, volt_old, 0);
682 ++ ret1 = regulator_set_voltage_tol(arm_reg, volt_old, 0);
683 ++ if (ret1)
684 ++ dev_warn(cpu_dev,
685 ++ "failed to restore vddarm voltage: %d\n", ret1);
686 + return ret;
687 + }
688 +
689 +diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
690 +index a7c522eac640..312f9f32e168 100644
691 +--- a/drivers/firmware/efi/arm-init.c
692 ++++ b/drivers/firmware/efi/arm-init.c
693 +@@ -265,6 +265,10 @@ void __init efi_init(void)
694 + (params.mmap & ~PAGE_MASK)));
695 +
696 + init_screen_info();
697 ++
698 ++ /* ARM does not permit early mappings to persist across paging_init() */
699 ++ if (IS_ENABLED(CONFIG_ARM))
700 ++ efi_memmap_unmap();
701 + }
702 +
703 + static int __init register_gop_device(void)
704 +diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
705 +index 8995a48bd067..ad1530aff633 100644
706 +--- a/drivers/firmware/efi/arm-runtime.c
707 ++++ b/drivers/firmware/efi/arm-runtime.c
708 +@@ -122,7 +122,7 @@ static int __init arm_enable_runtime_services(void)
709 + {
710 + u64 mapsize;
711 +
712 +- if (!efi_enabled(EFI_BOOT) || !efi_enabled(EFI_MEMMAP)) {
713 ++ if (!efi_enabled(EFI_BOOT)) {
714 + pr_info("EFI services will not be available.\n");
715 + return 0;
716 + }
717 +diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
718 +index adaa4a964f0c..678bc910e080 100644
719 +--- a/drivers/firmware/efi/libstub/Makefile
720 ++++ b/drivers/firmware/efi/libstub/Makefile
721 +@@ -13,7 +13,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \
722 +
723 + cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie
724 + cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
725 +- -fno-builtin -fpic -mno-single-pic-base
726 ++ -fno-builtin -fpic \
727 ++ $(call cc-option,-mno-single-pic-base)
728 +
729 + cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt
730 +
731 +diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
732 +index 5fc70520e04c..1907db2b38d8 100644
733 +--- a/drivers/firmware/efi/memmap.c
734 ++++ b/drivers/firmware/efi/memmap.c
735 +@@ -118,6 +118,9 @@ int __init efi_memmap_init_early(struct efi_memory_map_data *data)
736 +
737 + void __init efi_memmap_unmap(void)
738 + {
739 ++ if (!efi_enabled(EFI_MEMMAP))
740 ++ return;
741 ++
742 + if (!efi.memmap.late) {
743 + unsigned long size;
744 +
745 +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
746 +index 7d5de4ef4f22..21062cb6b85f 100644
747 +--- a/drivers/gpio/gpiolib.c
748 ++++ b/drivers/gpio/gpiolib.c
749 +@@ -1166,7 +1166,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
750 + gdev->descs = kcalloc(chip->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
751 + if (!gdev->descs) {
752 + status = -ENOMEM;
753 +- goto err_free_gdev;
754 ++ goto err_free_ida;
755 + }
756 +
757 + if (chip->ngpio == 0) {
758 +@@ -1298,8 +1298,9 @@ err_free_label:
759 + kfree(gdev->label);
760 + err_free_descs:
761 + kfree(gdev->descs);
762 +-err_free_gdev:
763 ++err_free_ida:
764 + ida_simple_remove(&gpio_ida, gdev->id);
765 ++err_free_gdev:
766 + /* failures here can mean systems won't boot... */
767 + pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__,
768 + gdev->base, gdev->base + gdev->ngpio - 1,
769 +diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
770 +index 69dab82a3771..bf589c53b908 100644
771 +--- a/drivers/gpu/drm/ast/ast_drv.c
772 ++++ b/drivers/gpu/drm/ast/ast_drv.c
773 +@@ -60,8 +60,29 @@ static const struct pci_device_id pciidlist[] = {
774 +
775 + MODULE_DEVICE_TABLE(pci, pciidlist);
776 +
777 ++static void ast_kick_out_firmware_fb(struct pci_dev *pdev)
778 ++{
779 ++ struct apertures_struct *ap;
780 ++ bool primary = false;
781 ++
782 ++ ap = alloc_apertures(1);
783 ++ if (!ap)
784 ++ return;
785 ++
786 ++ ap->ranges[0].base = pci_resource_start(pdev, 0);
787 ++ ap->ranges[0].size = pci_resource_len(pdev, 0);
788 ++
789 ++#ifdef CONFIG_X86
790 ++ primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
791 ++#endif
792 ++ drm_fb_helper_remove_conflicting_framebuffers(ap, "astdrmfb", primary);
793 ++ kfree(ap);
794 ++}
795 ++
796 + static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
797 + {
798 ++ ast_kick_out_firmware_fb(pdev);
799 ++
800 + return drm_get_pci_dev(pdev, ent, &driver);
801 + }
802 +
803 +diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
804 +index e9f1e6fe7b94..fae1176b2472 100644
805 +--- a/drivers/gpu/drm/ast/ast_mode.c
806 ++++ b/drivers/gpu/drm/ast/ast_mode.c
807 +@@ -568,6 +568,7 @@ static int ast_crtc_do_set_base(struct drm_crtc *crtc,
808 + }
809 + ast_bo_unreserve(bo);
810 +
811 ++ ast_set_offset_reg(crtc);
812 + ast_set_start_address_crt1(crtc, (u32)gpu_addr);
813 +
814 + return 0;
815 +@@ -1254,7 +1255,7 @@ static int ast_cursor_move(struct drm_crtc *crtc,
816 + ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xc7, ((y >> 8) & 0x07));
817 +
818 + /* dummy write to fire HWC */
819 +- ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xCB, 0xFF, 0x00);
820 ++ ast_show_cursor(crtc);
821 +
822 + return 0;
823 + }
824 +diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
825 +index 690c67507cbc..aba27ea9cea5 100644
826 +--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
827 ++++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
828 +@@ -1446,8 +1446,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
829 + }
830 +
831 + /* The CEC module handles HDMI hotplug detection */
832 +- cec_np = of_find_compatible_node(np->parent, NULL,
833 +- "mediatek,mt8173-cec");
834 ++ cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec");
835 + if (!cec_np) {
836 + dev_err(dev, "Failed to find CEC node\n");
837 + return -EINVAL;
838 +@@ -1457,8 +1456,10 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
839 + if (!cec_pdev) {
840 + dev_err(hdmi->dev, "Waiting for CEC device %pOF\n",
841 + cec_np);
842 ++ of_node_put(cec_np);
843 + return -EPROBE_DEFER;
844 + }
845 ++ of_node_put(cec_np);
846 + hdmi->cec_dev = &cec_pdev->dev;
847 +
848 + /*
849 +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
850 +index feb80dbb5948..6d59af07d338 100644
851 +--- a/drivers/infiniband/core/verbs.c
852 ++++ b/drivers/infiniband/core/verbs.c
853 +@@ -1285,7 +1285,7 @@ EXPORT_SYMBOL(ib_resolve_eth_dmac);
854 +
855 + /**
856 + * ib_modify_qp_with_udata - Modifies the attributes for the specified QP.
857 +- * @qp: The QP to modify.
858 ++ * @ib_qp: The QP to modify.
859 + * @attr: On input, specifies the QP attributes to modify. On output,
860 + * the current values of selected QP attributes are returned.
861 + * @attr_mask: A bit-mask used to specify which attributes of the QP
862 +@@ -1294,9 +1294,10 @@ EXPORT_SYMBOL(ib_resolve_eth_dmac);
863 + * are being modified.
864 + * It returns 0 on success and returns appropriate error code on error.
865 + */
866 +-int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr,
867 ++int ib_modify_qp_with_udata(struct ib_qp *ib_qp, struct ib_qp_attr *attr,
868 + int attr_mask, struct ib_udata *udata)
869 + {
870 ++ struct ib_qp *qp = ib_qp->real_qp;
871 + int ret;
872 +
873 + if (attr_mask & IB_QP_AV) {
874 +diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c
875 +index 8c954a0ae3b6..c14ec04f2a89 100644
876 +--- a/drivers/infiniband/hw/hfi1/user_sdma.c
877 ++++ b/drivers/infiniband/hw/hfi1/user_sdma.c
878 +@@ -328,7 +328,6 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
879 + u8 opcode, sc, vl;
880 + u16 pkey;
881 + u32 slid;
882 +- int req_queued = 0;
883 + u16 dlid;
884 + u32 selector;
885 +
886 +@@ -392,7 +391,6 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
887 + req->data_len = 0;
888 + req->pq = pq;
889 + req->cq = cq;
890 +- req->status = -1;
891 + req->ahg_idx = -1;
892 + req->iov_idx = 0;
893 + req->sent = 0;
894 +@@ -400,12 +398,14 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
895 + req->seqcomp = 0;
896 + req->seqsubmitted = 0;
897 + req->tids = NULL;
898 +- req->done = 0;
899 + req->has_error = 0;
900 + INIT_LIST_HEAD(&req->txps);
901 +
902 + memcpy(&req->info, &info, sizeof(info));
903 +
904 ++ /* The request is initialized, count it */
905 ++ atomic_inc(&pq->n_reqs);
906 ++
907 + if (req_opcode(info.ctrl) == EXPECTED) {
908 + /* expected must have a TID info and at least one data vector */
909 + if (req->data_iovs < 2) {
910 +@@ -500,7 +500,6 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
911 + ret = pin_vector_pages(req, &req->iovs[i]);
912 + if (ret) {
913 + req->data_iovs = i;
914 +- req->status = ret;
915 + goto free_req;
916 + }
917 + req->data_len += req->iovs[i].iov.iov_len;
918 +@@ -561,14 +560,10 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
919 + req->ahg_idx = sdma_ahg_alloc(req->sde);
920 +
921 + set_comp_state(pq, cq, info.comp_idx, QUEUED, 0);
922 +- atomic_inc(&pq->n_reqs);
923 +- req_queued = 1;
924 + /* Send the first N packets in the request to buy us some time */
925 + ret = user_sdma_send_pkts(req, pcount);
926 +- if (unlikely(ret < 0 && ret != -EBUSY)) {
927 +- req->status = ret;
928 ++ if (unlikely(ret < 0 && ret != -EBUSY))
929 + goto free_req;
930 +- }
931 +
932 + /*
933 + * It is possible that the SDMA engine would have processed all the
934 +@@ -588,14 +583,8 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
935 + while (req->seqsubmitted != req->info.npkts) {
936 + ret = user_sdma_send_pkts(req, pcount);
937 + if (ret < 0) {
938 +- if (ret != -EBUSY) {
939 +- req->status = ret;
940 +- WRITE_ONCE(req->has_error, 1);
941 +- if (ACCESS_ONCE(req->seqcomp) ==
942 +- req->seqsubmitted - 1)
943 +- goto free_req;
944 +- return ret;
945 +- }
946 ++ if (ret != -EBUSY)
947 ++ goto free_req;
948 + wait_event_interruptible_timeout(
949 + pq->busy.wait_dma,
950 + (pq->state == SDMA_PKT_Q_ACTIVE),
951 +@@ -606,10 +595,19 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
952 + *count += idx;
953 + return 0;
954 + free_req:
955 +- user_sdma_free_request(req, true);
956 +- if (req_queued)
957 ++ /*
958 ++ * If the submitted seqsubmitted == npkts, the completion routine
959 ++ * controls the final state. If sequbmitted < npkts, wait for any
960 ++ * outstanding packets to finish before cleaning up.
961 ++ */
962 ++ if (req->seqsubmitted < req->info.npkts) {
963 ++ if (req->seqsubmitted)
964 ++ wait_event(pq->busy.wait_dma,
965 ++ (req->seqcomp == req->seqsubmitted - 1));
966 ++ user_sdma_free_request(req, true);
967 + pq_update(pq);
968 +- set_comp_state(pq, cq, info.comp_idx, ERROR, req->status);
969 ++ set_comp_state(pq, cq, info.comp_idx, ERROR, ret);
970 ++ }
971 + return ret;
972 + }
973 +
974 +@@ -917,7 +915,6 @@ dosend:
975 + ret = sdma_send_txlist(req->sde, &pq->busy, &req->txps, &count);
976 + req->seqsubmitted += count;
977 + if (req->seqsubmitted == req->info.npkts) {
978 +- WRITE_ONCE(req->done, 1);
979 + /*
980 + * The txreq has already been submitted to the HW queue
981 + * so we can free the AHG entry now. Corruption will not
982 +@@ -1347,11 +1344,15 @@ static int set_txreq_header_ahg(struct user_sdma_request *req,
983 + return diff;
984 + }
985 +
986 +-/*
987 +- * SDMA tx request completion callback. Called when the SDMA progress
988 +- * state machine gets notification that the SDMA descriptors for this
989 +- * tx request have been processed by the DMA engine. Called in
990 +- * interrupt context.
991 ++/**
992 ++ * user_sdma_txreq_cb() - SDMA tx request completion callback.
993 ++ * @txreq: valid sdma tx request
994 ++ * @status: success/failure of request
995 ++ *
996 ++ * Called when the SDMA progress state machine gets notification that
997 ++ * the SDMA descriptors for this tx request have been processed by the
998 ++ * DMA engine. Called in interrupt context.
999 ++ * Only do work on completed sequences.
1000 + */
1001 + static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status)
1002 + {
1003 +@@ -1360,7 +1361,7 @@ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status)
1004 + struct user_sdma_request *req;
1005 + struct hfi1_user_sdma_pkt_q *pq;
1006 + struct hfi1_user_sdma_comp_q *cq;
1007 +- u16 idx;
1008 ++ enum hfi1_sdma_comp_state state = COMPLETE;
1009 +
1010 + if (!tx->req)
1011 + return;
1012 +@@ -1373,31 +1374,19 @@ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status)
1013 + SDMA_DBG(req, "SDMA completion with error %d",
1014 + status);
1015 + WRITE_ONCE(req->has_error, 1);
1016 ++ state = ERROR;
1017 + }
1018 +
1019 + req->seqcomp = tx->seqnum;
1020 + kmem_cache_free(pq->txreq_cache, tx);
1021 +- tx = NULL;
1022 +-
1023 +- idx = req->info.comp_idx;
1024 +- if (req->status == -1 && status == SDMA_TXREQ_S_OK) {
1025 +- if (req->seqcomp == req->info.npkts - 1) {
1026 +- req->status = 0;
1027 +- user_sdma_free_request(req, false);
1028 +- pq_update(pq);
1029 +- set_comp_state(pq, cq, idx, COMPLETE, 0);
1030 +- }
1031 +- } else {
1032 +- if (status != SDMA_TXREQ_S_OK)
1033 +- req->status = status;
1034 +- if (req->seqcomp == (ACCESS_ONCE(req->seqsubmitted) - 1) &&
1035 +- (READ_ONCE(req->done) ||
1036 +- READ_ONCE(req->has_error))) {
1037 +- user_sdma_free_request(req, false);
1038 +- pq_update(pq);
1039 +- set_comp_state(pq, cq, idx, ERROR, req->status);
1040 +- }
1041 +- }
1042 ++
1043 ++ /* sequence isn't complete? We are done */
1044 ++ if (req->seqcomp != req->info.npkts - 1)
1045 ++ return;
1046 ++
1047 ++ user_sdma_free_request(req, false);
1048 ++ set_comp_state(pq, cq, req->info.comp_idx, state, status);
1049 ++ pq_update(pq);
1050 + }
1051 +
1052 + static inline void pq_update(struct hfi1_user_sdma_pkt_q *pq)
1053 +@@ -1430,6 +1419,8 @@ static void user_sdma_free_request(struct user_sdma_request *req, bool unpin)
1054 + if (!node)
1055 + continue;
1056 +
1057 ++ req->iovs[i].node = NULL;
1058 ++
1059 + if (unpin)
1060 + hfi1_mmu_rb_remove(req->pq->handler,
1061 + &node->rb);
1062 +diff --git a/drivers/infiniband/hw/hfi1/user_sdma.h b/drivers/infiniband/hw/hfi1/user_sdma.h
1063 +index 9b8bb5634c0d..5af52334b7dc 100644
1064 +--- a/drivers/infiniband/hw/hfi1/user_sdma.h
1065 ++++ b/drivers/infiniband/hw/hfi1/user_sdma.h
1066 +@@ -196,8 +196,6 @@ struct user_sdma_request {
1067 + /* Writeable fields shared with interrupt */
1068 + u64 seqcomp ____cacheline_aligned_in_smp;
1069 + u64 seqsubmitted;
1070 +- /* status of the last txreq completed */
1071 +- int status;
1072 +
1073 + /* Send side fields */
1074 + struct list_head txps ____cacheline_aligned_in_smp;
1075 +@@ -219,7 +217,6 @@ struct user_sdma_request {
1076 + u16 tididx;
1077 + /* progress index moving along the iovs array */
1078 + u8 iov_idx;
1079 +- u8 done;
1080 + u8 has_error;
1081 +
1082 + struct user_sdma_iovec iovs[MAX_VECTORS_PER_REQ];
1083 +diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
1084 +index 39398dd074d6..c1021b4afb41 100644
1085 +--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
1086 ++++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
1087 +@@ -631,6 +631,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
1088 + return ERR_PTR(-ENOMEM);
1089 +
1090 + iwqp = (struct i40iw_qp *)mem;
1091 ++ iwqp->allocated_buffer = mem;
1092 + qp = &iwqp->sc_qp;
1093 + qp->back_qp = (void *)iwqp;
1094 + qp->push_idx = I40IW_INVALID_PUSH_PAGE_INDEX;
1095 +@@ -659,7 +660,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
1096 + goto error;
1097 + }
1098 +
1099 +- iwqp->allocated_buffer = mem;
1100 + iwqp->iwdev = iwdev;
1101 + iwqp->iwpd = iwpd;
1102 + iwqp->ibqp.qp_num = qp_num;
1103 +diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
1104 +index 53f775c41cd1..2e52015634f9 100644
1105 +--- a/drivers/input/joystick/xpad.c
1106 ++++ b/drivers/input/joystick/xpad.c
1107 +@@ -89,8 +89,10 @@
1108 +
1109 + #define XPAD_PKT_LEN 64
1110 +
1111 +-/* xbox d-pads should map to buttons, as is required for DDR pads
1112 +- but we map them to axes when possible to simplify things */
1113 ++/*
1114 ++ * xbox d-pads should map to buttons, as is required for DDR pads
1115 ++ * but we map them to axes when possible to simplify things
1116 ++ */
1117 + #define MAP_DPAD_TO_BUTTONS (1 << 0)
1118 + #define MAP_TRIGGERS_TO_BUTTONS (1 << 1)
1119 + #define MAP_STICKS_TO_NULL (1 << 2)
1120 +@@ -231,6 +233,8 @@ static const struct xpad_device {
1121 + { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
1122 + { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
1123 + { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
1124 ++ { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
1125 ++ { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
1126 + { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
1127 + { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
1128 + { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
1129 +@@ -390,15 +394,15 @@ static const signed short xpad_abs_triggers[] = {
1130 + * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
1131 + * wireless controllers have protocol 129.
1132 + */
1133 +-#define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \
1134 ++#define XPAD_XBOX360_VENDOR_PROTOCOL(vend, pr) \
1135 + .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \
1136 + .idVendor = (vend), \
1137 + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, \
1138 + .bInterfaceSubClass = 93, \
1139 + .bInterfaceProtocol = (pr)
1140 + #define XPAD_XBOX360_VENDOR(vend) \
1141 +- { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \
1142 +- { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) }
1143 ++ { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 1) }, \
1144 ++ { XPAD_XBOX360_VENDOR_PROTOCOL((vend), 129) }
1145 +
1146 + /* The Xbox One controller uses subclass 71 and protocol 208. */
1147 + #define XPAD_XBOXONE_VENDOR_PROTOCOL(vend, pr) \
1148 +@@ -408,7 +412,7 @@ static const signed short xpad_abs_triggers[] = {
1149 + .bInterfaceSubClass = 71, \
1150 + .bInterfaceProtocol = (pr)
1151 + #define XPAD_XBOXONE_VENDOR(vend) \
1152 +- { XPAD_XBOXONE_VENDOR_PROTOCOL(vend, 208) }
1153 ++ { XPAD_XBOXONE_VENDOR_PROTOCOL((vend), 208) }
1154 +
1155 + static const struct usb_device_id xpad_table[] = {
1156 + { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */
1157 +@@ -480,7 +484,8 @@ static const u8 xboxone_hori_init[] = {
1158 +
1159 + /*
1160 + * This packet is required for some of the PDP pads to start
1161 +- * sending input reports. One of those pads is (0x0e6f:0x02ab).
1162 ++ * sending input reports. These pads include: (0x0e6f:0x02ab),
1163 ++ * (0x0e6f:0x02a4).
1164 + */
1165 + static const u8 xboxone_pdp_init1[] = {
1166 + 0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
1167 +@@ -488,7 +493,8 @@ static const u8 xboxone_pdp_init1[] = {
1168 +
1169 + /*
1170 + * This packet is required for some of the PDP pads to start
1171 +- * sending input reports. One of those pads is (0x0e6f:0x02ab).
1172 ++ * sending input reports. These pads include: (0x0e6f:0x02ab),
1173 ++ * (0x0e6f:0x02a4).
1174 + */
1175 + static const u8 xboxone_pdp_init2[] = {
1176 + 0x06, 0x20, 0x00, 0x02, 0x01, 0x00
1177 +@@ -526,6 +532,10 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {
1178 + XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
1179 + XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init1),
1180 + XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2),
1181 ++ XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init1),
1182 ++ XBOXONE_INIT_PKT(0x0e6f, 0x02a4, xboxone_pdp_init2),
1183 ++ XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init1),
1184 ++ XBOXONE_INIT_PKT(0x0e6f, 0x02a6, xboxone_pdp_init2),
1185 + XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
1186 + XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
1187 + XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
1188 +@@ -1573,7 +1583,6 @@ static void xpad_close(struct input_dev *dev)
1189 + static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
1190 + {
1191 + struct usb_xpad *xpad = input_get_drvdata(input_dev);
1192 +- set_bit(abs, input_dev->absbit);
1193 +
1194 + switch (abs) {
1195 + case ABS_X:
1196 +@@ -1593,6 +1602,9 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
1197 + case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
1198 + input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
1199 + break;
1200 ++ default:
1201 ++ input_set_abs_params(input_dev, abs, 0, 0, 0, 0);
1202 ++ break;
1203 + }
1204 + }
1205 +
1206 +@@ -1633,10 +1645,7 @@ static int xpad_init_input(struct usb_xpad *xpad)
1207 + input_dev->close = xpad_close;
1208 + }
1209 +
1210 +- __set_bit(EV_KEY, input_dev->evbit);
1211 +-
1212 + if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
1213 +- __set_bit(EV_ABS, input_dev->evbit);
1214 + /* set up axes */
1215 + for (i = 0; xpad_abs[i] >= 0; i++)
1216 + xpad_set_up_abs(input_dev, xpad_abs[i]);
1217 +@@ -1644,21 +1653,22 @@ static int xpad_init_input(struct usb_xpad *xpad)
1218 +
1219 + /* set up standard buttons */
1220 + for (i = 0; xpad_common_btn[i] >= 0; i++)
1221 +- __set_bit(xpad_common_btn[i], input_dev->keybit);
1222 ++ input_set_capability(input_dev, EV_KEY, xpad_common_btn[i]);
1223 +
1224 + /* set up model-specific ones */
1225 + if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W ||
1226 + xpad->xtype == XTYPE_XBOXONE) {
1227 + for (i = 0; xpad360_btn[i] >= 0; i++)
1228 +- __set_bit(xpad360_btn[i], input_dev->keybit);
1229 ++ input_set_capability(input_dev, EV_KEY, xpad360_btn[i]);
1230 + } else {
1231 + for (i = 0; xpad_btn[i] >= 0; i++)
1232 +- __set_bit(xpad_btn[i], input_dev->keybit);
1233 ++ input_set_capability(input_dev, EV_KEY, xpad_btn[i]);
1234 + }
1235 +
1236 + if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
1237 + for (i = 0; xpad_btn_pad[i] >= 0; i++)
1238 +- __set_bit(xpad_btn_pad[i], input_dev->keybit);
1239 ++ input_set_capability(input_dev, EV_KEY,
1240 ++ xpad_btn_pad[i]);
1241 + }
1242 +
1243 + /*
1244 +@@ -1675,7 +1685,8 @@ static int xpad_init_input(struct usb_xpad *xpad)
1245 +
1246 + if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
1247 + for (i = 0; xpad_btn_triggers[i] >= 0; i++)
1248 +- __set_bit(xpad_btn_triggers[i], input_dev->keybit);
1249 ++ input_set_capability(input_dev, EV_KEY,
1250 ++ xpad_btn_triggers[i]);
1251 + } else {
1252 + for (i = 0; xpad_abs_triggers[i] >= 0; i++)
1253 + xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
1254 +diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
1255 +index 6c4bbd38700e..6f36e2d01e2e 100644
1256 +--- a/drivers/input/mouse/synaptics.c
1257 ++++ b/drivers/input/mouse/synaptics.c
1258 +@@ -99,9 +99,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode)
1259 + int synaptics_detect(struct psmouse *psmouse, bool set_properties)
1260 + {
1261 + struct ps2dev *ps2dev = &psmouse->ps2dev;
1262 +- u8 param[4];
1263 +-
1264 +- param[0] = 0;
1265 ++ u8 param[4] = { 0 };
1266 +
1267 + ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
1268 + ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
1269 +diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
1270 +index 44da037b13ba..0e386f5cc836 100644
1271 +--- a/drivers/mmc/host/sdhci-pci-core.c
1272 ++++ b/drivers/mmc/host/sdhci-pci-core.c
1273 +@@ -1607,8 +1607,13 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
1274 + host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
1275 +
1276 + if (slot->cd_idx >= 0) {
1277 +- ret = mmc_gpiod_request_cd(host->mmc, NULL, slot->cd_idx,
1278 ++ ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx,
1279 + slot->cd_override_level, 0, NULL);
1280 ++ if (ret && ret != -EPROBE_DEFER)
1281 ++ ret = mmc_gpiod_request_cd(host->mmc, NULL,
1282 ++ slot->cd_idx,
1283 ++ slot->cd_override_level,
1284 ++ 0, NULL);
1285 + if (ret == -EPROBE_DEFER)
1286 + goto remove;
1287 +
1288 +diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c
1289 +index 32a2f947a454..0b93f152d993 100644
1290 +--- a/drivers/mtd/nand/atmel/nand-controller.c
1291 ++++ b/drivers/mtd/nand/atmel/nand-controller.c
1292 +@@ -2077,8 +2077,7 @@ atmel_hsmc_nand_controller_legacy_init(struct atmel_hsmc_nand_controller *nc)
1293 + int ret;
1294 +
1295 + nand_np = dev->of_node;
1296 +- nfc_np = of_find_compatible_node(dev->of_node, NULL,
1297 +- "atmel,sama5d3-nfc");
1298 ++ nfc_np = of_get_compatible_child(dev->of_node, "atmel,sama5d3-nfc");
1299 + if (!nfc_np) {
1300 + dev_err(dev, "Could not find device node for sama5d3-nfc\n");
1301 + return -ENODEV;
1302 +@@ -2492,15 +2491,19 @@ static int atmel_nand_controller_probe(struct platform_device *pdev)
1303 + }
1304 +
1305 + if (caps->legacy_of_bindings) {
1306 ++ struct device_node *nfc_node;
1307 + u32 ale_offs = 21;
1308 +
1309 + /*
1310 + * If we are parsing legacy DT props and the DT contains a
1311 + * valid NFC node, forward the request to the sama5 logic.
1312 + */
1313 +- if (of_find_compatible_node(pdev->dev.of_node, NULL,
1314 +- "atmel,sama5d3-nfc"))
1315 ++ nfc_node = of_get_compatible_child(pdev->dev.of_node,
1316 ++ "atmel,sama5d3-nfc");
1317 ++ if (nfc_node) {
1318 + caps = &atmel_sama5_nand_caps;
1319 ++ of_node_put(nfc_node);
1320 ++ }
1321 +
1322 + /*
1323 + * Even if the compatible says we are dealing with an
1324 +diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
1325 +index 18a72da759a0..6445c693d935 100644
1326 +--- a/drivers/mtd/ubi/build.c
1327 ++++ b/drivers/mtd/ubi/build.c
1328 +@@ -526,6 +526,7 @@ void ubi_free_internal_volumes(struct ubi_device *ubi)
1329 + for (i = ubi->vtbl_slots;
1330 + i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
1331 + ubi_eba_replace_table(ubi->volumes[i], NULL);
1332 ++ ubi_fastmap_destroy_checkmap(ubi->volumes[i]);
1333 + kfree(ubi->volumes[i]);
1334 + }
1335 + }
1336 +diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
1337 +index d0884bd9d955..c4d4b8f07630 100644
1338 +--- a/drivers/mtd/ubi/eba.c
1339 ++++ b/drivers/mtd/ubi/eba.c
1340 +@@ -517,6 +517,9 @@ static int check_mapping(struct ubi_device *ubi, struct ubi_volume *vol, int lnu
1341 + if (!ubi->fast_attach)
1342 + return 0;
1343 +
1344 ++ if (!vol->checkmap || test_bit(lnum, vol->checkmap))
1345 ++ return 0;
1346 ++
1347 + vidb = ubi_alloc_vid_buf(ubi, GFP_NOFS);
1348 + if (!vidb)
1349 + return -ENOMEM;
1350 +@@ -551,6 +554,7 @@ static int check_mapping(struct ubi_device *ubi, struct ubi_volume *vol, int lnu
1351 + goto out_free;
1352 + }
1353 +
1354 ++ set_bit(lnum, vol->checkmap);
1355 + err = 0;
1356 +
1357 + out_free:
1358 +diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
1359 +index 5a832bc79b1b..63e8527f7b65 100644
1360 +--- a/drivers/mtd/ubi/fastmap.c
1361 ++++ b/drivers/mtd/ubi/fastmap.c
1362 +@@ -1101,6 +1101,26 @@ free_fm_sb:
1363 + goto out;
1364 + }
1365 +
1366 ++int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
1367 ++{
1368 ++ struct ubi_device *ubi = vol->ubi;
1369 ++
1370 ++ if (!ubi->fast_attach)
1371 ++ return 0;
1372 ++
1373 ++ vol->checkmap = kcalloc(BITS_TO_LONGS(leb_count), sizeof(unsigned long),
1374 ++ GFP_KERNEL);
1375 ++ if (!vol->checkmap)
1376 ++ return -ENOMEM;
1377 ++
1378 ++ return 0;
1379 ++}
1380 ++
1381 ++void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol)
1382 ++{
1383 ++ kfree(vol->checkmap);
1384 ++}
1385 ++
1386 + /**
1387 + * ubi_write_fastmap - writes a fastmap.
1388 + * @ubi: UBI device object
1389 +diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
1390 +index 5fe62653995e..f5ba97c46160 100644
1391 +--- a/drivers/mtd/ubi/ubi.h
1392 ++++ b/drivers/mtd/ubi/ubi.h
1393 +@@ -334,6 +334,9 @@ struct ubi_eba_leb_desc {
1394 + * @changing_leb: %1 if the atomic LEB change ioctl command is in progress
1395 + * @direct_writes: %1 if direct writes are enabled for this volume
1396 + *
1397 ++ * @checkmap: bitmap to remember which PEB->LEB mappings got checked,
1398 ++ * protected by UBI LEB lock tree.
1399 ++ *
1400 + * The @corrupted field indicates that the volume's contents is corrupted.
1401 + * Since UBI protects only static volumes, this field is not relevant to
1402 + * dynamic volumes - it is user's responsibility to assure their data
1403 +@@ -377,6 +380,10 @@ struct ubi_volume {
1404 + unsigned int updating:1;
1405 + unsigned int changing_leb:1;
1406 + unsigned int direct_writes:1;
1407 ++
1408 ++#ifdef CONFIG_MTD_UBI_FASTMAP
1409 ++ unsigned long *checkmap;
1410 ++#endif
1411 + };
1412 +
1413 + /**
1414 +@@ -965,8 +972,12 @@ size_t ubi_calc_fm_size(struct ubi_device *ubi);
1415 + int ubi_update_fastmap(struct ubi_device *ubi);
1416 + int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
1417 + struct ubi_attach_info *scan_ai);
1418 ++int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count);
1419 ++void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol);
1420 + #else
1421 + static inline int ubi_update_fastmap(struct ubi_device *ubi) { return 0; }
1422 ++int static inline ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count) { return 0; }
1423 ++static inline void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol) {}
1424 + #endif
1425 +
1426 + /* block.c */
1427 +diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
1428 +index 3fd8d7ff7a02..0be516780e92 100644
1429 +--- a/drivers/mtd/ubi/vmt.c
1430 ++++ b/drivers/mtd/ubi/vmt.c
1431 +@@ -139,6 +139,7 @@ static void vol_release(struct device *dev)
1432 + struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);
1433 +
1434 + ubi_eba_replace_table(vol, NULL);
1435 ++ ubi_fastmap_destroy_checkmap(vol);
1436 + kfree(vol);
1437 + }
1438 +
1439 +diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
1440 +index 263743e7b741..94d7a865b135 100644
1441 +--- a/drivers/mtd/ubi/vtbl.c
1442 ++++ b/drivers/mtd/ubi/vtbl.c
1443 +@@ -534,7 +534,7 @@ static int init_volumes(struct ubi_device *ubi,
1444 + const struct ubi_attach_info *ai,
1445 + const struct ubi_vtbl_record *vtbl)
1446 + {
1447 +- int i, reserved_pebs = 0;
1448 ++ int i, err, reserved_pebs = 0;
1449 + struct ubi_ainf_volume *av;
1450 + struct ubi_volume *vol;
1451 +
1452 +@@ -620,6 +620,16 @@ static int init_volumes(struct ubi_device *ubi,
1453 + (long long)(vol->used_ebs - 1) * vol->usable_leb_size;
1454 + vol->used_bytes += av->last_data_size;
1455 + vol->last_eb_bytes = av->last_data_size;
1456 ++
1457 ++ /*
1458 ++ * We use ubi->peb_count and not vol->reserved_pebs because
1459 ++ * we want to keep the code simple. Otherwise we'd have to
1460 ++ * resize/check the bitmap upon volume resize too.
1461 ++ * Allocating a few bytes more does not hurt.
1462 ++ */
1463 ++ err = ubi_fastmap_init_checkmap(vol, ubi->peb_count);
1464 ++ if (err)
1465 ++ return err;
1466 + }
1467 +
1468 + /* And add the layout volume */
1469 +@@ -645,6 +655,9 @@ static int init_volumes(struct ubi_device *ubi,
1470 + reserved_pebs += vol->reserved_pebs;
1471 + ubi->vol_count += 1;
1472 + vol->ubi = ubi;
1473 ++ err = ubi_fastmap_init_checkmap(vol, UBI_LAYOUT_VOLUME_EBS);
1474 ++ if (err)
1475 ++ return err;
1476 +
1477 + if (reserved_pebs > ubi->avail_pebs) {
1478 + ubi_err(ubi, "not enough PEBs, required %d, available %d",
1479 +@@ -849,6 +862,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
1480 + out_free:
1481 + vfree(ubi->vtbl);
1482 + for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
1483 ++ ubi_fastmap_destroy_checkmap(ubi->volumes[i]);
1484 + kfree(ubi->volumes[i]);
1485 + ubi->volumes[i] = NULL;
1486 + }
1487 +diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
1488 +index b6a681bce400..035daca63168 100644
1489 +--- a/drivers/net/can/dev.c
1490 ++++ b/drivers/net/can/dev.c
1491 +@@ -476,6 +476,34 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
1492 + }
1493 + EXPORT_SYMBOL_GPL(can_put_echo_skb);
1494 +
1495 ++struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
1496 ++{
1497 ++ struct can_priv *priv = netdev_priv(dev);
1498 ++ struct sk_buff *skb = priv->echo_skb[idx];
1499 ++ struct canfd_frame *cf;
1500 ++
1501 ++ if (idx >= priv->echo_skb_max) {
1502 ++ netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n",
1503 ++ __func__, idx, priv->echo_skb_max);
1504 ++ return NULL;
1505 ++ }
1506 ++
1507 ++ if (!skb) {
1508 ++ netdev_err(dev, "%s: BUG! Trying to echo non existing skb: can_priv::echo_skb[%u]\n",
1509 ++ __func__, idx);
1510 ++ return NULL;
1511 ++ }
1512 ++
1513 ++ /* Using "struct canfd_frame::len" for the frame
1514 ++ * length is supported on both CAN and CANFD frames.
1515 ++ */
1516 ++ cf = (struct canfd_frame *)skb->data;
1517 ++ *len_ptr = cf->len;
1518 ++ priv->echo_skb[idx] = NULL;
1519 ++
1520 ++ return skb;
1521 ++}
1522 ++
1523 + /*
1524 + * Get the skb from the stack and loop it back locally
1525 + *
1526 +@@ -485,22 +513,16 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb);
1527 + */
1528 + unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
1529 + {
1530 +- struct can_priv *priv = netdev_priv(dev);
1531 +-
1532 +- BUG_ON(idx >= priv->echo_skb_max);
1533 +-
1534 +- if (priv->echo_skb[idx]) {
1535 +- struct sk_buff *skb = priv->echo_skb[idx];
1536 +- struct can_frame *cf = (struct can_frame *)skb->data;
1537 +- u8 dlc = cf->can_dlc;
1538 ++ struct sk_buff *skb;
1539 ++ u8 len;
1540 +
1541 +- netif_rx(priv->echo_skb[idx]);
1542 +- priv->echo_skb[idx] = NULL;
1543 ++ skb = __can_get_echo_skb(dev, idx, &len);
1544 ++ if (!skb)
1545 ++ return 0;
1546 +
1547 +- return dlc;
1548 +- }
1549 ++ netif_rx(skb);
1550 +
1551 +- return 0;
1552 ++ return len;
1553 + }
1554 + EXPORT_SYMBOL_GPL(can_get_echo_skb);
1555 +
1556 +diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
1557 +index ed8a2a7ce500..9ef501fd153f 100644
1558 +--- a/drivers/net/can/flexcan.c
1559 ++++ b/drivers/net/can/flexcan.c
1560 +@@ -599,7 +599,7 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
1561 + if (tx_errors)
1562 + dev->stats.tx_errors++;
1563 +
1564 +- can_rx_offload_irq_queue_err_skb(&priv->offload, skb);
1565 ++ can_rx_offload_queue_tail(&priv->offload, skb);
1566 + }
1567 +
1568 + static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
1569 +@@ -639,7 +639,7 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
1570 + if (unlikely(new_state == CAN_STATE_BUS_OFF))
1571 + can_bus_off(dev);
1572 +
1573 +- can_rx_offload_irq_queue_err_skb(&priv->offload, skb);
1574 ++ can_rx_offload_queue_tail(&priv->offload, skb);
1575 + }
1576 +
1577 + static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload)
1578 +diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
1579 +index f394f77d7528..d227db45fec9 100644
1580 +--- a/drivers/net/can/rx-offload.c
1581 ++++ b/drivers/net/can/rx-offload.c
1582 +@@ -209,7 +209,54 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload)
1583 + }
1584 + EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_fifo);
1585 +
1586 +-int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_buff *skb)
1587 ++int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
1588 ++ struct sk_buff *skb, u32 timestamp)
1589 ++{
1590 ++ struct can_rx_offload_cb *cb;
1591 ++ unsigned long flags;
1592 ++
1593 ++ if (skb_queue_len(&offload->skb_queue) >
1594 ++ offload->skb_queue_len_max)
1595 ++ return -ENOMEM;
1596 ++
1597 ++ cb = can_rx_offload_get_cb(skb);
1598 ++ cb->timestamp = timestamp;
1599 ++
1600 ++ spin_lock_irqsave(&offload->skb_queue.lock, flags);
1601 ++ __skb_queue_add_sort(&offload->skb_queue, skb, can_rx_offload_compare);
1602 ++ spin_unlock_irqrestore(&offload->skb_queue.lock, flags);
1603 ++
1604 ++ can_rx_offload_schedule(offload);
1605 ++
1606 ++ return 0;
1607 ++}
1608 ++EXPORT_SYMBOL_GPL(can_rx_offload_queue_sorted);
1609 ++
1610 ++unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
1611 ++ unsigned int idx, u32 timestamp)
1612 ++{
1613 ++ struct net_device *dev = offload->dev;
1614 ++ struct net_device_stats *stats = &dev->stats;
1615 ++ struct sk_buff *skb;
1616 ++ u8 len;
1617 ++ int err;
1618 ++
1619 ++ skb = __can_get_echo_skb(dev, idx, &len);
1620 ++ if (!skb)
1621 ++ return 0;
1622 ++
1623 ++ err = can_rx_offload_queue_sorted(offload, skb, timestamp);
1624 ++ if (err) {
1625 ++ stats->rx_errors++;
1626 ++ stats->tx_fifo_errors++;
1627 ++ }
1628 ++
1629 ++ return len;
1630 ++}
1631 ++EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb);
1632 ++
1633 ++int can_rx_offload_queue_tail(struct can_rx_offload *offload,
1634 ++ struct sk_buff *skb)
1635 + {
1636 + if (skb_queue_len(&offload->skb_queue) >
1637 + offload->skb_queue_len_max)
1638 +@@ -220,7 +267,7 @@ int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_b
1639 +
1640 + return 0;
1641 + }
1642 +-EXPORT_SYMBOL_GPL(can_rx_offload_irq_queue_err_skb);
1643 ++EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail);
1644 +
1645 + static int can_rx_offload_init_queue(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight)
1646 + {
1647 +diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
1648 +index 53e320c92a8b..ddaf46239e39 100644
1649 +--- a/drivers/net/can/spi/hi311x.c
1650 ++++ b/drivers/net/can/spi/hi311x.c
1651 +@@ -760,7 +760,7 @@ static int hi3110_open(struct net_device *net)
1652 + {
1653 + struct hi3110_priv *priv = netdev_priv(net);
1654 + struct spi_device *spi = priv->spi;
1655 +- unsigned long flags = IRQF_ONESHOT | IRQF_TRIGGER_RISING;
1656 ++ unsigned long flags = IRQF_ONESHOT | IRQF_TRIGGER_HIGH;
1657 + int ret;
1658 +
1659 + ret = open_candev(net);
1660 +diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
1661 +index abbd2894f870..c421e2753c8c 100644
1662 +--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
1663 ++++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
1664 +@@ -360,7 +360,7 @@ static struct device_node *bcmgenet_mii_of_find_mdio(struct bcmgenet_priv *priv)
1665 + if (!compat)
1666 + return NULL;
1667 +
1668 +- priv->mdio_dn = of_find_compatible_node(dn, NULL, compat);
1669 ++ priv->mdio_dn = of_get_compatible_child(dn, compat);
1670 + kfree(compat);
1671 + if (!priv->mdio_dn) {
1672 + dev_err(kdev, "unable to find MDIO bus node\n");
1673 +diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
1674 +index b26da0952a4d..a5381b091710 100644
1675 +--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
1676 ++++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
1677 +@@ -611,7 +611,6 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
1678 + MLX4_MAX_PORTS;
1679 + else
1680 + res_alloc->guaranteed[t] = 0;
1681 +- res_alloc->res_free -= res_alloc->guaranteed[t];
1682 + break;
1683 + default:
1684 + break;
1685 +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
1686 +index 50e2e10a9050..e069b310d6a6 100644
1687 +--- a/drivers/net/usb/lan78xx.c
1688 ++++ b/drivers/net/usb/lan78xx.c
1689 +@@ -37,6 +37,7 @@
1690 + #include <linux/irqchip/chained_irq.h>
1691 + #include <linux/microchipphy.h>
1692 + #include <linux/phy.h>
1693 ++#include <linux/of_net.h>
1694 + #include "lan78xx.h"
1695 +
1696 + #define DRIVER_AUTHOR "WOOJUNG HUH <woojung.huh@×××××××××.com>"
1697 +@@ -1645,34 +1646,31 @@ static void lan78xx_init_mac_address(struct lan78xx_net *dev)
1698 + addr[5] = (addr_hi >> 8) & 0xFF;
1699 +
1700 + if (!is_valid_ether_addr(addr)) {
1701 +- /* reading mac address from EEPROM or OTP */
1702 +- if ((lan78xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
1703 +- addr) == 0) ||
1704 +- (lan78xx_read_otp(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
1705 +- addr) == 0)) {
1706 +- if (is_valid_ether_addr(addr)) {
1707 +- /* eeprom values are valid so use them */
1708 +- netif_dbg(dev, ifup, dev->net,
1709 +- "MAC address read from EEPROM");
1710 +- } else {
1711 +- /* generate random MAC */
1712 +- random_ether_addr(addr);
1713 +- netif_dbg(dev, ifup, dev->net,
1714 +- "MAC address set to random addr");
1715 +- }
1716 +-
1717 +- addr_lo = addr[0] | (addr[1] << 8) |
1718 +- (addr[2] << 16) | (addr[3] << 24);
1719 +- addr_hi = addr[4] | (addr[5] << 8);
1720 +-
1721 +- ret = lan78xx_write_reg(dev, RX_ADDRL, addr_lo);
1722 +- ret = lan78xx_write_reg(dev, RX_ADDRH, addr_hi);
1723 ++ if (!eth_platform_get_mac_address(&dev->udev->dev, addr)) {
1724 ++ /* valid address present in Device Tree */
1725 ++ netif_dbg(dev, ifup, dev->net,
1726 ++ "MAC address read from Device Tree");
1727 ++ } else if (((lan78xx_read_eeprom(dev, EEPROM_MAC_OFFSET,
1728 ++ ETH_ALEN, addr) == 0) ||
1729 ++ (lan78xx_read_otp(dev, EEPROM_MAC_OFFSET,
1730 ++ ETH_ALEN, addr) == 0)) &&
1731 ++ is_valid_ether_addr(addr)) {
1732 ++ /* eeprom values are valid so use them */
1733 ++ netif_dbg(dev, ifup, dev->net,
1734 ++ "MAC address read from EEPROM");
1735 + } else {
1736 + /* generate random MAC */
1737 + random_ether_addr(addr);
1738 + netif_dbg(dev, ifup, dev->net,
1739 + "MAC address set to random addr");
1740 + }
1741 ++
1742 ++ addr_lo = addr[0] | (addr[1] << 8) |
1743 ++ (addr[2] << 16) | (addr[3] << 24);
1744 ++ addr_hi = addr[4] | (addr[5] << 8);
1745 ++
1746 ++ ret = lan78xx_write_reg(dev, RX_ADDRL, addr_lo);
1747 ++ ret = lan78xx_write_reg(dev, RX_ADDRH, addr_hi);
1748 + }
1749 +
1750 + ret = lan78xx_write_reg(dev, MAF_LO(0), addr_lo);
1751 +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
1752 +index 083e5ce7eac7..cd6c5ece9a5d 100644
1753 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
1754 ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
1755 +@@ -6098,7 +6098,8 @@ static int brcmf_construct_chaninfo(struct brcmf_cfg80211_info *cfg,
1756 + * for subsequent chanspecs.
1757 + */
1758 + channel->flags = IEEE80211_CHAN_NO_HT40 |
1759 +- IEEE80211_CHAN_NO_80MHZ;
1760 ++ IEEE80211_CHAN_NO_80MHZ |
1761 ++ IEEE80211_CHAN_NO_160MHZ;
1762 + ch.bw = BRCMU_CHAN_BW_20;
1763 + cfg->d11inf.encchspec(&ch);
1764 + chaninfo = ch.chspec;
1765 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
1766 +index b71a9d11a50f..cebf0ce76d27 100644
1767 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
1768 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
1769 +@@ -590,7 +590,7 @@ static int iwl_mvm_config_ltr(struct iwl_mvm *mvm)
1770 + #define ACPI_WRDS_WIFI_DATA_SIZE (IWL_MVM_SAR_TABLE_SIZE + 2)
1771 + #define ACPI_EWRD_WIFI_DATA_SIZE ((IWL_MVM_SAR_PROFILE_NUM - 1) * \
1772 + IWL_MVM_SAR_TABLE_SIZE + 3)
1773 +-#define ACPI_WGDS_WIFI_DATA_SIZE 18
1774 ++#define ACPI_WGDS_WIFI_DATA_SIZE 19
1775 + #define ACPI_WGDS_NUM_BANDS 2
1776 + #define ACPI_WGDS_TABLE_SIZE 3
1777 +
1778 +@@ -964,7 +964,7 @@ static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
1779 + IWL_DEBUG_RADIO(mvm, "Sending GEO_TX_POWER_LIMIT\n");
1780 +
1781 + BUILD_BUG_ON(IWL_NUM_GEO_PROFILES * ACPI_WGDS_NUM_BANDS *
1782 +- ACPI_WGDS_TABLE_SIZE != ACPI_WGDS_WIFI_DATA_SIZE);
1783 ++ ACPI_WGDS_TABLE_SIZE + 1 != ACPI_WGDS_WIFI_DATA_SIZE);
1784 +
1785 + for (i = 0; i < IWL_NUM_GEO_PROFILES; i++) {
1786 + struct iwl_per_chain_offset *chain =
1787 +@@ -997,6 +997,11 @@ static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
1788 + return -ENOENT;
1789 + }
1790 +
1791 ++static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
1792 ++{
1793 ++ return -ENOENT;
1794 ++}
1795 ++
1796 + static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
1797 + {
1798 + return 0;
1799 +@@ -1023,8 +1028,11 @@ static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
1800 + IWL_DEBUG_RADIO(mvm,
1801 + "WRDS SAR BIOS table invalid or unavailable. (%d)\n",
1802 + ret);
1803 +- /* if not available, don't fail and don't bother with EWRD */
1804 +- return 0;
1805 ++ /*
1806 ++ * If not available, don't fail and don't bother with EWRD.
1807 ++ * Return 1 to tell that we can't use WGDS either.
1808 ++ */
1809 ++ return 1;
1810 + }
1811 +
1812 + ret = iwl_mvm_sar_get_ewrd_table(mvm);
1813 +@@ -1037,9 +1045,13 @@ static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
1814 + /* choose profile 1 (WRDS) as default for both chains */
1815 + ret = iwl_mvm_sar_select_profile(mvm, 1, 1);
1816 +
1817 +- /* if we don't have profile 0 from BIOS, just skip it */
1818 ++ /*
1819 ++ * If we don't have profile 0 from BIOS, just skip it. This
1820 ++ * means that SAR Geo will not be enabled either, even if we
1821 ++ * have other valid profiles.
1822 ++ */
1823 + if (ret == -ENOENT)
1824 +- return 0;
1825 ++ return 1;
1826 +
1827 + return ret;
1828 + }
1829 +@@ -1229,11 +1241,19 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
1830 + iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
1831 +
1832 + ret = iwl_mvm_sar_init(mvm);
1833 +- if (ret)
1834 +- goto error;
1835 ++ if (ret == 0) {
1836 ++ ret = iwl_mvm_sar_geo_init(mvm);
1837 ++ } else if (ret > 0 && !iwl_mvm_sar_get_wgds_table(mvm)) {
1838 ++ /*
1839 ++ * If basic SAR is not available, we check for WGDS,
1840 ++ * which should *not* be available either. If it is
1841 ++ * available, issue an error, because we can't use SAR
1842 ++ * Geo without basic SAR.
1843 ++ */
1844 ++ IWL_ERR(mvm, "BIOS contains WGDS but no WRDS\n");
1845 ++ }
1846 +
1847 +- ret = iwl_mvm_sar_geo_init(mvm);
1848 +- if (ret)
1849 ++ if (ret < 0)
1850 + goto error;
1851 +
1852 + iwl_mvm_leds_sync(mvm);
1853 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
1854 +index 80a653950e86..77ed6ecf5ee5 100644
1855 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
1856 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
1857 +@@ -328,8 +328,12 @@ struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy,
1858 + goto out;
1859 + }
1860 +
1861 +- if (changed)
1862 +- *changed = (resp->status == MCC_RESP_NEW_CHAN_PROFILE);
1863 ++ if (changed) {
1864 ++ u32 status = le32_to_cpu(resp->status);
1865 ++
1866 ++ *changed = (status == MCC_RESP_NEW_CHAN_PROFILE ||
1867 ++ status == MCC_RESP_ILLEGAL);
1868 ++ }
1869 +
1870 + regd = iwl_parse_nvm_mcc_info(mvm->trans->dev, mvm->cfg,
1871 + __le32_to_cpu(resp->n_channels),
1872 +@@ -4189,10 +4193,6 @@ static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw,
1873 + sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG);
1874 + }
1875 +
1876 +- if (!fw_has_capa(&mvm->fw->ucode_capa,
1877 +- IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS))
1878 +- return;
1879 +-
1880 + /* if beacon filtering isn't on mac80211 does it anyway */
1881 + if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER))
1882 + return;
1883 +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
1884 +index fb25b6f29323..ca2d66ce8424 100644
1885 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
1886 ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
1887 +@@ -732,9 +732,8 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
1888 + }
1889 +
1890 + IWL_DEBUG_LAR(mvm,
1891 +- "MCC response status: 0x%x. new MCC: 0x%x ('%c%c') change: %d n_chans: %d\n",
1892 +- status, mcc, mcc >> 8, mcc & 0xff,
1893 +- !!(status == MCC_RESP_NEW_CHAN_PROFILE), n_channels);
1894 ++ "MCC response status: 0x%x. new MCC: 0x%x ('%c%c') n_chans: %d\n",
1895 ++ status, mcc, mcc >> 8, mcc & 0xff, n_channels);
1896 +
1897 + exit:
1898 + iwl_free_resp(&cmd);
1899 +diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c
1900 +index 91162f8e0366..9a22056e8d9e 100644
1901 +--- a/drivers/nfc/nfcmrvl/uart.c
1902 ++++ b/drivers/nfc/nfcmrvl/uart.c
1903 +@@ -73,10 +73,9 @@ static int nfcmrvl_uart_parse_dt(struct device_node *node,
1904 + struct device_node *matched_node;
1905 + int ret;
1906 +
1907 +- matched_node = of_find_compatible_node(node, NULL, "marvell,nfc-uart");
1908 ++ matched_node = of_get_compatible_child(node, "marvell,nfc-uart");
1909 + if (!matched_node) {
1910 +- matched_node = of_find_compatible_node(node, NULL,
1911 +- "mrvl,nfc-uart");
1912 ++ matched_node = of_get_compatible_child(node, "mrvl,nfc-uart");
1913 + if (!matched_node)
1914 + return -ENODEV;
1915 + }
1916 +diff --git a/drivers/of/base.c b/drivers/of/base.c
1917 +index 63897531cd75..ce8a6e0c9b6a 100644
1918 +--- a/drivers/of/base.c
1919 ++++ b/drivers/of/base.c
1920 +@@ -737,6 +737,31 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
1921 + }
1922 + EXPORT_SYMBOL(of_get_next_available_child);
1923 +
1924 ++/**
1925 ++ * of_get_compatible_child - Find compatible child node
1926 ++ * @parent: parent node
1927 ++ * @compatible: compatible string
1928 ++ *
1929 ++ * Lookup child node whose compatible property contains the given compatible
1930 ++ * string.
1931 ++ *
1932 ++ * Returns a node pointer with refcount incremented, use of_node_put() on it
1933 ++ * when done; or NULL if not found.
1934 ++ */
1935 ++struct device_node *of_get_compatible_child(const struct device_node *parent,
1936 ++ const char *compatible)
1937 ++{
1938 ++ struct device_node *child;
1939 ++
1940 ++ for_each_child_of_node(parent, child) {
1941 ++ if (of_device_is_compatible(child, compatible))
1942 ++ break;
1943 ++ }
1944 ++
1945 ++ return child;
1946 ++}
1947 ++EXPORT_SYMBOL(of_get_compatible_child);
1948 ++
1949 + /**
1950 + * of_get_child_by_name - Find the child node by name for a given parent
1951 + * @node: parent node
1952 +diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
1953 +index 16cec66b1d0b..8fdb9d07c50a 100644
1954 +--- a/drivers/pci/endpoint/pci-ep-cfs.c
1955 ++++ b/drivers/pci/endpoint/pci-ep-cfs.c
1956 +@@ -97,16 +97,10 @@ static int pci_epc_epf_link(struct config_item *epc_item,
1957 + {
1958 + int ret;
1959 + u32 func_no = 0;
1960 +- struct pci_epc *epc;
1961 +- struct pci_epf *epf;
1962 + struct pci_epf_group *epf_group = to_pci_epf_group(epf_item);
1963 + struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
1964 +-
1965 +- epc = epc_group->epc;
1966 +- epf = epf_group->epf;
1967 +- ret = pci_epc_add_epf(epc, epf);
1968 +- if (ret)
1969 +- goto err_add_epf;
1970 ++ struct pci_epc *epc = epc_group->epc;
1971 ++ struct pci_epf *epf = epf_group->epf;
1972 +
1973 + func_no = find_first_zero_bit(&epc_group->function_num_map,
1974 + BITS_PER_LONG);
1975 +@@ -116,6 +110,10 @@ static int pci_epc_epf_link(struct config_item *epc_item,
1976 + set_bit(func_no, &epc_group->function_num_map);
1977 + epf->func_no = func_no;
1978 +
1979 ++ ret = pci_epc_add_epf(epc, epf);
1980 ++ if (ret)
1981 ++ goto err_add_epf;
1982 ++
1983 + ret = pci_epf_bind(epf);
1984 + if (ret)
1985 + goto err_epf_bind;
1986 +diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
1987 +index 66ed70c12733..6c43322dbb97 100644
1988 +--- a/drivers/pinctrl/meson/pinctrl-meson.c
1989 ++++ b/drivers/pinctrl/meson/pinctrl-meson.c
1990 +@@ -273,7 +273,7 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
1991 + dev_dbg(pc->dev, "pin %u: disable bias\n", pin);
1992 +
1993 + meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit);
1994 +- ret = regmap_update_bits(pc->reg_pull, reg,
1995 ++ ret = regmap_update_bits(pc->reg_pullen, reg,
1996 + BIT(bit), 0);
1997 + if (ret)
1998 + return ret;
1999 +diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
2000 +index a5915f498eea..0cc12bfe7b02 100644
2001 +--- a/drivers/power/supply/twl4030_charger.c
2002 ++++ b/drivers/power/supply/twl4030_charger.c
2003 +@@ -996,12 +996,13 @@ static int twl4030_bci_probe(struct platform_device *pdev)
2004 + if (bci->dev->of_node) {
2005 + struct device_node *phynode;
2006 +
2007 +- phynode = of_find_compatible_node(bci->dev->of_node->parent,
2008 +- NULL, "ti,twl4030-usb");
2009 ++ phynode = of_get_compatible_child(bci->dev->of_node->parent,
2010 ++ "ti,twl4030-usb");
2011 + if (phynode) {
2012 + bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
2013 + bci->transceiver = devm_usb_get_phy_by_node(
2014 + bci->dev, phynode, &bci->usb_nb);
2015 ++ of_node_put(phynode);
2016 + if (IS_ERR(bci->transceiver)) {
2017 + ret = PTR_ERR(bci->transceiver);
2018 + if (ret == -EPROBE_DEFER)
2019 +diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
2020 +index ac6e6a6a194c..ae6506a8b4f5 100644
2021 +--- a/drivers/rtc/rtc-omap.c
2022 ++++ b/drivers/rtc/rtc-omap.c
2023 +@@ -823,7 +823,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
2024 + rtc->pctldev = pinctrl_register(&rtc_pinctrl_desc, &pdev->dev, rtc);
2025 + if (IS_ERR(rtc->pctldev)) {
2026 + dev_err(&pdev->dev, "Couldn't register pinctrl driver\n");
2027 +- return PTR_ERR(rtc->pctldev);
2028 ++ ret = PTR_ERR(rtc->pctldev);
2029 ++ goto err;
2030 + }
2031 +
2032 + if (rtc->is_pmic_controller) {
2033 +diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
2034 +index f33447c5db85..9f1b14bf91ae 100644
2035 +--- a/drivers/rtc/rtc-pcf2127.c
2036 ++++ b/drivers/rtc/rtc-pcf2127.c
2037 +@@ -248,6 +248,9 @@ static int pcf2127_i2c_gather_write(void *context,
2038 + memcpy(buf + 1, val, val_size);
2039 +
2040 + ret = i2c_master_send(client, buf, val_size + 1);
2041 ++
2042 ++ kfree(buf);
2043 ++
2044 + if (ret != val_size + 1)
2045 + return ret < 0 ? ret : -EIO;
2046 +
2047 +diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
2048 +index 0475f9685a41..904fc9c37fde 100644
2049 +--- a/drivers/tty/n_tty.c
2050 ++++ b/drivers/tty/n_tty.c
2051 +@@ -154,17 +154,28 @@ static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i)
2052 + return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)];
2053 + }
2054 +
2055 ++/* If we are not echoing the data, perhaps this is a secret so erase it */
2056 ++static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size)
2057 ++{
2058 ++ bool icanon = !!L_ICANON(tty);
2059 ++ bool no_echo = !L_ECHO(tty);
2060 ++
2061 ++ if (icanon && no_echo)
2062 ++ memset(buffer, 0x00, size);
2063 ++}
2064 ++
2065 + static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
2066 + size_t tail, size_t n)
2067 + {
2068 + struct n_tty_data *ldata = tty->disc_data;
2069 + size_t size = N_TTY_BUF_SIZE - tail;
2070 +- const void *from = read_buf_addr(ldata, tail);
2071 ++ void *from = read_buf_addr(ldata, tail);
2072 + int uncopied;
2073 +
2074 + if (n > size) {
2075 + tty_audit_add_data(tty, from, size);
2076 + uncopied = copy_to_user(to, from, size);
2077 ++ zero_buffer(tty, from, size - uncopied);
2078 + if (uncopied)
2079 + return uncopied;
2080 + to += size;
2081 +@@ -173,7 +184,9 @@ static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
2082 + }
2083 +
2084 + tty_audit_add_data(tty, from, n);
2085 +- return copy_to_user(to, from, n);
2086 ++ uncopied = copy_to_user(to, from, n);
2087 ++ zero_buffer(tty, from, n - uncopied);
2088 ++ return uncopied;
2089 + }
2090 +
2091 + /**
2092 +@@ -1962,11 +1975,12 @@ static int copy_from_read_buf(struct tty_struct *tty,
2093 + n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail);
2094 + n = min(*nr, n);
2095 + if (n) {
2096 +- const unsigned char *from = read_buf_addr(ldata, tail);
2097 ++ unsigned char *from = read_buf_addr(ldata, tail);
2098 + retval = copy_to_user(*b, from, n);
2099 + n -= retval;
2100 + is_eof = n == 1 && *from == EOF_CHAR(tty);
2101 + tty_audit_add_data(tty, from, n);
2102 ++ zero_buffer(tty, from, n);
2103 + smp_store_release(&ldata->read_tail, ldata->read_tail + n);
2104 + /* Turn single EOF into zero-length read */
2105 + if (L_EXTPROC(tty) && ldata->icanon && is_eof &&
2106 +diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
2107 +index 677fa99b7747..217114227f8d 100644
2108 +--- a/drivers/tty/tty_buffer.c
2109 ++++ b/drivers/tty/tty_buffer.c
2110 +@@ -467,11 +467,15 @@ receive_buf(struct tty_port *port, struct tty_buffer *head, int count)
2111 + {
2112 + unsigned char *p = char_buf_ptr(head, head->read);
2113 + char *f = NULL;
2114 ++ int n;
2115 +
2116 + if (~head->flags & TTYB_NORMAL)
2117 + f = flag_buf_ptr(head, head->read);
2118 +
2119 +- return port->client_ops->receive_buf(port, p, f, count);
2120 ++ n = port->client_ops->receive_buf(port, p, f, count);
2121 ++ if (n > 0)
2122 ++ memset(p, 0, n);
2123 ++ return n;
2124 + }
2125 +
2126 + /**
2127 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2128 +index a9db0887edca..638dc6f66d70 100644
2129 +--- a/drivers/usb/core/hub.c
2130 ++++ b/drivers/usb/core/hub.c
2131 +@@ -2815,7 +2815,9 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
2132 + USB_PORT_FEAT_C_BH_PORT_RESET);
2133 + usb_clear_port_feature(hub->hdev, port1,
2134 + USB_PORT_FEAT_C_PORT_LINK_STATE);
2135 +- usb_clear_port_feature(hub->hdev, port1,
2136 ++
2137 ++ if (udev)
2138 ++ usb_clear_port_feature(hub->hdev, port1,
2139 + USB_PORT_FEAT_C_CONNECTION);
2140 +
2141 + /*
2142 +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
2143 +index 8b323a360e03..783d16a53466 100644
2144 +--- a/drivers/usb/dwc3/core.c
2145 ++++ b/drivers/usb/dwc3/core.c
2146 +@@ -1276,6 +1276,7 @@ static int dwc3_probe(struct platform_device *pdev)
2147 +
2148 + err5:
2149 + dwc3_event_buffers_cleanup(dwc);
2150 ++ dwc3_ulpi_exit(dwc);
2151 +
2152 + err4:
2153 + dwc3_free_scratch_buffers(dwc);
2154 +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
2155 +index d7fae66a0681..ac8d619ff887 100644
2156 +--- a/drivers/usb/dwc3/gadget.c
2157 ++++ b/drivers/usb/dwc3/gadget.c
2158 +@@ -1088,7 +1088,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
2159 + /* Now prepare one extra TRB to align transfer size */
2160 + trb = &dep->trb_pool[dep->trb_enqueue];
2161 + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr,
2162 +- maxp - rem, false, 0,
2163 ++ maxp - rem, false, 1,
2164 + req->request.stream_id,
2165 + req->request.short_not_ok,
2166 + req->request.no_interrupt);
2167 +@@ -1120,7 +1120,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
2168 + /* Now prepare one extra TRB to align transfer size */
2169 + trb = &dep->trb_pool[dep->trb_enqueue];
2170 + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem,
2171 +- false, 0, req->request.stream_id,
2172 ++ false, 1, req->request.stream_id,
2173 + req->request.short_not_ok,
2174 + req->request.no_interrupt);
2175 + } else if (req->request.zero && req->request.length &&
2176 +@@ -1136,7 +1136,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
2177 + /* Now prepare one extra TRB to handle ZLP */
2178 + trb = &dep->trb_pool[dep->trb_enqueue];
2179 + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
2180 +- false, 0, req->request.stream_id,
2181 ++ false, 1, req->request.stream_id,
2182 + req->request.short_not_ok,
2183 + req->request.no_interrupt);
2184 + } else {
2185 +@@ -2249,7 +2249,7 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
2186 + * with one TRB pending in the ring. We need to manually clear HWO bit
2187 + * from that TRB.
2188 + */
2189 +- if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) {
2190 ++ if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
2191 + trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
2192 + return 1;
2193 + }
2194 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
2195 +index d2a9767a8e9c..6b2f6c41e2a9 100644
2196 +--- a/drivers/usb/host/xhci-hub.c
2197 ++++ b/drivers/usb/host/xhci-hub.c
2198 +@@ -895,7 +895,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
2199 + status |= USB_PORT_STAT_SUSPEND;
2200 + }
2201 + if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME &&
2202 +- !DEV_SUPERSPEED_ANY(raw_port_status)) {
2203 ++ !DEV_SUPERSPEED_ANY(raw_port_status) && hcd->speed < HCD_USB3) {
2204 + if ((raw_port_status & PORT_RESET) ||
2205 + !(raw_port_status & PORT_PE))
2206 + return 0xffffffff;
2207 +@@ -941,7 +941,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
2208 + time_left = wait_for_completion_timeout(
2209 + &bus_state->rexit_done[wIndex],
2210 + msecs_to_jiffies(
2211 +- XHCI_MAX_REXIT_TIMEOUT));
2212 ++ XHCI_MAX_REXIT_TIMEOUT_MS));
2213 + spin_lock_irqsave(&xhci->lock, flags);
2214 +
2215 + if (time_left) {
2216 +@@ -955,7 +955,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
2217 + } else {
2218 + int port_status = readl(port_array[wIndex]);
2219 + xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n",
2220 +- XHCI_MAX_REXIT_TIMEOUT,
2221 ++ XHCI_MAX_REXIT_TIMEOUT_MS,
2222 + port_status);
2223 + status |= USB_PORT_STAT_SUSPEND;
2224 + clear_bit(wIndex, &bus_state->rexit_ports);
2225 +@@ -1481,13 +1481,16 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
2226 + __le32 __iomem **port_array;
2227 + struct xhci_bus_state *bus_state;
2228 + unsigned long flags;
2229 ++ u32 portsc_buf[USB_MAXCHILDREN];
2230 ++ bool wake_enabled;
2231 +
2232 + max_ports = xhci_get_ports(hcd, &port_array);
2233 + bus_state = &xhci->bus_state[hcd_index(hcd)];
2234 ++ wake_enabled = hcd->self.root_hub->do_remote_wakeup;
2235 +
2236 + spin_lock_irqsave(&xhci->lock, flags);
2237 +
2238 +- if (hcd->self.root_hub->do_remote_wakeup) {
2239 ++ if (wake_enabled) {
2240 + if (bus_state->resuming_ports || /* USB2 */
2241 + bus_state->port_remote_wakeup) { /* USB3 */
2242 + spin_unlock_irqrestore(&xhci->lock, flags);
2243 +@@ -1495,26 +1498,36 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
2244 + return -EBUSY;
2245 + }
2246 + }
2247 +-
2248 +- port_index = max_ports;
2249 ++ /*
2250 ++ * Prepare ports for suspend, but don't write anything before all ports
2251 ++ * are checked and we know bus suspend can proceed
2252 ++ */
2253 + bus_state->bus_suspended = 0;
2254 ++ port_index = max_ports;
2255 + while (port_index--) {
2256 +- /* suspend the port if the port is not suspended */
2257 + u32 t1, t2;
2258 +- int slot_id;
2259 +
2260 + t1 = readl(port_array[port_index]);
2261 + t2 = xhci_port_state_to_neutral(t1);
2262 ++ portsc_buf[port_index] = 0;
2263 +
2264 +- if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {
2265 +- xhci_dbg(xhci, "port %d not suspended\n", port_index);
2266 +- slot_id = xhci_find_slot_id_by_port(hcd, xhci,
2267 +- port_index + 1);
2268 +- if (slot_id) {
2269 ++ /* Bail out if a USB3 port has a new device in link training */
2270 ++ if ((t1 & PORT_PLS_MASK) == XDEV_POLLING) {
2271 ++ bus_state->bus_suspended = 0;
2272 ++ spin_unlock_irqrestore(&xhci->lock, flags);
2273 ++ xhci_dbg(xhci, "Bus suspend bailout, port in polling\n");
2274 ++ return -EBUSY;
2275 ++ }
2276 ++
2277 ++ /* suspend ports in U0, or bail out for new connect changes */
2278 ++ if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) {
2279 ++ if ((t1 & PORT_CSC) && wake_enabled) {
2280 ++ bus_state->bus_suspended = 0;
2281 + spin_unlock_irqrestore(&xhci->lock, flags);
2282 +- xhci_stop_device(xhci, slot_id, 1);
2283 +- spin_lock_irqsave(&xhci->lock, flags);
2284 ++ xhci_dbg(xhci, "Bus suspend bailout, port connect change\n");
2285 ++ return -EBUSY;
2286 + }
2287 ++ xhci_dbg(xhci, "port %d not suspended\n", port_index);
2288 + t2 &= ~PORT_PLS_MASK;
2289 + t2 |= PORT_LINK_STROBE | XDEV_U3;
2290 + set_bit(port_index, &bus_state->bus_suspended);
2291 +@@ -1523,7 +1536,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
2292 + * including the USB 3.0 roothub, but only if CONFIG_PM
2293 + * is enabled, so also enable remote wake here.
2294 + */
2295 +- if (hcd->self.root_hub->do_remote_wakeup) {
2296 ++ if (wake_enabled) {
2297 + if (t1 & PORT_CONNECT) {
2298 + t2 |= PORT_WKOC_E | PORT_WKDISC_E;
2299 + t2 &= ~PORT_WKCONN_E;
2300 +@@ -1543,7 +1556,26 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
2301 +
2302 + t1 = xhci_port_state_to_neutral(t1);
2303 + if (t1 != t2)
2304 +- writel(t2, port_array[port_index]);
2305 ++ portsc_buf[port_index] = t2;
2306 ++ }
2307 ++
2308 ++ /* write port settings, stopping and suspending ports if needed */
2309 ++ port_index = max_ports;
2310 ++ while (port_index--) {
2311 ++ if (!portsc_buf[port_index])
2312 ++ continue;
2313 ++ if (test_bit(port_index, &bus_state->bus_suspended)) {
2314 ++ int slot_id;
2315 ++
2316 ++ slot_id = xhci_find_slot_id_by_port(hcd, xhci,
2317 ++ port_index + 1);
2318 ++ if (slot_id) {
2319 ++ spin_unlock_irqrestore(&xhci->lock, flags);
2320 ++ xhci_stop_device(xhci, slot_id, 1);
2321 ++ spin_lock_irqsave(&xhci->lock, flags);
2322 ++ }
2323 ++ }
2324 ++ writel(portsc_buf[port_index], port_array[port_index]);
2325 + }
2326 + hcd->state = HC_STATE_SUSPENDED;
2327 + bus_state->next_statechange = jiffies + msecs_to_jiffies(10);
2328 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
2329 +index 9218f506f8e3..4b07b6859b4c 100644
2330 +--- a/drivers/usb/host/xhci-pci.c
2331 ++++ b/drivers/usb/host/xhci-pci.c
2332 +@@ -236,6 +236,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
2333 + if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
2334 + xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
2335 +
2336 ++ if ((pdev->vendor == PCI_VENDOR_ID_BROADCOM ||
2337 ++ pdev->vendor == PCI_VENDOR_ID_CAVIUM) &&
2338 ++ pdev->device == 0x9026)
2339 ++ xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
2340 ++
2341 + if (xhci->quirks & XHCI_RESET_ON_RESUME)
2342 + xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
2343 + "QUIRK: Resetting on resume");
2344 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
2345 +index 6996235e34a9..aa230706b875 100644
2346 +--- a/drivers/usb/host/xhci-ring.c
2347 ++++ b/drivers/usb/host/xhci-ring.c
2348 +@@ -1568,6 +1568,35 @@ static void handle_device_notification(struct xhci_hcd *xhci,
2349 + usb_wakeup_notification(udev->parent, udev->portnum);
2350 + }
2351 +
2352 ++/*
2353 ++ * Quirk hanlder for errata seen on Cavium ThunderX2 processor XHCI
2354 ++ * Controller.
2355 ++ * As per ThunderX2errata-129 USB 2 device may come up as USB 1
2356 ++ * If a connection to a USB 1 device is followed by another connection
2357 ++ * to a USB 2 device.
2358 ++ *
2359 ++ * Reset the PHY after the USB device is disconnected if device speed
2360 ++ * is less than HCD_USB3.
2361 ++ * Retry the reset sequence max of 4 times checking the PLL lock status.
2362 ++ *
2363 ++ */
2364 ++static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci)
2365 ++{
2366 ++ struct usb_hcd *hcd = xhci_to_hcd(xhci);
2367 ++ u32 pll_lock_check;
2368 ++ u32 retry_count = 4;
2369 ++
2370 ++ do {
2371 ++ /* Assert PHY reset */
2372 ++ writel(0x6F, hcd->regs + 0x1048);
2373 ++ udelay(10);
2374 ++ /* De-assert the PHY reset */
2375 ++ writel(0x7F, hcd->regs + 0x1048);
2376 ++ udelay(200);
2377 ++ pll_lock_check = readl(hcd->regs + 0x1070);
2378 ++ } while (!(pll_lock_check & 0x1) && --retry_count);
2379 ++}
2380 ++
2381 + static void handle_port_status(struct xhci_hcd *xhci,
2382 + union xhci_trb *event)
2383 + {
2384 +@@ -1717,7 +1746,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
2385 + * RExit to a disconnect state). If so, let the the driver know it's
2386 + * out of the RExit state.
2387 + */
2388 +- if (!DEV_SUPERSPEED_ANY(portsc) &&
2389 ++ if (!DEV_SUPERSPEED_ANY(portsc) && hcd->speed < HCD_USB3 &&
2390 + test_and_clear_bit(faked_port_index,
2391 + &bus_state->rexit_ports)) {
2392 + complete(&bus_state->rexit_done[faked_port_index]);
2393 +@@ -1725,9 +1754,13 @@ static void handle_port_status(struct xhci_hcd *xhci,
2394 + goto cleanup;
2395 + }
2396 +
2397 +- if (hcd->speed < HCD_USB3)
2398 ++ if (hcd->speed < HCD_USB3) {
2399 + xhci_test_and_clear_bit(xhci, port_array, faked_port_index,
2400 + PORT_PLC);
2401 ++ if ((xhci->quirks & XHCI_RESET_PLL_ON_DISCONNECT) &&
2402 ++ (portsc & PORT_CSC) && !(portsc & PORT_CONNECT))
2403 ++ xhci_cavium_reset_phy_quirk(xhci);
2404 ++ }
2405 +
2406 + cleanup:
2407 + /* Update event ring dequeue pointer before dropping the lock */
2408 +@@ -2335,6 +2368,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2409 + goto cleanup;
2410 + case COMP_RING_UNDERRUN:
2411 + case COMP_RING_OVERRUN:
2412 ++ case COMP_STOPPED_LENGTH_INVALID:
2413 + goto cleanup;
2414 + default:
2415 + xhci_err(xhci, "ERROR Transfer event for unknown stream ring slot %u ep %u\n",
2416 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2417 +index 64ddba3f79a9..faf048682194 100644
2418 +--- a/drivers/usb/host/xhci.c
2419 ++++ b/drivers/usb/host/xhci.c
2420 +@@ -43,8 +43,8 @@ static int link_quirk;
2421 + module_param(link_quirk, int, S_IRUGO | S_IWUSR);
2422 + MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
2423 +
2424 +-static unsigned int quirks;
2425 +-module_param(quirks, uint, S_IRUGO);
2426 ++static unsigned long long quirks;
2427 ++module_param(quirks, ullong, S_IRUGO);
2428 + MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default");
2429 +
2430 + static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
2431 +@@ -4956,7 +4956,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
2432 + return retval;
2433 + xhci_dbg(xhci, "Called HCD init\n");
2434 +
2435 +- xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%08x\n",
2436 ++ xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%016llx\n",
2437 + xhci->hcc_params, xhci->hci_version, xhci->quirks);
2438 +
2439 + return 0;
2440 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
2441 +index 11232e62b898..74ba20556020 100644
2442 +--- a/drivers/usb/host/xhci.h
2443 ++++ b/drivers/usb/host/xhci.h
2444 +@@ -1684,7 +1684,7 @@ struct xhci_bus_state {
2445 + * It can take up to 20 ms to transition from RExit to U0 on the
2446 + * Intel Lynx Point LP xHCI host.
2447 + */
2448 +-#define XHCI_MAX_REXIT_TIMEOUT (20 * 1000)
2449 ++#define XHCI_MAX_REXIT_TIMEOUT_MS 20
2450 +
2451 + static inline unsigned int hcd_index(struct usb_hcd *hcd)
2452 + {
2453 +@@ -1794,12 +1794,12 @@ struct xhci_hcd {
2454 + #define XHCI_STATE_DYING (1 << 0)
2455 + #define XHCI_STATE_HALTED (1 << 1)
2456 + #define XHCI_STATE_REMOVING (1 << 2)
2457 +- unsigned int quirks;
2458 +-#define XHCI_LINK_TRB_QUIRK (1 << 0)
2459 +-#define XHCI_RESET_EP_QUIRK (1 << 1)
2460 +-#define XHCI_NEC_HOST (1 << 2)
2461 +-#define XHCI_AMD_PLL_FIX (1 << 3)
2462 +-#define XHCI_SPURIOUS_SUCCESS (1 << 4)
2463 ++ unsigned long long quirks;
2464 ++#define XHCI_LINK_TRB_QUIRK BIT_ULL(0)
2465 ++#define XHCI_RESET_EP_QUIRK BIT_ULL(1)
2466 ++#define XHCI_NEC_HOST BIT_ULL(2)
2467 ++#define XHCI_AMD_PLL_FIX BIT_ULL(3)
2468 ++#define XHCI_SPURIOUS_SUCCESS BIT_ULL(4)
2469 + /*
2470 + * Certain Intel host controllers have a limit to the number of endpoint
2471 + * contexts they can handle. Ideally, they would signal that they can't handle
2472 +@@ -1809,33 +1809,36 @@ struct xhci_hcd {
2473 + * commands, reset device commands, disable slot commands, and address device
2474 + * commands.
2475 + */
2476 +-#define XHCI_EP_LIMIT_QUIRK (1 << 5)
2477 +-#define XHCI_BROKEN_MSI (1 << 6)
2478 +-#define XHCI_RESET_ON_RESUME (1 << 7)
2479 +-#define XHCI_SW_BW_CHECKING (1 << 8)
2480 +-#define XHCI_AMD_0x96_HOST (1 << 9)
2481 +-#define XHCI_TRUST_TX_LENGTH (1 << 10)
2482 +-#define XHCI_LPM_SUPPORT (1 << 11)
2483 +-#define XHCI_INTEL_HOST (1 << 12)
2484 +-#define XHCI_SPURIOUS_REBOOT (1 << 13)
2485 +-#define XHCI_COMP_MODE_QUIRK (1 << 14)
2486 +-#define XHCI_AVOID_BEI (1 << 15)
2487 +-#define XHCI_PLAT (1 << 16)
2488 +-#define XHCI_SLOW_SUSPEND (1 << 17)
2489 +-#define XHCI_SPURIOUS_WAKEUP (1 << 18)
2490 ++#define XHCI_EP_LIMIT_QUIRK BIT_ULL(5)
2491 ++#define XHCI_BROKEN_MSI BIT_ULL(6)
2492 ++#define XHCI_RESET_ON_RESUME BIT_ULL(7)
2493 ++#define XHCI_SW_BW_CHECKING BIT_ULL(8)
2494 ++#define XHCI_AMD_0x96_HOST BIT_ULL(9)
2495 ++#define XHCI_TRUST_TX_LENGTH BIT_ULL(10)
2496 ++#define XHCI_LPM_SUPPORT BIT_ULL(11)
2497 ++#define XHCI_INTEL_HOST BIT_ULL(12)
2498 ++#define XHCI_SPURIOUS_REBOOT BIT_ULL(13)
2499 ++#define XHCI_COMP_MODE_QUIRK BIT_ULL(14)
2500 ++#define XHCI_AVOID_BEI BIT_ULL(15)
2501 ++#define XHCI_PLAT BIT_ULL(16)
2502 ++#define XHCI_SLOW_SUSPEND BIT_ULL(17)
2503 ++#define XHCI_SPURIOUS_WAKEUP BIT_ULL(18)
2504 + /* For controllers with a broken beyond repair streams implementation */
2505 +-#define XHCI_BROKEN_STREAMS (1 << 19)
2506 +-#define XHCI_PME_STUCK_QUIRK (1 << 20)
2507 +-#define XHCI_MTK_HOST (1 << 21)
2508 +-#define XHCI_SSIC_PORT_UNUSED (1 << 22)
2509 +-#define XHCI_NO_64BIT_SUPPORT (1 << 23)
2510 +-#define XHCI_MISSING_CAS (1 << 24)
2511 ++#define XHCI_BROKEN_STREAMS BIT_ULL(19)
2512 ++#define XHCI_PME_STUCK_QUIRK BIT_ULL(20)
2513 ++#define XHCI_MTK_HOST BIT_ULL(21)
2514 ++#define XHCI_SSIC_PORT_UNUSED BIT_ULL(22)
2515 ++#define XHCI_NO_64BIT_SUPPORT BIT_ULL(23)
2516 ++#define XHCI_MISSING_CAS BIT_ULL(24)
2517 + /* For controller with a broken Port Disable implementation */
2518 +-#define XHCI_BROKEN_PORT_PED (1 << 25)
2519 +-#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
2520 +-#define XHCI_U2_DISABLE_WAKE (1 << 27)
2521 +-#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28)
2522 +-#define XHCI_SUSPEND_DELAY (1 << 30)
2523 ++#define XHCI_BROKEN_PORT_PED BIT_ULL(25)
2524 ++#define XHCI_LIMIT_ENDPOINT_INTERVAL_7 BIT_ULL(26)
2525 ++#define XHCI_U2_DISABLE_WAKE BIT_ULL(27)
2526 ++#define XHCI_ASMEDIA_MODIFY_FLOWCONTROL BIT_ULL(28)
2527 ++#define XHCI_HW_LPM_DISABLE BIT_ULL(29)
2528 ++#define XHCI_SUSPEND_DELAY BIT_ULL(30)
2529 ++#define XHCI_INTEL_USB_ROLE_SW BIT_ULL(31)
2530 ++#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)
2531 +
2532 + unsigned int num_active_eps;
2533 + unsigned int limit_active_eps;
2534 +diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
2535 +index b0405d6aac85..48db9a9f13f9 100644
2536 +--- a/fs/9p/vfs_dir.c
2537 ++++ b/fs/9p/vfs_dir.c
2538 +@@ -76,15 +76,6 @@ static inline int dt_type(struct p9_wstat *mistat)
2539 + return rettype;
2540 + }
2541 +
2542 +-static void p9stat_init(struct p9_wstat *stbuf)
2543 +-{
2544 +- stbuf->name = NULL;
2545 +- stbuf->uid = NULL;
2546 +- stbuf->gid = NULL;
2547 +- stbuf->muid = NULL;
2548 +- stbuf->extension = NULL;
2549 +-}
2550 +-
2551 + /**
2552 + * v9fs_alloc_rdir_buf - Allocate buffer used for read and readdir
2553 + * @filp: opened file structure
2554 +@@ -145,12 +136,10 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)
2555 + rdir->tail = n;
2556 + }
2557 + while (rdir->head < rdir->tail) {
2558 +- p9stat_init(&st);
2559 + err = p9stat_read(fid->clnt, rdir->buf + rdir->head,
2560 + rdir->tail - rdir->head, &st);
2561 + if (err) {
2562 + p9_debug(P9_DEBUG_VFS, "returned %d\n", err);
2563 +- p9stat_free(&st);
2564 + return -EIO;
2565 + }
2566 + reclen = st.size+2;
2567 +diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
2568 +index 9a69392f1fb3..d81c148682e7 100644
2569 +--- a/fs/bfs/inode.c
2570 ++++ b/fs/bfs/inode.c
2571 +@@ -350,7 +350,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
2572 +
2573 + s->s_magic = BFS_MAGIC;
2574 +
2575 +- if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end)) {
2576 ++ if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) ||
2577 ++ le32_to_cpu(bfs_sb->s_start) < BFS_BSIZE) {
2578 + printf("Superblock is corrupted\n");
2579 + goto out1;
2580 + }
2581 +@@ -359,9 +360,11 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
2582 + sizeof(struct bfs_inode)
2583 + + BFS_ROOT_INO - 1;
2584 + imap_len = (info->si_lasti / 8) + 1;
2585 +- info->si_imap = kzalloc(imap_len, GFP_KERNEL);
2586 +- if (!info->si_imap)
2587 ++ info->si_imap = kzalloc(imap_len, GFP_KERNEL | __GFP_NOWARN);
2588 ++ if (!info->si_imap) {
2589 ++ printf("Cannot allocate %u bytes\n", imap_len);
2590 + goto out1;
2591 ++ }
2592 + for (i = 0; i < BFS_ROOT_INO; i++)
2593 + set_bit(i, info->si_imap);
2594 +
2595 +diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
2596 +index 28d6c65c8bb3..057be88eb1b4 100644
2597 +--- a/fs/gfs2/ops_fstype.c
2598 ++++ b/fs/gfs2/ops_fstype.c
2599 +@@ -72,13 +72,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
2600 + if (!sdp)
2601 + return NULL;
2602 +
2603 +- sb->s_fs_info = sdp;
2604 + sdp->sd_vfs = sb;
2605 + sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);
2606 + if (!sdp->sd_lkstats) {
2607 + kfree(sdp);
2608 + return NULL;
2609 + }
2610 ++ sb->s_fs_info = sdp;
2611 +
2612 + set_bit(SDF_NOJOURNALID, &sdp->sd_flags);
2613 + gfs2_tune_init(&sdp->sd_tune);
2614 +diff --git a/fs/namei.c b/fs/namei.c
2615 +index 0b46b858cd42..d1e467b7b9de 100644
2616 +--- a/fs/namei.c
2617 ++++ b/fs/namei.c
2618 +@@ -904,6 +904,8 @@ static inline void put_link(struct nameidata *nd)
2619 +
2620 + int sysctl_protected_symlinks __read_mostly = 0;
2621 + int sysctl_protected_hardlinks __read_mostly = 0;
2622 ++int sysctl_protected_fifos __read_mostly;
2623 ++int sysctl_protected_regular __read_mostly;
2624 +
2625 + /**
2626 + * may_follow_link - Check symlink following for unsafe situations
2627 +@@ -1017,6 +1019,45 @@ static int may_linkat(struct path *link)
2628 + return -EPERM;
2629 + }
2630 +
2631 ++/**
2632 ++ * may_create_in_sticky - Check whether an O_CREAT open in a sticky directory
2633 ++ * should be allowed, or not, on files that already
2634 ++ * exist.
2635 ++ * @dir: the sticky parent directory
2636 ++ * @inode: the inode of the file to open
2637 ++ *
2638 ++ * Block an O_CREAT open of a FIFO (or a regular file) when:
2639 ++ * - sysctl_protected_fifos (or sysctl_protected_regular) is enabled
2640 ++ * - the file already exists
2641 ++ * - we are in a sticky directory
2642 ++ * - we don't own the file
2643 ++ * - the owner of the directory doesn't own the file
2644 ++ * - the directory is world writable
2645 ++ * If the sysctl_protected_fifos (or sysctl_protected_regular) is set to 2
2646 ++ * the directory doesn't have to be world writable: being group writable will
2647 ++ * be enough.
2648 ++ *
2649 ++ * Returns 0 if the open is allowed, -ve on error.
2650 ++ */
2651 ++static int may_create_in_sticky(struct dentry * const dir,
2652 ++ struct inode * const inode)
2653 ++{
2654 ++ if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) ||
2655 ++ (!sysctl_protected_regular && S_ISREG(inode->i_mode)) ||
2656 ++ likely(!(dir->d_inode->i_mode & S_ISVTX)) ||
2657 ++ uid_eq(inode->i_uid, dir->d_inode->i_uid) ||
2658 ++ uid_eq(current_fsuid(), inode->i_uid))
2659 ++ return 0;
2660 ++
2661 ++ if (likely(dir->d_inode->i_mode & 0002) ||
2662 ++ (dir->d_inode->i_mode & 0020 &&
2663 ++ ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) ||
2664 ++ (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) {
2665 ++ return -EACCES;
2666 ++ }
2667 ++ return 0;
2668 ++}
2669 ++
2670 + static __always_inline
2671 + const char *get_link(struct nameidata *nd)
2672 + {
2673 +@@ -3355,9 +3396,15 @@ finish_open:
2674 + if (error)
2675 + return error;
2676 + audit_inode(nd->name, nd->path.dentry, 0);
2677 +- error = -EISDIR;
2678 +- if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
2679 +- goto out;
2680 ++ if (open_flag & O_CREAT) {
2681 ++ error = -EISDIR;
2682 ++ if (d_is_dir(nd->path.dentry))
2683 ++ goto out;
2684 ++ error = may_create_in_sticky(dir,
2685 ++ d_backing_inode(nd->path.dentry));
2686 ++ if (unlikely(error))
2687 ++ goto out;
2688 ++ }
2689 + error = -ENOTDIR;
2690 + if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
2691 + goto out;
2692 +diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
2693 +index 61f1cf2d9f44..c0c0b992210e 100644
2694 +--- a/include/linux/can/dev.h
2695 ++++ b/include/linux/can/dev.h
2696 +@@ -163,6 +163,7 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
2697 +
2698 + void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
2699 + unsigned int idx);
2700 ++struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr);
2701 + unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
2702 + void can_free_echo_skb(struct net_device *dev, unsigned int idx);
2703 +
2704 +diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
2705 +index cb31683bbe15..8268811a697e 100644
2706 +--- a/include/linux/can/rx-offload.h
2707 ++++ b/include/linux/can/rx-offload.h
2708 +@@ -41,7 +41,12 @@ int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *
2709 + int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight);
2710 + int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg);
2711 + int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
2712 +-int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_buff *skb);
2713 ++int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
2714 ++ struct sk_buff *skb, u32 timestamp);
2715 ++unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
2716 ++ unsigned int idx, u32 timestamp);
2717 ++int can_rx_offload_queue_tail(struct can_rx_offload *offload,
2718 ++ struct sk_buff *skb);
2719 + void can_rx_offload_reset(struct can_rx_offload *offload);
2720 + void can_rx_offload_del(struct can_rx_offload *offload);
2721 + void can_rx_offload_enable(struct can_rx_offload *offload);
2722 +diff --git a/include/linux/fs.h b/include/linux/fs.h
2723 +index 7374639f0aa0..f6a577edec67 100644
2724 +--- a/include/linux/fs.h
2725 ++++ b/include/linux/fs.h
2726 +@@ -72,6 +72,8 @@ extern struct inodes_stat_t inodes_stat;
2727 + extern int leases_enable, lease_break_time;
2728 + extern int sysctl_protected_symlinks;
2729 + extern int sysctl_protected_hardlinks;
2730 ++extern int sysctl_protected_fifos;
2731 ++extern int sysctl_protected_regular;
2732 +
2733 + typedef __kernel_rwf_t rwf_t;
2734 +
2735 +diff --git a/include/linux/integrity.h b/include/linux/integrity.h
2736 +index c2d6082a1a4c..858d3f4a2241 100644
2737 +--- a/include/linux/integrity.h
2738 ++++ b/include/linux/integrity.h
2739 +@@ -14,6 +14,7 @@
2740 +
2741 + enum integrity_status {
2742 + INTEGRITY_PASS = 0,
2743 ++ INTEGRITY_PASS_IMMUTABLE,
2744 + INTEGRITY_FAIL,
2745 + INTEGRITY_NOLABEL,
2746 + INTEGRITY_NOXATTRS,
2747 +diff --git a/include/linux/of.h b/include/linux/of.h
2748 +index b240ed69dc96..70b7dacf9238 100644
2749 +--- a/include/linux/of.h
2750 ++++ b/include/linux/of.h
2751 +@@ -288,6 +288,8 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
2752 + extern struct device_node *of_get_next_available_child(
2753 + const struct device_node *node, struct device_node *prev);
2754 +
2755 ++extern struct device_node *of_get_compatible_child(const struct device_node *parent,
2756 ++ const char *compatible);
2757 + extern struct device_node *of_get_child_by_name(const struct device_node *node,
2758 + const char *name);
2759 +
2760 +@@ -625,6 +627,12 @@ static inline bool of_have_populated_dt(void)
2761 + return false;
2762 + }
2763 +
2764 ++static inline struct device_node *of_get_compatible_child(const struct device_node *parent,
2765 ++ const char *compatible)
2766 ++{
2767 ++ return NULL;
2768 ++}
2769 ++
2770 + static inline struct device_node *of_get_child_by_name(
2771 + const struct device_node *node,
2772 + const char *name)
2773 +diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h
2774 +index 43b1d7648e82..a8aef18c6244 100644
2775 +--- a/include/linux/pfn_t.h
2776 ++++ b/include/linux/pfn_t.h
2777 +@@ -10,7 +10,7 @@
2778 + * PFN_DEV - pfn is not covered by system memmap by default
2779 + * PFN_MAP - pfn has a dynamic page mapping established by a device driver
2780 + */
2781 +-#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
2782 ++#define PFN_FLAGS_MASK (((u64) (~PAGE_MASK)) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
2783 + #define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1))
2784 + #define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2))
2785 + #define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
2786 +diff --git a/include/net/sock.h b/include/net/sock.h
2787 +index 9bd5d68076d9..64a330544dad 100644
2788 +--- a/include/net/sock.h
2789 ++++ b/include/net/sock.h
2790 +@@ -1452,6 +1452,7 @@ static inline void lock_sock(struct sock *sk)
2791 + lock_sock_nested(sk, 0);
2792 + }
2793 +
2794 ++void __release_sock(struct sock *sk);
2795 + void release_sock(struct sock *sk);
2796 +
2797 + /* BH context may only use the following locking interface. */
2798 +diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
2799 +index ed5d34925ad0..6a4b41484afe 100644
2800 +--- a/kernel/debug/kdb/kdb_io.c
2801 ++++ b/kernel/debug/kdb/kdb_io.c
2802 +@@ -216,7 +216,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
2803 + int count;
2804 + int i;
2805 + int diag, dtab_count;
2806 +- int key;
2807 ++ int key, buf_size, ret;
2808 +
2809 +
2810 + diag = kdbgetintenv("DTABCOUNT", &dtab_count);
2811 +@@ -336,9 +336,8 @@ poll_again:
2812 + else
2813 + p_tmp = tmpbuffer;
2814 + len = strlen(p_tmp);
2815 +- count = kallsyms_symbol_complete(p_tmp,
2816 +- sizeof(tmpbuffer) -
2817 +- (p_tmp - tmpbuffer));
2818 ++ buf_size = sizeof(tmpbuffer) - (p_tmp - tmpbuffer);
2819 ++ count = kallsyms_symbol_complete(p_tmp, buf_size);
2820 + if (tab == 2 && count > 0) {
2821 + kdb_printf("\n%d symbols are found.", count);
2822 + if (count > dtab_count) {
2823 +@@ -350,9 +349,13 @@ poll_again:
2824 + }
2825 + kdb_printf("\n");
2826 + for (i = 0; i < count; i++) {
2827 +- if (WARN_ON(!kallsyms_symbol_next(p_tmp, i)))
2828 ++ ret = kallsyms_symbol_next(p_tmp, i, buf_size);
2829 ++ if (WARN_ON(!ret))
2830 + break;
2831 +- kdb_printf("%s ", p_tmp);
2832 ++ if (ret != -E2BIG)
2833 ++ kdb_printf("%s ", p_tmp);
2834 ++ else
2835 ++ kdb_printf("%s... ", p_tmp);
2836 + *(p_tmp + len) = '\0';
2837 + }
2838 + if (i >= dtab_count)
2839 +diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
2840 +index fc224fbcf954..f2158e463a0f 100644
2841 +--- a/kernel/debug/kdb/kdb_private.h
2842 ++++ b/kernel/debug/kdb/kdb_private.h
2843 +@@ -83,7 +83,7 @@ typedef struct __ksymtab {
2844 + unsigned long sym_start;
2845 + unsigned long sym_end;
2846 + } kdb_symtab_t;
2847 +-extern int kallsyms_symbol_next(char *prefix_name, int flag);
2848 ++extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size);
2849 + extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
2850 +
2851 + /* Exported Symbols for kernel loadable modules to use. */
2852 +diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
2853 +index 84422d2b95c0..014f6fbb3832 100644
2854 +--- a/kernel/debug/kdb/kdb_support.c
2855 ++++ b/kernel/debug/kdb/kdb_support.c
2856 +@@ -221,11 +221,13 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len)
2857 + * Parameters:
2858 + * prefix_name prefix of a symbol name to lookup
2859 + * flag 0 means search from the head, 1 means continue search.
2860 ++ * buf_size maximum length that can be written to prefix_name
2861 ++ * buffer
2862 + * Returns:
2863 + * 1 if a symbol matches the given prefix.
2864 + * 0 if no string found
2865 + */
2866 +-int kallsyms_symbol_next(char *prefix_name, int flag)
2867 ++int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size)
2868 + {
2869 + int prefix_len = strlen(prefix_name);
2870 + static loff_t pos;
2871 +@@ -235,10 +237,8 @@ int kallsyms_symbol_next(char *prefix_name, int flag)
2872 + pos = 0;
2873 +
2874 + while ((name = kdb_walk_kallsyms(&pos))) {
2875 +- if (strncmp(name, prefix_name, prefix_len) == 0) {
2876 +- strncpy(prefix_name, name, strlen(name)+1);
2877 +- return 1;
2878 +- }
2879 ++ if (!strncmp(name, prefix_name, prefix_len))
2880 ++ return strscpy(prefix_name, name, buf_size);
2881 + }
2882 + return 0;
2883 + }
2884 +diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
2885 +index 3e3650e94ae6..710ce1d6b982 100644
2886 +--- a/kernel/rcu/tree.c
2887 ++++ b/kernel/rcu/tree.c
2888 +@@ -2772,6 +2772,15 @@ void rcu_check_callbacks(int user)
2889 + rcu_bh_qs();
2890 + }
2891 + rcu_preempt_check_callbacks();
2892 ++ /* The load-acquire pairs with the store-release setting to true. */
2893 ++ if (smp_load_acquire(this_cpu_ptr(&rcu_dynticks.rcu_urgent_qs))) {
2894 ++ /* Idle and userspace execution already are quiescent states. */
2895 ++ if (!rcu_is_cpu_rrupt_from_idle() && !user) {
2896 ++ set_tsk_need_resched(current);
2897 ++ set_preempt_need_resched();
2898 ++ }
2899 ++ __this_cpu_write(rcu_dynticks.rcu_urgent_qs, false);
2900 ++ }
2901 + if (rcu_pending())
2902 + invoke_rcu_core();
2903 + if (user)
2904 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2905 +index 069550540a39..d330b1ce3b94 100644
2906 +--- a/kernel/sysctl.c
2907 ++++ b/kernel/sysctl.c
2908 +@@ -1793,6 +1793,24 @@ static struct ctl_table fs_table[] = {
2909 + .extra1 = &zero,
2910 + .extra2 = &one,
2911 + },
2912 ++ {
2913 ++ .procname = "protected_fifos",
2914 ++ .data = &sysctl_protected_fifos,
2915 ++ .maxlen = sizeof(int),
2916 ++ .mode = 0600,
2917 ++ .proc_handler = proc_dointvec_minmax,
2918 ++ .extra1 = &zero,
2919 ++ .extra2 = &two,
2920 ++ },
2921 ++ {
2922 ++ .procname = "protected_regular",
2923 ++ .data = &sysctl_protected_regular,
2924 ++ .maxlen = sizeof(int),
2925 ++ .mode = 0600,
2926 ++ .proc_handler = proc_dointvec_minmax,
2927 ++ .extra1 = &zero,
2928 ++ .extra2 = &two,
2929 ++ },
2930 + {
2931 + .procname = "suid_dumpable",
2932 + .data = &suid_dumpable,
2933 +diff --git a/mm/memory.c b/mm/memory.c
2934 +index 93d5d324904b..b6cfe0cf0ead 100644
2935 +--- a/mm/memory.c
2936 ++++ b/mm/memory.c
2937 +@@ -3697,10 +3697,36 @@ static int do_fault(struct vm_fault *vmf)
2938 + struct vm_area_struct *vma = vmf->vma;
2939 + int ret;
2940 +
2941 +- /* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */
2942 +- if (!vma->vm_ops->fault)
2943 +- ret = VM_FAULT_SIGBUS;
2944 +- else if (!(vmf->flags & FAULT_FLAG_WRITE))
2945 ++ /*
2946 ++ * The VMA was not fully populated on mmap() or missing VM_DONTEXPAND
2947 ++ */
2948 ++ if (!vma->vm_ops->fault) {
2949 ++ /*
2950 ++ * If we find a migration pmd entry or a none pmd entry, which
2951 ++ * should never happen, return SIGBUS
2952 ++ */
2953 ++ if (unlikely(!pmd_present(*vmf->pmd)))
2954 ++ ret = VM_FAULT_SIGBUS;
2955 ++ else {
2956 ++ vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm,
2957 ++ vmf->pmd,
2958 ++ vmf->address,
2959 ++ &vmf->ptl);
2960 ++ /*
2961 ++ * Make sure this is not a temporary clearing of pte
2962 ++ * by holding ptl and checking again. A R/M/W update
2963 ++ * of pte involves: take ptl, clearing the pte so that
2964 ++ * we don't have concurrent modification by hardware
2965 ++ * followed by an update.
2966 ++ */
2967 ++ if (unlikely(pte_none(*vmf->pte)))
2968 ++ ret = VM_FAULT_SIGBUS;
2969 ++ else
2970 ++ ret = VM_FAULT_NOPAGE;
2971 ++
2972 ++ pte_unmap_unlock(vmf->pte, vmf->ptl);
2973 ++ }
2974 ++ } else if (!(vmf->flags & FAULT_FLAG_WRITE))
2975 + ret = do_read_fault(vmf);
2976 + else if (!(vma->vm_flags & VM_SHARED))
2977 + ret = do_cow_fault(vmf);
2978 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
2979 +index a604b5da6755..2074f424dabf 100644
2980 +--- a/mm/page_alloc.c
2981 ++++ b/mm/page_alloc.c
2982 +@@ -3867,17 +3867,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
2983 + unsigned int cpuset_mems_cookie;
2984 + int reserve_flags;
2985 +
2986 +- /*
2987 +- * In the slowpath, we sanity check order to avoid ever trying to
2988 +- * reclaim >= MAX_ORDER areas which will never succeed. Callers may
2989 +- * be using allocators in order of preference for an area that is
2990 +- * too large.
2991 +- */
2992 +- if (order >= MAX_ORDER) {
2993 +- WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
2994 +- return NULL;
2995 +- }
2996 +-
2997 + /*
2998 + * We also sanity check to catch abuse of atomic reserves being used by
2999 + * callers that are not in atomic context.
3000 +@@ -4179,6 +4168,15 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
3001 + gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */
3002 + struct alloc_context ac = { };
3003 +
3004 ++ /*
3005 ++ * There are several places where we assume that the order value is sane
3006 ++ * so bail out early if the request is out of bound.
3007 ++ */
3008 ++ if (unlikely(order >= MAX_ORDER)) {
3009 ++ WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
3010 ++ return NULL;
3011 ++ }
3012 ++
3013 + gfp_mask &= gfp_allowed_mask;
3014 + alloc_mask = gfp_mask;
3015 + if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))
3016 +diff --git a/mm/shmem.c b/mm/shmem.c
3017 +index ea786a504e1b..fa08f56fd5e5 100644
3018 +--- a/mm/shmem.c
3019 ++++ b/mm/shmem.c
3020 +@@ -2590,9 +2590,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
3021 + inode_lock(inode);
3022 + /* We're holding i_mutex so we can access i_size directly */
3023 +
3024 +- if (offset < 0)
3025 +- offset = -EINVAL;
3026 +- else if (offset >= inode->i_size)
3027 ++ if (offset < 0 || offset >= inode->i_size)
3028 + offset = -ENXIO;
3029 + else {
3030 + start = offset >> PAGE_SHIFT;
3031 +diff --git a/mm/slab.c b/mm/slab.c
3032 +index 198c1e2c5358..68ab88e2920e 100644
3033 +--- a/mm/slab.c
3034 ++++ b/mm/slab.c
3035 +@@ -3670,6 +3670,8 @@ __do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller)
3036 + struct kmem_cache *cachep;
3037 + void *ret;
3038 +
3039 ++ if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
3040 ++ return NULL;
3041 + cachep = kmalloc_slab(size, flags);
3042 + if (unlikely(ZERO_OR_NULL_PTR(cachep)))
3043 + return cachep;
3044 +@@ -3705,6 +3707,8 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
3045 + struct kmem_cache *cachep;
3046 + void *ret;
3047 +
3048 ++ if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
3049 ++ return NULL;
3050 + cachep = kmalloc_slab(size, flags);
3051 + if (unlikely(ZERO_OR_NULL_PTR(cachep)))
3052 + return cachep;
3053 +diff --git a/mm/slab_common.c b/mm/slab_common.c
3054 +index 91d271b90600..f6764cf162b8 100644
3055 +--- a/mm/slab_common.c
3056 ++++ b/mm/slab_common.c
3057 +@@ -971,18 +971,18 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
3058 + {
3059 + int index;
3060 +
3061 +- if (unlikely(size > KMALLOC_MAX_SIZE)) {
3062 +- WARN_ON_ONCE(!(flags & __GFP_NOWARN));
3063 +- return NULL;
3064 +- }
3065 +-
3066 + if (size <= 192) {
3067 + if (!size)
3068 + return ZERO_SIZE_PTR;
3069 +
3070 + index = size_index[size_index_elem(size)];
3071 +- } else
3072 ++ } else {
3073 ++ if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
3074 ++ WARN_ON(1);
3075 ++ return NULL;
3076 ++ }
3077 + index = fls(size - 1);
3078 ++ }
3079 +
3080 + #ifdef CONFIG_ZONE_DMA
3081 + if (unlikely((flags & GFP_DMA)))
3082 +diff --git a/mm/z3fold.c b/mm/z3fold.c
3083 +index f33403d718ac..2813cdfa46b9 100644
3084 +--- a/mm/z3fold.c
3085 ++++ b/mm/z3fold.c
3086 +@@ -99,6 +99,7 @@ struct z3fold_header {
3087 + #define NCHUNKS ((PAGE_SIZE - ZHDR_SIZE_ALIGNED) >> CHUNK_SHIFT)
3088 +
3089 + #define BUDDY_MASK (0x3)
3090 ++#define BUDDY_SHIFT 2
3091 +
3092 + /**
3093 + * struct z3fold_pool - stores metadata for each z3fold pool
3094 +@@ -145,7 +146,7 @@ enum z3fold_page_flags {
3095 + MIDDLE_CHUNK_MAPPED,
3096 + NEEDS_COMPACTING,
3097 + PAGE_STALE,
3098 +- UNDER_RECLAIM
3099 ++ PAGE_CLAIMED, /* by either reclaim or free */
3100 + };
3101 +
3102 + /*****************
3103 +@@ -174,7 +175,7 @@ static struct z3fold_header *init_z3fold_page(struct page *page,
3104 + clear_bit(MIDDLE_CHUNK_MAPPED, &page->private);
3105 + clear_bit(NEEDS_COMPACTING, &page->private);
3106 + clear_bit(PAGE_STALE, &page->private);
3107 +- clear_bit(UNDER_RECLAIM, &page->private);
3108 ++ clear_bit(PAGE_CLAIMED, &page->private);
3109 +
3110 + spin_lock_init(&zhdr->page_lock);
3111 + kref_init(&zhdr->refcount);
3112 +@@ -223,8 +224,11 @@ static unsigned long encode_handle(struct z3fold_header *zhdr, enum buddy bud)
3113 + unsigned long handle;
3114 +
3115 + handle = (unsigned long)zhdr;
3116 +- if (bud != HEADLESS)
3117 +- handle += (bud + zhdr->first_num) & BUDDY_MASK;
3118 ++ if (bud != HEADLESS) {
3119 ++ handle |= (bud + zhdr->first_num) & BUDDY_MASK;
3120 ++ if (bud == LAST)
3121 ++ handle |= (zhdr->last_chunks << BUDDY_SHIFT);
3122 ++ }
3123 + return handle;
3124 + }
3125 +
3126 +@@ -234,6 +238,12 @@ static struct z3fold_header *handle_to_z3fold_header(unsigned long handle)
3127 + return (struct z3fold_header *)(handle & PAGE_MASK);
3128 + }
3129 +
3130 ++/* only for LAST bud, returns zero otherwise */
3131 ++static unsigned short handle_to_chunks(unsigned long handle)
3132 ++{
3133 ++ return (handle & ~PAGE_MASK) >> BUDDY_SHIFT;
3134 ++}
3135 ++
3136 + /*
3137 + * (handle & BUDDY_MASK) < zhdr->first_num is possible in encode_handle
3138 + * but that doesn't matter. because the masking will result in the
3139 +@@ -717,37 +727,39 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
3140 + page = virt_to_page(zhdr);
3141 +
3142 + if (test_bit(PAGE_HEADLESS, &page->private)) {
3143 +- /* HEADLESS page stored */
3144 +- bud = HEADLESS;
3145 +- } else {
3146 +- z3fold_page_lock(zhdr);
3147 +- bud = handle_to_buddy(handle);
3148 +-
3149 +- switch (bud) {
3150 +- case FIRST:
3151 +- zhdr->first_chunks = 0;
3152 +- break;
3153 +- case MIDDLE:
3154 +- zhdr->middle_chunks = 0;
3155 +- zhdr->start_middle = 0;
3156 +- break;
3157 +- case LAST:
3158 +- zhdr->last_chunks = 0;
3159 +- break;
3160 +- default:
3161 +- pr_err("%s: unknown bud %d\n", __func__, bud);
3162 +- WARN_ON(1);
3163 +- z3fold_page_unlock(zhdr);
3164 +- return;
3165 ++ /* if a headless page is under reclaim, just leave.
3166 ++ * NB: we use test_and_set_bit for a reason: if the bit
3167 ++ * has not been set before, we release this page
3168 ++ * immediately so we don't care about its value any more.
3169 ++ */
3170 ++ if (!test_and_set_bit(PAGE_CLAIMED, &page->private)) {
3171 ++ spin_lock(&pool->lock);
3172 ++ list_del(&page->lru);
3173 ++ spin_unlock(&pool->lock);
3174 ++ free_z3fold_page(page);
3175 ++ atomic64_dec(&pool->pages_nr);
3176 + }
3177 ++ return;
3178 + }
3179 +
3180 +- if (bud == HEADLESS) {
3181 +- spin_lock(&pool->lock);
3182 +- list_del(&page->lru);
3183 +- spin_unlock(&pool->lock);
3184 +- free_z3fold_page(page);
3185 +- atomic64_dec(&pool->pages_nr);
3186 ++ /* Non-headless case */
3187 ++ z3fold_page_lock(zhdr);
3188 ++ bud = handle_to_buddy(handle);
3189 ++
3190 ++ switch (bud) {
3191 ++ case FIRST:
3192 ++ zhdr->first_chunks = 0;
3193 ++ break;
3194 ++ case MIDDLE:
3195 ++ zhdr->middle_chunks = 0;
3196 ++ break;
3197 ++ case LAST:
3198 ++ zhdr->last_chunks = 0;
3199 ++ break;
3200 ++ default:
3201 ++ pr_err("%s: unknown bud %d\n", __func__, bud);
3202 ++ WARN_ON(1);
3203 ++ z3fold_page_unlock(zhdr);
3204 + return;
3205 + }
3206 +
3207 +@@ -755,7 +767,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
3208 + atomic64_dec(&pool->pages_nr);
3209 + return;
3210 + }
3211 +- if (test_bit(UNDER_RECLAIM, &page->private)) {
3212 ++ if (test_bit(PAGE_CLAIMED, &page->private)) {
3213 + z3fold_page_unlock(zhdr);
3214 + return;
3215 + }
3216 +@@ -833,20 +845,30 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
3217 + }
3218 + list_for_each_prev(pos, &pool->lru) {
3219 + page = list_entry(pos, struct page, lru);
3220 ++
3221 ++ /* this bit could have been set by free, in which case
3222 ++ * we pass over to the next page in the pool.
3223 ++ */
3224 ++ if (test_and_set_bit(PAGE_CLAIMED, &page->private))
3225 ++ continue;
3226 ++
3227 ++ zhdr = page_address(page);
3228 + if (test_bit(PAGE_HEADLESS, &page->private))
3229 +- /* candidate found */
3230 + break;
3231 +
3232 +- zhdr = page_address(page);
3233 +- if (!z3fold_page_trylock(zhdr))
3234 ++ if (!z3fold_page_trylock(zhdr)) {
3235 ++ zhdr = NULL;
3236 + continue; /* can't evict at this point */
3237 ++ }
3238 + kref_get(&zhdr->refcount);
3239 + list_del_init(&zhdr->buddy);
3240 + zhdr->cpu = -1;
3241 +- set_bit(UNDER_RECLAIM, &page->private);
3242 + break;
3243 + }
3244 +
3245 ++ if (!zhdr)
3246 ++ break;
3247 ++
3248 + list_del_init(&page->lru);
3249 + spin_unlock(&pool->lock);
3250 +
3251 +@@ -895,6 +917,7 @@ next:
3252 + if (test_bit(PAGE_HEADLESS, &page->private)) {
3253 + if (ret == 0) {
3254 + free_z3fold_page(page);
3255 ++ atomic64_dec(&pool->pages_nr);
3256 + return 0;
3257 + }
3258 + spin_lock(&pool->lock);
3259 +@@ -902,7 +925,7 @@ next:
3260 + spin_unlock(&pool->lock);
3261 + } else {
3262 + z3fold_page_lock(zhdr);
3263 +- clear_bit(UNDER_RECLAIM, &page->private);
3264 ++ clear_bit(PAGE_CLAIMED, &page->private);
3265 + if (kref_put(&zhdr->refcount,
3266 + release_z3fold_page_locked)) {
3267 + atomic64_dec(&pool->pages_nr);
3268 +@@ -961,7 +984,7 @@ static void *z3fold_map(struct z3fold_pool *pool, unsigned long handle)
3269 + set_bit(MIDDLE_CHUNK_MAPPED, &page->private);
3270 + break;
3271 + case LAST:
3272 +- addr += PAGE_SIZE - (zhdr->last_chunks << CHUNK_SHIFT);
3273 ++ addr += PAGE_SIZE - (handle_to_chunks(handle) << CHUNK_SHIFT);
3274 + break;
3275 + default:
3276 + pr_err("unknown buddy id %d\n", buddy);
3277 +diff --git a/net/can/raw.c b/net/can/raw.c
3278 +index 864c80dbdb72..e1f26441b49a 100644
3279 +--- a/net/can/raw.c
3280 ++++ b/net/can/raw.c
3281 +@@ -745,18 +745,19 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
3282 + } else
3283 + ifindex = ro->ifindex;
3284 +
3285 +- if (ro->fd_frames) {
3286 ++ dev = dev_get_by_index(sock_net(sk), ifindex);
3287 ++ if (!dev)
3288 ++ return -ENXIO;
3289 ++
3290 ++ err = -EINVAL;
3291 ++ if (ro->fd_frames && dev->mtu == CANFD_MTU) {
3292 + if (unlikely(size != CANFD_MTU && size != CAN_MTU))
3293 +- return -EINVAL;
3294 ++ goto put_dev;
3295 + } else {
3296 + if (unlikely(size != CAN_MTU))
3297 +- return -EINVAL;
3298 ++ goto put_dev;
3299 + }
3300 +
3301 +- dev = dev_get_by_index(sock_net(sk), ifindex);
3302 +- if (!dev)
3303 +- return -ENXIO;
3304 +-
3305 + skb = sock_alloc_send_skb(sk, size + sizeof(struct can_skb_priv),
3306 + msg->msg_flags & MSG_DONTWAIT, &err);
3307 + if (!skb)
3308 +diff --git a/net/core/sock.c b/net/core/sock.c
3309 +index 68d08ed5521e..36f19458e2fe 100644
3310 +--- a/net/core/sock.c
3311 ++++ b/net/core/sock.c
3312 +@@ -2242,7 +2242,7 @@ static void __lock_sock(struct sock *sk)
3313 + finish_wait(&sk->sk_lock.wq, &wait);
3314 + }
3315 +
3316 +-static void __release_sock(struct sock *sk)
3317 ++void __release_sock(struct sock *sk)
3318 + __releases(&sk->sk_lock.slock)
3319 + __acquires(&sk->sk_lock.slock)
3320 + {
3321 +diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
3322 +index b8d95cb71c25..44a7e16bf3b5 100644
3323 +--- a/net/ieee802154/6lowpan/6lowpan_i.h
3324 ++++ b/net/ieee802154/6lowpan/6lowpan_i.h
3325 +@@ -20,8 +20,8 @@ typedef unsigned __bitwise lowpan_rx_result;
3326 + struct frag_lowpan_compare_key {
3327 + u16 tag;
3328 + u16 d_size;
3329 +- const struct ieee802154_addr src;
3330 +- const struct ieee802154_addr dst;
3331 ++ struct ieee802154_addr src;
3332 ++ struct ieee802154_addr dst;
3333 + };
3334 +
3335 + /* Equivalent of ipv4 struct ipq
3336 +diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
3337 +index 1790b65944b3..2cc224106b69 100644
3338 +--- a/net/ieee802154/6lowpan/reassembly.c
3339 ++++ b/net/ieee802154/6lowpan/reassembly.c
3340 +@@ -75,14 +75,14 @@ fq_find(struct net *net, const struct lowpan_802154_cb *cb,
3341 + {
3342 + struct netns_ieee802154_lowpan *ieee802154_lowpan =
3343 + net_ieee802154_lowpan(net);
3344 +- struct frag_lowpan_compare_key key = {
3345 +- .tag = cb->d_tag,
3346 +- .d_size = cb->d_size,
3347 +- .src = *src,
3348 +- .dst = *dst,
3349 +- };
3350 ++ struct frag_lowpan_compare_key key = {};
3351 + struct inet_frag_queue *q;
3352 +
3353 ++ key.tag = cb->d_tag;
3354 ++ key.d_size = cb->d_size;
3355 ++ key.src = *src;
3356 ++ key.dst = *dst;
3357 ++
3358 + q = inet_frag_find(&ieee802154_lowpan->frags, &key);
3359 + if (!q)
3360 + return NULL;
3361 +@@ -372,7 +372,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, u8 frag_type)
3362 + struct lowpan_frag_queue *fq;
3363 + struct net *net = dev_net(skb->dev);
3364 + struct lowpan_802154_cb *cb = lowpan_802154_cb(skb);
3365 +- struct ieee802154_hdr hdr;
3366 ++ struct ieee802154_hdr hdr = {};
3367 + int err;
3368 +
3369 + if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
3370 +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
3371 +index f9c985460faa..8109985e78a1 100644
3372 +--- a/net/ipv4/tcp.c
3373 ++++ b/net/ipv4/tcp.c
3374 +@@ -2217,16 +2217,10 @@ adjudge_to_death:
3375 + sock_hold(sk);
3376 + sock_orphan(sk);
3377 +
3378 +- /* It is the last release_sock in its life. It will remove backlog. */
3379 +- release_sock(sk);
3380 +-
3381 +-
3382 +- /* Now socket is owned by kernel and we acquire BH lock
3383 +- * to finish close. No need to check for user refs.
3384 +- */
3385 + local_bh_disable();
3386 + bh_lock_sock(sk);
3387 +- WARN_ON(sock_owned_by_user(sk));
3388 ++ /* remove backlog if any, without releasing ownership. */
3389 ++ __release_sock(sk);
3390 +
3391 + percpu_counter_inc(sk->sk_prot->orphan_count);
3392 +
3393 +@@ -2295,6 +2289,7 @@ adjudge_to_death:
3394 + out:
3395 + bh_unlock_sock(sk);
3396 + local_bh_enable();
3397 ++ release_sock(sk);
3398 + sock_put(sk);
3399 + }
3400 + EXPORT_SYMBOL(tcp_close);
3401 +diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
3402 +index b49f5afab405..2e472d5c3ea4 100644
3403 +--- a/net/llc/af_llc.c
3404 ++++ b/net/llc/af_llc.c
3405 +@@ -730,7 +730,6 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
3406 + struct sk_buff *skb = NULL;
3407 + struct sock *sk = sock->sk;
3408 + struct llc_sock *llc = llc_sk(sk);
3409 +- unsigned long cpu_flags;
3410 + size_t copied = 0;
3411 + u32 peek_seq = 0;
3412 + u32 *seq, skb_len;
3413 +@@ -855,9 +854,8 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
3414 + goto copy_uaddr;
3415 +
3416 + if (!(flags & MSG_PEEK)) {
3417 +- spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags);
3418 +- sk_eat_skb(sk, skb);
3419 +- spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
3420 ++ skb_unlink(skb, &sk->sk_receive_queue);
3421 ++ kfree_skb(skb);
3422 + *seq = 0;
3423 + }
3424 +
3425 +@@ -878,9 +876,8 @@ copy_uaddr:
3426 + llc_cmsg_rcv(msg, skb);
3427 +
3428 + if (!(flags & MSG_PEEK)) {
3429 +- spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags);
3430 +- sk_eat_skb(sk, skb);
3431 +- spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
3432 ++ skb_unlink(skb, &sk->sk_receive_queue);
3433 ++ kfree_skb(skb);
3434 + *seq = 0;
3435 + }
3436 +
3437 +diff --git a/net/sctp/associola.c b/net/sctp/associola.c
3438 +index 58f7d8cfd748..4982b31fec8e 100644
3439 +--- a/net/sctp/associola.c
3440 ++++ b/net/sctp/associola.c
3441 +@@ -497,8 +497,9 @@ void sctp_assoc_set_primary(struct sctp_association *asoc,
3442 + void sctp_assoc_rm_peer(struct sctp_association *asoc,
3443 + struct sctp_transport *peer)
3444 + {
3445 +- struct list_head *pos;
3446 +- struct sctp_transport *transport;
3447 ++ struct sctp_transport *transport;
3448 ++ struct list_head *pos;
3449 ++ struct sctp_chunk *ch;
3450 +
3451 + pr_debug("%s: association:%p addr:%pISpc\n",
3452 + __func__, asoc, &peer->ipaddr.sa);
3453 +@@ -562,7 +563,6 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
3454 + */
3455 + if (!list_empty(&peer->transmitted)) {
3456 + struct sctp_transport *active = asoc->peer.active_path;
3457 +- struct sctp_chunk *ch;
3458 +
3459 + /* Reset the transport of each chunk on this list */
3460 + list_for_each_entry(ch, &peer->transmitted,
3461 +@@ -584,6 +584,10 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
3462 + sctp_transport_hold(active);
3463 + }
3464 +
3465 ++ list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list)
3466 ++ if (ch->transport == peer)
3467 ++ ch->transport = NULL;
3468 ++
3469 + asoc->peer.transport_count--;
3470 +
3471 + sctp_transport_free(peer);
3472 +diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
3473 +index f1df9837f1ac..1ac08dcbf85d 100644
3474 +--- a/net/sunrpc/auth_generic.c
3475 ++++ b/net/sunrpc/auth_generic.c
3476 +@@ -281,13 +281,7 @@ static bool generic_key_to_expire(struct rpc_cred *cred)
3477 + {
3478 + struct auth_cred *acred = &container_of(cred, struct generic_cred,
3479 + gc_base)->acred;
3480 +- bool ret;
3481 +-
3482 +- get_rpccred(cred);
3483 +- ret = test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags);
3484 +- put_rpccred(cred);
3485 +-
3486 +- return ret;
3487 ++ return test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags);
3488 + }
3489 +
3490 + static const struct rpc_credops generic_credops = {
3491 +diff --git a/security/integrity/evm/evm.h b/security/integrity/evm/evm.h
3492 +index f5f12727771a..2ff02459fcfd 100644
3493 +--- a/security/integrity/evm/evm.h
3494 ++++ b/security/integrity/evm/evm.h
3495 +@@ -48,7 +48,7 @@ int evm_calc_hmac(struct dentry *dentry, const char *req_xattr_name,
3496 + size_t req_xattr_value_len, char *digest);
3497 + int evm_calc_hash(struct dentry *dentry, const char *req_xattr_name,
3498 + const char *req_xattr_value,
3499 +- size_t req_xattr_value_len, char *digest);
3500 ++ size_t req_xattr_value_len, char type, char *digest);
3501 + int evm_init_hmac(struct inode *inode, const struct xattr *xattr,
3502 + char *hmac_val);
3503 + int evm_init_secfs(void);
3504 +diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
3505 +index ee9c3de5065a..f1f030ae363b 100644
3506 +--- a/security/integrity/evm/evm_crypto.c
3507 ++++ b/security/integrity/evm/evm_crypto.c
3508 +@@ -139,7 +139,7 @@ out:
3509 + * protection.)
3510 + */
3511 + static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
3512 +- char *digest)
3513 ++ char type, char *digest)
3514 + {
3515 + struct h_misc {
3516 + unsigned long ino;
3517 +@@ -150,8 +150,13 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
3518 + } hmac_misc;
3519 +
3520 + memset(&hmac_misc, 0, sizeof(hmac_misc));
3521 +- hmac_misc.ino = inode->i_ino;
3522 +- hmac_misc.generation = inode->i_generation;
3523 ++ /* Don't include the inode or generation number in portable
3524 ++ * signatures
3525 ++ */
3526 ++ if (type != EVM_XATTR_PORTABLE_DIGSIG) {
3527 ++ hmac_misc.ino = inode->i_ino;
3528 ++ hmac_misc.generation = inode->i_generation;
3529 ++ }
3530 + /* The hmac uid and gid must be encoded in the initial user
3531 + * namespace (not the filesystems user namespace) as encoding
3532 + * them in the filesystems user namespace allows an attack
3533 +@@ -164,7 +169,8 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
3534 + hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid);
3535 + hmac_misc.mode = inode->i_mode;
3536 + crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
3537 +- if (evm_hmac_attrs & EVM_ATTR_FSUUID)
3538 ++ if ((evm_hmac_attrs & EVM_ATTR_FSUUID) &&
3539 ++ type != EVM_XATTR_PORTABLE_DIGSIG)
3540 + crypto_shash_update(desc, &inode->i_sb->s_uuid.b[0],
3541 + sizeof(inode->i_sb->s_uuid));
3542 + crypto_shash_final(desc, digest);
3543 +@@ -190,6 +196,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
3544 + char *xattr_value = NULL;
3545 + int error;
3546 + int size;
3547 ++ bool ima_present = false;
3548 +
3549 + if (!(inode->i_opflags & IOP_XATTR))
3550 + return -EOPNOTSUPP;
3551 +@@ -200,11 +207,18 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
3552 +
3553 + error = -ENODATA;
3554 + for (xattrname = evm_config_xattrnames; *xattrname != NULL; xattrname++) {
3555 ++ bool is_ima = false;
3556 ++
3557 ++ if (strcmp(*xattrname, XATTR_NAME_IMA) == 0)
3558 ++ is_ima = true;
3559 ++
3560 + if ((req_xattr_name && req_xattr_value)
3561 + && !strcmp(*xattrname, req_xattr_name)) {
3562 + error = 0;
3563 + crypto_shash_update(desc, (const u8 *)req_xattr_value,
3564 + req_xattr_value_len);
3565 ++ if (is_ima)
3566 ++ ima_present = true;
3567 + continue;
3568 + }
3569 + size = vfs_getxattr_alloc(dentry, *xattrname,
3570 +@@ -219,9 +233,14 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
3571 + error = 0;
3572 + xattr_size = size;
3573 + crypto_shash_update(desc, (const u8 *)xattr_value, xattr_size);
3574 ++ if (is_ima)
3575 ++ ima_present = true;
3576 + }
3577 +- hmac_add_misc(desc, inode, digest);
3578 ++ hmac_add_misc(desc, inode, type, digest);
3579 +
3580 ++ /* Portable EVM signatures must include an IMA hash */
3581 ++ if (type == EVM_XATTR_PORTABLE_DIGSIG && !ima_present)
3582 ++ return -EPERM;
3583 + out:
3584 + kfree(xattr_value);
3585 + kfree(desc);
3586 +@@ -233,17 +252,45 @@ int evm_calc_hmac(struct dentry *dentry, const char *req_xattr_name,
3587 + char *digest)
3588 + {
3589 + return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value,
3590 +- req_xattr_value_len, EVM_XATTR_HMAC, digest);
3591 ++ req_xattr_value_len, EVM_XATTR_HMAC, digest);
3592 + }
3593 +
3594 + int evm_calc_hash(struct dentry *dentry, const char *req_xattr_name,
3595 + const char *req_xattr_value, size_t req_xattr_value_len,
3596 +- char *digest)
3597 ++ char type, char *digest)
3598 + {
3599 + return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value,
3600 +- req_xattr_value_len, IMA_XATTR_DIGEST, digest);
3601 ++ req_xattr_value_len, type, digest);
3602 ++}
3603 ++
3604 ++static int evm_is_immutable(struct dentry *dentry, struct inode *inode)
3605 ++{
3606 ++ const struct evm_ima_xattr_data *xattr_data = NULL;
3607 ++ struct integrity_iint_cache *iint;
3608 ++ int rc = 0;
3609 ++
3610 ++ iint = integrity_iint_find(inode);
3611 ++ if (iint && (iint->flags & EVM_IMMUTABLE_DIGSIG))
3612 ++ return 1;
3613 ++
3614 ++ /* Do this the hard way */
3615 ++ rc = vfs_getxattr_alloc(dentry, XATTR_NAME_EVM, (char **)&xattr_data, 0,
3616 ++ GFP_NOFS);
3617 ++ if (rc <= 0) {
3618 ++ if (rc == -ENODATA)
3619 ++ return 0;
3620 ++ return rc;
3621 ++ }
3622 ++ if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG)
3623 ++ rc = 1;
3624 ++ else
3625 ++ rc = 0;
3626 ++
3627 ++ kfree(xattr_data);
3628 ++ return rc;
3629 + }
3630 +
3631 ++
3632 + /*
3633 + * Calculate the hmac and update security.evm xattr
3634 + *
3635 +@@ -256,6 +303,16 @@ int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name,
3636 + struct evm_ima_xattr_data xattr_data;
3637 + int rc = 0;
3638 +
3639 ++ /*
3640 ++ * Don't permit any transformation of the EVM xattr if the signature
3641 ++ * is of an immutable type
3642 ++ */
3643 ++ rc = evm_is_immutable(dentry, inode);
3644 ++ if (rc < 0)
3645 ++ return rc;
3646 ++ if (rc)
3647 ++ return -EPERM;
3648 ++
3649 + rc = evm_calc_hmac(dentry, xattr_name, xattr_value,
3650 + xattr_value_len, xattr_data.digest);
3651 + if (rc == 0) {
3652 +@@ -281,7 +338,7 @@ int evm_init_hmac(struct inode *inode, const struct xattr *lsm_xattr,
3653 + }
3654 +
3655 + crypto_shash_update(desc, lsm_xattr->value, lsm_xattr->value_len);
3656 +- hmac_add_misc(desc, inode, hmac_val);
3657 ++ hmac_add_misc(desc, inode, EVM_XATTR_HMAC, hmac_val);
3658 + kfree(desc);
3659 + return 0;
3660 + }
3661 +diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
3662 +index 063d38aef64e..1d1a7053144b 100644
3663 +--- a/security/integrity/evm/evm_main.c
3664 ++++ b/security/integrity/evm/evm_main.c
3665 +@@ -31,7 +31,7 @@
3666 + int evm_initialized;
3667 +
3668 + static char *integrity_status_msg[] = {
3669 +- "pass", "fail", "no_label", "no_xattrs", "unknown"
3670 ++ "pass", "pass_immutable", "fail", "no_label", "no_xattrs", "unknown"
3671 + };
3672 + char *evm_hmac = "hmac(sha1)";
3673 + char *evm_hash = "sha1";
3674 +@@ -120,7 +120,8 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
3675 + enum integrity_status evm_status = INTEGRITY_PASS;
3676 + int rc, xattr_len;
3677 +
3678 +- if (iint && iint->evm_status == INTEGRITY_PASS)
3679 ++ if (iint && (iint->evm_status == INTEGRITY_PASS ||
3680 ++ iint->evm_status == INTEGRITY_PASS_IMMUTABLE))
3681 + return iint->evm_status;
3682 +
3683 + /* if status is not PASS, try to check again - against -ENOMEM */
3684 +@@ -161,22 +162,26 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
3685 + rc = -EINVAL;
3686 + break;
3687 + case EVM_IMA_XATTR_DIGSIG:
3688 ++ case EVM_XATTR_PORTABLE_DIGSIG:
3689 + rc = evm_calc_hash(dentry, xattr_name, xattr_value,
3690 +- xattr_value_len, calc.digest);
3691 ++ xattr_value_len, xattr_data->type,
3692 ++ calc.digest);
3693 + if (rc)
3694 + break;
3695 + rc = integrity_digsig_verify(INTEGRITY_KEYRING_EVM,
3696 + (const char *)xattr_data, xattr_len,
3697 + calc.digest, sizeof(calc.digest));
3698 + if (!rc) {
3699 +- /* Replace RSA with HMAC if not mounted readonly and
3700 +- * not immutable
3701 +- */
3702 +- if (!IS_RDONLY(d_backing_inode(dentry)) &&
3703 +- !IS_IMMUTABLE(d_backing_inode(dentry)))
3704 ++ if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG) {
3705 ++ if (iint)
3706 ++ iint->flags |= EVM_IMMUTABLE_DIGSIG;
3707 ++ evm_status = INTEGRITY_PASS_IMMUTABLE;
3708 ++ } else if (!IS_RDONLY(d_backing_inode(dentry)) &&
3709 ++ !IS_IMMUTABLE(d_backing_inode(dentry))) {
3710 + evm_update_evmxattr(dentry, xattr_name,
3711 + xattr_value,
3712 + xattr_value_len);
3713 ++ }
3714 + }
3715 + break;
3716 + default:
3717 +@@ -277,7 +282,7 @@ static enum integrity_status evm_verify_current_integrity(struct dentry *dentry)
3718 + * affect security.evm. An interesting side affect of writing posix xattr
3719 + * acls is their modifying of the i_mode, which is included in security.evm.
3720 + * For posix xattr acls only, permit security.evm, even if it currently
3721 +- * doesn't exist, to be updated.
3722 ++ * doesn't exist, to be updated unless the EVM signature is immutable.
3723 + */
3724 + static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name,
3725 + const void *xattr_value, size_t xattr_value_len)
3726 +@@ -345,7 +350,8 @@ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
3727 + if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) {
3728 + if (!xattr_value_len)
3729 + return -EINVAL;
3730 +- if (xattr_data->type != EVM_IMA_XATTR_DIGSIG)
3731 ++ if (xattr_data->type != EVM_IMA_XATTR_DIGSIG &&
3732 ++ xattr_data->type != EVM_XATTR_PORTABLE_DIGSIG)
3733 + return -EPERM;
3734 + }
3735 + return evm_protect_xattr(dentry, xattr_name, xattr_value,
3736 +@@ -422,6 +428,9 @@ void evm_inode_post_removexattr(struct dentry *dentry, const char *xattr_name)
3737 + /**
3738 + * evm_inode_setattr - prevent updating an invalid EVM extended attribute
3739 + * @dentry: pointer to the affected dentry
3740 ++ *
3741 ++ * Permit update of file attributes when files have a valid EVM signature,
3742 ++ * except in the case of them having an immutable portable signature.
3743 + */
3744 + int evm_inode_setattr(struct dentry *dentry, struct iattr *attr)
3745 + {
3746 +diff --git a/security/integrity/iint.c b/security/integrity/iint.c
3747 +index 6fc888ca468e..f4a40fb84b1e 100644
3748 +--- a/security/integrity/iint.c
3749 ++++ b/security/integrity/iint.c
3750 +@@ -74,6 +74,7 @@ static void iint_free(struct integrity_iint_cache *iint)
3751 + iint->ima_hash = NULL;
3752 + iint->version = 0;
3753 + iint->flags = 0UL;
3754 ++ iint->atomic_flags = 0UL;
3755 + iint->ima_file_status = INTEGRITY_UNKNOWN;
3756 + iint->ima_mmap_status = INTEGRITY_UNKNOWN;
3757 + iint->ima_bprm_status = INTEGRITY_UNKNOWN;
3758 +@@ -155,12 +156,14 @@ static void init_once(void *foo)
3759 + memset(iint, 0, sizeof(*iint));
3760 + iint->version = 0;
3761 + iint->flags = 0UL;
3762 ++ iint->atomic_flags = 0;
3763 + iint->ima_file_status = INTEGRITY_UNKNOWN;
3764 + iint->ima_mmap_status = INTEGRITY_UNKNOWN;
3765 + iint->ima_bprm_status = INTEGRITY_UNKNOWN;
3766 + iint->ima_read_status = INTEGRITY_UNKNOWN;
3767 + iint->evm_status = INTEGRITY_UNKNOWN;
3768 + iint->measured_pcrs = 0;
3769 ++ mutex_init(&iint->mutex);
3770 + }
3771 +
3772 + static int __init integrity_iintcache_init(void)
3773 +diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
3774 +index c2edba8de35e..c7e8db0ea4c0 100644
3775 +--- a/security/integrity/ima/ima_api.c
3776 ++++ b/security/integrity/ima/ima_api.c
3777 +@@ -199,42 +199,59 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
3778 + struct inode *inode = file_inode(file);
3779 + const char *filename = file->f_path.dentry->d_name.name;
3780 + int result = 0;
3781 ++ int length;
3782 ++ void *tmpbuf;
3783 ++ u64 i_version;
3784 + struct {
3785 + struct ima_digest_data hdr;
3786 + char digest[IMA_MAX_DIGEST_SIZE];
3787 + } hash;
3788 +
3789 +- if (!(iint->flags & IMA_COLLECTED)) {
3790 +- u64 i_version = file_inode(file)->i_version;
3791 ++ if (iint->flags & IMA_COLLECTED)
3792 ++ goto out;
3793 +
3794 +- if (file->f_flags & O_DIRECT) {
3795 +- audit_cause = "failed(directio)";
3796 +- result = -EACCES;
3797 +- goto out;
3798 +- }
3799 ++ /*
3800 ++ * Dectecting file change is based on i_version. On filesystems
3801 ++ * which do not support i_version, support is limited to an initial
3802 ++ * measurement/appraisal/audit.
3803 ++ */
3804 ++ i_version = file_inode(file)->i_version;
3805 ++ hash.hdr.algo = algo;
3806 +
3807 +- hash.hdr.algo = algo;
3808 +-
3809 +- result = (!buf) ? ima_calc_file_hash(file, &hash.hdr) :
3810 +- ima_calc_buffer_hash(buf, size, &hash.hdr);
3811 +- if (!result) {
3812 +- int length = sizeof(hash.hdr) + hash.hdr.length;
3813 +- void *tmpbuf = krealloc(iint->ima_hash, length,
3814 +- GFP_NOFS);
3815 +- if (tmpbuf) {
3816 +- iint->ima_hash = tmpbuf;
3817 +- memcpy(iint->ima_hash, &hash, length);
3818 +- iint->version = i_version;
3819 +- iint->flags |= IMA_COLLECTED;
3820 +- } else
3821 +- result = -ENOMEM;
3822 +- }
3823 ++ /* Initialize hash digest to 0's in case of failure */
3824 ++ memset(&hash.digest, 0, sizeof(hash.digest));
3825 ++
3826 ++ if (buf)
3827 ++ result = ima_calc_buffer_hash(buf, size, &hash.hdr);
3828 ++ else
3829 ++ result = ima_calc_file_hash(file, &hash.hdr);
3830 ++
3831 ++ if (result && result != -EBADF && result != -EINVAL)
3832 ++ goto out;
3833 ++
3834 ++ length = sizeof(hash.hdr) + hash.hdr.length;
3835 ++ tmpbuf = krealloc(iint->ima_hash, length, GFP_NOFS);
3836 ++ if (!tmpbuf) {
3837 ++ result = -ENOMEM;
3838 ++ goto out;
3839 + }
3840 ++
3841 ++ iint->ima_hash = tmpbuf;
3842 ++ memcpy(iint->ima_hash, &hash, length);
3843 ++ iint->version = i_version;
3844 ++
3845 ++ /* Possibly temporary failure due to type of read (eg. O_DIRECT) */
3846 ++ if (!result)
3847 ++ iint->flags |= IMA_COLLECTED;
3848 + out:
3849 +- if (result)
3850 ++ if (result) {
3851 ++ if (file->f_flags & O_DIRECT)
3852 ++ audit_cause = "failed(directio)";
3853 ++
3854 + integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode,
3855 + filename, "collect_data", audit_cause,
3856 + result, 0);
3857 ++ }
3858 + return result;
3859 + }
3860 +
3861 +@@ -278,7 +295,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint,
3862 + }
3863 +
3864 + result = ima_store_template(entry, violation, inode, filename, pcr);
3865 +- if (!result || result == -EEXIST) {
3866 ++ if ((!result || result == -EEXIST) && !(file->f_flags & O_DIRECT)) {
3867 + iint->flags |= IMA_MEASURED;
3868 + iint->measured_pcrs |= (0x1 << pcr);
3869 + }
3870 +diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
3871 +index 348db9b78681..84eb6cc956bf 100644
3872 +--- a/security/integrity/ima/ima_appraise.c
3873 ++++ b/security/integrity/ima/ima_appraise.c
3874 +@@ -230,7 +230,9 @@ int ima_appraise_measurement(enum ima_hooks func,
3875 + }
3876 +
3877 + status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint);
3878 +- if ((status != INTEGRITY_PASS) && (status != INTEGRITY_UNKNOWN)) {
3879 ++ if ((status != INTEGRITY_PASS) &&
3880 ++ (status != INTEGRITY_PASS_IMMUTABLE) &&
3881 ++ (status != INTEGRITY_UNKNOWN)) {
3882 + if ((status == INTEGRITY_NOLABEL)
3883 + || (status == INTEGRITY_NOXATTRS))
3884 + cause = "missing-HMAC";
3885 +@@ -249,6 +251,7 @@ int ima_appraise_measurement(enum ima_hooks func,
3886 + status = INTEGRITY_FAIL;
3887 + break;
3888 + }
3889 ++ clear_bit(IMA_DIGSIG, &iint->atomic_flags);
3890 + if (xattr_len - sizeof(xattr_value->type) - hash_start >=
3891 + iint->ima_hash->length)
3892 + /* xattr length may be longer. md5 hash in previous
3893 +@@ -267,7 +270,7 @@ int ima_appraise_measurement(enum ima_hooks func,
3894 + status = INTEGRITY_PASS;
3895 + break;
3896 + case EVM_IMA_XATTR_DIGSIG:
3897 +- iint->flags |= IMA_DIGSIG;
3898 ++ set_bit(IMA_DIGSIG, &iint->atomic_flags);
3899 + rc = integrity_digsig_verify(INTEGRITY_KEYRING_IMA,
3900 + (const char *)xattr_value, rc,
3901 + iint->ima_hash->digest,
3902 +@@ -318,7 +321,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)
3903 + int rc = 0;
3904 +
3905 + /* do not collect and update hash for digital signatures */
3906 +- if (iint->flags & IMA_DIGSIG)
3907 ++ if (test_bit(IMA_DIGSIG, &iint->atomic_flags))
3908 + return;
3909 +
3910 + if (iint->ima_file_status != INTEGRITY_PASS)
3911 +@@ -328,7 +331,9 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)
3912 + if (rc < 0)
3913 + return;
3914 +
3915 ++ inode_lock(file_inode(file));
3916 + ima_fix_xattr(dentry, iint);
3917 ++ inode_unlock(file_inode(file));
3918 + }
3919 +
3920 + /**
3921 +@@ -351,16 +356,14 @@ void ima_inode_post_setattr(struct dentry *dentry)
3922 + return;
3923 +
3924 + must_appraise = ima_must_appraise(inode, MAY_ACCESS, POST_SETATTR);
3925 ++ if (!must_appraise)
3926 ++ __vfs_removexattr(dentry, XATTR_NAME_IMA);
3927 + iint = integrity_iint_find(inode);
3928 + if (iint) {
3929 +- iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
3930 +- IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK |
3931 +- IMA_ACTION_RULE_FLAGS);
3932 +- if (must_appraise)
3933 +- iint->flags |= IMA_APPRAISE;
3934 ++ set_bit(IMA_CHANGE_ATTR, &iint->atomic_flags);
3935 ++ if (!must_appraise)
3936 ++ clear_bit(IMA_UPDATE_XATTR, &iint->atomic_flags);
3937 + }
3938 +- if (!must_appraise)
3939 +- __vfs_removexattr(dentry, XATTR_NAME_IMA);
3940 + }
3941 +
3942 + /*
3943 +@@ -389,12 +392,12 @@ static void ima_reset_appraise_flags(struct inode *inode, int digsig)
3944 + iint = integrity_iint_find(inode);
3945 + if (!iint)
3946 + return;
3947 +-
3948 +- iint->flags &= ~IMA_DONE_MASK;
3949 + iint->measured_pcrs = 0;
3950 ++ set_bit(IMA_CHANGE_XATTR, &iint->atomic_flags);
3951 + if (digsig)
3952 +- iint->flags |= IMA_DIGSIG;
3953 +- return;
3954 ++ set_bit(IMA_DIGSIG, &iint->atomic_flags);
3955 ++ else
3956 ++ clear_bit(IMA_DIGSIG, &iint->atomic_flags);
3957 + }
3958 +
3959 + int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
3960 +diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
3961 +index 90453aa1c813..cb041af9eddb 100644
3962 +--- a/security/integrity/ima/ima_crypto.c
3963 ++++ b/security/integrity/ima/ima_crypto.c
3964 +@@ -443,6 +443,16 @@ int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash)
3965 + loff_t i_size;
3966 + int rc;
3967 +
3968 ++ /*
3969 ++ * For consistency, fail file's opened with the O_DIRECT flag on
3970 ++ * filesystems mounted with/without DAX option.
3971 ++ */
3972 ++ if (file->f_flags & O_DIRECT) {
3973 ++ hash->length = hash_digest_size[ima_hash_algo];
3974 ++ hash->algo = ima_hash_algo;
3975 ++ return -EINVAL;
3976 ++ }
3977 ++
3978 + i_size = i_size_read(file_inode(file));
3979 +
3980 + if (ima_ahash_minsize && i_size >= ima_ahash_minsize) {
3981 +diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
3982 +index f8553179bdd7..92d0ca7309f9 100644
3983 +--- a/security/integrity/ima/ima_main.c
3984 ++++ b/security/integrity/ima/ima_main.c
3985 +@@ -99,10 +99,13 @@ static void ima_rdwr_violation_check(struct file *file,
3986 + if (!iint)
3987 + iint = integrity_iint_find(inode);
3988 + /* IMA_MEASURE is set from reader side */
3989 +- if (iint && (iint->flags & IMA_MEASURE))
3990 ++ if (iint && test_bit(IMA_MUST_MEASURE,
3991 ++ &iint->atomic_flags))
3992 + send_tomtou = true;
3993 + }
3994 + } else {
3995 ++ if (must_measure)
3996 ++ set_bit(IMA_MUST_MEASURE, &iint->atomic_flags);
3997 + if ((atomic_read(&inode->i_writecount) > 0) && must_measure)
3998 + send_writers = true;
3999 + }
4000 +@@ -124,21 +127,24 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint,
4001 + struct inode *inode, struct file *file)
4002 + {
4003 + fmode_t mode = file->f_mode;
4004 ++ bool update;
4005 +
4006 + if (!(mode & FMODE_WRITE))
4007 + return;
4008 +
4009 +- inode_lock(inode);
4010 ++ mutex_lock(&iint->mutex);
4011 + if (atomic_read(&inode->i_writecount) == 1) {
4012 ++ update = test_and_clear_bit(IMA_UPDATE_XATTR,
4013 ++ &iint->atomic_flags);
4014 + if ((iint->version != inode->i_version) ||
4015 + (iint->flags & IMA_NEW_FILE)) {
4016 + iint->flags &= ~(IMA_DONE_MASK | IMA_NEW_FILE);
4017 + iint->measured_pcrs = 0;
4018 +- if (iint->flags & IMA_APPRAISE)
4019 ++ if (update)
4020 + ima_update_xattr(iint, file);
4021 + }
4022 + }
4023 +- inode_unlock(inode);
4024 ++ mutex_unlock(&iint->mutex);
4025 + }
4026 +
4027 + /**
4028 +@@ -171,7 +177,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
4029 + char *pathbuf = NULL;
4030 + char filename[NAME_MAX];
4031 + const char *pathname = NULL;
4032 +- int rc = -ENOMEM, action, must_appraise;
4033 ++ int rc = 0, action, must_appraise = 0;
4034 + int pcr = CONFIG_IMA_MEASURE_PCR_IDX;
4035 + struct evm_ima_xattr_data *xattr_value = NULL;
4036 + int xattr_len = 0;
4037 +@@ -202,17 +208,31 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
4038 + if (action) {
4039 + iint = integrity_inode_get(inode);
4040 + if (!iint)
4041 +- goto out;
4042 ++ rc = -ENOMEM;
4043 + }
4044 +
4045 +- if (violation_check) {
4046 ++ if (!rc && violation_check)
4047 + ima_rdwr_violation_check(file, iint, action & IMA_MEASURE,
4048 + &pathbuf, &pathname);
4049 +- if (!action) {
4050 +- rc = 0;
4051 +- goto out_free;
4052 +- }
4053 +- }
4054 ++
4055 ++ inode_unlock(inode);
4056 ++
4057 ++ if (rc)
4058 ++ goto out;
4059 ++ if (!action)
4060 ++ goto out;
4061 ++
4062 ++ mutex_lock(&iint->mutex);
4063 ++
4064 ++ if (test_and_clear_bit(IMA_CHANGE_ATTR, &iint->atomic_flags))
4065 ++ /* reset appraisal flags if ima_inode_post_setattr was called */
4066 ++ iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
4067 ++ IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK |
4068 ++ IMA_ACTION_FLAGS);
4069 ++
4070 ++ if (test_and_clear_bit(IMA_CHANGE_XATTR, &iint->atomic_flags))
4071 ++ /* reset all flags if ima_inode_setxattr was called */
4072 ++ iint->flags &= ~IMA_DONE_MASK;
4073 +
4074 + /* Determine if already appraised/measured based on bitmask
4075 + * (IMA_MEASURE, IMA_MEASURED, IMA_XXXX_APPRAISE, IMA_XXXX_APPRAISED,
4076 +@@ -230,7 +250,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
4077 + if (!action) {
4078 + if (must_appraise)
4079 + rc = ima_get_cache_status(iint, func);
4080 +- goto out_digsig;
4081 ++ goto out_locked;
4082 + }
4083 +
4084 + template_desc = ima_template_desc_current();
4085 +@@ -242,11 +262,8 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
4086 + hash_algo = ima_get_hash_algo(xattr_value, xattr_len);
4087 +
4088 + rc = ima_collect_measurement(iint, file, buf, size, hash_algo);
4089 +- if (rc != 0) {
4090 +- if (file->f_flags & O_DIRECT)
4091 +- rc = (iint->flags & IMA_PERMIT_DIRECTIO) ? 0 : -EACCES;
4092 +- goto out_digsig;
4093 +- }
4094 ++ if (rc != 0 && rc != -EBADF && rc != -EINVAL)
4095 ++ goto out_locked;
4096 +
4097 + if (!pathbuf) /* ima_rdwr_violation possibly pre-fetched */
4098 + pathname = ima_d_path(&file->f_path, &pathbuf, filename);
4099 +@@ -254,24 +271,32 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
4100 + if (action & IMA_MEASURE)
4101 + ima_store_measurement(iint, file, pathname,
4102 + xattr_value, xattr_len, pcr);
4103 +- if (action & IMA_APPRAISE_SUBMASK)
4104 ++ if (rc == 0 && (action & IMA_APPRAISE_SUBMASK)) {
4105 ++ inode_lock(inode);
4106 + rc = ima_appraise_measurement(func, iint, file, pathname,
4107 + xattr_value, xattr_len, opened);
4108 ++ inode_unlock(inode);
4109 ++ }
4110 + if (action & IMA_AUDIT)
4111 + ima_audit_measurement(iint, pathname);
4112 +
4113 +-out_digsig:
4114 +- if ((mask & MAY_WRITE) && (iint->flags & IMA_DIGSIG) &&
4115 ++ if ((file->f_flags & O_DIRECT) && (iint->flags & IMA_PERMIT_DIRECTIO))
4116 ++ rc = 0;
4117 ++out_locked:
4118 ++ if ((mask & MAY_WRITE) && test_bit(IMA_DIGSIG, &iint->atomic_flags) &&
4119 + !(iint->flags & IMA_NEW_FILE))
4120 + rc = -EACCES;
4121 ++ mutex_unlock(&iint->mutex);
4122 + kfree(xattr_value);
4123 +-out_free:
4124 ++out:
4125 + if (pathbuf)
4126 + __putname(pathbuf);
4127 +-out:
4128 +- inode_unlock(inode);
4129 +- if ((rc && must_appraise) && (ima_appraise & IMA_APPRAISE_ENFORCE))
4130 +- return -EACCES;
4131 ++ if (must_appraise) {
4132 ++ if (rc && (ima_appraise & IMA_APPRAISE_ENFORCE))
4133 ++ return -EACCES;
4134 ++ if (file->f_mode & FMODE_WRITE)
4135 ++ set_bit(IMA_UPDATE_XATTR, &iint->atomic_flags);
4136 ++ }
4137 + return 0;
4138 + }
4139 +
4140 +diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
4141 +index a53e7e4ab06c..f43ac351c172 100644
4142 +--- a/security/integrity/integrity.h
4143 ++++ b/security/integrity/integrity.h
4144 +@@ -29,10 +29,10 @@
4145 + /* iint cache flags */
4146 + #define IMA_ACTION_FLAGS 0xff000000
4147 + #define IMA_ACTION_RULE_FLAGS 0x06000000
4148 +-#define IMA_DIGSIG 0x01000000
4149 +-#define IMA_DIGSIG_REQUIRED 0x02000000
4150 +-#define IMA_PERMIT_DIRECTIO 0x04000000
4151 +-#define IMA_NEW_FILE 0x08000000
4152 ++#define IMA_DIGSIG_REQUIRED 0x01000000
4153 ++#define IMA_PERMIT_DIRECTIO 0x02000000
4154 ++#define IMA_NEW_FILE 0x04000000
4155 ++#define EVM_IMMUTABLE_DIGSIG 0x08000000
4156 +
4157 + #define IMA_DO_MASK (IMA_MEASURE | IMA_APPRAISE | IMA_AUDIT | \
4158 + IMA_APPRAISE_SUBMASK)
4159 +@@ -53,11 +53,19 @@
4160 + #define IMA_APPRAISED_SUBMASK (IMA_FILE_APPRAISED | IMA_MMAP_APPRAISED | \
4161 + IMA_BPRM_APPRAISED | IMA_READ_APPRAISED)
4162 +
4163 ++/* iint cache atomic_flags */
4164 ++#define IMA_CHANGE_XATTR 0
4165 ++#define IMA_UPDATE_XATTR 1
4166 ++#define IMA_CHANGE_ATTR 2
4167 ++#define IMA_DIGSIG 3
4168 ++#define IMA_MUST_MEASURE 4
4169 ++
4170 + enum evm_ima_xattr_type {
4171 + IMA_XATTR_DIGEST = 0x01,
4172 + EVM_XATTR_HMAC,
4173 + EVM_IMA_XATTR_DIGSIG,
4174 + IMA_XATTR_DIGEST_NG,
4175 ++ EVM_XATTR_PORTABLE_DIGSIG,
4176 + IMA_XATTR_LAST
4177 + };
4178 +
4179 +@@ -100,10 +108,12 @@ struct signature_v2_hdr {
4180 + /* integrity data associated with an inode */
4181 + struct integrity_iint_cache {
4182 + struct rb_node rb_node; /* rooted in integrity_iint_tree */
4183 ++ struct mutex mutex; /* protects: version, flags, digest */
4184 + struct inode *inode; /* back pointer to inode in question */
4185 + u64 version; /* track inode changes */
4186 + unsigned long flags;
4187 + unsigned long measured_pcrs;
4188 ++ unsigned long atomic_flags;
4189 + enum integrity_status ima_file_status:4;
4190 + enum integrity_status ima_mmap_status:4;
4191 + enum integrity_status ima_bprm_status:4;
4192 +diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
4193 +index 6e8c8056d7ad..6688ac5b991e 100644
4194 +--- a/security/selinux/ss/policydb.c
4195 ++++ b/security/selinux/ss/policydb.c
4196 +@@ -1099,7 +1099,7 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len)
4197 + if ((len == 0) || (len == (u32)-1))
4198 + return -EINVAL;
4199 +
4200 +- str = kmalloc(len + 1, flags);
4201 ++ str = kmalloc(len + 1, flags | __GFP_NOWARN);
4202 + if (!str)
4203 + return -ENOMEM;
4204 +
4205 +diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
4206 +index b4f954e6d2db..df358e838b5b 100644
4207 +--- a/sound/core/oss/pcm_oss.c
4208 ++++ b/sound/core/oss/pcm_oss.c
4209 +@@ -1062,8 +1062,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
4210 + runtime->oss.channels = params_channels(params);
4211 + runtime->oss.rate = params_rate(params);
4212 +
4213 +- vfree(runtime->oss.buffer);
4214 +- runtime->oss.buffer = vmalloc(runtime->oss.period_bytes);
4215 ++ kvfree(runtime->oss.buffer);
4216 ++ runtime->oss.buffer = kvzalloc(runtime->oss.period_bytes, GFP_KERNEL);
4217 + if (!runtime->oss.buffer) {
4218 + err = -ENOMEM;
4219 + goto failure;
4220 +@@ -2328,7 +2328,7 @@ static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
4221 + {
4222 + struct snd_pcm_runtime *runtime;
4223 + runtime = substream->runtime;
4224 +- vfree(runtime->oss.buffer);
4225 ++ kvfree(runtime->oss.buffer);
4226 + runtime->oss.buffer = NULL;
4227 + #ifdef CONFIG_SND_PCM_OSS_PLUGINS
4228 + snd_pcm_oss_plugin_clear(substream);
4229 +diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
4230 +index 85a56af104bd..617845d4a811 100644
4231 +--- a/sound/core/oss/pcm_plugin.c
4232 ++++ b/sound/core/oss/pcm_plugin.c
4233 +@@ -66,8 +66,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
4234 + return -ENXIO;
4235 + size /= 8;
4236 + if (plugin->buf_frames < frames) {
4237 +- vfree(plugin->buf);
4238 +- plugin->buf = vmalloc(size);
4239 ++ kvfree(plugin->buf);
4240 ++ plugin->buf = kvzalloc(size, GFP_KERNEL);
4241 + plugin->buf_frames = frames;
4242 + }
4243 + if (!plugin->buf) {
4244 +@@ -191,7 +191,7 @@ int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin)
4245 + if (plugin->private_free)
4246 + plugin->private_free(plugin);
4247 + kfree(plugin->buf_channels);
4248 +- vfree(plugin->buf);
4249 ++ kvfree(plugin->buf);
4250 + kfree(plugin);
4251 + return 0;
4252 + }
4253 +diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile
4254 +index d79ab161cc75..f68b4bc55273 100644
4255 +--- a/tools/power/cpupower/bench/Makefile
4256 ++++ b/tools/power/cpupower/bench/Makefile
4257 +@@ -9,7 +9,7 @@ endif
4258 + ifeq ($(strip $(STATIC)),true)
4259 + LIBS = -L../ -L$(OUTPUT) -lm
4260 + OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o \
4261 +- $(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/sysfs.o
4262 ++ $(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/cpupower.o
4263 + else
4264 + LIBS = -L../ -L$(OUTPUT) -lm -lcpupower
4265 + OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o
4266 +diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c
4267 +index 1b993fe1ce23..0c0f3e3f0d80 100644
4268 +--- a/tools/power/cpupower/lib/cpufreq.c
4269 ++++ b/tools/power/cpupower/lib/cpufreq.c
4270 +@@ -28,7 +28,7 @@ static unsigned int sysfs_cpufreq_read_file(unsigned int cpu, const char *fname,
4271 +
4272 + snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/cpufreq/%s",
4273 + cpu, fname);
4274 +- return sysfs_read_file(path, buf, buflen);
4275 ++ return cpupower_read_sysfs(path, buf, buflen);
4276 + }
4277 +
4278 + /* helper function to write a new value to a /sys file */
4279 +diff --git a/tools/power/cpupower/lib/cpuidle.c b/tools/power/cpupower/lib/cpuidle.c
4280 +index 9bd4c7655fdb..852d25462388 100644
4281 +--- a/tools/power/cpupower/lib/cpuidle.c
4282 ++++ b/tools/power/cpupower/lib/cpuidle.c
4283 +@@ -319,7 +319,7 @@ static unsigned int sysfs_cpuidle_read_file(const char *fname, char *buf,
4284 +
4285 + snprintf(path, sizeof(path), PATH_TO_CPU "cpuidle/%s", fname);
4286 +
4287 +- return sysfs_read_file(path, buf, buflen);
4288 ++ return cpupower_read_sysfs(path, buf, buflen);
4289 + }
4290 +
4291 +
4292 +diff --git a/tools/power/cpupower/lib/cpupower.c b/tools/power/cpupower/lib/cpupower.c
4293 +index 9c395ec924de..9711d628b0f4 100644
4294 +--- a/tools/power/cpupower/lib/cpupower.c
4295 ++++ b/tools/power/cpupower/lib/cpupower.c
4296 +@@ -15,7 +15,7 @@
4297 + #include "cpupower.h"
4298 + #include "cpupower_intern.h"
4299 +
4300 +-unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen)
4301 ++unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen)
4302 + {
4303 + int fd;
4304 + ssize_t numread;
4305 +@@ -95,7 +95,7 @@ static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *re
4306 +
4307 + snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/topology/%s",
4308 + cpu, fname);
4309 +- if (sysfs_read_file(path, linebuf, MAX_LINE_LEN) == 0)
4310 ++ if (cpupower_read_sysfs(path, linebuf, MAX_LINE_LEN) == 0)
4311 + return -1;
4312 + *result = strtol(linebuf, &endp, 0);
4313 + if (endp == linebuf || errno == ERANGE)
4314 +diff --git a/tools/power/cpupower/lib/cpupower_intern.h b/tools/power/cpupower/lib/cpupower_intern.h
4315 +index 92affdfbe417..4887c76d23f8 100644
4316 +--- a/tools/power/cpupower/lib/cpupower_intern.h
4317 ++++ b/tools/power/cpupower/lib/cpupower_intern.h
4318 +@@ -3,4 +3,4 @@
4319 + #define MAX_LINE_LEN 4096
4320 + #define SYSFS_PATH_MAX 255
4321 +
4322 +-unsigned int sysfs_read_file(const char *path, char *buf, size_t buflen);
4323 ++unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen);