Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.19 commit in: /
Date: Thu, 10 Jun 2021 11:47:00
Message-Id: 1623325604.6b2a68bf1a50782b86e60e62e8f5b8fa1f87dd59.mpagano@gentoo
1 commit: 6b2a68bf1a50782b86e60e62e8f5b8fa1f87dd59
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jun 10 11:46:44 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 10 11:46:44 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=6b2a68bf
7
8 Linux patch 4.19.194
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1193_linux-4.19.194.patch | 2835 +++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2839 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 757010f..50ca271 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -811,6 +811,10 @@ Patch: 1192_linux-4.19.193.patch
21 From: https://www.kernel.org
22 Desc: Linux 4.19.193
23
24 +Patch: 1193_linux-4.19.194.patch
25 +From: https://www.kernel.org
26 +Desc: Linux 4.19.194
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/1193_linux-4.19.194.patch b/1193_linux-4.19.194.patch
33 new file mode 100644
34 index 0000000..4d073e2
35 --- /dev/null
36 +++ b/1193_linux-4.19.194.patch
37 @@ -0,0 +1,2835 @@
38 +diff --git a/Makefile b/Makefile
39 +index e5d41b6792d7f..8ea26b64b3347 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 19
46 +-SUBLEVEL = 193
47 ++SUBLEVEL = 194
48 + EXTRAVERSION =
49 + NAME = "People's Front"
50 +
51 +diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
52 +index fe97b2ad82b91..98e8bc9195830 100644
53 +--- a/arch/arm64/kvm/sys_regs.c
54 ++++ b/arch/arm64/kvm/sys_regs.c
55 +@@ -426,14 +426,14 @@ static bool trap_bvr(struct kvm_vcpu *vcpu,
56 + struct sys_reg_params *p,
57 + const struct sys_reg_desc *rd)
58 + {
59 +- u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
60 ++ u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
61 +
62 + if (p->is_write)
63 + reg_to_dbg(vcpu, p, dbg_reg);
64 + else
65 + dbg_to_reg(vcpu, p, dbg_reg);
66 +
67 +- trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
68 ++ trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
69 +
70 + return true;
71 + }
72 +@@ -441,7 +441,7 @@ static bool trap_bvr(struct kvm_vcpu *vcpu,
73 + static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
74 + const struct kvm_one_reg *reg, void __user *uaddr)
75 + {
76 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
77 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
78 +
79 + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
80 + return -EFAULT;
81 +@@ -451,7 +451,7 @@ static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
82 + static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
83 + const struct kvm_one_reg *reg, void __user *uaddr)
84 + {
85 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
86 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
87 +
88 + if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
89 + return -EFAULT;
90 +@@ -461,21 +461,21 @@ static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
91 + static void reset_bvr(struct kvm_vcpu *vcpu,
92 + const struct sys_reg_desc *rd)
93 + {
94 +- vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg] = rd->val;
95 ++ vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm] = rd->val;
96 + }
97 +
98 + static bool trap_bcr(struct kvm_vcpu *vcpu,
99 + struct sys_reg_params *p,
100 + const struct sys_reg_desc *rd)
101 + {
102 +- u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
103 ++ u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
104 +
105 + if (p->is_write)
106 + reg_to_dbg(vcpu, p, dbg_reg);
107 + else
108 + dbg_to_reg(vcpu, p, dbg_reg);
109 +
110 +- trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
111 ++ trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
112 +
113 + return true;
114 + }
115 +@@ -483,7 +483,7 @@ static bool trap_bcr(struct kvm_vcpu *vcpu,
116 + static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
117 + const struct kvm_one_reg *reg, void __user *uaddr)
118 + {
119 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
120 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
121 +
122 + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
123 + return -EFAULT;
124 +@@ -494,7 +494,7 @@ static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
125 + static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
126 + const struct kvm_one_reg *reg, void __user *uaddr)
127 + {
128 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
129 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
130 +
131 + if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
132 + return -EFAULT;
133 +@@ -504,22 +504,22 @@ static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
134 + static void reset_bcr(struct kvm_vcpu *vcpu,
135 + const struct sys_reg_desc *rd)
136 + {
137 +- vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg] = rd->val;
138 ++ vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm] = rd->val;
139 + }
140 +
141 + static bool trap_wvr(struct kvm_vcpu *vcpu,
142 + struct sys_reg_params *p,
143 + const struct sys_reg_desc *rd)
144 + {
145 +- u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
146 ++ u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
147 +
148 + if (p->is_write)
149 + reg_to_dbg(vcpu, p, dbg_reg);
150 + else
151 + dbg_to_reg(vcpu, p, dbg_reg);
152 +
153 +- trace_trap_reg(__func__, rd->reg, p->is_write,
154 +- vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]);
155 ++ trace_trap_reg(__func__, rd->CRm, p->is_write,
156 ++ vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]);
157 +
158 + return true;
159 + }
160 +@@ -527,7 +527,7 @@ static bool trap_wvr(struct kvm_vcpu *vcpu,
161 + static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
162 + const struct kvm_one_reg *reg, void __user *uaddr)
163 + {
164 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
165 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
166 +
167 + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
168 + return -EFAULT;
169 +@@ -537,7 +537,7 @@ static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
170 + static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
171 + const struct kvm_one_reg *reg, void __user *uaddr)
172 + {
173 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
174 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
175 +
176 + if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
177 + return -EFAULT;
178 +@@ -547,21 +547,21 @@ static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
179 + static void reset_wvr(struct kvm_vcpu *vcpu,
180 + const struct sys_reg_desc *rd)
181 + {
182 +- vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg] = rd->val;
183 ++ vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm] = rd->val;
184 + }
185 +
186 + static bool trap_wcr(struct kvm_vcpu *vcpu,
187 + struct sys_reg_params *p,
188 + const struct sys_reg_desc *rd)
189 + {
190 +- u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
191 ++ u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
192 +
193 + if (p->is_write)
194 + reg_to_dbg(vcpu, p, dbg_reg);
195 + else
196 + dbg_to_reg(vcpu, p, dbg_reg);
197 +
198 +- trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
199 ++ trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
200 +
201 + return true;
202 + }
203 +@@ -569,7 +569,7 @@ static bool trap_wcr(struct kvm_vcpu *vcpu,
204 + static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
205 + const struct kvm_one_reg *reg, void __user *uaddr)
206 + {
207 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
208 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
209 +
210 + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
211 + return -EFAULT;
212 +@@ -579,7 +579,7 @@ static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
213 + static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
214 + const struct kvm_one_reg *reg, void __user *uaddr)
215 + {
216 +- __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
217 ++ __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
218 +
219 + if (copy_to_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
220 + return -EFAULT;
221 +@@ -589,7 +589,7 @@ static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
222 + static void reset_wcr(struct kvm_vcpu *vcpu,
223 + const struct sys_reg_desc *rd)
224 + {
225 +- vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg] = rd->val;
226 ++ vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm] = rd->val;
227 + }
228 +
229 + static void reset_amair_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
230 +diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
231 +index b5354e216b07c..163c2af44a44f 100644
232 +--- a/arch/x86/include/asm/apic.h
233 ++++ b/arch/x86/include/asm/apic.h
234 +@@ -172,6 +172,7 @@ static inline int apic_is_clustered_box(void)
235 + extern int setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask);
236 + extern void lapic_assign_system_vectors(void);
237 + extern void lapic_assign_legacy_vector(unsigned int isairq, bool replace);
238 ++extern void lapic_update_legacy_vectors(void);
239 + extern void lapic_online(void);
240 + extern void lapic_offline(void);
241 +
242 +diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
243 +index da6b52c709641..9791828f3fcdd 100644
244 +--- a/arch/x86/kernel/apic/apic.c
245 ++++ b/arch/x86/kernel/apic/apic.c
246 +@@ -2507,6 +2507,7 @@ void __init apic_bsp_setup(bool upmode)
247 + end_local_APIC_setup();
248 + irq_remap_enable_fault_handling();
249 + setup_IO_APIC();
250 ++ lapic_update_legacy_vectors();
251 + }
252 +
253 + #ifdef CONFIG_UP_LATE_INIT
254 +diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
255 +index f0d0535e8f345..dc7c759442f17 100644
256 +--- a/arch/x86/kernel/apic/vector.c
257 ++++ b/arch/x86/kernel/apic/vector.c
258 +@@ -682,6 +682,26 @@ void lapic_assign_legacy_vector(unsigned int irq, bool replace)
259 + irq_matrix_assign_system(vector_matrix, ISA_IRQ_VECTOR(irq), replace);
260 + }
261 +
262 ++void __init lapic_update_legacy_vectors(void)
263 ++{
264 ++ unsigned int i;
265 ++
266 ++ if (IS_ENABLED(CONFIG_X86_IO_APIC) && nr_ioapics > 0)
267 ++ return;
268 ++
269 ++ /*
270 ++ * If the IO/APIC is disabled via config, kernel command line or
271 ++ * lack of enumeration then all legacy interrupts are routed
272 ++ * through the PIC. Make sure that they are marked as legacy
273 ++ * vectors. PIC_CASCADE_IRQ has already been marked in
274 ++ * lapic_assign_system_vectors().
275 ++ */
276 ++ for (i = 0; i < nr_legacy_irqs(); i++) {
277 ++ if (i != PIC_CASCADE_IR)
278 ++ lapic_assign_legacy_vector(i, true);
279 ++ }
280 ++}
281 ++
282 + void __init lapic_assign_system_vectors(void)
283 + {
284 + unsigned int i, vector = 0;
285 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
286 +index 8cb9277aa6ff2..ad24e67772778 100644
287 +--- a/arch/x86/kvm/svm.c
288 ++++ b/arch/x86/kvm/svm.c
289 +@@ -4033,7 +4033,7 @@ static int cr_interception(struct vcpu_svm *svm)
290 + err = 0;
291 + if (cr >= 16) { /* mov to cr */
292 + cr -= 16;
293 +- val = kvm_register_read(&svm->vcpu, reg);
294 ++ val = kvm_register_readl(&svm->vcpu, reg);
295 + switch (cr) {
296 + case 0:
297 + if (!check_selective_cr0_intercepted(svm, val))
298 +@@ -4078,7 +4078,7 @@ static int cr_interception(struct vcpu_svm *svm)
299 + kvm_queue_exception(&svm->vcpu, UD_VECTOR);
300 + return 1;
301 + }
302 +- kvm_register_write(&svm->vcpu, reg, val);
303 ++ kvm_register_writel(&svm->vcpu, reg, val);
304 + }
305 + return kvm_complete_insn_gp(&svm->vcpu, err);
306 + }
307 +@@ -4108,13 +4108,13 @@ static int dr_interception(struct vcpu_svm *svm)
308 + if (dr >= 16) { /* mov to DRn */
309 + if (!kvm_require_dr(&svm->vcpu, dr - 16))
310 + return 1;
311 +- val = kvm_register_read(&svm->vcpu, reg);
312 ++ val = kvm_register_readl(&svm->vcpu, reg);
313 + kvm_set_dr(&svm->vcpu, dr - 16, val);
314 + } else {
315 + if (!kvm_require_dr(&svm->vcpu, dr))
316 + return 1;
317 + kvm_get_dr(&svm->vcpu, dr, &val);
318 +- kvm_register_write(&svm->vcpu, reg, val);
319 ++ kvm_register_writel(&svm->vcpu, reg, val);
320 + }
321 +
322 + return kvm_skip_emulated_instruction(&svm->vcpu);
323 +diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
324 +index 92a1468610867..d60e57d14c859 100644
325 +--- a/drivers/acpi/bus.c
326 ++++ b/drivers/acpi/bus.c
327 +@@ -1054,16 +1054,6 @@ void __init acpi_early_init(void)
328 + goto error0;
329 + }
330 +
331 +- if (!acpi_gbl_execute_tables_as_methods &&
332 +- acpi_gbl_group_module_level_code) {
333 +- status = acpi_load_tables();
334 +- if (ACPI_FAILURE(status)) {
335 +- printk(KERN_ERR PREFIX
336 +- "Unable to load the System Description Tables\n");
337 +- goto error0;
338 +- }
339 +- }
340 +-
341 + #ifdef CONFIG_X86
342 + if (!acpi_ioapic) {
343 + /* compatible (0) means level (3) */
344 +@@ -1133,26 +1123,24 @@ static int __init acpi_bus_init(void)
345 +
346 + acpi_os_initialize1();
347 +
348 ++ status = acpi_load_tables();
349 ++ if (ACPI_FAILURE(status)) {
350 ++ printk(KERN_ERR PREFIX
351 ++ "Unable to load the System Description Tables\n");
352 ++ goto error1;
353 ++ }
354 ++
355 + /*
356 +- * ACPI 2.0 requires the EC driver to be loaded and work before
357 +- * the EC device is found in the namespace (i.e. before
358 +- * acpi_load_tables() is called).
359 ++ * ACPI 2.0 requires the EC driver to be loaded and work before the EC
360 ++ * device is found in the namespace.
361 ++ *
362 ++ * This is accomplished by looking for the ECDT table and getting the EC
363 ++ * parameters out of that.
364 + *
365 +- * This is accomplished by looking for the ECDT table, and getting
366 +- * the EC parameters out of that.
367 ++ * Do that before calling acpi_initialize_objects() which may trigger EC
368 ++ * address space accesses.
369 + */
370 +- status = acpi_ec_ecdt_probe();
371 +- /* Ignore result. Not having an ECDT is not fatal. */
372 +-
373 +- if (acpi_gbl_execute_tables_as_methods ||
374 +- !acpi_gbl_group_module_level_code) {
375 +- status = acpi_load_tables();
376 +- if (ACPI_FAILURE(status)) {
377 +- printk(KERN_ERR PREFIX
378 +- "Unable to load the System Description Tables\n");
379 +- goto error1;
380 +- }
381 +- }
382 ++ acpi_ec_ecdt_probe();
383 +
384 + status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE);
385 + if (ACPI_FAILURE(status)) {
386 +diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
387 +index 116989cf3d457..97da083afd324 100644
388 +--- a/drivers/firmware/efi/cper.c
389 ++++ b/drivers/firmware/efi/cper.c
390 +@@ -275,8 +275,7 @@ static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
391 + if (!msg || !(mem->validation_bits & CPER_MEM_VALID_MODULE_HANDLE))
392 + return 0;
393 +
394 +- n = 0;
395 +- len = CPER_REC_LEN - 1;
396 ++ len = CPER_REC_LEN;
397 + dmi_memdev_name(mem->mem_dev_handle, &bank, &device);
398 + if (bank && device)
399 + n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
400 +@@ -285,7 +284,6 @@ static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
401 + "DIMM location: not present. DMI handle: 0x%.4x ",
402 + mem->mem_dev_handle);
403 +
404 +- msg[n] = '\0';
405 + return n;
406 + }
407 +
408 +diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
409 +index aac972b056d91..e0889922cc6d7 100644
410 +--- a/drivers/firmware/efi/memattr.c
411 ++++ b/drivers/firmware/efi/memattr.c
412 +@@ -69,11 +69,6 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
413 + return false;
414 + }
415 +
416 +- if (!(in->attribute & (EFI_MEMORY_RO | EFI_MEMORY_XP))) {
417 +- pr_warn("Entry attributes invalid: RO and XP bits both cleared\n");
418 +- return false;
419 +- }
420 +-
421 + if (PAGE_SIZE > EFI_PAGE_SIZE &&
422 + (!PAGE_ALIGNED(in->phys_addr) ||
423 + !PAGE_ALIGNED(in->num_pages << EFI_PAGE_SHIFT))) {
424 +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
425 +index ccda72f748ee5..c20945ed1dc19 100644
426 +--- a/drivers/hid/hid-multitouch.c
427 ++++ b/drivers/hid/hid-multitouch.c
428 +@@ -588,9 +588,13 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
429 + if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
430 + continue;
431 +
432 +- for (n = 0; n < field->report_count; n++) {
433 +- if (field->usage[n].hid == HID_DG_CONTACTID)
434 +- rdata->is_mt_collection = true;
435 ++ if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) {
436 ++ for (n = 0; n < field->report_count; n++) {
437 ++ if (field->usage[n].hid == HID_DG_CONTACTID) {
438 ++ rdata->is_mt_collection = true;
439 ++ break;
440 ++ }
441 ++ }
442 + }
443 + }
444 +
445 +diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
446 +index 1f8d403d3db4d..19f4b807a5d1d 100644
447 +--- a/drivers/hid/i2c-hid/i2c-hid-core.c
448 ++++ b/drivers/hid/i2c-hid/i2c-hid-core.c
449 +@@ -1160,8 +1160,8 @@ static int i2c_hid_probe(struct i2c_client *client,
450 + hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
451 + hid->product = le16_to_cpu(ihid->hdesc.wProductID);
452 +
453 +- snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX",
454 +- client->name, hid->vendor, hid->product);
455 ++ snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
456 ++ client->name, (u16)hid->vendor, (u16)hid->product);
457 + strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
458 +
459 + ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
460 +diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
461 +index 08174d341f4a1..bc75f1efa0f4c 100644
462 +--- a/drivers/hid/usbhid/hid-pidff.c
463 ++++ b/drivers/hid/usbhid/hid-pidff.c
464 +@@ -1304,6 +1304,7 @@ int hid_pidff_init(struct hid_device *hid)
465 +
466 + if (pidff->pool[PID_DEVICE_MANAGED_POOL].value &&
467 + pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) {
468 ++ error = -EPERM;
469 + hid_notice(hid,
470 + "device does not support device managed pool\n");
471 + goto fail;
472 +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
473 +index 6033970fb667b..ebcf4ea66385a 100644
474 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
475 ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
476 +@@ -5252,7 +5252,6 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
477 +
478 + pf->fw_fid = le16_to_cpu(resp->fid);
479 + pf->port_id = le16_to_cpu(resp->port_id);
480 +- bp->dev->dev_port = pf->port_id;
481 + memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN);
482 + pf->first_vf_id = le16_to_cpu(resp->first_vf_id);
483 + pf->max_vfs = le16_to_cpu(resp->max_vfs);
484 +diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
485 +index a10756f0b0d8b..7f94b445595ce 100644
486 +--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
487 ++++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
488 +@@ -1071,11 +1071,14 @@ static struct sk_buff *ixgbevf_run_xdp(struct ixgbevf_adapter *adapter,
489 + case XDP_TX:
490 + xdp_ring = adapter->xdp_ring[rx_ring->queue_index];
491 + result = ixgbevf_xmit_xdp_ring(xdp_ring, xdp);
492 ++ if (result == IXGBEVF_XDP_CONSUMED)
493 ++ goto out_failure;
494 + break;
495 + default:
496 + bpf_warn_invalid_xdp_action(act);
497 + /* fallthrough */
498 + case XDP_ABORTED:
499 ++out_failure:
500 + trace_xdp_exception(rx_ring->netdev, xdp_prog, act);
501 + /* fallthrough -- handle aborts by dropping packet */
502 + case XDP_DROP:
503 +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
504 +index faca70c3647d3..82ec00a7370d4 100644
505 +--- a/drivers/net/usb/cdc_ncm.c
506 ++++ b/drivers/net/usb/cdc_ncm.c
507 +@@ -1590,6 +1590,15 @@ cdc_ncm_speed_change(struct usbnet *dev,
508 + uint32_t rx_speed = le32_to_cpu(data->DLBitRRate);
509 + uint32_t tx_speed = le32_to_cpu(data->ULBitRate);
510 +
511 ++ /* if the speed hasn't changed, don't report it.
512 ++ * RTL8156 shipped before 2021 sends notification about every 32ms.
513 ++ */
514 ++ if (dev->rx_speed == rx_speed && dev->tx_speed == tx_speed)
515 ++ return;
516 ++
517 ++ dev->rx_speed = rx_speed;
518 ++ dev->tx_speed = tx_speed;
519 ++
520 + /*
521 + * Currently the USB-NET API does not support reporting the actual
522 + * device speed. Do print it instead.
523 +@@ -1633,7 +1642,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
524 + * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be
525 + * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
526 + */
527 +- usbnet_link_change(dev, !!event->wValue, 0);
528 ++ if (netif_carrier_ok(dev->net) != !!event->wValue)
529 ++ usbnet_link_change(dev, !!event->wValue, 0);
530 + break;
531 +
532 + case USB_CDC_NOTIFY_SPEED_CHANGE:
533 +diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
534 +index af26a8a20e0bc..5919ecb7d4b76 100644
535 +--- a/drivers/usb/dwc2/core_intr.c
536 ++++ b/drivers/usb/dwc2/core_intr.c
537 +@@ -700,7 +700,11 @@ static inline void dwc_handle_gpwrdn_disc_det(struct dwc2_hsotg *hsotg,
538 + dwc2_writel(hsotg, gpwrdn_tmp, GPWRDN);
539 +
540 + hsotg->hibernated = 0;
541 ++
542 ++#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || \
543 ++ IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
544 + hsotg->bus_suspended = 0;
545 ++#endif
546 +
547 + if (gpwrdn & GPWRDN_IDSTS) {
548 + hsotg->op_state = OTG_STATE_B_PERIPHERAL;
549 +diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig
550 +index 42dc1d3d71cf0..fcbfd0aacebcd 100644
551 +--- a/drivers/vfio/pci/Kconfig
552 ++++ b/drivers/vfio/pci/Kconfig
553 +@@ -1,6 +1,7 @@
554 + config VFIO_PCI
555 + tristate "VFIO support for PCI devices"
556 + depends on VFIO && PCI && EVENTFD
557 ++ depends on MMU
558 + select VFIO_VIRQFD
559 + select IRQ_BYPASS_MANAGER
560 + help
561 +diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
562 +index a1a26465d224c..86e917f1cc211 100644
563 +--- a/drivers/vfio/pci/vfio_pci_config.c
564 ++++ b/drivers/vfio/pci/vfio_pci_config.c
565 +@@ -1579,7 +1579,7 @@ static int vfio_ecap_init(struct vfio_pci_device *vdev)
566 + if (len == 0xFF) {
567 + len = vfio_ext_cap_len(vdev, ecap, epos);
568 + if (len < 0)
569 +- return ret;
570 ++ return len;
571 + }
572 + }
573 +
574 +diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
575 +index 460760d0becfe..c29fc6844f845 100644
576 +--- a/drivers/vfio/platform/vfio_platform_common.c
577 ++++ b/drivers/vfio/platform/vfio_platform_common.c
578 +@@ -295,7 +295,7 @@ err_irq:
579 + vfio_platform_regions_cleanup(vdev);
580 + err_reg:
581 + mutex_unlock(&driver_lock);
582 +- module_put(THIS_MODULE);
583 ++ module_put(vdev->parent_module);
584 + return ret;
585 + }
586 +
587 +diff --git a/drivers/xen/xen-pciback/vpci.c b/drivers/xen/xen-pciback/vpci.c
588 +index f6ba18191c0f9..30313084f06c1 100644
589 +--- a/drivers/xen/xen-pciback/vpci.c
590 ++++ b/drivers/xen/xen-pciback/vpci.c
591 +@@ -69,7 +69,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
592 + struct pci_dev *dev, int devid,
593 + publish_pci_dev_cb publish_cb)
594 + {
595 +- int err = 0, slot, func = -1;
596 ++ int err = 0, slot, func = PCI_FUNC(dev->devfn);
597 + struct pci_dev_entry *t, *dev_entry;
598 + struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
599 +
600 +@@ -94,23 +94,26 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
601 +
602 + /*
603 + * Keep multi-function devices together on the virtual PCI bus, except
604 +- * virtual functions.
605 ++ * that we want to keep virtual functions at func 0 on their own. They
606 ++ * aren't multi-function devices and hence their presence at func 0
607 ++ * may cause guests to not scan the other functions.
608 + */
609 +- if (!dev->is_virtfn) {
610 ++ if (!dev->is_virtfn || func) {
611 + for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
612 + if (list_empty(&vpci_dev->dev_list[slot]))
613 + continue;
614 +
615 + t = list_entry(list_first(&vpci_dev->dev_list[slot]),
616 + struct pci_dev_entry, list);
617 ++ if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn))
618 ++ continue;
619 +
620 + if (match_slot(dev, t->dev)) {
621 + pr_info("vpci: %s: assign to virtual slot %d func %d\n",
622 + pci_name(dev), slot,
623 +- PCI_FUNC(dev->devfn));
624 ++ func);
625 + list_add_tail(&dev_entry->list,
626 + &vpci_dev->dev_list[slot]);
627 +- func = PCI_FUNC(dev->devfn);
628 + goto unlock;
629 + }
630 + }
631 +@@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
632 + pci_name(dev), slot);
633 + list_add_tail(&dev_entry->list,
634 + &vpci_dev->dev_list[slot]);
635 +- func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
636 + goto unlock;
637 + }
638 + }
639 +diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
640 +index ce5e0f6c6af4f..bf46ed74eae67 100644
641 +--- a/fs/btrfs/extent-tree.c
642 ++++ b/fs/btrfs/extent-tree.c
643 +@@ -1984,16 +1984,20 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr,
644 + for (i = 0; i < bbio->num_stripes; i++, stripe++) {
645 + u64 bytes;
646 + struct request_queue *req_q;
647 ++ struct btrfs_device *device = stripe->dev;
648 +
649 +- if (!stripe->dev->bdev) {
650 ++ if (!device->bdev) {
651 + ASSERT(btrfs_test_opt(fs_info, DEGRADED));
652 + continue;
653 + }
654 +- req_q = bdev_get_queue(stripe->dev->bdev);
655 ++ req_q = bdev_get_queue(device->bdev);
656 + if (!blk_queue_discard(req_q))
657 + continue;
658 +
659 +- ret = btrfs_issue_discard(stripe->dev->bdev,
660 ++ if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state))
661 ++ continue;
662 ++
663 ++ ret = btrfs_issue_discard(device->bdev,
664 + stripe->physical,
665 + stripe->length,
666 + &bytes);
667 +@@ -2501,7 +2505,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
668 + head->qgroup_reserved);
669 + btrfs_delayed_ref_unlock(head);
670 + btrfs_put_delayed_ref_head(head);
671 +- return 0;
672 ++ return ret;
673 + }
674 +
675 + /*
676 +diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
677 +index 1b8a04b767ffd..40db31b69ef7b 100644
678 +--- a/fs/btrfs/file-item.c
679 ++++ b/fs/btrfs/file-item.c
680 +@@ -586,7 +586,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
681 + u64 end_byte = bytenr + len;
682 + u64 csum_end;
683 + struct extent_buffer *leaf;
684 +- int ret;
685 ++ int ret = 0;
686 + u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
687 + int blocksize_bits = fs_info->sb->s_blocksize_bits;
688 +
689 +@@ -605,6 +605,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
690 + path->leave_spinning = 1;
691 + ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
692 + if (ret > 0) {
693 ++ ret = 0;
694 + if (path->slots[0] == 0)
695 + break;
696 + path->slots[0]--;
697 +@@ -661,7 +662,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
698 + ret = btrfs_del_items(trans, root, path,
699 + path->slots[0], del_nr);
700 + if (ret)
701 +- goto out;
702 ++ break;
703 + if (key.offset == bytenr)
704 + break;
705 + } else if (key.offset < bytenr && csum_end > end_byte) {
706 +@@ -705,8 +706,9 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
707 + ret = btrfs_split_item(trans, root, path, &key, offset);
708 + if (ret && ret != -EAGAIN) {
709 + btrfs_abort_transaction(trans, ret);
710 +- goto out;
711 ++ break;
712 + }
713 ++ ret = 0;
714 +
715 + key.offset = end_byte - 1;
716 + } else {
717 +@@ -716,8 +718,6 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
718 + }
719 + btrfs_release_path(path);
720 + }
721 +- ret = 0;
722 +-out:
723 + btrfs_free_path(path);
724 + return ret;
725 + }
726 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
727 +index 8c6f619c9ee6a..bf0e0e3e09c5d 100644
728 +--- a/fs/btrfs/inode.c
729 ++++ b/fs/btrfs/inode.c
730 +@@ -3162,6 +3162,18 @@ out:
731 + if (ret || truncated) {
732 + u64 start, end;
733 +
734 ++ /*
735 ++ * If we failed to finish this ordered extent for any reason we
736 ++ * need to make sure BTRFS_ORDERED_IOERR is set on the ordered
737 ++ * extent, and mark the inode with the error if it wasn't
738 ++ * already set. Any error during writeback would have already
739 ++ * set the mapping error, so we need to set it if we're the ones
740 ++ * marking this ordered extent as failed.
741 ++ */
742 ++ if (ret && !test_and_set_bit(BTRFS_ORDERED_IOERR,
743 ++ &ordered_extent->flags))
744 ++ mapping_set_error(ordered_extent->inode->i_mapping, -EIO);
745 ++
746 + if (truncated)
747 + start = ordered_extent->file_offset + logical_len;
748 + else
749 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
750 +index 1cd610ddbb244..93e59ce001742 100644
751 +--- a/fs/btrfs/tree-log.c
752 ++++ b/fs/btrfs/tree-log.c
753 +@@ -1699,6 +1699,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
754 + break;
755 +
756 + if (ret == 1) {
757 ++ ret = 0;
758 + if (path->slots[0] == 0)
759 + break;
760 + path->slots[0]--;
761 +@@ -1711,17 +1712,19 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
762 +
763 + ret = btrfs_del_item(trans, root, path);
764 + if (ret)
765 +- goto out;
766 ++ break;
767 +
768 + btrfs_release_path(path);
769 + inode = read_one_inode(root, key.offset);
770 +- if (!inode)
771 +- return -EIO;
772 ++ if (!inode) {
773 ++ ret = -EIO;
774 ++ break;
775 ++ }
776 +
777 + ret = fixup_inode_link_count(trans, root, inode);
778 + iput(inode);
779 + if (ret)
780 +- goto out;
781 ++ break;
782 +
783 + /*
784 + * fixup on a directory may create new entries,
785 +@@ -1730,8 +1733,6 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
786 + */
787 + key.offset = (u64)-1;
788 + }
789 +- ret = 0;
790 +-out:
791 + btrfs_release_path(path);
792 + return ret;
793 + }
794 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
795 +index 36708d9d71cbb..093cb675841b0 100644
796 +--- a/fs/ext4/extents.c
797 ++++ b/fs/ext4/extents.c
798 +@@ -3263,7 +3263,10 @@ static int ext4_split_extent_at(handle_t *handle,
799 + ext4_ext_mark_unwritten(ex2);
800 +
801 + err = ext4_ext_insert_extent(handle, inode, ppath, &newex, flags);
802 +- if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) {
803 ++ if (err != -ENOSPC && err != -EDQUOT)
804 ++ goto out;
805 ++
806 ++ if (EXT4_EXT_MAY_ZEROOUT & split_flag) {
807 + if (split_flag & (EXT4_EXT_DATA_VALID1|EXT4_EXT_DATA_VALID2)) {
808 + if (split_flag & EXT4_EXT_DATA_VALID1) {
809 + err = ext4_ext_zeroout(inode, ex2);
810 +@@ -3289,30 +3292,30 @@ static int ext4_split_extent_at(handle_t *handle,
811 + ext4_ext_pblock(&orig_ex));
812 + }
813 +
814 +- if (err)
815 +- goto fix_extent_len;
816 +- /* update the extent length and mark as initialized */
817 +- ex->ee_len = cpu_to_le16(ee_len);
818 +- ext4_ext_try_to_merge(handle, inode, path, ex);
819 +- err = ext4_ext_dirty(handle, inode, path + path->p_depth);
820 +- if (err)
821 +- goto fix_extent_len;
822 +-
823 +- /* update extent status tree */
824 +- err = ext4_zeroout_es(inode, &zero_ex);
825 +-
826 +- goto out;
827 +- } else if (err)
828 +- goto fix_extent_len;
829 +-
830 +-out:
831 +- ext4_ext_show_leaf(inode, path);
832 +- return err;
833 ++ if (!err) {
834 ++ /* update the extent length and mark as initialized */
835 ++ ex->ee_len = cpu_to_le16(ee_len);
836 ++ ext4_ext_try_to_merge(handle, inode, path, ex);
837 ++ err = ext4_ext_dirty(handle, inode, path + path->p_depth);
838 ++ if (!err)
839 ++ /* update extent status tree */
840 ++ err = ext4_zeroout_es(inode, &zero_ex);
841 ++ /* If we failed at this point, we don't know in which
842 ++ * state the extent tree exactly is so don't try to fix
843 ++ * length of the original extent as it may do even more
844 ++ * damage.
845 ++ */
846 ++ goto out;
847 ++ }
848 ++ }
849 +
850 + fix_extent_len:
851 + ex->ee_len = orig_ex.ee_len;
852 + ext4_ext_dirty(handle, inode, path + path->p_depth);
853 + return err;
854 ++out:
855 ++ ext4_ext_show_leaf(inode, path);
856 ++ return err;
857 + }
858 +
859 + /*
860 +diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
861 +index 5c507569ef704..94df697e26385 100644
862 +--- a/fs/ocfs2/file.c
863 ++++ b/fs/ocfs2/file.c
864 +@@ -1863,6 +1863,45 @@ out:
865 + return ret;
866 + }
867 +
868 ++/*
869 ++ * zero out partial blocks of one cluster.
870 ++ *
871 ++ * start: file offset where zero starts, will be made upper block aligned.
872 ++ * len: it will be trimmed to the end of current cluster if "start + len"
873 ++ * is bigger than it.
874 ++ */
875 ++static int ocfs2_zeroout_partial_cluster(struct inode *inode,
876 ++ u64 start, u64 len)
877 ++{
878 ++ int ret;
879 ++ u64 start_block, end_block, nr_blocks;
880 ++ u64 p_block, offset;
881 ++ u32 cluster, p_cluster, nr_clusters;
882 ++ struct super_block *sb = inode->i_sb;
883 ++ u64 end = ocfs2_align_bytes_to_clusters(sb, start);
884 ++
885 ++ if (start + len < end)
886 ++ end = start + len;
887 ++
888 ++ start_block = ocfs2_blocks_for_bytes(sb, start);
889 ++ end_block = ocfs2_blocks_for_bytes(sb, end);
890 ++ nr_blocks = end_block - start_block;
891 ++ if (!nr_blocks)
892 ++ return 0;
893 ++
894 ++ cluster = ocfs2_bytes_to_clusters(sb, start);
895 ++ ret = ocfs2_get_clusters(inode, cluster, &p_cluster,
896 ++ &nr_clusters, NULL);
897 ++ if (ret)
898 ++ return ret;
899 ++ if (!p_cluster)
900 ++ return 0;
901 ++
902 ++ offset = start_block - ocfs2_clusters_to_blocks(sb, cluster);
903 ++ p_block = ocfs2_clusters_to_blocks(sb, p_cluster) + offset;
904 ++ return sb_issue_zeroout(sb, p_block, nr_blocks, GFP_NOFS);
905 ++}
906 ++
907 + /*
908 + * Parts of this function taken from xfs_change_file_space()
909 + */
910 +@@ -1873,7 +1912,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
911 + {
912 + int ret;
913 + s64 llen;
914 +- loff_t size;
915 ++ loff_t size, orig_isize;
916 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
917 + struct buffer_head *di_bh = NULL;
918 + handle_t *handle;
919 +@@ -1904,6 +1943,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
920 + goto out_inode_unlock;
921 + }
922 +
923 ++ orig_isize = i_size_read(inode);
924 + switch (sr->l_whence) {
925 + case 0: /*SEEK_SET*/
926 + break;
927 +@@ -1911,7 +1951,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
928 + sr->l_start += f_pos;
929 + break;
930 + case 2: /*SEEK_END*/
931 +- sr->l_start += i_size_read(inode);
932 ++ sr->l_start += orig_isize;
933 + break;
934 + default:
935 + ret = -EINVAL;
936 +@@ -1965,6 +2005,14 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
937 + default:
938 + ret = -EINVAL;
939 + }
940 ++
941 ++ /* zeroout eof blocks in the cluster. */
942 ++ if (!ret && change_size && orig_isize < size) {
943 ++ ret = ocfs2_zeroout_partial_cluster(inode, orig_isize,
944 ++ size - orig_isize);
945 ++ if (!ret)
946 ++ i_size_write(inode, size);
947 ++ }
948 + up_write(&OCFS2_I(inode)->ip_alloc_sem);
949 + if (ret) {
950 + mlog_errno(ret);
951 +@@ -1981,9 +2029,6 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
952 + goto out_inode_unlock;
953 + }
954 +
955 +- if (change_size && i_size_read(inode) < size)
956 +- i_size_write(inode, size);
957 +-
958 + inode->i_ctime = inode->i_mtime = current_time(inode);
959 + ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
960 + if (ret < 0)
961 +diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
962 +index d8b4d31acd18e..efe30b9b11908 100644
963 +--- a/include/linux/perf_event.h
964 ++++ b/include/linux/perf_event.h
965 +@@ -747,6 +747,11 @@ struct perf_event_context {
966 + int nr_stat;
967 + int nr_freq;
968 + int rotate_disable;
969 ++ /*
970 ++ * Set when nr_events != nr_active, except tolerant to events not
971 ++ * necessary to be active due to scheduling constraints, such as cgroups.
972 ++ */
973 ++ int rotate_necessary;
974 + atomic_t refcount;
975 + struct task_struct *task;
976 +
977 +diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
978 +index e2ec3582e5493..452ca06ed2534 100644
979 +--- a/include/linux/usb/usbnet.h
980 ++++ b/include/linux/usb/usbnet.h
981 +@@ -83,6 +83,8 @@ struct usbnet {
982 + # define EVENT_LINK_CHANGE 11
983 + # define EVENT_SET_RX_MODE 12
984 + # define EVENT_NO_IP_ALIGN 13
985 ++ u32 rx_speed; /* in bps - NOT Mbps */
986 ++ u32 tx_speed; /* in bps - NOT Mbps */
987 + };
988 +
989 + static inline struct usb_driver *driver_of(struct usb_interface *intf)
990 +diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h
991 +index 028b754ae9b17..0baf2e21a533f 100644
992 +--- a/include/net/caif/caif_dev.h
993 ++++ b/include/net/caif/caif_dev.h
994 +@@ -119,7 +119,7 @@ void caif_free_client(struct cflayer *adap_layer);
995 + * The link_support layer is used to add any Link Layer specific
996 + * framing.
997 + */
998 +-void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
999 ++int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1000 + struct cflayer *link_support, int head_room,
1001 + struct cflayer **layer, int (**rcv_func)(
1002 + struct sk_buff *, struct net_device *,
1003 +diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
1004 +index 70bfd017581fb..219094ace893c 100644
1005 +--- a/include/net/caif/cfcnfg.h
1006 ++++ b/include/net/caif/cfcnfg.h
1007 +@@ -62,7 +62,7 @@ void cfcnfg_remove(struct cfcnfg *cfg);
1008 + * @fcs: Specify if checksum is used in CAIF Framing Layer.
1009 + * @head_room: Head space needed by link specific protocol.
1010 + */
1011 +-void
1012 ++int
1013 + cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
1014 + struct net_device *dev, struct cflayer *phy_layer,
1015 + enum cfcnfg_phy_preference pref,
1016 +diff --git a/include/net/caif/cfserl.h b/include/net/caif/cfserl.h
1017 +index b5b020f3c72eb..bc3fae07a25f9 100644
1018 +--- a/include/net/caif/cfserl.h
1019 ++++ b/include/net/caif/cfserl.h
1020 +@@ -9,4 +9,5 @@
1021 + #include <net/caif/caif_layer.h>
1022 +
1023 + struct cflayer *cfserl_create(int instance, bool use_stx);
1024 ++void cfserl_release(struct cflayer *layer);
1025 + #endif
1026 +diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
1027 +index 71ca8c4dc290f..8481fc7676c0b 100644
1028 +--- a/include/uapi/linux/bpf.h
1029 ++++ b/include/uapi/linux/bpf.h
1030 +@@ -228,6 +228,20 @@ enum bpf_attach_type {
1031 + */
1032 + #define BPF_F_STRICT_ALIGNMENT (1U << 0)
1033 +
1034 ++/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
1035 ++ * verifier will allow any alignment whatsoever. On platforms
1036 ++ * with strict alignment requirements for loads ands stores (such
1037 ++ * as sparc and mips) the verifier validates that all loads and
1038 ++ * stores provably follow this requirement. This flag turns that
1039 ++ * checking and enforcement off.
1040 ++ *
1041 ++ * It is mostly used for testing when we want to validate the
1042 ++ * context and memory access aspects of the verifier, but because
1043 ++ * of an unaligned access the alignment check would trigger before
1044 ++ * the one we are interested in.
1045 ++ */
1046 ++#define BPF_F_ANY_ALIGNMENT (1U << 1)
1047 ++
1048 + /* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
1049 + #define BPF_PSEUDO_MAP_FD 1
1050 +
1051 +diff --git a/init/main.c b/init/main.c
1052 +index fdfef08da0c4b..7baad67c2e937 100644
1053 +--- a/init/main.c
1054 ++++ b/init/main.c
1055 +@@ -1124,7 +1124,7 @@ static noinline void __init kernel_init_freeable(void)
1056 + */
1057 + set_mems_allowed(node_states[N_MEMORY]);
1058 +
1059 +- cad_pid = task_pid(current);
1060 ++ cad_pid = get_pid(task_pid(current));
1061 +
1062 + smp_prepare_cpus(setup_max_cpus);
1063 +
1064 +diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
1065 +index 21a366a661acd..353a8d672302b 100644
1066 +--- a/kernel/bpf/syscall.c
1067 ++++ b/kernel/bpf/syscall.c
1068 +@@ -1367,9 +1367,14 @@ static int bpf_prog_load(union bpf_attr *attr)
1069 + if (CHECK_ATTR(BPF_PROG_LOAD))
1070 + return -EINVAL;
1071 +
1072 +- if (attr->prog_flags & ~BPF_F_STRICT_ALIGNMENT)
1073 ++ if (attr->prog_flags & ~(BPF_F_STRICT_ALIGNMENT | BPF_F_ANY_ALIGNMENT))
1074 + return -EINVAL;
1075 +
1076 ++ if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) &&
1077 ++ (attr->prog_flags & BPF_F_ANY_ALIGNMENT) &&
1078 ++ !capable(CAP_SYS_ADMIN))
1079 ++ return -EPERM;
1080 ++
1081 + /* copy eBPF program license from user space */
1082 + if (strncpy_from_user(license, u64_to_user_ptr(attr->license),
1083 + sizeof(license) - 1) < 0)
1084 +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
1085 +index 1f4c88ce58deb..4ce032c4acd03 100644
1086 +--- a/kernel/bpf/verifier.c
1087 ++++ b/kernel/bpf/verifier.c
1088 +@@ -6440,6 +6440,9 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
1089 + if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
1090 + env->strict_alignment = true;
1091 +
1092 ++ if (attr->prog_flags & BPF_F_ANY_ALIGNMENT)
1093 ++ env->strict_alignment = false;
1094 ++
1095 + ret = replace_map_fd_with_map_ptr(env);
1096 + if (ret < 0)
1097 + goto skip_full_check;
1098 +diff --git a/kernel/events/core.c b/kernel/events/core.c
1099 +index b8b74a4a524c1..d3be2cd57af12 100644
1100 +--- a/kernel/events/core.c
1101 ++++ b/kernel/events/core.c
1102 +@@ -2952,6 +2952,12 @@ static void ctx_sched_out(struct perf_event_context *ctx,
1103 + if (!ctx->nr_active || !(is_active & EVENT_ALL))
1104 + return;
1105 +
1106 ++ /*
1107 ++ * If we had been multiplexing, no rotations are necessary, now no events
1108 ++ * are active.
1109 ++ */
1110 ++ ctx->rotate_necessary = 0;
1111 ++
1112 + perf_pmu_disable(ctx->pmu);
1113 + if (is_active & EVENT_PINNED) {
1114 + list_for_each_entry_safe(event, tmp, &ctx->pinned_active, active_list)
1115 +@@ -3319,10 +3325,13 @@ static int flexible_sched_in(struct perf_event *event, void *data)
1116 + return 0;
1117 +
1118 + if (group_can_go_on(event, sid->cpuctx, sid->can_add_hw)) {
1119 +- if (!group_sched_in(event, sid->cpuctx, sid->ctx))
1120 +- list_add_tail(&event->active_list, &sid->ctx->flexible_active);
1121 +- else
1122 ++ int ret = group_sched_in(event, sid->cpuctx, sid->ctx);
1123 ++ if (ret) {
1124 + sid->can_add_hw = 0;
1125 ++ sid->ctx->rotate_necessary = 1;
1126 ++ return 0;
1127 ++ }
1128 ++ list_add_tail(&event->active_list, &sid->ctx->flexible_active);
1129 + }
1130 +
1131 + return 0;
1132 +@@ -3680,34 +3689,39 @@ static void rotate_ctx(struct perf_event_context *ctx, struct perf_event *event)
1133 + perf_event_groups_insert(&ctx->flexible_groups, event);
1134 + }
1135 +
1136 ++/* pick an event from the flexible_groups to rotate */
1137 + static inline struct perf_event *
1138 +-ctx_first_active(struct perf_event_context *ctx)
1139 ++ctx_event_to_rotate(struct perf_event_context *ctx)
1140 + {
1141 +- return list_first_entry_or_null(&ctx->flexible_active,
1142 +- struct perf_event, active_list);
1143 ++ struct perf_event *event;
1144 ++
1145 ++ /* pick the first active flexible event */
1146 ++ event = list_first_entry_or_null(&ctx->flexible_active,
1147 ++ struct perf_event, active_list);
1148 ++
1149 ++ /* if no active flexible event, pick the first event */
1150 ++ if (!event) {
1151 ++ event = rb_entry_safe(rb_first(&ctx->flexible_groups.tree),
1152 ++ typeof(*event), group_node);
1153 ++ }
1154 ++
1155 ++ return event;
1156 + }
1157 +
1158 + static bool perf_rotate_context(struct perf_cpu_context *cpuctx)
1159 + {
1160 + struct perf_event *cpu_event = NULL, *task_event = NULL;
1161 +- bool cpu_rotate = false, task_rotate = false;
1162 +- struct perf_event_context *ctx = NULL;
1163 ++ struct perf_event_context *task_ctx = NULL;
1164 ++ int cpu_rotate, task_rotate;
1165 +
1166 + /*
1167 + * Since we run this from IRQ context, nobody can install new
1168 + * events, thus the event count values are stable.
1169 + */
1170 +
1171 +- if (cpuctx->ctx.nr_events) {
1172 +- if (cpuctx->ctx.nr_events != cpuctx->ctx.nr_active)
1173 +- cpu_rotate = true;
1174 +- }
1175 +-
1176 +- ctx = cpuctx->task_ctx;
1177 +- if (ctx && ctx->nr_events) {
1178 +- if (ctx->nr_events != ctx->nr_active)
1179 +- task_rotate = true;
1180 +- }
1181 ++ cpu_rotate = cpuctx->ctx.rotate_necessary;
1182 ++ task_ctx = cpuctx->task_ctx;
1183 ++ task_rotate = task_ctx ? task_ctx->rotate_necessary : 0;
1184 +
1185 + if (!(cpu_rotate || task_rotate))
1186 + return false;
1187 +@@ -3716,25 +3730,25 @@ static bool perf_rotate_context(struct perf_cpu_context *cpuctx)
1188 + perf_pmu_disable(cpuctx->ctx.pmu);
1189 +
1190 + if (task_rotate)
1191 +- task_event = ctx_first_active(ctx);
1192 ++ task_event = ctx_event_to_rotate(task_ctx);
1193 + if (cpu_rotate)
1194 +- cpu_event = ctx_first_active(&cpuctx->ctx);
1195 ++ cpu_event = ctx_event_to_rotate(&cpuctx->ctx);
1196 +
1197 + /*
1198 + * As per the order given at ctx_resched() first 'pop' task flexible
1199 + * and then, if needed CPU flexible.
1200 + */
1201 +- if (task_event || (ctx && cpu_event))
1202 +- ctx_sched_out(ctx, cpuctx, EVENT_FLEXIBLE);
1203 ++ if (task_event || (task_ctx && cpu_event))
1204 ++ ctx_sched_out(task_ctx, cpuctx, EVENT_FLEXIBLE);
1205 + if (cpu_event)
1206 + cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
1207 +
1208 + if (task_event)
1209 +- rotate_ctx(ctx, task_event);
1210 ++ rotate_ctx(task_ctx, task_event);
1211 + if (cpu_event)
1212 + rotate_ctx(&cpuctx->ctx, cpu_event);
1213 +
1214 +- perf_event_sched_in(cpuctx, ctx, current);
1215 ++ perf_event_sched_in(cpuctx, task_ctx, current);
1216 +
1217 + perf_pmu_enable(cpuctx->ctx.pmu);
1218 + perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
1219 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
1220 +index 80392cdd5f3b2..f06687053f96b 100644
1221 +--- a/kernel/sched/fair.c
1222 ++++ b/kernel/sched/fair.c
1223 +@@ -6154,6 +6154,7 @@ static inline int select_idle_smt(struct task_struct *p, struct sched_domain *sd
1224 + */
1225 + static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int target)
1226 + {
1227 ++ struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask);
1228 + struct sched_domain *this_sd;
1229 + u64 avg_cost, avg_idle;
1230 + u64 time, cost;
1231 +@@ -6184,11 +6185,11 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
1232 +
1233 + time = local_clock();
1234 +
1235 +- for_each_cpu_wrap(cpu, sched_domain_span(sd), target) {
1236 ++ cpumask_and(cpus, sched_domain_span(sd), &p->cpus_allowed);
1237 ++
1238 ++ for_each_cpu_wrap(cpu, cpus, target) {
1239 + if (!--nr)
1240 + return -1;
1241 +- if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
1242 +- continue;
1243 + if (available_idle_cpu(cpu))
1244 + break;
1245 + }
1246 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
1247 +index 2f769a6615688..c69f12e4c1499 100644
1248 +--- a/mm/hugetlb.c
1249 ++++ b/mm/hugetlb.c
1250 +@@ -4154,10 +4154,20 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
1251 + struct page *page;
1252 +
1253 + if (!*pagep) {
1254 +- ret = -ENOMEM;
1255 ++ /* If a page already exists, then it's UFFDIO_COPY for
1256 ++ * a non-missing case. Return -EEXIST.
1257 ++ */
1258 ++ if (vm_shared &&
1259 ++ hugetlbfs_pagecache_present(h, dst_vma, dst_addr)) {
1260 ++ ret = -EEXIST;
1261 ++ goto out;
1262 ++ }
1263 ++
1264 + page = alloc_huge_page(dst_vma, dst_addr, 0);
1265 +- if (IS_ERR(page))
1266 ++ if (IS_ERR(page)) {
1267 ++ ret = -ENOMEM;
1268 + goto out;
1269 ++ }
1270 +
1271 + ret = copy_huge_page_from_user(page,
1272 + (const void __user *) src_addr,
1273 +diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
1274 +index 04d6f50798c98..219cdbb476fb7 100644
1275 +--- a/net/bluetooth/hci_core.c
1276 ++++ b/net/bluetooth/hci_core.c
1277 +@@ -1498,8 +1498,13 @@ static int hci_dev_do_open(struct hci_dev *hdev)
1278 + } else {
1279 + /* Init failed, cleanup */
1280 + flush_work(&hdev->tx_work);
1281 +- flush_work(&hdev->cmd_work);
1282 ++
1283 ++ /* Since hci_rx_work() is possible to awake new cmd_work
1284 ++ * it should be flushed first to avoid unexpected call of
1285 ++ * hci_cmd_work()
1286 ++ */
1287 + flush_work(&hdev->rx_work);
1288 ++ flush_work(&hdev->cmd_work);
1289 +
1290 + skb_queue_purge(&hdev->cmd_q);
1291 + skb_queue_purge(&hdev->rx_q);
1292 +diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
1293 +index e506c51ff7653..06156de24c50b 100644
1294 +--- a/net/bluetooth/hci_sock.c
1295 ++++ b/net/bluetooth/hci_sock.c
1296 +@@ -755,7 +755,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
1297 + /* Detach sockets from device */
1298 + read_lock(&hci_sk_list.lock);
1299 + sk_for_each(sk, &hci_sk_list.head) {
1300 +- bh_lock_sock_nested(sk);
1301 ++ lock_sock(sk);
1302 + if (hci_pi(sk)->hdev == hdev) {
1303 + hci_pi(sk)->hdev = NULL;
1304 + sk->sk_err = EPIPE;
1305 +@@ -764,7 +764,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
1306 +
1307 + hci_dev_put(hdev);
1308 + }
1309 +- bh_unlock_sock(sk);
1310 ++ release_sock(sk);
1311 + }
1312 + read_unlock(&hci_sk_list.lock);
1313 + }
1314 +diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
1315 +index 711d7156efd8b..cc305d84168f4 100644
1316 +--- a/net/caif/caif_dev.c
1317 ++++ b/net/caif/caif_dev.c
1318 +@@ -303,7 +303,7 @@ static void dev_flowctrl(struct net_device *dev, int on)
1319 + caifd_put(caifd);
1320 + }
1321 +
1322 +-void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1323 ++int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1324 + struct cflayer *link_support, int head_room,
1325 + struct cflayer **layer,
1326 + int (**rcv_func)(struct sk_buff *, struct net_device *,
1327 +@@ -314,11 +314,12 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1328 + enum cfcnfg_phy_preference pref;
1329 + struct cfcnfg *cfg = get_cfcnfg(dev_net(dev));
1330 + struct caif_device_entry_list *caifdevs;
1331 ++ int res;
1332 +
1333 + caifdevs = caif_device_list(dev_net(dev));
1334 + caifd = caif_device_alloc(dev);
1335 + if (!caifd)
1336 +- return;
1337 ++ return -ENOMEM;
1338 + *layer = &caifd->layer;
1339 + spin_lock_init(&caifd->flow_lock);
1340 +
1341 +@@ -339,7 +340,7 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1342 + strlcpy(caifd->layer.name, dev->name,
1343 + sizeof(caifd->layer.name));
1344 + caifd->layer.transmit = transmit;
1345 +- cfcnfg_add_phy_layer(cfg,
1346 ++ res = cfcnfg_add_phy_layer(cfg,
1347 + dev,
1348 + &caifd->layer,
1349 + pref,
1350 +@@ -349,6 +350,7 @@ void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
1351 + mutex_unlock(&caifdevs->lock);
1352 + if (rcv_func)
1353 + *rcv_func = receive;
1354 ++ return res;
1355 + }
1356 + EXPORT_SYMBOL(caif_enroll_dev);
1357 +
1358 +@@ -363,6 +365,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
1359 + struct cflayer *layer, *link_support;
1360 + int head_room = 0;
1361 + struct caif_device_entry_list *caifdevs;
1362 ++ int res;
1363 +
1364 + cfg = get_cfcnfg(dev_net(dev));
1365 + caifdevs = caif_device_list(dev_net(dev));
1366 +@@ -388,8 +391,10 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
1367 + break;
1368 + }
1369 + }
1370 +- caif_enroll_dev(dev, caifdev, link_support, head_room,
1371 ++ res = caif_enroll_dev(dev, caifdev, link_support, head_room,
1372 + &layer, NULL);
1373 ++ if (res)
1374 ++ cfserl_release(link_support);
1375 + caifdev->flowctrl = dev_flowctrl;
1376 + break;
1377 +
1378 +diff --git a/net/caif/caif_usb.c b/net/caif/caif_usb.c
1379 +index 1a082a946045e..76d49a1bc6f68 100644
1380 +--- a/net/caif/caif_usb.c
1381 ++++ b/net/caif/caif_usb.c
1382 +@@ -116,6 +116,11 @@ static struct cflayer *cfusbl_create(int phyid, u8 ethaddr[ETH_ALEN],
1383 + return (struct cflayer *) this;
1384 + }
1385 +
1386 ++static void cfusbl_release(struct cflayer *layer)
1387 ++{
1388 ++ kfree(layer);
1389 ++}
1390 ++
1391 + static struct packet_type caif_usb_type __read_mostly = {
1392 + .type = cpu_to_be16(ETH_P_802_EX1),
1393 + };
1394 +@@ -128,6 +133,7 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
1395 + struct cflayer *layer, *link_support;
1396 + struct usbnet *usbnet;
1397 + struct usb_device *usbdev;
1398 ++ int res;
1399 +
1400 + /* Check whether we have a NCM device, and find its VID/PID. */
1401 + if (!(dev->dev.parent && dev->dev.parent->driver &&
1402 +@@ -170,8 +176,11 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
1403 + if (dev->num_tx_queues > 1)
1404 + pr_warn("USB device uses more than one tx queue\n");
1405 +
1406 +- caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN,
1407 ++ res = caif_enroll_dev(dev, &common, link_support, CFUSB_MAX_HEADLEN,
1408 + &layer, &caif_usb_type.func);
1409 ++ if (res)
1410 ++ goto err;
1411 ++
1412 + if (!pack_added)
1413 + dev_add_pack(&caif_usb_type);
1414 + pack_added = true;
1415 +@@ -179,6 +188,9 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
1416 + strlcpy(layer->name, dev->name, sizeof(layer->name));
1417 +
1418 + return 0;
1419 ++err:
1420 ++ cfusbl_release(link_support);
1421 ++ return res;
1422 + }
1423 +
1424 + static struct notifier_block caif_device_notifier = {
1425 +diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
1426 +index 8f00bea093b94..b456b79abd3b7 100644
1427 +--- a/net/caif/cfcnfg.c
1428 ++++ b/net/caif/cfcnfg.c
1429 +@@ -450,7 +450,7 @@ unlock:
1430 + rcu_read_unlock();
1431 + }
1432 +
1433 +-void
1434 ++int
1435 + cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
1436 + struct net_device *dev, struct cflayer *phy_layer,
1437 + enum cfcnfg_phy_preference pref,
1438 +@@ -459,7 +459,7 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
1439 + {
1440 + struct cflayer *frml;
1441 + struct cfcnfg_phyinfo *phyinfo = NULL;
1442 +- int i;
1443 ++ int i, res = 0;
1444 + u8 phyid;
1445 +
1446 + mutex_lock(&cnfg->lock);
1447 +@@ -473,12 +473,15 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
1448 + goto got_phyid;
1449 + }
1450 + pr_warn("Too many CAIF Link Layers (max 6)\n");
1451 ++ res = -EEXIST;
1452 + goto out;
1453 +
1454 + got_phyid:
1455 + phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC);
1456 +- if (!phyinfo)
1457 ++ if (!phyinfo) {
1458 ++ res = -ENOMEM;
1459 + goto out_err;
1460 ++ }
1461 +
1462 + phy_layer->id = phyid;
1463 + phyinfo->pref = pref;
1464 +@@ -492,8 +495,10 @@ got_phyid:
1465 +
1466 + frml = cffrml_create(phyid, fcs);
1467 +
1468 +- if (!frml)
1469 ++ if (!frml) {
1470 ++ res = -ENOMEM;
1471 + goto out_err;
1472 ++ }
1473 + phyinfo->frm_layer = frml;
1474 + layer_set_up(frml, cnfg->mux);
1475 +
1476 +@@ -511,11 +516,12 @@ got_phyid:
1477 + list_add_rcu(&phyinfo->node, &cnfg->phys);
1478 + out:
1479 + mutex_unlock(&cnfg->lock);
1480 +- return;
1481 ++ return res;
1482 +
1483 + out_err:
1484 + kfree(phyinfo);
1485 + mutex_unlock(&cnfg->lock);
1486 ++ return res;
1487 + }
1488 + EXPORT_SYMBOL(cfcnfg_add_phy_layer);
1489 +
1490 +diff --git a/net/caif/cfserl.c b/net/caif/cfserl.c
1491 +index ce60f06d76de3..af1e1e36dc90a 100644
1492 +--- a/net/caif/cfserl.c
1493 ++++ b/net/caif/cfserl.c
1494 +@@ -31,6 +31,11 @@ static int cfserl_transmit(struct cflayer *layr, struct cfpkt *pkt);
1495 + static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
1496 + int phyid);
1497 +
1498 ++void cfserl_release(struct cflayer *layer)
1499 ++{
1500 ++ kfree(layer);
1501 ++}
1502 ++
1503 + struct cflayer *cfserl_create(int instance, bool use_stx)
1504 + {
1505 + struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
1506 +diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
1507 +index c0930b9fe848b..7531cb1665d2b 100644
1508 +--- a/net/ieee802154/nl-mac.c
1509 ++++ b/net/ieee802154/nl-mac.c
1510 +@@ -688,8 +688,10 @@ int ieee802154_llsec_getparams(struct sk_buff *skb, struct genl_info *info)
1511 + nla_put_u8(msg, IEEE802154_ATTR_LLSEC_SECLEVEL, params.out_level) ||
1512 + nla_put_u32(msg, IEEE802154_ATTR_LLSEC_FRAME_COUNTER,
1513 + be32_to_cpu(params.frame_counter)) ||
1514 +- ieee802154_llsec_fill_key_id(msg, &params.out_key))
1515 ++ ieee802154_llsec_fill_key_id(msg, &params.out_key)) {
1516 ++ rc = -ENOBUFS;
1517 + goto out_free;
1518 ++ }
1519 +
1520 + dev_put(dev);
1521 +
1522 +diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
1523 +index b231e40f006a6..ca1dd9ff07aba 100644
1524 +--- a/net/ieee802154/nl-phy.c
1525 ++++ b/net/ieee802154/nl-phy.c
1526 +@@ -249,8 +249,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
1527 + }
1528 +
1529 + if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) ||
1530 +- nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name))
1531 ++ nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) {
1532 ++ rc = -EMSGSIZE;
1533 + goto nla_put_failure;
1534 ++ }
1535 + dev_put(dev);
1536 +
1537 + wpan_phy_put(phy);
1538 +diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
1539 +index 3ad1de081e3c7..6208fa09fe713 100644
1540 +--- a/net/netfilter/ipvs/ip_vs_ctl.c
1541 ++++ b/net/netfilter/ipvs/ip_vs_ctl.c
1542 +@@ -1269,7 +1269,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u,
1543 + ip_vs_addr_copy(svc->af, &svc->addr, &u->addr);
1544 + svc->port = u->port;
1545 + svc->fwmark = u->fwmark;
1546 +- svc->flags = u->flags;
1547 ++ svc->flags = u->flags & ~IP_VS_SVC_F_HASHED;
1548 + svc->timeout = u->timeout * HZ;
1549 + svc->netmask = u->netmask;
1550 + svc->ipvs = ipvs;
1551 +diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
1552 +index ddcb1b6074745..c8b0f1122c44d 100644
1553 +--- a/net/netfilter/nfnetlink_cthelper.c
1554 ++++ b/net/netfilter/nfnetlink_cthelper.c
1555 +@@ -381,10 +381,14 @@ static int
1556 + nfnl_cthelper_update(const struct nlattr * const tb[],
1557 + struct nf_conntrack_helper *helper)
1558 + {
1559 ++ u32 size;
1560 + int ret;
1561 +
1562 +- if (tb[NFCTH_PRIV_DATA_LEN])
1563 +- return -EBUSY;
1564 ++ if (tb[NFCTH_PRIV_DATA_LEN]) {
1565 ++ size = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN]));
1566 ++ if (size != helper->data_len)
1567 ++ return -EBUSY;
1568 ++ }
1569 +
1570 + if (tb[NFCTH_POLICY]) {
1571 + ret = nfnl_cthelper_update_policy(helper, tb[NFCTH_POLICY]);
1572 +diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
1573 +index 59de4f54dd18c..23f7116d122a2 100644
1574 +--- a/net/nfc/llcp_sock.c
1575 ++++ b/net/nfc/llcp_sock.c
1576 +@@ -122,6 +122,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
1577 + if (!llcp_sock->service_name) {
1578 + nfc_llcp_local_put(llcp_sock->local);
1579 + llcp_sock->local = NULL;
1580 ++ llcp_sock->dev = NULL;
1581 + ret = -ENOMEM;
1582 + goto put_dev;
1583 + }
1584 +@@ -131,6 +132,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
1585 + llcp_sock->local = NULL;
1586 + kfree(llcp_sock->service_name);
1587 + llcp_sock->service_name = NULL;
1588 ++ llcp_sock->dev = NULL;
1589 + ret = -EADDRINUSE;
1590 + goto put_dev;
1591 + }
1592 +diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
1593 +index 2649a0a0d45e0..e1006ed4d90ab 100644
1594 +--- a/net/tipc/bearer.c
1595 ++++ b/net/tipc/bearer.c
1596 +@@ -231,7 +231,8 @@ void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)
1597 + */
1598 + static int tipc_enable_bearer(struct net *net, const char *name,
1599 + u32 disc_domain, u32 prio,
1600 +- struct nlattr *attr[])
1601 ++ struct nlattr *attr[],
1602 ++ struct netlink_ext_ack *extack)
1603 + {
1604 + struct tipc_net *tn = tipc_net(net);
1605 + struct tipc_bearer_names b_names;
1606 +@@ -242,20 +243,24 @@ static int tipc_enable_bearer(struct net *net, const char *name,
1607 + int bearer_id = 0;
1608 + int res = -EINVAL;
1609 + char *errstr = "";
1610 ++ u32 i;
1611 +
1612 + if (!bearer_name_validate(name, &b_names)) {
1613 + errstr = "illegal name";
1614 ++ NL_SET_ERR_MSG(extack, "Illegal name");
1615 + goto rejected;
1616 + }
1617 +
1618 + if (prio > TIPC_MAX_LINK_PRI && prio != TIPC_MEDIA_LINK_PRI) {
1619 + errstr = "illegal priority";
1620 ++ NL_SET_ERR_MSG(extack, "Illegal priority");
1621 + goto rejected;
1622 + }
1623 +
1624 + m = tipc_media_find(b_names.media_name);
1625 + if (!m) {
1626 + errstr = "media not registered";
1627 ++ NL_SET_ERR_MSG(extack, "Media not registered");
1628 + goto rejected;
1629 + }
1630 +
1631 +@@ -263,33 +268,43 @@ static int tipc_enable_bearer(struct net *net, const char *name,
1632 + prio = m->priority;
1633 +
1634 + /* Check new bearer vs existing ones and find free bearer id if any */
1635 +- while (bearer_id < MAX_BEARERS) {
1636 +- b = rtnl_dereference(tn->bearer_list[bearer_id]);
1637 +- if (!b)
1638 +- break;
1639 ++ bearer_id = MAX_BEARERS;
1640 ++ i = MAX_BEARERS;
1641 ++ while (i-- != 0) {
1642 ++ b = rtnl_dereference(tn->bearer_list[i]);
1643 ++ if (!b) {
1644 ++ bearer_id = i;
1645 ++ continue;
1646 ++ }
1647 + if (!strcmp(name, b->name)) {
1648 + errstr = "already enabled";
1649 ++ NL_SET_ERR_MSG(extack, "Already enabled");
1650 + goto rejected;
1651 + }
1652 +- bearer_id++;
1653 +- if (b->priority != prio)
1654 +- continue;
1655 +- if (++with_this_prio <= 2)
1656 +- continue;
1657 +- pr_warn("Bearer <%s>: already 2 bearers with priority %u\n",
1658 +- name, prio);
1659 +- if (prio == TIPC_MIN_LINK_PRI) {
1660 +- errstr = "cannot adjust to lower";
1661 +- goto rejected;
1662 ++
1663 ++ if (b->priority == prio &&
1664 ++ (++with_this_prio > 2)) {
1665 ++ pr_warn("Bearer <%s>: already 2 bearers with priority %u\n",
1666 ++ name, prio);
1667 ++
1668 ++ if (prio == TIPC_MIN_LINK_PRI) {
1669 ++ errstr = "cannot adjust to lower";
1670 ++ NL_SET_ERR_MSG(extack, "Cannot adjust to lower");
1671 ++ goto rejected;
1672 ++ }
1673 ++
1674 ++ pr_warn("Bearer <%s>: trying with adjusted priority\n",
1675 ++ name);
1676 ++ prio--;
1677 ++ bearer_id = MAX_BEARERS;
1678 ++ i = MAX_BEARERS;
1679 ++ with_this_prio = 1;
1680 + }
1681 +- pr_warn("Bearer <%s>: trying with adjusted priority\n", name);
1682 +- prio--;
1683 +- bearer_id = 0;
1684 +- with_this_prio = 1;
1685 + }
1686 +
1687 + if (bearer_id >= MAX_BEARERS) {
1688 + errstr = "max 3 bearers permitted";
1689 ++ NL_SET_ERR_MSG(extack, "Max 3 bearers permitted");
1690 + goto rejected;
1691 + }
1692 +
1693 +@@ -303,6 +318,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
1694 + if (res) {
1695 + kfree(b);
1696 + errstr = "failed to enable media";
1697 ++ NL_SET_ERR_MSG(extack, "Failed to enable media");
1698 + goto rejected;
1699 + }
1700 +
1701 +@@ -318,6 +334,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
1702 + if (res) {
1703 + bearer_disable(net, b);
1704 + errstr = "failed to create discoverer";
1705 ++ NL_SET_ERR_MSG(extack, "Failed to create discoverer");
1706 + goto rejected;
1707 + }
1708 +
1709 +@@ -795,6 +812,7 @@ int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info)
1710 + bearer = tipc_bearer_find(net, name);
1711 + if (!bearer) {
1712 + err = -EINVAL;
1713 ++ NL_SET_ERR_MSG(info->extack, "Bearer not found");
1714 + goto err_out;
1715 + }
1716 +
1717 +@@ -834,8 +852,10 @@ int __tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info)
1718 + name = nla_data(attrs[TIPC_NLA_BEARER_NAME]);
1719 +
1720 + bearer = tipc_bearer_find(net, name);
1721 +- if (!bearer)
1722 ++ if (!bearer) {
1723 ++ NL_SET_ERR_MSG(info->extack, "Bearer not found");
1724 + return -EINVAL;
1725 ++ }
1726 +
1727 + bearer_disable(net, bearer);
1728 +
1729 +@@ -893,7 +913,8 @@ int __tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
1730 + prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
1731 + }
1732 +
1733 +- return tipc_enable_bearer(net, bearer, domain, prio, attrs);
1734 ++ return tipc_enable_bearer(net, bearer, domain, prio, attrs,
1735 ++ info->extack);
1736 + }
1737 +
1738 + int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info)
1739 +@@ -932,6 +953,7 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
1740 + b = tipc_bearer_find(net, name);
1741 + if (!b) {
1742 + rtnl_unlock();
1743 ++ NL_SET_ERR_MSG(info->extack, "Bearer not found");
1744 + return -EINVAL;
1745 + }
1746 +
1747 +@@ -972,8 +994,10 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
1748 + name = nla_data(attrs[TIPC_NLA_BEARER_NAME]);
1749 +
1750 + b = tipc_bearer_find(net, name);
1751 +- if (!b)
1752 ++ if (!b) {
1753 ++ NL_SET_ERR_MSG(info->extack, "Bearer not found");
1754 + return -EINVAL;
1755 ++ }
1756 +
1757 + if (attrs[TIPC_NLA_BEARER_PROP]) {
1758 + struct nlattr *props[TIPC_NLA_PROP_MAX + 1];
1759 +@@ -992,12 +1016,18 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
1760 + if (props[TIPC_NLA_PROP_WIN])
1761 + b->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
1762 + if (props[TIPC_NLA_PROP_MTU]) {
1763 +- if (b->media->type_id != TIPC_MEDIA_TYPE_UDP)
1764 ++ if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) {
1765 ++ NL_SET_ERR_MSG(info->extack,
1766 ++ "MTU property is unsupported");
1767 + return -EINVAL;
1768 ++ }
1769 + #ifdef CONFIG_TIPC_MEDIA_UDP
1770 + if (tipc_udp_mtu_bad(nla_get_u32
1771 +- (props[TIPC_NLA_PROP_MTU])))
1772 ++ (props[TIPC_NLA_PROP_MTU]))) {
1773 ++ NL_SET_ERR_MSG(info->extack,
1774 ++ "MTU value is out-of-range");
1775 + return -EINVAL;
1776 ++ }
1777 + b->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
1778 + tipc_node_apply_property(net, b, TIPC_NLA_PROP_MTU);
1779 + #endif
1780 +@@ -1125,6 +1155,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
1781 + rtnl_lock();
1782 + media = tipc_media_find(name);
1783 + if (!media) {
1784 ++ NL_SET_ERR_MSG(info->extack, "Media not found");
1785 + err = -EINVAL;
1786 + goto err_out;
1787 + }
1788 +@@ -1161,9 +1192,10 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
1789 + name = nla_data(attrs[TIPC_NLA_MEDIA_NAME]);
1790 +
1791 + m = tipc_media_find(name);
1792 +- if (!m)
1793 ++ if (!m) {
1794 ++ NL_SET_ERR_MSG(info->extack, "Media not found");
1795 + return -EINVAL;
1796 +-
1797 ++ }
1798 + if (attrs[TIPC_NLA_MEDIA_PROP]) {
1799 + struct nlattr *props[TIPC_NLA_PROP_MAX + 1];
1800 +
1801 +@@ -1179,12 +1211,18 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
1802 + if (props[TIPC_NLA_PROP_WIN])
1803 + m->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
1804 + if (props[TIPC_NLA_PROP_MTU]) {
1805 +- if (m->type_id != TIPC_MEDIA_TYPE_UDP)
1806 ++ if (m->type_id != TIPC_MEDIA_TYPE_UDP) {
1807 ++ NL_SET_ERR_MSG(info->extack,
1808 ++ "MTU property is unsupported");
1809 + return -EINVAL;
1810 ++ }
1811 + #ifdef CONFIG_TIPC_MEDIA_UDP
1812 + if (tipc_udp_mtu_bad(nla_get_u32
1813 +- (props[TIPC_NLA_PROP_MTU])))
1814 ++ (props[TIPC_NLA_PROP_MTU]))) {
1815 ++ NL_SET_ERR_MSG(info->extack,
1816 ++ "MTU value is out-of-range");
1817 + return -EINVAL;
1818 ++ }
1819 + m->mtu = nla_get_u32(props[TIPC_NLA_PROP_MTU]);
1820 + #endif
1821 + }
1822 +diff --git a/net/wireless/core.h b/net/wireless/core.h
1823 +index f5d58652108dd..5f177dad2fa80 100644
1824 +--- a/net/wireless/core.h
1825 ++++ b/net/wireless/core.h
1826 +@@ -404,6 +404,8 @@ void cfg80211_sme_abandon_assoc(struct wireless_dev *wdev);
1827 +
1828 + /* internal helpers */
1829 + bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher);
1830 ++bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev,
1831 ++ int key_idx, bool pairwise);
1832 + int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
1833 + struct key_params *params, int key_idx,
1834 + bool pairwise, const u8 *mac_addr);
1835 +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
1836 +index 5f0605275fa39..04c4fd376e1d5 100644
1837 +--- a/net/wireless/nl80211.c
1838 ++++ b/net/wireless/nl80211.c
1839 +@@ -3624,9 +3624,6 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
1840 + if (err)
1841 + return err;
1842 +
1843 +- if (key.idx < 0)
1844 +- return -EINVAL;
1845 +-
1846 + if (info->attrs[NL80211_ATTR_MAC])
1847 + mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1848 +
1849 +@@ -3642,6 +3639,10 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
1850 + key.type != NL80211_KEYTYPE_GROUP)
1851 + return -EINVAL;
1852 +
1853 ++ if (!cfg80211_valid_key_idx(rdev, key.idx,
1854 ++ key.type == NL80211_KEYTYPE_PAIRWISE))
1855 ++ return -EINVAL;
1856 ++
1857 + if (!rdev->ops->del_key)
1858 + return -EOPNOTSUPP;
1859 +
1860 +diff --git a/net/wireless/util.c b/net/wireless/util.c
1861 +index 6f9cff2ee7953..c4536468dfbea 100644
1862 +--- a/net/wireless/util.c
1863 ++++ b/net/wireless/util.c
1864 +@@ -214,11 +214,48 @@ bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher)
1865 + return false;
1866 + }
1867 +
1868 ++static bool
1869 ++cfg80211_igtk_cipher_supported(struct cfg80211_registered_device *rdev)
1870 ++{
1871 ++ struct wiphy *wiphy = &rdev->wiphy;
1872 ++ int i;
1873 ++
1874 ++ for (i = 0; i < wiphy->n_cipher_suites; i++) {
1875 ++ switch (wiphy->cipher_suites[i]) {
1876 ++ case WLAN_CIPHER_SUITE_AES_CMAC:
1877 ++ case WLAN_CIPHER_SUITE_BIP_CMAC_256:
1878 ++ case WLAN_CIPHER_SUITE_BIP_GMAC_128:
1879 ++ case WLAN_CIPHER_SUITE_BIP_GMAC_256:
1880 ++ return true;
1881 ++ }
1882 ++ }
1883 ++
1884 ++ return false;
1885 ++}
1886 ++
1887 ++bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev,
1888 ++ int key_idx, bool pairwise)
1889 ++{
1890 ++ int max_key_idx;
1891 ++
1892 ++ if (pairwise)
1893 ++ max_key_idx = 3;
1894 ++ else if (cfg80211_igtk_cipher_supported(rdev))
1895 ++ max_key_idx = 5;
1896 ++ else
1897 ++ max_key_idx = 3;
1898 ++
1899 ++ if (key_idx < 0 || key_idx > max_key_idx)
1900 ++ return false;
1901 ++
1902 ++ return true;
1903 ++}
1904 ++
1905 + int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
1906 + struct key_params *params, int key_idx,
1907 + bool pairwise, const u8 *mac_addr)
1908 + {
1909 +- if (key_idx < 0 || key_idx > 5)
1910 ++ if (!cfg80211_valid_key_idx(rdev, key_idx, pairwise))
1911 + return -EINVAL;
1912 +
1913 + if (!pairwise && mac_addr && !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
1914 +diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
1915 +index 2719bb2596530..a760e130bd0d6 100644
1916 +--- a/samples/vfio-mdev/mdpy-fb.c
1917 ++++ b/samples/vfio-mdev/mdpy-fb.c
1918 +@@ -117,22 +117,27 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
1919 + if (format != DRM_FORMAT_XRGB8888) {
1920 + pci_err(pdev, "format mismatch (0x%x != 0x%x)\n",
1921 + format, DRM_FORMAT_XRGB8888);
1922 +- return -EINVAL;
1923 ++ ret = -EINVAL;
1924 ++ goto err_release_regions;
1925 + }
1926 + if (width < 100 || width > 10000) {
1927 + pci_err(pdev, "width (%d) out of range\n", width);
1928 +- return -EINVAL;
1929 ++ ret = -EINVAL;
1930 ++ goto err_release_regions;
1931 + }
1932 + if (height < 100 || height > 10000) {
1933 + pci_err(pdev, "height (%d) out of range\n", height);
1934 +- return -EINVAL;
1935 ++ ret = -EINVAL;
1936 ++ goto err_release_regions;
1937 + }
1938 + pci_info(pdev, "mdpy found: %dx%d framebuffer\n",
1939 + width, height);
1940 +
1941 + info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
1942 +- if (!info)
1943 ++ if (!info) {
1944 ++ ret = -ENOMEM;
1945 + goto err_release_regions;
1946 ++ }
1947 + pci_set_drvdata(pdev, info);
1948 + par = info->par;
1949 +
1950 +diff --git a/sound/core/timer.c b/sound/core/timer.c
1951 +index b5dc51030316a..b4fe1324b56c2 100644
1952 +--- a/sound/core/timer.c
1953 ++++ b/sound/core/timer.c
1954 +@@ -500,9 +500,10 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
1955 + return;
1956 + if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
1957 + return;
1958 ++ event += 10; /* convert to SNDRV_TIMER_EVENT_MXXX */
1959 + list_for_each_entry(ts, &ti->slave_active_head, active_list)
1960 + if (ts->ccallback)
1961 +- ts->ccallback(ts, event + 100, &tstamp, resolution);
1962 ++ ts->ccallback(ts, event, &tstamp, resolution);
1963 + }
1964 +
1965 + /* start/continue a master timer */
1966 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
1967 +index f9ebbee3824bb..42c30fba699fb 100644
1968 +--- a/sound/pci/hda/patch_realtek.c
1969 ++++ b/sound/pci/hda/patch_realtek.c
1970 +@@ -7095,6 +7095,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
1971 + SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
1972 + SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
1973 + SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1974 ++ SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1975 + SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1976 + SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
1977 + SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_LED),
1978 +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
1979 +index 169679419b398..a74e07eff60c3 100644
1980 +--- a/sound/usb/mixer_quirks.c
1981 ++++ b/sound/usb/mixer_quirks.c
1982 +@@ -1708,7 +1708,7 @@ static struct snd_kcontrol_new snd_microii_mixer_spdif[] = {
1983 + static int snd_microii_controls_create(struct usb_mixer_interface *mixer)
1984 + {
1985 + int err, i;
1986 +- const static usb_mixer_elem_resume_func_t resume_funcs[] = {
1987 ++ static const usb_mixer_elem_resume_func_t resume_funcs[] = {
1988 + snd_microii_spdif_default_update,
1989 + NULL,
1990 + snd_microii_spdif_switch_update
1991 +diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
1992 +index 13944978ada5b..9e060c6a01ac2 100644
1993 +--- a/tools/include/uapi/linux/bpf.h
1994 ++++ b/tools/include/uapi/linux/bpf.h
1995 +@@ -226,6 +226,20 @@ enum bpf_attach_type {
1996 + */
1997 + #define BPF_F_STRICT_ALIGNMENT (1U << 0)
1998 +
1999 ++/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
2000 ++ * verifier will allow any alignment whatsoever. On platforms
2001 ++ * with strict alignment requirements for loads ands stores (such
2002 ++ * as sparc and mips) the verifier validates that all loads and
2003 ++ * stores provably follow this requirement. This flag turns that
2004 ++ * checking and enforcement off.
2005 ++ *
2006 ++ * It is mostly used for testing when we want to validate the
2007 ++ * context and memory access aspects of the verifier, but because
2008 ++ * of an unaligned access the alignment check would trigger before
2009 ++ * the one we are interested in.
2010 ++ */
2011 ++#define BPF_F_ANY_ALIGNMENT (1U << 1)
2012 ++
2013 + /* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */
2014 + #define BPF_PSEUDO_MAP_FD 1
2015 +
2016 +diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
2017 +index 482025b728399..f28ae6a68697a 100644
2018 +--- a/tools/lib/bpf/bpf.c
2019 ++++ b/tools/lib/bpf/bpf.c
2020 +@@ -261,9 +261,9 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
2021 + }
2022 +
2023 + int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
2024 +- size_t insns_cnt, int strict_alignment,
2025 +- const char *license, __u32 kern_version,
2026 +- char *log_buf, size_t log_buf_sz, int log_level)
2027 ++ size_t insns_cnt, __u32 prog_flags, const char *license,
2028 ++ __u32 kern_version, char *log_buf, size_t log_buf_sz,
2029 ++ int log_level)
2030 + {
2031 + union bpf_attr attr;
2032 +
2033 +@@ -277,7 +277,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
2034 + attr.log_level = log_level;
2035 + log_buf[0] = 0;
2036 + attr.kern_version = kern_version;
2037 +- attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0;
2038 ++ attr.prog_flags = prog_flags;
2039 +
2040 + return sys_bpf_prog_load(&attr, sizeof(attr));
2041 + }
2042 +diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
2043 +index c3145ab3bdcac..7f2e947d940c1 100644
2044 +--- a/tools/lib/bpf/bpf.h
2045 ++++ b/tools/lib/bpf/bpf.h
2046 +@@ -79,7 +79,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
2047 + __u32 kern_version, char *log_buf,
2048 + size_t log_buf_sz);
2049 + int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
2050 +- size_t insns_cnt, int strict_alignment,
2051 ++ size_t insns_cnt, __u32 prog_flags,
2052 + const char *license, __u32 kern_version,
2053 + char *log_buf, size_t log_buf_sz, int log_level);
2054 +
2055 +diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/test_align.c
2056 +index 5f377ec53f2f8..3c789d03b629d 100644
2057 +--- a/tools/testing/selftests/bpf/test_align.c
2058 ++++ b/tools/testing/selftests/bpf/test_align.c
2059 +@@ -620,8 +620,8 @@ static int do_test_single(struct bpf_align_test *test)
2060 +
2061 + prog_len = probe_filter_length(prog);
2062 + fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
2063 +- prog, prog_len, 1, "GPL", 0,
2064 +- bpf_vlog, sizeof(bpf_vlog), 2);
2065 ++ prog, prog_len, BPF_F_STRICT_ALIGNMENT,
2066 ++ "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 2);
2067 + if (fd_prog < 0 && test->result != REJECT) {
2068 + printf("Failed to load program.\n");
2069 + printf("%s", bpf_vlog);
2070 +diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
2071 +index e1e4b6ab83f74..b44324530948d 100644
2072 +--- a/tools/testing/selftests/bpf/test_verifier.c
2073 ++++ b/tools/testing/selftests/bpf/test_verifier.c
2074 +@@ -70,7 +70,7 @@ struct bpf_test {
2075 + int fixup_cgroup_storage[MAX_FIXUPS];
2076 + const char *errstr;
2077 + const char *errstr_unpriv;
2078 +- uint32_t retval;
2079 ++ uint32_t retval, retval_unpriv;
2080 + enum {
2081 + UNDEF,
2082 + ACCEPT,
2083 +@@ -963,6 +963,7 @@ static struct bpf_test tests[] = {
2084 + .errstr_unpriv = "attempt to corrupt spilled",
2085 + .errstr = "corrupted spill",
2086 + .result = REJECT,
2087 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2088 + },
2089 + {
2090 + "invalid src register in STX",
2091 +@@ -1777,6 +1778,7 @@ static struct bpf_test tests[] = {
2092 + .errstr = "invalid bpf_context access",
2093 + .result = REJECT,
2094 + .prog_type = BPF_PROG_TYPE_SK_MSG,
2095 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2096 + },
2097 + {
2098 + "invalid read past end of SK_MSG",
2099 +@@ -1799,6 +1801,7 @@ static struct bpf_test tests[] = {
2100 + .errstr = "invalid bpf_context access",
2101 + .result = REJECT,
2102 + .prog_type = BPF_PROG_TYPE_SK_MSG,
2103 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2104 + },
2105 + {
2106 + "direct packet read for SK_MSG",
2107 +@@ -2175,6 +2178,7 @@ static struct bpf_test tests[] = {
2108 + },
2109 + .errstr = "invalid bpf_context access",
2110 + .result = REJECT,
2111 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2112 + },
2113 + {
2114 + "check skb->hash half load not permitted, unaligned 3",
2115 +@@ -2191,6 +2195,7 @@ static struct bpf_test tests[] = {
2116 + },
2117 + .errstr = "invalid bpf_context access",
2118 + .result = REJECT,
2119 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2120 + },
2121 + {
2122 + "check cb access: half, wrong type",
2123 +@@ -2986,6 +2991,8 @@ static struct bpf_test tests[] = {
2124 + .fixup_prog1 = { 2 },
2125 + .result = ACCEPT,
2126 + .retval = 42,
2127 ++ /* Verifier rewrite for unpriv skips tail call here. */
2128 ++ .retval_unpriv = 2,
2129 + },
2130 + {
2131 + "stack pointer arithmetic",
2132 +@@ -3149,6 +3156,7 @@ static struct bpf_test tests[] = {
2133 + .result = REJECT,
2134 + .errstr = "R0 invalid mem access 'inv'",
2135 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2136 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2137 + },
2138 + {
2139 + "raw_stack: skb_load_bytes, spilled regs corruption 2",
2140 +@@ -3179,6 +3187,7 @@ static struct bpf_test tests[] = {
2141 + .result = REJECT,
2142 + .errstr = "R3 invalid mem access 'inv'",
2143 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2144 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2145 + },
2146 + {
2147 + "raw_stack: skb_load_bytes, spilled regs + data",
2148 +@@ -3678,6 +3687,7 @@ static struct bpf_test tests[] = {
2149 + .errstr = "R2 invalid mem access 'inv'",
2150 + .result = REJECT,
2151 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2152 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2153 + },
2154 + {
2155 + "direct packet access: test16 (arith on data_end)",
2156 +@@ -3780,6 +3790,7 @@ static struct bpf_test tests[] = {
2157 + },
2158 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2159 + .result = ACCEPT,
2160 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2161 + },
2162 + {
2163 + "direct packet access: test21 (x += pkt_ptr, 2)",
2164 +@@ -3805,6 +3816,7 @@ static struct bpf_test tests[] = {
2165 + },
2166 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2167 + .result = ACCEPT,
2168 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2169 + },
2170 + {
2171 + "direct packet access: test22 (x += pkt_ptr, 3)",
2172 +@@ -3835,6 +3847,7 @@ static struct bpf_test tests[] = {
2173 + },
2174 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2175 + .result = ACCEPT,
2176 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2177 + },
2178 + {
2179 + "direct packet access: test23 (x += pkt_ptr, 4)",
2180 +@@ -3861,6 +3874,7 @@ static struct bpf_test tests[] = {
2181 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2182 + .result = REJECT,
2183 + .errstr = "invalid access to packet, off=0 size=8, R5(id=1,off=0,r=0)",
2184 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2185 + },
2186 + {
2187 + "direct packet access: test24 (x += pkt_ptr, 5)",
2188 +@@ -3886,6 +3900,7 @@ static struct bpf_test tests[] = {
2189 + },
2190 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2191 + .result = ACCEPT,
2192 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2193 + },
2194 + {
2195 + "direct packet access: test25 (marking on <, good access)",
2196 +@@ -4765,6 +4780,7 @@ static struct bpf_test tests[] = {
2197 + .result = REJECT,
2198 + .errstr = "invalid access to map value, value_size=64 off=-2 size=4",
2199 + .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
2200 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2201 + },
2202 + {
2203 + "invalid cgroup storage access 5",
2204 +@@ -4798,6 +4814,7 @@ static struct bpf_test tests[] = {
2205 + .fixup_cgroup_storage = { 1 },
2206 + .result = REJECT,
2207 + .errstr = "get_local_storage() doesn't support non-zero flags",
2208 ++ .errstr_unpriv = "R2 leaks addr into helper function",
2209 + .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
2210 + },
2211 + {
2212 +@@ -6430,6 +6447,7 @@ static struct bpf_test tests[] = {
2213 + .errstr = "invalid mem access 'inv'",
2214 + .result = REJECT,
2215 + .result_unpriv = REJECT,
2216 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2217 + },
2218 + {
2219 + "map element value illegal alu op, 5",
2220 +@@ -6452,6 +6470,7 @@ static struct bpf_test tests[] = {
2221 + .fixup_map2 = { 3 },
2222 + .errstr = "R0 invalid mem access 'inv'",
2223 + .result = REJECT,
2224 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2225 + },
2226 + {
2227 + "map element value is preserved across register spilling",
2228 +@@ -6945,6 +6964,7 @@ static struct bpf_test tests[] = {
2229 + .result = ACCEPT,
2230 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2231 + .retval = 0 /* csum_diff of 64-byte packet */,
2232 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2233 + },
2234 + {
2235 + "helper access to variable memory: size = 0 not allowed on NULL (!ARG_PTR_TO_MEM_OR_NULL)",
2236 +@@ -8911,6 +8931,7 @@ static struct bpf_test tests[] = {
2237 + },
2238 + .result = ACCEPT,
2239 + .prog_type = BPF_PROG_TYPE_XDP,
2240 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2241 + },
2242 + {
2243 + "XDP pkt read, pkt_data' > pkt_end, bad access 1",
2244 +@@ -8948,6 +8969,7 @@ static struct bpf_test tests[] = {
2245 + .errstr = "R1 offset is outside of the packet",
2246 + .result = REJECT,
2247 + .prog_type = BPF_PROG_TYPE_XDP,
2248 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2249 + },
2250 + {
2251 + "XDP pkt read, pkt_end > pkt_data', good access",
2252 +@@ -8986,6 +9008,7 @@ static struct bpf_test tests[] = {
2253 + .errstr = "R1 offset is outside of the packet",
2254 + .result = REJECT,
2255 + .prog_type = BPF_PROG_TYPE_XDP,
2256 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2257 + },
2258 + {
2259 + "XDP pkt read, pkt_end > pkt_data', bad access 2",
2260 +@@ -9004,6 +9027,7 @@ static struct bpf_test tests[] = {
2261 + .errstr = "R1 offset is outside of the packet",
2262 + .result = REJECT,
2263 + .prog_type = BPF_PROG_TYPE_XDP,
2264 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2265 + },
2266 + {
2267 + "XDP pkt read, pkt_data' < pkt_end, good access",
2268 +@@ -9042,6 +9066,7 @@ static struct bpf_test tests[] = {
2269 + .errstr = "R1 offset is outside of the packet",
2270 + .result = REJECT,
2271 + .prog_type = BPF_PROG_TYPE_XDP,
2272 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2273 + },
2274 + {
2275 + "XDP pkt read, pkt_data' < pkt_end, bad access 2",
2276 +@@ -9060,6 +9085,7 @@ static struct bpf_test tests[] = {
2277 + .errstr = "R1 offset is outside of the packet",
2278 + .result = REJECT,
2279 + .prog_type = BPF_PROG_TYPE_XDP,
2280 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2281 + },
2282 + {
2283 + "XDP pkt read, pkt_end < pkt_data', good access",
2284 +@@ -9077,6 +9103,7 @@ static struct bpf_test tests[] = {
2285 + },
2286 + .result = ACCEPT,
2287 + .prog_type = BPF_PROG_TYPE_XDP,
2288 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2289 + },
2290 + {
2291 + "XDP pkt read, pkt_end < pkt_data', bad access 1",
2292 +@@ -9114,6 +9141,7 @@ static struct bpf_test tests[] = {
2293 + .errstr = "R1 offset is outside of the packet",
2294 + .result = REJECT,
2295 + .prog_type = BPF_PROG_TYPE_XDP,
2296 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2297 + },
2298 + {
2299 + "XDP pkt read, pkt_data' >= pkt_end, good access",
2300 +@@ -9150,6 +9178,7 @@ static struct bpf_test tests[] = {
2301 + .errstr = "R1 offset is outside of the packet",
2302 + .result = REJECT,
2303 + .prog_type = BPF_PROG_TYPE_XDP,
2304 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2305 + },
2306 + {
2307 + "XDP pkt read, pkt_data' >= pkt_end, bad access 2",
2308 +@@ -9187,6 +9216,7 @@ static struct bpf_test tests[] = {
2309 + },
2310 + .result = ACCEPT,
2311 + .prog_type = BPF_PROG_TYPE_XDP,
2312 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2313 + },
2314 + {
2315 + "XDP pkt read, pkt_end >= pkt_data', bad access 1",
2316 +@@ -9225,6 +9255,7 @@ static struct bpf_test tests[] = {
2317 + .errstr = "R1 offset is outside of the packet",
2318 + .result = REJECT,
2319 + .prog_type = BPF_PROG_TYPE_XDP,
2320 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2321 + },
2322 + {
2323 + "XDP pkt read, pkt_data' <= pkt_end, good access",
2324 +@@ -9243,6 +9274,7 @@ static struct bpf_test tests[] = {
2325 + },
2326 + .result = ACCEPT,
2327 + .prog_type = BPF_PROG_TYPE_XDP,
2328 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2329 + },
2330 + {
2331 + "XDP pkt read, pkt_data' <= pkt_end, bad access 1",
2332 +@@ -9281,6 +9313,7 @@ static struct bpf_test tests[] = {
2333 + .errstr = "R1 offset is outside of the packet",
2334 + .result = REJECT,
2335 + .prog_type = BPF_PROG_TYPE_XDP,
2336 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2337 + },
2338 + {
2339 + "XDP pkt read, pkt_end <= pkt_data', good access",
2340 +@@ -9317,6 +9350,7 @@ static struct bpf_test tests[] = {
2341 + .errstr = "R1 offset is outside of the packet",
2342 + .result = REJECT,
2343 + .prog_type = BPF_PROG_TYPE_XDP,
2344 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2345 + },
2346 + {
2347 + "XDP pkt read, pkt_end <= pkt_data', bad access 2",
2348 +@@ -9353,6 +9387,7 @@ static struct bpf_test tests[] = {
2349 + },
2350 + .result = ACCEPT,
2351 + .prog_type = BPF_PROG_TYPE_XDP,
2352 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2353 + },
2354 + {
2355 + "XDP pkt read, pkt_meta' > pkt_data, bad access 1",
2356 +@@ -9390,6 +9425,7 @@ static struct bpf_test tests[] = {
2357 + .errstr = "R1 offset is outside of the packet",
2358 + .result = REJECT,
2359 + .prog_type = BPF_PROG_TYPE_XDP,
2360 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2361 + },
2362 + {
2363 + "XDP pkt read, pkt_data > pkt_meta', good access",
2364 +@@ -9428,6 +9464,7 @@ static struct bpf_test tests[] = {
2365 + .errstr = "R1 offset is outside of the packet",
2366 + .result = REJECT,
2367 + .prog_type = BPF_PROG_TYPE_XDP,
2368 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2369 + },
2370 + {
2371 + "XDP pkt read, pkt_data > pkt_meta', bad access 2",
2372 +@@ -9446,6 +9483,7 @@ static struct bpf_test tests[] = {
2373 + .errstr = "R1 offset is outside of the packet",
2374 + .result = REJECT,
2375 + .prog_type = BPF_PROG_TYPE_XDP,
2376 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2377 + },
2378 + {
2379 + "XDP pkt read, pkt_meta' < pkt_data, good access",
2380 +@@ -9484,6 +9522,7 @@ static struct bpf_test tests[] = {
2381 + .errstr = "R1 offset is outside of the packet",
2382 + .result = REJECT,
2383 + .prog_type = BPF_PROG_TYPE_XDP,
2384 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2385 + },
2386 + {
2387 + "XDP pkt read, pkt_meta' < pkt_data, bad access 2",
2388 +@@ -9502,6 +9541,7 @@ static struct bpf_test tests[] = {
2389 + .errstr = "R1 offset is outside of the packet",
2390 + .result = REJECT,
2391 + .prog_type = BPF_PROG_TYPE_XDP,
2392 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2393 + },
2394 + {
2395 + "XDP pkt read, pkt_data < pkt_meta', good access",
2396 +@@ -9519,6 +9559,7 @@ static struct bpf_test tests[] = {
2397 + },
2398 + .result = ACCEPT,
2399 + .prog_type = BPF_PROG_TYPE_XDP,
2400 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2401 + },
2402 + {
2403 + "XDP pkt read, pkt_data < pkt_meta', bad access 1",
2404 +@@ -9556,6 +9597,7 @@ static struct bpf_test tests[] = {
2405 + .errstr = "R1 offset is outside of the packet",
2406 + .result = REJECT,
2407 + .prog_type = BPF_PROG_TYPE_XDP,
2408 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2409 + },
2410 + {
2411 + "XDP pkt read, pkt_meta' >= pkt_data, good access",
2412 +@@ -9592,6 +9634,7 @@ static struct bpf_test tests[] = {
2413 + .errstr = "R1 offset is outside of the packet",
2414 + .result = REJECT,
2415 + .prog_type = BPF_PROG_TYPE_XDP,
2416 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2417 + },
2418 + {
2419 + "XDP pkt read, pkt_meta' >= pkt_data, bad access 2",
2420 +@@ -9629,6 +9672,7 @@ static struct bpf_test tests[] = {
2421 + },
2422 + .result = ACCEPT,
2423 + .prog_type = BPF_PROG_TYPE_XDP,
2424 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2425 + },
2426 + {
2427 + "XDP pkt read, pkt_data >= pkt_meta', bad access 1",
2428 +@@ -9667,6 +9711,7 @@ static struct bpf_test tests[] = {
2429 + .errstr = "R1 offset is outside of the packet",
2430 + .result = REJECT,
2431 + .prog_type = BPF_PROG_TYPE_XDP,
2432 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2433 + },
2434 + {
2435 + "XDP pkt read, pkt_meta' <= pkt_data, good access",
2436 +@@ -9685,6 +9730,7 @@ static struct bpf_test tests[] = {
2437 + },
2438 + .result = ACCEPT,
2439 + .prog_type = BPF_PROG_TYPE_XDP,
2440 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2441 + },
2442 + {
2443 + "XDP pkt read, pkt_meta' <= pkt_data, bad access 1",
2444 +@@ -9723,6 +9769,7 @@ static struct bpf_test tests[] = {
2445 + .errstr = "R1 offset is outside of the packet",
2446 + .result = REJECT,
2447 + .prog_type = BPF_PROG_TYPE_XDP,
2448 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2449 + },
2450 + {
2451 + "XDP pkt read, pkt_data <= pkt_meta', good access",
2452 +@@ -9759,6 +9806,7 @@ static struct bpf_test tests[] = {
2453 + .errstr = "R1 offset is outside of the packet",
2454 + .result = REJECT,
2455 + .prog_type = BPF_PROG_TYPE_XDP,
2456 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2457 + },
2458 + {
2459 + "XDP pkt read, pkt_data <= pkt_meta', bad access 2",
2460 +@@ -9873,6 +9921,7 @@ static struct bpf_test tests[] = {
2461 + .errstr_unpriv = "R1 has pointer with unsupported alu operation",
2462 + .errstr = "dereference of modified ctx ptr",
2463 + .result = REJECT,
2464 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2465 + },
2466 + {
2467 + "check deducing bounds from const, 8",
2468 +@@ -9887,6 +9936,7 @@ static struct bpf_test tests[] = {
2469 + .errstr_unpriv = "R1 has pointer with unsupported alu operation",
2470 + .errstr = "dereference of modified ctx ptr",
2471 + .result = REJECT,
2472 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2473 + },
2474 + {
2475 + "check deducing bounds from const, 9",
2476 +@@ -10362,6 +10412,7 @@ static struct bpf_test tests[] = {
2477 + .result = REJECT,
2478 + .errstr = "R6 invalid mem access 'inv'",
2479 + .prog_type = BPF_PROG_TYPE_XDP,
2480 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2481 + },
2482 + {
2483 + "calls: two calls with args",
2484 +@@ -11227,6 +11278,7 @@ static struct bpf_test tests[] = {
2485 + .fixup_map1 = { 12, 22 },
2486 + .result = REJECT,
2487 + .errstr = "invalid access to map value, value_size=8 off=2 size=8",
2488 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2489 + },
2490 + {
2491 + "calls: two calls that receive map_value via arg=ptr_stack_of_caller. test2",
2492 +@@ -11370,6 +11422,7 @@ static struct bpf_test tests[] = {
2493 + .fixup_map1 = { 12, 22 },
2494 + .result = REJECT,
2495 + .errstr = "invalid access to map value, value_size=8 off=2 size=8",
2496 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2497 + },
2498 + {
2499 + "calls: two calls that receive map_value_ptr_or_null via arg. test1",
2500 +@@ -11541,6 +11594,7 @@ static struct bpf_test tests[] = {
2501 + .result = ACCEPT,
2502 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2503 + .retval = POINTER_VALUE,
2504 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2505 + },
2506 + {
2507 + "calls: pkt_ptr spill into caller stack 2",
2508 +@@ -11572,6 +11626,7 @@ static struct bpf_test tests[] = {
2509 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2510 + .errstr = "invalid access to packet",
2511 + .result = REJECT,
2512 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2513 + },
2514 + {
2515 + "calls: pkt_ptr spill into caller stack 3",
2516 +@@ -11607,6 +11662,7 @@ static struct bpf_test tests[] = {
2517 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2518 + .result = ACCEPT,
2519 + .retval = 1,
2520 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2521 + },
2522 + {
2523 + "calls: pkt_ptr spill into caller stack 4",
2524 +@@ -11641,6 +11697,7 @@ static struct bpf_test tests[] = {
2525 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2526 + .result = ACCEPT,
2527 + .retval = 1,
2528 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2529 + },
2530 + {
2531 + "calls: pkt_ptr spill into caller stack 5",
2532 +@@ -11674,6 +11731,7 @@ static struct bpf_test tests[] = {
2533 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2534 + .errstr = "same insn cannot be used with different",
2535 + .result = REJECT,
2536 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2537 + },
2538 + {
2539 + "calls: pkt_ptr spill into caller stack 6",
2540 +@@ -11709,6 +11767,7 @@ static struct bpf_test tests[] = {
2541 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2542 + .errstr = "R4 invalid mem access",
2543 + .result = REJECT,
2544 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2545 + },
2546 + {
2547 + "calls: pkt_ptr spill into caller stack 7",
2548 +@@ -11743,6 +11802,7 @@ static struct bpf_test tests[] = {
2549 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2550 + .errstr = "R4 invalid mem access",
2551 + .result = REJECT,
2552 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2553 + },
2554 + {
2555 + "calls: pkt_ptr spill into caller stack 8",
2556 +@@ -11783,6 +11843,7 @@ static struct bpf_test tests[] = {
2557 + },
2558 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2559 + .result = ACCEPT,
2560 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2561 + },
2562 + {
2563 + "calls: pkt_ptr spill into caller stack 9",
2564 +@@ -11824,6 +11885,7 @@ static struct bpf_test tests[] = {
2565 + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
2566 + .errstr = "invalid access to packet",
2567 + .result = REJECT,
2568 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2569 + },
2570 + {
2571 + "calls: caller stack init to zero or map_value_or_null",
2572 +@@ -12189,6 +12251,7 @@ static struct bpf_test tests[] = {
2573 + .result = REJECT,
2574 + .errstr = "BPF_XADD stores into R2 packet",
2575 + .prog_type = BPF_PROG_TYPE_XDP,
2576 ++ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
2577 + },
2578 + {
2579 + "xadd/w check whether src/dst got mangled, 1",
2580 +@@ -12628,18 +12691,18 @@ static int create_map(uint32_t type, uint32_t size_key,
2581 + return fd;
2582 + }
2583 +
2584 +-static int create_prog_dummy1(void)
2585 ++static int create_prog_dummy1(enum bpf_map_type prog_type)
2586 + {
2587 + struct bpf_insn prog[] = {
2588 + BPF_MOV64_IMM(BPF_REG_0, 42),
2589 + BPF_EXIT_INSN(),
2590 + };
2591 +
2592 +- return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, prog,
2593 ++ return bpf_load_program(prog_type, prog,
2594 + ARRAY_SIZE(prog), "GPL", 0, NULL, 0);
2595 + }
2596 +
2597 +-static int create_prog_dummy2(int mfd, int idx)
2598 ++static int create_prog_dummy2(enum bpf_map_type prog_type, int mfd, int idx)
2599 + {
2600 + struct bpf_insn prog[] = {
2601 + BPF_MOV64_IMM(BPF_REG_3, idx),
2602 +@@ -12650,11 +12713,12 @@ static int create_prog_dummy2(int mfd, int idx)
2603 + BPF_EXIT_INSN(),
2604 + };
2605 +
2606 +- return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, prog,
2607 ++ return bpf_load_program(prog_type, prog,
2608 + ARRAY_SIZE(prog), "GPL", 0, NULL, 0);
2609 + }
2610 +
2611 +-static int create_prog_array(uint32_t max_elem, int p1key)
2612 ++static int create_prog_array(enum bpf_map_type prog_type, uint32_t max_elem,
2613 ++ int p1key)
2614 + {
2615 + int p2key = 1;
2616 + int mfd, p1fd, p2fd;
2617 +@@ -12666,8 +12730,8 @@ static int create_prog_array(uint32_t max_elem, int p1key)
2618 + return -1;
2619 + }
2620 +
2621 +- p1fd = create_prog_dummy1();
2622 +- p2fd = create_prog_dummy2(mfd, p2key);
2623 ++ p1fd = create_prog_dummy1(prog_type);
2624 ++ p2fd = create_prog_dummy2(prog_type, mfd, p2key);
2625 + if (p1fd < 0 || p2fd < 0)
2626 + goto out;
2627 + if (bpf_map_update_elem(mfd, &p1key, &p1fd, BPF_ANY) < 0)
2628 +@@ -12722,8 +12786,8 @@ static int create_cgroup_storage(void)
2629 +
2630 + static char bpf_vlog[UINT_MAX >> 8];
2631 +
2632 +-static void do_test_fixup(struct bpf_test *test, struct bpf_insn *prog,
2633 +- int *map_fds)
2634 ++static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
2635 ++ struct bpf_insn *prog, int *map_fds)
2636 + {
2637 + int *fixup_map1 = test->fixup_map1;
2638 + int *fixup_map2 = test->fixup_map2;
2639 +@@ -12778,7 +12842,7 @@ static void do_test_fixup(struct bpf_test *test, struct bpf_insn *prog,
2640 + }
2641 +
2642 + if (*fixup_prog1) {
2643 +- map_fds[4] = create_prog_array(4, 0);
2644 ++ map_fds[4] = create_prog_array(prog_type, 4, 0);
2645 + do {
2646 + prog[*fixup_prog1].imm = map_fds[4];
2647 + fixup_prog1++;
2648 +@@ -12786,7 +12850,7 @@ static void do_test_fixup(struct bpf_test *test, struct bpf_insn *prog,
2649 + }
2650 +
2651 + if (*fixup_prog2) {
2652 +- map_fds[5] = create_prog_array(8, 7);
2653 ++ map_fds[5] = create_prog_array(prog_type, 8, 7);
2654 + do {
2655 + prog[*fixup_prog2].imm = map_fds[5];
2656 + fixup_prog2++;
2657 +@@ -12810,54 +12874,90 @@ static void do_test_fixup(struct bpf_test *test, struct bpf_insn *prog,
2658 + }
2659 + }
2660 +
2661 ++static int set_admin(bool admin)
2662 ++{
2663 ++ cap_t caps;
2664 ++ const cap_value_t cap_val = CAP_SYS_ADMIN;
2665 ++ int ret = -1;
2666 ++
2667 ++ caps = cap_get_proc();
2668 ++ if (!caps) {
2669 ++ perror("cap_get_proc");
2670 ++ return -1;
2671 ++ }
2672 ++ if (cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap_val,
2673 ++ admin ? CAP_SET : CAP_CLEAR)) {
2674 ++ perror("cap_set_flag");
2675 ++ goto out;
2676 ++ }
2677 ++ if (cap_set_proc(caps)) {
2678 ++ perror("cap_set_proc");
2679 ++ goto out;
2680 ++ }
2681 ++ ret = 0;
2682 ++out:
2683 ++ if (cap_free(caps))
2684 ++ perror("cap_free");
2685 ++ return ret;
2686 ++}
2687 ++
2688 + static void do_test_single(struct bpf_test *test, bool unpriv,
2689 + int *passes, int *errors)
2690 + {
2691 +- int fd_prog, expected_ret, reject_from_alignment;
2692 ++ int fd_prog, expected_ret, alignment_prevented_execution;
2693 + int prog_len, prog_type = test->prog_type;
2694 + struct bpf_insn *prog = test->insns;
2695 + int map_fds[MAX_NR_MAPS];
2696 + const char *expected_err;
2697 ++ uint32_t expected_val;
2698 + uint32_t retval;
2699 ++ __u32 pflags;
2700 + int i, err;
2701 +
2702 + for (i = 0; i < MAX_NR_MAPS; i++)
2703 + map_fds[i] = -1;
2704 +
2705 +- do_test_fixup(test, prog, map_fds);
2706 ++ if (!prog_type)
2707 ++ prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
2708 ++ do_test_fixup(test, prog_type, prog, map_fds);
2709 + prog_len = probe_filter_length(prog);
2710 +
2711 +- fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER,
2712 +- prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT,
2713 ++ pflags = 0;
2714 ++ if (test->flags & F_LOAD_WITH_STRICT_ALIGNMENT)
2715 ++ pflags |= BPF_F_STRICT_ALIGNMENT;
2716 ++ if (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS)
2717 ++ pflags |= BPF_F_ANY_ALIGNMENT;
2718 ++ fd_prog = bpf_verify_program(prog_type, prog, prog_len, pflags,
2719 + "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1);
2720 +
2721 + expected_ret = unpriv && test->result_unpriv != UNDEF ?
2722 + test->result_unpriv : test->result;
2723 + expected_err = unpriv && test->errstr_unpriv ?
2724 + test->errstr_unpriv : test->errstr;
2725 ++ expected_val = unpriv && test->retval_unpriv ?
2726 ++ test->retval_unpriv : test->retval;
2727 ++
2728 ++ alignment_prevented_execution = 0;
2729 +
2730 +- reject_from_alignment = fd_prog < 0 &&
2731 +- (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS) &&
2732 +- strstr(bpf_vlog, "misaligned");
2733 +-#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2734 +- if (reject_from_alignment) {
2735 +- printf("FAIL\nFailed due to alignment despite having efficient unaligned access: '%s'!\n",
2736 +- strerror(errno));
2737 +- goto fail_log;
2738 +- }
2739 +-#endif
2740 + if (expected_ret == ACCEPT) {
2741 +- if (fd_prog < 0 && !reject_from_alignment) {
2742 ++ if (fd_prog < 0) {
2743 + printf("FAIL\nFailed to load prog '%s'!\n",
2744 + strerror(errno));
2745 + goto fail_log;
2746 + }
2747 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2748 ++ if (fd_prog >= 0 &&
2749 ++ (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS)) {
2750 ++ alignment_prevented_execution = 1;
2751 ++ goto test_ok;
2752 ++ }
2753 ++#endif
2754 + } else {
2755 + if (fd_prog >= 0) {
2756 + printf("FAIL\nUnexpected success to load!\n");
2757 + goto fail_log;
2758 + }
2759 +- if (!strstr(bpf_vlog, expected_err) && !reject_from_alignment) {
2760 ++ if (!strstr(bpf_vlog, expected_err)) {
2761 + printf("FAIL\nUnexpected error message!\n\tEXP: %s\n\tRES: %s\n",
2762 + expected_err, bpf_vlog);
2763 + goto fail_log;
2764 +@@ -12868,22 +12968,29 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
2765 + __u8 tmp[TEST_DATA_LEN << 2];
2766 + __u32 size_tmp = sizeof(tmp);
2767 +
2768 ++ if (unpriv)
2769 ++ set_admin(true);
2770 + err = bpf_prog_test_run(fd_prog, 1, test->data,
2771 + sizeof(test->data), tmp, &size_tmp,
2772 + &retval, NULL);
2773 ++ if (unpriv)
2774 ++ set_admin(false);
2775 + if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) {
2776 + printf("Unexpected bpf_prog_test_run error\n");
2777 + goto fail_log;
2778 + }
2779 +- if (!err && retval != test->retval &&
2780 +- test->retval != POINTER_VALUE) {
2781 +- printf("FAIL retval %d != %d\n", retval, test->retval);
2782 ++ if (!err && retval != expected_val &&
2783 ++ expected_val != POINTER_VALUE) {
2784 ++ printf("FAIL retval %d != %d\n", retval, expected_val);
2785 + goto fail_log;
2786 + }
2787 + }
2788 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2789 ++test_ok:
2790 ++#endif
2791 + (*passes)++;
2792 +- printf("OK%s\n", reject_from_alignment ?
2793 +- " (NOTE: reject due to unknown alignment)" : "");
2794 ++ printf("OK%s\n", alignment_prevented_execution ?
2795 ++ " (NOTE: not executed due to unknown alignment)" : "");
2796 + close_fds:
2797 + close(fd_prog);
2798 + for (i = 0; i < MAX_NR_MAPS; i++)
2799 +@@ -12920,33 +13027,6 @@ static bool is_admin(void)
2800 + return (sysadmin == CAP_SET);
2801 + }
2802 +
2803 +-static int set_admin(bool admin)
2804 +-{
2805 +- cap_t caps;
2806 +- const cap_value_t cap_val = CAP_SYS_ADMIN;
2807 +- int ret = -1;
2808 +-
2809 +- caps = cap_get_proc();
2810 +- if (!caps) {
2811 +- perror("cap_get_proc");
2812 +- return -1;
2813 +- }
2814 +- if (cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap_val,
2815 +- admin ? CAP_SET : CAP_CLEAR)) {
2816 +- perror("cap_set_flag");
2817 +- goto out;
2818 +- }
2819 +- if (cap_set_proc(caps)) {
2820 +- perror("cap_set_proc");
2821 +- goto out;
2822 +- }
2823 +- ret = 0;
2824 +-out:
2825 +- if (cap_free(caps))
2826 +- perror("cap_free");
2827 +- return ret;
2828 +-}
2829 +-
2830 + static void get_unpriv_disabled()
2831 + {
2832 + char buf[2];
2833 +@@ -12963,6 +13043,26 @@ static void get_unpriv_disabled()
2834 + fclose(fd);
2835 + }
2836 +
2837 ++static bool test_as_unpriv(struct bpf_test *test)
2838 ++{
2839 ++#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2840 ++ /* Some architectures have strict alignment requirements. In
2841 ++ * that case, the BPF verifier detects if a program has
2842 ++ * unaligned accesses and rejects them. A user can pass
2843 ++ * BPF_F_ANY_ALIGNMENT to a program to override this
2844 ++ * check. That, however, will only work when a privileged user
2845 ++ * loads a program. An unprivileged user loading a program
2846 ++ * with this flag will be rejected prior entering the
2847 ++ * verifier.
2848 ++ */
2849 ++ if (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS)
2850 ++ return false;
2851 ++#endif
2852 ++ return !test->prog_type ||
2853 ++ test->prog_type == BPF_PROG_TYPE_SOCKET_FILTER ||
2854 ++ test->prog_type == BPF_PROG_TYPE_CGROUP_SKB;
2855 ++}
2856 ++
2857 + static int do_test(bool unpriv, unsigned int from, unsigned int to)
2858 + {
2859 + int i, passes = 0, errors = 0, skips = 0;
2860 +@@ -12973,10 +13073,10 @@ static int do_test(bool unpriv, unsigned int from, unsigned int to)
2861 + /* Program types that are not supported by non-root we
2862 + * skip right away.
2863 + */
2864 +- if (!test->prog_type && unpriv_disabled) {
2865 ++ if (test_as_unpriv(test) && unpriv_disabled) {
2866 + printf("#%d/u %s SKIP\n", i, test->descr);
2867 + skips++;
2868 +- } else if (!test->prog_type) {
2869 ++ } else if (test_as_unpriv(test)) {
2870 + if (!unpriv)
2871 + set_admin(false);
2872 + printf("#%d/u %s ", i, test->descr);