Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0244-5.4.145-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3635 - (show annotations) (download)
Mon Oct 24 12:34:12 2022 UTC (18 months ago) by niro
File size: 48255 byte(s)
-sync kernel patches
1 diff --git a/Makefile b/Makefile
2 index 3c3804197b511..c32a36c8ffc90 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 144
10 +SUBLEVEL = 145
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
15 index 8383155c8c824..a9d0b5310165f 100644
16 --- a/arch/arc/Kconfig
17 +++ b/arch/arc/Kconfig
18 @@ -29,6 +29,7 @@ config ARC
19 select GENERIC_SMP_IDLE_THREAD
20 select HAVE_ARCH_KGDB
21 select HAVE_ARCH_TRACEHOOK
22 + select HAVE_COPY_THREAD_TLS
23 select HAVE_DEBUG_STACKOVERFLOW
24 select HAVE_FUTEX_CMPXCHG if FUTEX
25 select HAVE_IOREMAP_PROT
26 diff --git a/arch/arc/include/asm/syscalls.h b/arch/arc/include/asm/syscalls.h
27 index 7ddba13e9b599..c3f4714a4f5cd 100644
28 --- a/arch/arc/include/asm/syscalls.h
29 +++ b/arch/arc/include/asm/syscalls.h
30 @@ -11,6 +11,7 @@
31 #include <linux/types.h>
32
33 int sys_clone_wrapper(int, int, int, int, int);
34 +int sys_clone3_wrapper(void *, size_t);
35 int sys_cacheflush(uint32_t, uint32_t uint32_t);
36 int sys_arc_settls(void *);
37 int sys_arc_gettls(void);
38 diff --git a/arch/arc/include/uapi/asm/unistd.h b/arch/arc/include/uapi/asm/unistd.h
39 index 5eafa11151623..fa2713ae6bea5 100644
40 --- a/arch/arc/include/uapi/asm/unistd.h
41 +++ b/arch/arc/include/uapi/asm/unistd.h
42 @@ -21,6 +21,7 @@
43 #define __ARCH_WANT_SET_GET_RLIMIT
44 #define __ARCH_WANT_SYS_EXECVE
45 #define __ARCH_WANT_SYS_CLONE
46 +#define __ARCH_WANT_SYS_CLONE3
47 #define __ARCH_WANT_SYS_VFORK
48 #define __ARCH_WANT_SYS_FORK
49 #define __ARCH_WANT_TIME32_SYSCALLS
50 diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
51 index b37ca852a9f7e..cef1d3f2656f6 100644
52 --- a/arch/arc/kernel/entry.S
53 +++ b/arch/arc/kernel/entry.S
54 @@ -35,6 +35,18 @@ ENTRY(sys_clone_wrapper)
55 b .Lret_from_system_call
56 END(sys_clone_wrapper)
57
58 +ENTRY(sys_clone3_wrapper)
59 + SAVE_CALLEE_SAVED_USER
60 + bl @sys_clone3
61 + DISCARD_CALLEE_SAVED_USER
62 +
63 + GET_CURR_THR_INFO_FLAGS r10
64 + btst r10, TIF_SYSCALL_TRACE
65 + bnz tracesys_exit
66 +
67 + b .Lret_from_system_call
68 +END(sys_clone3_wrapper)
69 +
70 ENTRY(ret_from_fork)
71 ; when the forked child comes here from the __switch_to function
72 ; r0 has the last task pointer.
73 diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
74 index e1889ce3faf96..bfd4cbe74aa36 100644
75 --- a/arch/arc/kernel/process.c
76 +++ b/arch/arc/kernel/process.c
77 @@ -171,9 +171,8 @@ asmlinkage void ret_from_fork(void);
78 * | user_r25 |
79 * ------------------ <===== END of PAGE
80 */
81 -int copy_thread(unsigned long clone_flags,
82 - unsigned long usp, unsigned long kthread_arg,
83 - struct task_struct *p)
84 +int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
85 + unsigned long kthread_arg, struct task_struct *p, unsigned long tls)
86 {
87 struct pt_regs *c_regs; /* child's pt_regs */
88 unsigned long *childksp; /* to unwind out of __switch_to() */
89 @@ -231,7 +230,7 @@ int copy_thread(unsigned long clone_flags,
90 * set task's userland tls data ptr from 4th arg
91 * clone C-lib call is difft from clone sys-call
92 */
93 - task_thread_info(p)->thr_ptr = regs->r3;
94 + task_thread_info(p)->thr_ptr = tls;
95 } else {
96 /* Normal fork case: set parent's TLS ptr in child */
97 task_thread_info(p)->thr_ptr =
98 diff --git a/arch/arc/kernel/sys.c b/arch/arc/kernel/sys.c
99 index fddecc76efb7c..1069446bdc589 100644
100 --- a/arch/arc/kernel/sys.c
101 +++ b/arch/arc/kernel/sys.c
102 @@ -7,6 +7,7 @@
103 #include <asm/syscalls.h>
104
105 #define sys_clone sys_clone_wrapper
106 +#define sys_clone3 sys_clone3_wrapper
107
108 #undef __SYSCALL
109 #define __SYSCALL(nr, call) [nr] = (call),
110 diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
111 index 8cad59465af39..8b679e2ca3c3d 100644
112 --- a/arch/arm/kernel/Makefile
113 +++ b/arch/arm/kernel/Makefile
114 @@ -17,10 +17,14 @@ CFLAGS_REMOVE_return_address.o = -pg
115 # Object file lists.
116
117 obj-y := elf.o entry-common.o irq.o opcodes.o \
118 - process.o ptrace.o reboot.o return_address.o \
119 + process.o ptrace.o reboot.o \
120 setup.o signal.o sigreturn_codes.o \
121 stacktrace.o sys_arm.o time.o traps.o
122
123 +ifneq ($(CONFIG_ARM_UNWIND),y)
124 +obj-$(CONFIG_FRAME_POINTER) += return_address.o
125 +endif
126 +
127 obj-$(CONFIG_ATAGS) += atags_parse.o
128 obj-$(CONFIG_ATAGS_PROC) += atags_proc.o
129 obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += atags_compat.o
130 diff --git a/arch/arm/kernel/return_address.c b/arch/arm/kernel/return_address.c
131 index b0d2f1fe891d1..7b42ac010fdfd 100644
132 --- a/arch/arm/kernel/return_address.c
133 +++ b/arch/arm/kernel/return_address.c
134 @@ -7,8 +7,6 @@
135 */
136 #include <linux/export.h>
137 #include <linux/ftrace.h>
138 -
139 -#if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
140 #include <linux/sched.h>
141
142 #include <asm/stacktrace.h>
143 @@ -53,6 +51,4 @@ void *return_address(unsigned int level)
144 return NULL;
145 }
146
147 -#endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) */
148 -
149 EXPORT_SYMBOL_GPL(return_address);
150 diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
151 index 92608f34d3123..1d83966f5ef64 100644
152 --- a/arch/powerpc/boot/crt0.S
153 +++ b/arch/powerpc/boot/crt0.S
154 @@ -44,9 +44,6 @@ p_end: .long _end
155 p_pstack: .long _platform_stack_top
156 #endif
157
158 - .globl _zimage_start
159 - /* Clang appears to require the .weak directive to be after the symbol
160 - * is defined. See https://bugs.llvm.org/show_bug.cgi?id=38921 */
161 .weak _zimage_start
162 _zimage_start:
163 .globl _zimage_start_lib
164 diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
165 index 39169885adfa8..ff07040287c40 100644
166 --- a/arch/x86/events/amd/ibs.c
167 +++ b/arch/x86/events/amd/ibs.c
168 @@ -90,6 +90,7 @@ struct perf_ibs {
169 unsigned long offset_mask[1];
170 int offset_max;
171 unsigned int fetch_count_reset_broken : 1;
172 + unsigned int fetch_ignore_if_zero_rip : 1;
173 struct cpu_perf_ibs __percpu *pcpu;
174
175 struct attribute **format_attrs;
176 @@ -663,6 +664,10 @@ fail:
177 if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {
178 regs.flags &= ~PERF_EFLAGS_EXACT;
179 } else {
180 + /* Workaround for erratum #1197 */
181 + if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
182 + goto out;
183 +
184 set_linear_ip(&regs, ibs_data.regs[1]);
185 regs.flags |= PERF_EFLAGS_EXACT;
186 }
187 @@ -756,6 +761,9 @@ static __init void perf_event_ibs_init(void)
188 if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
189 perf_ibs_fetch.fetch_count_reset_broken = 1;
190
191 + if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10)
192 + perf_ibs_fetch.fetch_ignore_if_zero_rip = 1;
193 +
194 perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
195
196 if (ibs_caps & IBS_CAPS_OPCNT) {
197 diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
198 index 6a98a76516214..2da6139b0977f 100644
199 --- a/arch/x86/events/amd/iommu.c
200 +++ b/arch/x86/events/amd/iommu.c
201 @@ -18,8 +18,6 @@
202 #include "../perf_event.h"
203 #include "iommu.h"
204
205 -#define COUNTER_SHIFT 16
206 -
207 /* iommu pmu conf masks */
208 #define GET_CSOURCE(x) ((x)->conf & 0xFFULL)
209 #define GET_DEVID(x) (((x)->conf >> 8) & 0xFFFFULL)
210 @@ -285,22 +283,31 @@ static void perf_iommu_start(struct perf_event *event, int flags)
211 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
212 hwc->state = 0;
213
214 + /*
215 + * To account for power-gating, which prevents write to
216 + * the counter, we need to enable the counter
217 + * before setting up counter register.
218 + */
219 + perf_iommu_enable_event(event);
220 +
221 if (flags & PERF_EF_RELOAD) {
222 - u64 prev_raw_count = local64_read(&hwc->prev_count);
223 + u64 count = 0;
224 struct amd_iommu *iommu = perf_event_2_iommu(event);
225
226 + /*
227 + * Since the IOMMU PMU only support counting mode,
228 + * the counter always start with value zero.
229 + */
230 amd_iommu_pc_set_reg(iommu, hwc->iommu_bank, hwc->iommu_cntr,
231 - IOMMU_PC_COUNTER_REG, &prev_raw_count);
232 + IOMMU_PC_COUNTER_REG, &count);
233 }
234
235 - perf_iommu_enable_event(event);
236 perf_event_update_userpage(event);
237 -
238 }
239
240 static void perf_iommu_read(struct perf_event *event)
241 {
242 - u64 count, prev, delta;
243 + u64 count;
244 struct hw_perf_event *hwc = &event->hw;
245 struct amd_iommu *iommu = perf_event_2_iommu(event);
246
247 @@ -311,14 +318,11 @@ static void perf_iommu_read(struct perf_event *event)
248 /* IOMMU pc counter register is only 48 bits */
249 count &= GENMASK_ULL(47, 0);
250
251 - prev = local64_read(&hwc->prev_count);
252 - if (local64_cmpxchg(&hwc->prev_count, prev, count) != prev)
253 - return;
254 -
255 - /* Handle 48-bit counter overflow */
256 - delta = (count << COUNTER_SHIFT) - (prev << COUNTER_SHIFT);
257 - delta >>= COUNTER_SHIFT;
258 - local64_add(delta, &event->count);
259 + /*
260 + * Since the counter always start with value zero,
261 + * simply just accumulate the count for the event.
262 + */
263 + local64_add(count, &event->count);
264 }
265
266 static void perf_iommu_stop(struct perf_event *event, int flags)
267 @@ -328,15 +332,16 @@ static void perf_iommu_stop(struct perf_event *event, int flags)
268 if (hwc->state & PERF_HES_UPTODATE)
269 return;
270
271 + /*
272 + * To account for power-gating, in which reading the counter would
273 + * return zero, we need to read the register before disabling.
274 + */
275 + perf_iommu_read(event);
276 + hwc->state |= PERF_HES_UPTODATE;
277 +
278 perf_iommu_disable_event(event);
279 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
280 hwc->state |= PERF_HES_STOPPED;
281 -
282 - if (hwc->state & PERF_HES_UPTODATE)
283 - return;
284 -
285 - perf_iommu_read(event);
286 - hwc->state |= PERF_HES_UPTODATE;
287 }
288
289 static int perf_iommu_add(struct perf_event *event, int flags)
290 diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c
291 index abef51320e3a5..c4892b7d0c36b 100644
292 --- a/arch/x86/events/amd/power.c
293 +++ b/arch/x86/events/amd/power.c
294 @@ -217,6 +217,7 @@ static struct pmu pmu_class = {
295 .stop = pmu_event_stop,
296 .read = pmu_event_read,
297 .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
298 + .module = THIS_MODULE,
299 };
300
301 static int power_cpu_exit(unsigned int cpu)
302 diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
303 index 05e43d0f430bc..da289a44d5116 100644
304 --- a/arch/x86/events/intel/pt.c
305 +++ b/arch/x86/events/intel/pt.c
306 @@ -62,7 +62,7 @@ static struct pt_cap_desc {
307 PT_CAP(single_range_output, 0, CPUID_ECX, BIT(2)),
308 PT_CAP(output_subsys, 0, CPUID_ECX, BIT(3)),
309 PT_CAP(payloads_lip, 0, CPUID_ECX, BIT(31)),
310 - PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x3),
311 + PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x7),
312 PT_CAP(mtc_periods, 1, CPUID_EAX, 0xffff0000),
313 PT_CAP(cycle_thresholds, 1, CPUID_EBX, 0xffff),
314 PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),
315 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
316 index b1b96d461bc76..d65d1afb27161 100644
317 --- a/arch/x86/kernel/reboot.c
318 +++ b/arch/x86/kernel/reboot.c
319 @@ -388,10 +388,11 @@ static const struct dmi_system_id reboot_dmi_table[] __initconst = {
320 },
321 { /* Handle problems with rebooting on the OptiPlex 990. */
322 .callback = set_pci_reboot,
323 - .ident = "Dell OptiPlex 990",
324 + .ident = "Dell OptiPlex 990 BIOS A0x",
325 .matches = {
326 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
327 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"),
328 + DMI_MATCH(DMI_BIOS_VERSION, "A0"),
329 },
330 },
331 { /* Handle problems with rebooting on Dell 300's */
332 diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
333 index 8352037322dfb..499bdd1f0c715 100644
334 --- a/arch/xtensa/Kconfig
335 +++ b/arch/xtensa/Kconfig
336 @@ -27,7 +27,7 @@ config XTENSA
337 select HAVE_DMA_CONTIGUOUS
338 select HAVE_EXIT_THREAD
339 select HAVE_FUNCTION_TRACER
340 - select HAVE_FUTEX_CMPXCHG if !MMU
341 + select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
342 select HAVE_HW_BREAKPOINT if PERF_EVENTS
343 select HAVE_IRQ_TIME_ACCOUNTING
344 select HAVE_OPROFILE
345 diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
346 index 0fc27ac14f29c..9f6782329a237 100644
347 --- a/drivers/block/Kconfig
348 +++ b/drivers/block/Kconfig
349 @@ -230,7 +230,7 @@ config BLK_DEV_LOOP_MIN_COUNT
350 dynamically allocated with the /dev/loop-control interface.
351
352 config BLK_DEV_CRYPTOLOOP
353 - tristate "Cryptoloop Support"
354 + tristate "Cryptoloop Support (DEPRECATED)"
355 select CRYPTO
356 select CRYPTO_CBC
357 depends on BLK_DEV_LOOP
358 @@ -242,7 +242,7 @@ config BLK_DEV_CRYPTOLOOP
359 WARNING: This device is not safe for journaled file systems like
360 ext3 or Reiserfs. Please use the Device Mapper crypto module
361 instead, which can be configured to be on-disk compatible with the
362 - cryptoloop device.
363 + cryptoloop device. cryptoloop support will be removed in Linux 5.16.
364
365 source "drivers/block/drbd/Kconfig"
366
367 diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
368 index 3cabc335ae744..f0a91faa43a89 100644
369 --- a/drivers/block/cryptoloop.c
370 +++ b/drivers/block/cryptoloop.c
371 @@ -189,6 +189,8 @@ init_cryptoloop(void)
372
373 if (rc)
374 printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
375 + else
376 + pr_warn("the cryptoloop driver has been deprecated and will be removed in in Linux 5.16\n");
377 return rc;
378 }
379
380 diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
381 index a1c85d1521f5c..82b244cb313e6 100644
382 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c
383 +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
384 @@ -585,21 +585,21 @@ static const struct ipu_rgb def_bgra_16 = {
385 .bits_per_pixel = 16,
386 };
387
388 -#define Y_OFFSET(pix, x, y) ((x) + pix->width * (y))
389 -#define U_OFFSET(pix, x, y) ((pix->width * pix->height) + \
390 - (pix->width * ((y) / 2) / 2) + (x) / 2)
391 -#define V_OFFSET(pix, x, y) ((pix->width * pix->height) + \
392 - (pix->width * pix->height / 4) + \
393 - (pix->width * ((y) / 2) / 2) + (x) / 2)
394 -#define U2_OFFSET(pix, x, y) ((pix->width * pix->height) + \
395 - (pix->width * (y) / 2) + (x) / 2)
396 -#define V2_OFFSET(pix, x, y) ((pix->width * pix->height) + \
397 - (pix->width * pix->height / 2) + \
398 - (pix->width * (y) / 2) + (x) / 2)
399 -#define UV_OFFSET(pix, x, y) ((pix->width * pix->height) + \
400 - (pix->width * ((y) / 2)) + (x))
401 -#define UV2_OFFSET(pix, x, y) ((pix->width * pix->height) + \
402 - (pix->width * y) + (x))
403 +#define Y_OFFSET(pix, x, y) ((x) + pix->bytesperline * (y))
404 +#define U_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
405 + (pix->bytesperline * ((y) / 2) / 2) + (x) / 2)
406 +#define V_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
407 + (pix->bytesperline * pix->height / 4) + \
408 + (pix->bytesperline * ((y) / 2) / 2) + (x) / 2)
409 +#define U2_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
410 + (pix->bytesperline * (y) / 2) + (x) / 2)
411 +#define V2_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
412 + (pix->bytesperline * pix->height / 2) + \
413 + (pix->bytesperline * (y) / 2) + (x) / 2)
414 +#define UV_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
415 + (pix->bytesperline * ((y) / 2)) + (x))
416 +#define UV2_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
417 + (pix->bytesperline * y) + (x))
418
419 #define NUM_ALPHA_CHANNELS 7
420
421 diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
422 index 21f90a8874852..7d6a4ff6e1421 100644
423 --- a/drivers/media/usb/stkwebcam/stk-webcam.c
424 +++ b/drivers/media/usb/stkwebcam/stk-webcam.c
425 @@ -1346,7 +1346,7 @@ static int stk_camera_probe(struct usb_interface *interface,
426 if (!dev->isoc_ep) {
427 pr_err("Could not find isoc-in endpoint\n");
428 err = -ENODEV;
429 - goto error;
430 + goto error_put;
431 }
432 dev->vsettings.palette = V4L2_PIX_FMT_RGB565;
433 dev->vsettings.mode = MODE_VGA;
434 @@ -1359,10 +1359,12 @@ static int stk_camera_probe(struct usb_interface *interface,
435
436 err = stk_register_video_device(dev);
437 if (err)
438 - goto error;
439 + goto error_put;
440
441 return 0;
442
443 +error_put:
444 + usb_put_intf(interface);
445 error:
446 v4l2_ctrl_handler_free(hdl);
447 v4l2_device_unregister(&dev->v4l2_dev);
448 diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
449 index 43a3f0dbf857c..f5aec28c77306 100644
450 --- a/drivers/net/ethernet/cadence/macb_ptp.c
451 +++ b/drivers/net/ethernet/cadence/macb_ptp.c
452 @@ -275,6 +275,12 @@ void gem_ptp_rxstamp(struct macb *bp, struct sk_buff *skb,
453
454 if (GEM_BFEXT(DMA_RXVALID, desc->addr)) {
455 desc_ptp = macb_ptp_desc(bp, desc);
456 + /* Unlikely but check */
457 + if (!desc_ptp) {
458 + dev_warn_ratelimited(&bp->pdev->dev,
459 + "Timestamp not supported in BD\n");
460 + return;
461 + }
462 gem_hw_timestamp(bp, desc_ptp->ts_1, desc_ptp->ts_2, &ts);
463 memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));
464 shhwtstamps->hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
465 @@ -307,8 +313,11 @@ int gem_ptp_txstamp(struct macb_queue *queue, struct sk_buff *skb,
466 if (CIRC_SPACE(head, tail, PTP_TS_BUFFER_SIZE) == 0)
467 return -ENOMEM;
468
469 - skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
470 desc_ptp = macb_ptp_desc(queue->bp, desc);
471 + /* Unlikely but check */
472 + if (!desc_ptp)
473 + return -EINVAL;
474 + skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
475 tx_timestamp = &queue->tx_timestamps[head];
476 tx_timestamp->skb = skb;
477 /* ensure ts_1/ts_2 is loaded after ctrl (TX_USED check) */
478 diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
479 index bc1f5b36b5bf2..1db49424aa43c 100644
480 --- a/drivers/net/ethernet/qlogic/qed/qed_main.c
481 +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
482 @@ -559,7 +559,12 @@ static int qed_enable_msix(struct qed_dev *cdev,
483 rc = cnt;
484 }
485
486 - if (rc > 0) {
487 + /* For VFs, we should return with an error in case we didn't get the
488 + * exact number of msix vectors as we requested.
489 + * Not doing that will lead to a crash when starting queues for
490 + * this VF.
491 + */
492 + if ((IS_PF(cdev) && rc > 0) || (IS_VF(cdev) && rc == cnt)) {
493 /* MSI-x configuration was achieved */
494 int_params->out.int_mode = QED_INT_MODE_MSIX;
495 int_params->out.num_vectors = rc;
496 diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
497 index ce3e62e73e4cd..1133f6fe21a0e 100644
498 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c
499 +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
500 @@ -1773,6 +1773,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev)
501 }
502
503 edev->int_info.used_cnt = 0;
504 + edev->int_info.msix_cnt = 0;
505 }
506
507 static int qede_req_msix_irqs(struct qede_dev *edev)
508 @@ -2317,7 +2318,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode,
509 goto out;
510 err4:
511 qede_sync_free_irqs(edev);
512 - memset(&edev->int_info.msix_cnt, 0, sizeof(struct qed_int_info));
513 err3:
514 qede_napi_disable_remove(edev);
515 err2:
516 diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
517 index fb51548c57e94..623d86e5e970f 100644
518 --- a/drivers/net/ethernet/realtek/r8169_main.c
519 +++ b/drivers/net/ethernet/realtek/r8169_main.c
520 @@ -4713,6 +4713,7 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)
521 rtl_eri_clear_bits(tp, 0x1b0, ERIAR_MASK_0011, BIT(12));
522
523 rtl_pcie_state_l2l3_disable(tp);
524 + rtl_hw_aspm_clkreq_enable(tp, true);
525 }
526
527 static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
528 diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
529 index 9a7af7dda70dc..bddd64e918ce0 100644
530 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c
531 +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
532 @@ -939,10 +939,8 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
533 wmb();
534 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
535
536 - if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {
537 - netdev_info(ndev, "%s -> netif_stop_queue\n", __func__);
538 + if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1))
539 netif_stop_queue(ndev);
540 - }
541
542 return NETDEV_TX_OK;
543 }
544 diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
545 index 0241f0dcc093f..97c343d31f989 100644
546 --- a/drivers/pci/quirks.c
547 +++ b/drivers/pci/quirks.c
548 @@ -3246,12 +3246,12 @@ static void fixup_mpss_256(struct pci_dev *dev)
549 {
550 dev->pcie_mpss = 1; /* 256 bytes */
551 }
552 -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
553 - PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
554 -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
555 - PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
556 -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
557 - PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
558 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
559 + PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
560 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
561 + PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
562 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
563 + PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
564
565 /*
566 * Intel 5000 and 5100 Memory controllers have an erratum with read completion
567 diff --git a/drivers/reset/reset-zynqmp.c b/drivers/reset/reset-zynqmp.c
568 index 99e75d92dadab..8a7473b6ba585 100644
569 --- a/drivers/reset/reset-zynqmp.c
570 +++ b/drivers/reset/reset-zynqmp.c
571 @@ -46,7 +46,8 @@ static int zynqmp_reset_status(struct reset_controller_dev *rcdev,
572 unsigned long id)
573 {
574 struct zynqmp_reset_data *priv = to_zynqmp_reset_data(rcdev);
575 - int val, err;
576 + int err;
577 + u32 val;
578
579 err = priv->eemi_ops->reset_get_status(ZYNQMP_RESET_ID + id, &val);
580 if (err)
581 diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
582 index 448d7b11dec4c..f5c8e4eb62ae6 100644
583 --- a/drivers/usb/host/xhci-debugfs.c
584 +++ b/drivers/usb/host/xhci-debugfs.c
585 @@ -197,12 +197,13 @@ static void xhci_ring_dump_segment(struct seq_file *s,
586 int i;
587 dma_addr_t dma;
588 union xhci_trb *trb;
589 + char str[XHCI_MSG_MAX];
590
591 for (i = 0; i < TRBS_PER_SEGMENT; i++) {
592 trb = &seg->trbs[i];
593 dma = seg->dma + i * sizeof(*trb);
594 seq_printf(s, "%pad: %s\n", &dma,
595 - xhci_decode_trb(le32_to_cpu(trb->generic.field[0]),
596 + xhci_decode_trb(str, XHCI_MSG_MAX, le32_to_cpu(trb->generic.field[0]),
597 le32_to_cpu(trb->generic.field[1]),
598 le32_to_cpu(trb->generic.field[2]),
599 le32_to_cpu(trb->generic.field[3])));
600 @@ -340,9 +341,10 @@ static int xhci_portsc_show(struct seq_file *s, void *unused)
601 {
602 struct xhci_port *port = s->private;
603 u32 portsc;
604 + char str[XHCI_MSG_MAX];
605
606 portsc = readl(port->addr);
607 - seq_printf(s, "%s\n", xhci_decode_portsc(portsc));
608 + seq_printf(s, "%s\n", xhci_decode_portsc(str, portsc));
609
610 return 0;
611 }
612 diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
613 index c1025d321a417..3da75b367f952 100644
614 --- a/drivers/usb/host/xhci-rcar.c
615 +++ b/drivers/usb/host/xhci-rcar.c
616 @@ -134,6 +134,13 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd)
617 const struct soc_device_attribute *attr;
618 const char *firmware_name;
619
620 + /*
621 + * According to the datasheet, "Upon the completion of FW Download,
622 + * there is no need to write or reload FW".
623 + */
624 + if (readl(regs + RCAR_USB3_DL_CTRL) & RCAR_USB3_DL_CTRL_FW_SUCCESS)
625 + return 0;
626 +
627 attr = soc_device_match(rcar_quirks_match);
628 if (attr)
629 quirks = (uintptr_t)attr->data;
630 diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
631 index 87da9098fb347..dab2af3f2c4f7 100644
632 --- a/drivers/usb/host/xhci-trace.h
633 +++ b/drivers/usb/host/xhci-trace.h
634 @@ -25,8 +25,6 @@
635 #include "xhci.h"
636 #include "xhci-dbgcap.h"
637
638 -#define XHCI_MSG_MAX 500
639 -
640 DECLARE_EVENT_CLASS(xhci_log_msg,
641 TP_PROTO(struct va_format *vaf),
642 TP_ARGS(vaf),
643 @@ -122,6 +120,7 @@ DECLARE_EVENT_CLASS(xhci_log_trb,
644 __field(u32, field1)
645 __field(u32, field2)
646 __field(u32, field3)
647 + __dynamic_array(char, str, XHCI_MSG_MAX)
648 ),
649 TP_fast_assign(
650 __entry->type = ring->type;
651 @@ -131,7 +130,7 @@ DECLARE_EVENT_CLASS(xhci_log_trb,
652 __entry->field3 = le32_to_cpu(trb->field[3]);
653 ),
654 TP_printk("%s: %s", xhci_ring_type_string(__entry->type),
655 - xhci_decode_trb(__entry->field0, __entry->field1,
656 + xhci_decode_trb(__get_str(str), XHCI_MSG_MAX, __entry->field0, __entry->field1,
657 __entry->field2, __entry->field3)
658 )
659 );
660 @@ -523,6 +522,7 @@ DECLARE_EVENT_CLASS(xhci_log_portsc,
661 TP_STRUCT__entry(
662 __field(u32, portnum)
663 __field(u32, portsc)
664 + __dynamic_array(char, str, XHCI_MSG_MAX)
665 ),
666 TP_fast_assign(
667 __entry->portnum = portnum;
668 @@ -530,7 +530,7 @@ DECLARE_EVENT_CLASS(xhci_log_portsc,
669 ),
670 TP_printk("port-%d: %s",
671 __entry->portnum,
672 - xhci_decode_portsc(__entry->portsc)
673 + xhci_decode_portsc(__get_str(str), __entry->portsc)
674 )
675 );
676
677 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
678 index 834f32fe99308..02df309e44093 100644
679 --- a/drivers/usb/host/xhci.h
680 +++ b/drivers/usb/host/xhci.h
681 @@ -22,6 +22,9 @@
682 #include "xhci-ext-caps.h"
683 #include "pci-quirks.h"
684
685 +/* max buffer size for trace and debug messages */
686 +#define XHCI_MSG_MAX 500
687 +
688 /* xHCI PCI Configuration Registers */
689 #define XHCI_SBRN_OFFSET (0x60)
690
691 @@ -2217,15 +2220,14 @@ static inline char *xhci_slot_state_string(u32 state)
692 }
693 }
694
695 -static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
696 - u32 field3)
697 +static inline const char *xhci_decode_trb(char *str, size_t size,
698 + u32 field0, u32 field1, u32 field2, u32 field3)
699 {
700 - static char str[256];
701 int type = TRB_FIELD_TO_TYPE(field3);
702
703 switch (type) {
704 case TRB_LINK:
705 - sprintf(str,
706 + snprintf(str, size,
707 "LINK %08x%08x intr %d type '%s' flags %c:%c:%c:%c",
708 field1, field0, GET_INTR_TARGET(field2),
709 xhci_trb_type_string(type),
710 @@ -2242,7 +2244,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
711 case TRB_HC_EVENT:
712 case TRB_DEV_NOTE:
713 case TRB_MFINDEX_WRAP:
714 - sprintf(str,
715 + snprintf(str, size,
716 "TRB %08x%08x status '%s' len %d slot %d ep %d type '%s' flags %c:%c",
717 field1, field0,
718 xhci_trb_comp_code_string(GET_COMP_CODE(field2)),
719 @@ -2255,7 +2257,8 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
720
721 break;
722 case TRB_SETUP:
723 - sprintf(str, "bRequestType %02x bRequest %02x wValue %02x%02x wIndex %02x%02x wLength %d length %d TD size %d intr %d type '%s' flags %c:%c:%c",
724 + snprintf(str, size,
725 + "bRequestType %02x bRequest %02x wValue %02x%02x wIndex %02x%02x wLength %d length %d TD size %d intr %d type '%s' flags %c:%c:%c",
726 field0 & 0xff,
727 (field0 & 0xff00) >> 8,
728 (field0 & 0xff000000) >> 24,
729 @@ -2272,7 +2275,8 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
730 field3 & TRB_CYCLE ? 'C' : 'c');
731 break;
732 case TRB_DATA:
733 - sprintf(str, "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c",
734 + snprintf(str, size,
735 + "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c",
736 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),
737 GET_INTR_TARGET(field2),
738 xhci_trb_type_string(type),
739 @@ -2285,7 +2289,8 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
740 field3 & TRB_CYCLE ? 'C' : 'c');
741 break;
742 case TRB_STATUS:
743 - sprintf(str, "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c",
744 + snprintf(str, size,
745 + "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c",
746 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),
747 GET_INTR_TARGET(field2),
748 xhci_trb_type_string(type),
749 @@ -2298,7 +2303,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
750 case TRB_ISOC:
751 case TRB_EVENT_DATA:
752 case TRB_TR_NOOP:
753 - sprintf(str,
754 + snprintf(str, size,
755 "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c:%c",
756 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),
757 GET_INTR_TARGET(field2),
758 @@ -2315,21 +2320,21 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
759
760 case TRB_CMD_NOOP:
761 case TRB_ENABLE_SLOT:
762 - sprintf(str,
763 + snprintf(str, size,
764 "%s: flags %c",
765 xhci_trb_type_string(type),
766 field3 & TRB_CYCLE ? 'C' : 'c');
767 break;
768 case TRB_DISABLE_SLOT:
769 case TRB_NEG_BANDWIDTH:
770 - sprintf(str,
771 + snprintf(str, size,
772 "%s: slot %d flags %c",
773 xhci_trb_type_string(type),
774 TRB_TO_SLOT_ID(field3),
775 field3 & TRB_CYCLE ? 'C' : 'c');
776 break;
777 case TRB_ADDR_DEV:
778 - sprintf(str,
779 + snprintf(str, size,
780 "%s: ctx %08x%08x slot %d flags %c:%c",
781 xhci_trb_type_string(type),
782 field1, field0,
783 @@ -2338,7 +2343,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
784 field3 & TRB_CYCLE ? 'C' : 'c');
785 break;
786 case TRB_CONFIG_EP:
787 - sprintf(str,
788 + snprintf(str, size,
789 "%s: ctx %08x%08x slot %d flags %c:%c",
790 xhci_trb_type_string(type),
791 field1, field0,
792 @@ -2347,7 +2352,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
793 field3 & TRB_CYCLE ? 'C' : 'c');
794 break;
795 case TRB_EVAL_CONTEXT:
796 - sprintf(str,
797 + snprintf(str, size,
798 "%s: ctx %08x%08x slot %d flags %c",
799 xhci_trb_type_string(type),
800 field1, field0,
801 @@ -2355,7 +2360,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
802 field3 & TRB_CYCLE ? 'C' : 'c');
803 break;
804 case TRB_RESET_EP:
805 - sprintf(str,
806 + snprintf(str, size,
807 "%s: ctx %08x%08x slot %d ep %d flags %c:%c",
808 xhci_trb_type_string(type),
809 field1, field0,
810 @@ -2376,7 +2381,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
811 field3 & TRB_CYCLE ? 'C' : 'c');
812 break;
813 case TRB_SET_DEQ:
814 - sprintf(str,
815 + snprintf(str, size,
816 "%s: deq %08x%08x stream %d slot %d ep %d flags %c",
817 xhci_trb_type_string(type),
818 field1, field0,
819 @@ -2387,14 +2392,14 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
820 field3 & TRB_CYCLE ? 'C' : 'c');
821 break;
822 case TRB_RESET_DEV:
823 - sprintf(str,
824 + snprintf(str, size,
825 "%s: slot %d flags %c",
826 xhci_trb_type_string(type),
827 TRB_TO_SLOT_ID(field3),
828 field3 & TRB_CYCLE ? 'C' : 'c');
829 break;
830 case TRB_FORCE_EVENT:
831 - sprintf(str,
832 + snprintf(str, size,
833 "%s: event %08x%08x vf intr %d vf id %d flags %c",
834 xhci_trb_type_string(type),
835 field1, field0,
836 @@ -2403,14 +2408,14 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
837 field3 & TRB_CYCLE ? 'C' : 'c');
838 break;
839 case TRB_SET_LT:
840 - sprintf(str,
841 + snprintf(str, size,
842 "%s: belt %d flags %c",
843 xhci_trb_type_string(type),
844 TRB_TO_BELT(field3),
845 field3 & TRB_CYCLE ? 'C' : 'c');
846 break;
847 case TRB_GET_BW:
848 - sprintf(str,
849 + snprintf(str, size,
850 "%s: ctx %08x%08x slot %d speed %d flags %c",
851 xhci_trb_type_string(type),
852 field1, field0,
853 @@ -2419,7 +2424,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
854 field3 & TRB_CYCLE ? 'C' : 'c');
855 break;
856 case TRB_FORCE_HEADER:
857 - sprintf(str,
858 + snprintf(str, size,
859 "%s: info %08x%08x%08x pkt type %d roothub port %d flags %c",
860 xhci_trb_type_string(type),
861 field2, field1, field0 & 0xffffffe0,
862 @@ -2428,7 +2433,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
863 field3 & TRB_CYCLE ? 'C' : 'c');
864 break;
865 default:
866 - sprintf(str,
867 + snprintf(str, size,
868 "type '%s' -> raw %08x %08x %08x %08x",
869 xhci_trb_type_string(type),
870 field0, field1, field2, field3);
871 @@ -2553,9 +2558,8 @@ static inline const char *xhci_portsc_link_state_string(u32 portsc)
872 return "Unknown";
873 }
874
875 -static inline const char *xhci_decode_portsc(u32 portsc)
876 +static inline const char *xhci_decode_portsc(char *str, u32 portsc)
877 {
878 - static char str[256];
879 int ret;
880
881 ret = sprintf(str, "%s %s %s Link:%s PortSpeed:%d ",
882 diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
883 index 08db02f3172df..619c4598e64ea 100644
884 --- a/drivers/usb/mtu3/mtu3_gadget.c
885 +++ b/drivers/usb/mtu3/mtu3_gadget.c
886 @@ -72,14 +72,12 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
887 u32 interval = 0;
888 u32 mult = 0;
889 u32 burst = 0;
890 - int max_packet;
891 int ret;
892
893 desc = mep->desc;
894 comp_desc = mep->comp_desc;
895 mep->type = usb_endpoint_type(desc);
896 - max_packet = usb_endpoint_maxp(desc);
897 - mep->maxp = max_packet & GENMASK(10, 0);
898 + mep->maxp = usb_endpoint_maxp(desc);
899
900 switch (mtu->g.speed) {
901 case USB_SPEED_SUPER:
902 @@ -100,7 +98,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
903 usb_endpoint_xfer_int(desc)) {
904 interval = desc->bInterval;
905 interval = clamp_val(interval, 1, 16) - 1;
906 - burst = (max_packet & GENMASK(12, 11)) >> 11;
907 + mult = usb_endpoint_maxp_mult(desc) - 1;
908 }
909 break;
910 default:
911 diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
912 index aefc1b58d9563..f5caf38ba2be0 100644
913 --- a/drivers/usb/serial/mos7720.c
914 +++ b/drivers/usb/serial/mos7720.c
915 @@ -226,8 +226,10 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
916 int status;
917
918 buf = kmalloc(1, GFP_KERNEL);
919 - if (!buf)
920 + if (!buf) {
921 + *data = 0;
922 return -ENOMEM;
923 + }
924
925 status = usb_control_msg(usbdev, pipe, request, requesttype, value,
926 index, buf, 1, MOS_WDR_TIMEOUT);
927 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
928 index 29552d4f6845b..33b8fedab6c67 100644
929 --- a/fs/btrfs/inode.c
930 +++ b/fs/btrfs/inode.c
931 @@ -543,7 +543,7 @@ again:
932 * inode has not been flagged as nocompress. This flag can
933 * change at any time if we discover bad compression ratios.
934 */
935 - if (nr_pages > 1 && inode_need_compress(inode, start, end)) {
936 + if (inode_need_compress(inode, start, end)) {
937 WARN_ON(pages);
938 pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
939 if (!pages) {
940 diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c
941 index a5a40a76b8ed7..82575cfbb04db 100644
942 --- a/fs/crypto/hooks.c
943 +++ b/fs/crypto/hooks.c
944 @@ -305,3 +305,47 @@ err_kfree:
945 return ERR_PTR(err);
946 }
947 EXPORT_SYMBOL_GPL(fscrypt_get_symlink);
948 +
949 +/**
950 + * fscrypt_symlink_getattr() - set the correct st_size for encrypted symlinks
951 + * @path: the path for the encrypted symlink being queried
952 + * @stat: the struct being filled with the symlink's attributes
953 + *
954 + * Override st_size of encrypted symlinks to be the length of the decrypted
955 + * symlink target (or the no-key encoded symlink target, if the key is
956 + * unavailable) rather than the length of the encrypted symlink target. This is
957 + * necessary for st_size to match the symlink target that userspace actually
958 + * sees. POSIX requires this, and some userspace programs depend on it.
959 + *
960 + * This requires reading the symlink target from disk if needed, setting up the
961 + * inode's encryption key if possible, and then decrypting or encoding the
962 + * symlink target. This makes lstat() more heavyweight than is normally the
963 + * case. However, decrypted symlink targets will be cached in ->i_link, so
964 + * usually the symlink won't have to be read and decrypted again later if/when
965 + * it is actually followed, readlink() is called, or lstat() is called again.
966 + *
967 + * Return: 0 on success, -errno on failure
968 + */
969 +int fscrypt_symlink_getattr(const struct path *path, struct kstat *stat)
970 +{
971 + struct dentry *dentry = path->dentry;
972 + struct inode *inode = d_inode(dentry);
973 + const char *link;
974 + DEFINE_DELAYED_CALL(done);
975 +
976 + /*
977 + * To get the symlink target that userspace will see (whether it's the
978 + * decrypted target or the no-key encoded target), we can just get it in
979 + * the same way the VFS does during path resolution and readlink().
980 + */
981 + link = READ_ONCE(inode->i_link);
982 + if (!link) {
983 + link = inode->i_op->get_link(dentry, inode, &done);
984 + if (IS_ERR(link))
985 + return PTR_ERR(link);
986 + }
987 + stat->size = strlen(link);
988 + do_delayed_call(&done);
989 + return 0;
990 +}
991 +EXPORT_SYMBOL_GPL(fscrypt_symlink_getattr);
992 diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
993 index 519378a15bc6b..46151bda62368 100644
994 --- a/fs/ext4/inline.c
995 +++ b/fs/ext4/inline.c
996 @@ -750,6 +750,12 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
997 ext4_write_lock_xattr(inode, &no_expand);
998 BUG_ON(!ext4_has_inline_data(inode));
999
1000 + /*
1001 + * ei->i_inline_off may have changed since ext4_write_begin()
1002 + * called ext4_try_to_write_inline_data()
1003 + */
1004 + (void) ext4_find_inline_data_nolock(inode);
1005 +
1006 kaddr = kmap_atomic(page);
1007 ext4_write_inline_data(inode, &iloc, kaddr, pos, len);
1008 kunmap_atomic(kaddr);
1009 diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
1010 index dd05af983092d..a9457fed351ed 100644
1011 --- a/fs/ext4/symlink.c
1012 +++ b/fs/ext4/symlink.c
1013 @@ -52,10 +52,19 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
1014 return paddr;
1015 }
1016
1017 +static int ext4_encrypted_symlink_getattr(const struct path *path,
1018 + struct kstat *stat, u32 request_mask,
1019 + unsigned int query_flags)
1020 +{
1021 + ext4_getattr(path, stat, request_mask, query_flags);
1022 +
1023 + return fscrypt_symlink_getattr(path, stat);
1024 +}
1025 +
1026 const struct inode_operations ext4_encrypted_symlink_inode_operations = {
1027 .get_link = ext4_encrypted_get_link,
1028 .setattr = ext4_setattr,
1029 - .getattr = ext4_getattr,
1030 + .getattr = ext4_encrypted_symlink_getattr,
1031 .listxattr = ext4_listxattr,
1032 };
1033
1034 diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
1035 index 3a97ac56821ba..81a18ba18e301 100644
1036 --- a/fs/f2fs/namei.c
1037 +++ b/fs/f2fs/namei.c
1038 @@ -1256,9 +1256,18 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
1039 return target;
1040 }
1041
1042 +static int f2fs_encrypted_symlink_getattr(const struct path *path,
1043 + struct kstat *stat, u32 request_mask,
1044 + unsigned int query_flags)
1045 +{
1046 + f2fs_getattr(path, stat, request_mask, query_flags);
1047 +
1048 + return fscrypt_symlink_getattr(path, stat);
1049 +}
1050 +
1051 const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
1052 .get_link = f2fs_encrypted_get_link,
1053 - .getattr = f2fs_getattr,
1054 + .getattr = f2fs_encrypted_symlink_getattr,
1055 .setattr = f2fs_setattr,
1056 #ifdef CONFIG_F2FS_FS_XATTR
1057 .listxattr = f2fs_listxattr,
1058 diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
1059 index 8dada89bbe4da..6069c63d833ae 100644
1060 --- a/fs/ubifs/file.c
1061 +++ b/fs/ubifs/file.c
1062 @@ -1629,6 +1629,16 @@ static const char *ubifs_get_link(struct dentry *dentry,
1063 return fscrypt_get_symlink(inode, ui->data, ui->data_len, done);
1064 }
1065
1066 +static int ubifs_symlink_getattr(const struct path *path, struct kstat *stat,
1067 + u32 request_mask, unsigned int query_flags)
1068 +{
1069 + ubifs_getattr(path, stat, request_mask, query_flags);
1070 +
1071 + if (IS_ENCRYPTED(d_inode(path->dentry)))
1072 + return fscrypt_symlink_getattr(path, stat);
1073 + return 0;
1074 +}
1075 +
1076 const struct address_space_operations ubifs_file_address_operations = {
1077 .readpage = ubifs_readpage,
1078 .writepage = ubifs_writepage,
1079 @@ -1654,7 +1664,7 @@ const struct inode_operations ubifs_file_inode_operations = {
1080 const struct inode_operations ubifs_symlink_inode_operations = {
1081 .get_link = ubifs_get_link,
1082 .setattr = ubifs_setattr,
1083 - .getattr = ubifs_getattr,
1084 + .getattr = ubifs_symlink_getattr,
1085 #ifdef CONFIG_UBIFS_FS_XATTR
1086 .listxattr = ubifs_listxattr,
1087 #endif
1088 diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
1089 index 032e5bcf97012..0d1a53d6c52dc 100644
1090 --- a/include/linux/fscrypt.h
1091 +++ b/include/linux/fscrypt.h
1092 @@ -298,6 +298,7 @@ extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
1093 extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
1094 unsigned int max_size,
1095 struct delayed_call *done);
1096 +int fscrypt_symlink_getattr(const struct path *path, struct kstat *stat);
1097 static inline void fscrypt_set_ops(struct super_block *sb,
1098 const struct fscrypt_operations *s_cop)
1099 {
1100 @@ -585,6 +586,12 @@ static inline const char *fscrypt_get_symlink(struct inode *inode,
1101 return ERR_PTR(-EOPNOTSUPP);
1102 }
1103
1104 +static inline int fscrypt_symlink_getattr(const struct path *path,
1105 + struct kstat *stat)
1106 +{
1107 + return -EOPNOTSUPP;
1108 +}
1109 +
1110 static inline void fscrypt_set_ops(struct super_block *sb,
1111 const struct fscrypt_operations *s_cop)
1112 {
1113 diff --git a/kernel/kthread.c b/kernel/kthread.c
1114 index b2bac5d929d2b..63f7eb3c2640d 100644
1115 --- a/kernel/kthread.c
1116 +++ b/kernel/kthread.c
1117 @@ -76,6 +76,25 @@ static inline struct kthread *to_kthread(struct task_struct *k)
1118 return (__force void *)k->set_child_tid;
1119 }
1120
1121 +/*
1122 + * Variant of to_kthread() that doesn't assume @p is a kthread.
1123 + *
1124 + * Per construction; when:
1125 + *
1126 + * (p->flags & PF_KTHREAD) && p->set_child_tid
1127 + *
1128 + * the task is both a kthread and struct kthread is persistent. However
1129 + * PF_KTHREAD on it's own is not, kernel_thread() can exec() (See umh.c and
1130 + * begin_new_exec()).
1131 + */
1132 +static inline struct kthread *__to_kthread(struct task_struct *p)
1133 +{
1134 + void *kthread = (__force void *)p->set_child_tid;
1135 + if (kthread && !(p->flags & PF_KTHREAD))
1136 + kthread = NULL;
1137 + return kthread;
1138 +}
1139 +
1140 void free_kthread_struct(struct task_struct *k)
1141 {
1142 struct kthread *kthread;
1143 @@ -176,10 +195,11 @@ void *kthread_data(struct task_struct *task)
1144 */
1145 void *kthread_probe_data(struct task_struct *task)
1146 {
1147 - struct kthread *kthread = to_kthread(task);
1148 + struct kthread *kthread = __to_kthread(task);
1149 void *data = NULL;
1150
1151 - probe_kernel_read(&data, &kthread->data, sizeof(data));
1152 + if (kthread)
1153 + probe_kernel_read(&data, &kthread->data, sizeof(data));
1154 return data;
1155 }
1156
1157 @@ -490,9 +510,9 @@ void kthread_set_per_cpu(struct task_struct *k, int cpu)
1158 set_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
1159 }
1160
1161 -bool kthread_is_per_cpu(struct task_struct *k)
1162 +bool kthread_is_per_cpu(struct task_struct *p)
1163 {
1164 - struct kthread *kthread = to_kthread(k);
1165 + struct kthread *kthread = __to_kthread(p);
1166 if (!kthread)
1167 return false;
1168
1169 @@ -1272,11 +1292,9 @@ EXPORT_SYMBOL(kthread_destroy_worker);
1170 */
1171 void kthread_associate_blkcg(struct cgroup_subsys_state *css)
1172 {
1173 - struct kthread *kthread;
1174 + struct kthread *kthread = __to_kthread(current);
1175 +
1176
1177 - if (!(current->flags & PF_KTHREAD))
1178 - return;
1179 - kthread = to_kthread(current);
1180 if (!kthread)
1181 return;
1182
1183 @@ -1298,13 +1316,10 @@ EXPORT_SYMBOL(kthread_associate_blkcg);
1184 */
1185 struct cgroup_subsys_state *kthread_blkcg(void)
1186 {
1187 - struct kthread *kthread;
1188 + struct kthread *kthread = __to_kthread(current);
1189
1190 - if (current->flags & PF_KTHREAD) {
1191 - kthread = to_kthread(current);
1192 - if (kthread)
1193 - return kthread->blkcg_css;
1194 - }
1195 + if (kthread)
1196 + return kthread->blkcg_css;
1197 return NULL;
1198 }
1199 EXPORT_SYMBOL(kthread_blkcg);
1200 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
1201 index 74cb20f32f72f..87d9fad9d01d6 100644
1202 --- a/kernel/sched/fair.c
1203 +++ b/kernel/sched/fair.c
1204 @@ -7301,7 +7301,7 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
1205 return 0;
1206
1207 /* Disregard pcpu kthreads; they are where they need to be. */
1208 - if ((p->flags & PF_KTHREAD) && kthread_is_per_cpu(p))
1209 + if (kthread_is_per_cpu(p))
1210 return 0;
1211
1212 if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) {
1213 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
1214 index 4357f5475a504..283ac9d9f6dd0 100644
1215 --- a/mm/page_alloc.c
1216 +++ b/mm/page_alloc.c
1217 @@ -906,7 +906,7 @@ static inline void __free_one_page(struct page *page,
1218 unsigned int max_order;
1219 struct capture_control *capc = task_capc(zone);
1220
1221 - max_order = min_t(unsigned int, MAX_ORDER, pageblock_order + 1);
1222 + max_order = min_t(unsigned int, MAX_ORDER - 1, pageblock_order);
1223
1224 VM_BUG_ON(!zone_is_initialized(zone));
1225 VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page);
1226 @@ -919,7 +919,7 @@ static inline void __free_one_page(struct page *page,
1227 VM_BUG_ON_PAGE(bad_range(zone, page), page);
1228
1229 continue_merging:
1230 - while (order < max_order - 1) {
1231 + while (order < max_order) {
1232 if (compaction_capture(capc, page, order, migratetype)) {
1233 __mod_zone_freepage_state(zone, -(1 << order),
1234 migratetype);
1235 @@ -945,7 +945,7 @@ continue_merging:
1236 pfn = combined_pfn;
1237 order++;
1238 }
1239 - if (max_order < MAX_ORDER) {
1240 + if (order < MAX_ORDER - 1) {
1241 /* If we are here, it means order is >= pageblock_order.
1242 * We want to prevent merge between freepages on isolate
1243 * pageblock and normal pageblock. Without this, pageblock
1244 @@ -966,7 +966,7 @@ continue_merging:
1245 is_migrate_isolate(buddy_mt)))
1246 goto done_merging;
1247 }
1248 - max_order++;
1249 + max_order = order + 1;
1250 goto continue_merging;
1251 }
1252
1253 diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
1254 index c88612242c89f..f86f948a4b4c1 100644
1255 --- a/net/ipv4/icmp.c
1256 +++ b/net/ipv4/icmp.c
1257 @@ -460,6 +460,23 @@ out_bh_enable:
1258 local_bh_enable();
1259 }
1260
1261 +/*
1262 + * The device used for looking up which routing table to use for sending an ICMP
1263 + * error is preferably the source whenever it is set, which should ensure the
1264 + * icmp error can be sent to the source host, else lookup using the routing
1265 + * table of the destination device, else use the main routing table (index 0).
1266 + */
1267 +static struct net_device *icmp_get_route_lookup_dev(struct sk_buff *skb)
1268 +{
1269 + struct net_device *route_lookup_dev = NULL;
1270 +
1271 + if (skb->dev)
1272 + route_lookup_dev = skb->dev;
1273 + else if (skb_dst(skb))
1274 + route_lookup_dev = skb_dst(skb)->dev;
1275 + return route_lookup_dev;
1276 +}
1277 +
1278 static struct rtable *icmp_route_lookup(struct net *net,
1279 struct flowi4 *fl4,
1280 struct sk_buff *skb_in,
1281 @@ -468,6 +485,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
1282 int type, int code,
1283 struct icmp_bxm *param)
1284 {
1285 + struct net_device *route_lookup_dev;
1286 struct rtable *rt, *rt2;
1287 struct flowi4 fl4_dec;
1288 int err;
1289 @@ -482,7 +500,8 @@ static struct rtable *icmp_route_lookup(struct net *net,
1290 fl4->flowi4_proto = IPPROTO_ICMP;
1291 fl4->fl4_icmp_type = type;
1292 fl4->fl4_icmp_code = code;
1293 - fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);
1294 + route_lookup_dev = icmp_get_route_lookup_dev(skb_in);
1295 + fl4->flowi4_oif = l3mdev_master_ifindex(route_lookup_dev);
1296
1297 security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
1298 rt = ip_route_output_key_hash(net, fl4, skb_in);
1299 @@ -506,7 +525,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
1300 if (err)
1301 goto relookup_failed;
1302
1303 - if (inet_addr_type_dev_table(net, skb_dst(skb_in)->dev,
1304 + if (inet_addr_type_dev_table(net, route_lookup_dev,
1305 fl4_dec.saddr) == RTN_LOCAL) {
1306 rt2 = __ip_route_output_key(net, &fl4_dec);
1307 if (IS_ERR(rt2))
1308 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
1309 index d2b1ae83f258d..b1ecc91955172 100644
1310 --- a/net/ipv4/igmp.c
1311 +++ b/net/ipv4/igmp.c
1312 @@ -2730,6 +2730,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
1313 rv = 1;
1314 } else if (im) {
1315 if (src_addr) {
1316 + spin_lock_bh(&im->lock);
1317 for (psf = im->sources; psf; psf = psf->sf_next) {
1318 if (psf->sf_inaddr == src_addr)
1319 break;
1320 @@ -2740,6 +2741,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
1321 im->sfcount[MCAST_EXCLUDE];
1322 else
1323 rv = im->sfcount[MCAST_EXCLUDE] != 0;
1324 + spin_unlock_bh(&im->lock);
1325 } else
1326 rv = 1; /* unspecified source; tentatively allow */
1327 }
1328 diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
1329 index 1662573a40309..fd300c3adddec 100644
1330 --- a/sound/core/pcm_lib.c
1331 +++ b/sound/core/pcm_lib.c
1332 @@ -1736,7 +1736,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
1333 channels = params_channels(params);
1334 frame_size = snd_pcm_format_size(format, channels);
1335 if (frame_size > 0)
1336 - params->fifo_size /= (unsigned)frame_size;
1337 + params->fifo_size /= frame_size;
1338 }
1339 return 0;
1340 }
1341 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
1342 index f486e680aed1d..abe371c01fba2 100644
1343 --- a/sound/pci/hda/patch_realtek.c
1344 +++ b/sound/pci/hda/patch_realtek.c
1345 @@ -9160,6 +9160,16 @@ static int patch_alc269(struct hda_codec *codec)
1346
1347 snd_hda_pick_fixup(codec, alc269_fixup_models,
1348 alc269_fixup_tbl, alc269_fixups);
1349 + /* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
1350 + * the quirk breaks the latter (bko#214101).
1351 + * Clear the wrong entry.
1352 + */
1353 + if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
1354 + codec->core.vendor_id == 0x10ec0294) {
1355 + codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
1356 + codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
1357 + }
1358 +
1359 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
1360 snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
1361 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
1362 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
1363 index 4d20f3f45f7e2..d5d828817c5e8 100644
1364 --- a/sound/usb/quirks.c
1365 +++ b/sound/usb/quirks.c
1366 @@ -1841,6 +1841,7 @@ static const struct registration_quirk registration_quirks[] = {
1367 REG_QUIRK_ENTRY(0x0951, 0x16ed, 2), /* Kingston HyperX Cloud Alpha S */
1368 REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */
1369 REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2), /* JBL Quantum 600 */
1370 + REG_QUIRK_ENTRY(0x0ecb, 0x1f47, 2), /* JBL Quantum 800 */
1371 REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2), /* JBL Quantum 400 */
1372 REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2), /* JBL Quantum 600 */
1373 REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2), /* JBL Quantum 800 */