Merge ~xnox/ubuntu/+source/linux/+git/focal:5.4-revocation-certs into ~ubuntu-kernel/ubuntu/+source/linux/+git/focal:master-next

Proposed by Dimitri John Ledkov
Status: Needs review
Proposed branch: ~xnox/ubuntu/+source/linux/+git/focal:5.4-revocation-certs
Merge into: ~ubuntu-kernel/ubuntu/+source/linux/+git/focal:master-next
Diff against target: 4122 lines (+1416/-495)
127 files modified
Makefile (+1/-1)
arch/arc/Kconfig (+1/-0)
arch/arc/include/asm/syscalls.h (+1/-0)
arch/arc/include/uapi/asm/unistd.h (+1/-0)
arch/arc/kernel/entry.S (+12/-0)
arch/arc/kernel/process.c (+3/-4)
arch/arc/kernel/sys.c (+1/-0)
arch/arc/kernel/vmlinux.lds.S (+2/-0)
arch/arm/kernel/Makefile (+5/-1)
arch/arm/kernel/return_address.c (+0/-4)
arch/arm64/boot/dts/qcom/msm8994-angler-rev-101.dts (+4/-0)
arch/parisc/include/asm/string.h (+0/-15)
arch/parisc/kernel/parisc_ksyms.c (+0/-4)
arch/parisc/lib/Makefile (+2/-2)
arch/parisc/lib/memset.c (+72/-0)
arch/powerpc/boot/crt0.S (+0/-3)
arch/x86/events/amd/ibs.c (+8/-0)
arch/x86/events/amd/iommu.c (+26/-21)
arch/x86/events/amd/power.c (+1/-0)
arch/x86/events/intel/pt.c (+1/-1)
arch/x86/events/intel/uncore_snbep.c (+1/-1)
arch/x86/kernel/reboot.c (+2/-1)
arch/x86/kernel/setup.c (+1/-0)
arch/x86/kvm/mmu.c (+9/-1)
arch/x86/platform/efi/efi.c (+3/-0)
arch/xtensa/Kconfig (+1/-1)
certs/.gitignore (+1/-0)
certs/Kconfig (+8/-0)
certs/Makefile (+17/-2)
certs/blacklist.c (+24/-0)
certs/common.c (+1/-0)
certs/revocation_certificates.S (+21/-0)
debian.master/config/annotations (+1/-0)
debian.master/config/config.common.ubuntu (+1/-0)
debian.master/upstream-stable (+1/-1)
debian/revoked-certs/canonical-uefi-2012-all.pem (+86/-0)
debian/rules (+13/-1)
dev/null (+0/-136)
drivers/block/Kconfig (+2/-2)
drivers/block/cryptoloop.c (+2/-0)
drivers/block/floppy.c (+13/-14)
drivers/firmware/efi/Makefile (+1/-0)
drivers/firmware/efi/arm-init.c (+1/-0)
drivers/firmware/efi/efi.c (+6/-0)
drivers/firmware/efi/mokvar-table.c (+362/-0)
drivers/gpu/drm/drm_ioc32.c (+1/-3)
drivers/gpu/drm/i915/gt/intel_timeline.c (+8/-0)
drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c (+1/-1)
drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h (+1/-0)
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c (+9/-0)
drivers/gpu/ipu-v3/ipu-cpmem.c (+15/-15)
drivers/infiniband/hw/bnxt_re/ib_verbs.c (+1/-0)
drivers/infiniband/hw/efa/efa_main.c (+1/-0)
drivers/infiniband/hw/hfi1/sdma.c (+4/-5)
drivers/media/usb/stkwebcam/stk-webcam.c (+4/-2)
drivers/mmc/host/sdhci-msm.c (+18/-0)
drivers/net/can/usb/esd_usb2.c (+2/-2)
drivers/net/dsa/mt7530.c (+1/-4)
drivers/net/ethernet/apm/xgene-v2/main.c (+3/-1)
drivers/net/ethernet/cadence/macb_ptp.c (+10/-1)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h (+3/-0)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c (+2/-11)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c (+31/-1)
drivers/net/ethernet/intel/e1000e/ich8lan.c (+13/-1)
drivers/net/ethernet/intel/e1000e/ich8lan.h (+3/-0)
drivers/net/ethernet/marvell/mvneta.c (+1/-1)
drivers/net/ethernet/qlogic/qed/qed_ll2.c (+20/-0)
drivers/net/ethernet/qlogic/qed/qed_main.c (+6/-1)
drivers/net/ethernet/qlogic/qed/qed_rdma.c (+1/-2)
drivers/net/ethernet/qlogic/qede/qede_main.c (+1/-1)
drivers/net/ethernet/realtek/r8169_main.c (+1/-0)
drivers/net/ethernet/xilinx/ll_temac_main.c (+1/-3)
drivers/opp/of.c (+3/-2)
drivers/pci/quirks.c (+6/-6)
drivers/reset/reset-zynqmp.c (+2/-1)
drivers/scsi/scsi_sysfs.c (+6/-3)
drivers/tty/vt/vt_ioctl.c (+7/-4)
drivers/usb/dwc3/gadget.c (+11/-12)
drivers/usb/gadget/function/u_audio.c (+2/-3)
drivers/usb/host/xhci-debugfs.c (+4/-2)
drivers/usb/host/xhci-rcar.c (+7/-0)
drivers/usb/host/xhci-trace.h (+4/-4)
drivers/usb/host/xhci.h (+28/-24)
drivers/usb/mtu3/mtu3_gadget.c (+2/-4)
drivers/usb/serial/ch341.c (+0/-1)
drivers/usb/serial/mos7720.c (+3/-1)
drivers/usb/serial/option.c (+2/-0)
drivers/vhost/vringh.c (+1/-1)
drivers/virtio/virtio_pci_common.c (+7/-0)
drivers/virtio/virtio_ring.c (+4/-2)
fs/btrfs/btrfs_inode.h (+15/-0)
fs/btrfs/file.c (+2/-8)
fs/btrfs/inode.c (+2/-4)
fs/btrfs/transaction.h (+1/-1)
fs/btrfs/volumes.c (+1/-1)
fs/crypto/hooks.c (+44/-0)
fs/ext4/symlink.c (+10/-1)
fs/f2fs/namei.c (+10/-1)
fs/overlayfs/export.c (+1/-1)
fs/proc/base.c (+10/-1)
fs/ubifs/file.c (+11/-1)
include/linux/efi.h (+34/-0)
include/linux/fscrypt.h (+7/-0)
include/linux/netdevice.h (+4/-0)
include/linux/once.h (+2/-2)
include/linux/oom.h (+2/-2)
kernel/audit_tree.c (+1/-1)
kernel/bpf/verifier.c (+55/-2)
kernel/kthread.c (+29/-14)
kernel/sched/fair.c (+1/-1)
lib/once.c (+8/-3)
mm/oom_kill.c (+10/-12)
mm/page_alloc.c (+4/-4)
net/core/rtnetlink.c (+2/-1)
net/ipv4/icmp.c (+21/-2)
net/ipv4/igmp.c (+2/-0)
net/ipv4/ip_gre.c (+2/-0)
net/netfilter/nf_conntrack_core.c (+22/-49)
net/qrtr/qrtr.c (+1/-1)
net/rds/ib_frmr.c (+2/-2)
net/socket.c (+5/-1)
scripts/Makefile (+1/-0)
security/integrity/platform_certs/keyring_handler.c (+1/-0)
security/integrity/platform_certs/load_uefi.c (+101/-37)
sound/core/pcm_lib.c (+1/-1)
sound/pci/hda/patch_realtek.c (+10/-0)
sound/usb/quirks.c (+1/-0)
Reviewer Review Type Date Requested Status
Ubuntu Kernel Repositories Pending
Review via email: mp+409374@code.launchpad.net

Commit message

Backport builtin revocation certificates and mokvar table driver

To post a comment you must log in.

Unmerged commits

1b21f28... by Dimitri John Ledkov

UBUNTU: [Config] Configure CONFIG_SYSTEM_REVOCATION_KEYS with revoked keys

BugLink: https://bugs.launchpad.net/bugs/1932029
Signed-off-by: Dimitri John Ledkov <email address hidden>
Signed-off-by: Andrea Righi <email address hidden>
(cherry picked from commit 741f622c4dbc162b82f8c9045f9c6c6446f57eb5)
(xnox: cherry-pick is from impish:linux)
Signed-off-by: Dimitri John Ledkov <email address hidden>

d764c30... by Dimitri John Ledkov

UBUNTU: [Packaging] Revoke 2012 UEFI signing certificate as built-in

BugLink: https://bugs.launchpad.net/bugs/1932029
Signed-off-by: Dimitri John Ledkov <email address hidden>
Signed-off-by: Andrea Righi <email address hidden>
(cherry picked from commit 3f72ce72f0b51b6da2638cdded93bb32b9dad2ec)
(xnox: cherry-pick is from impish:linux)
Signed-off-by: Dimitri John Ledkov <email address hidden>

4598103... by Dimitri John Ledkov

UBUNTU: [Packaging] build canonical-revoked-certs.pem from branch/arch certs

BugLink: https://bugs.launchpad.net/bugs/1932029
Signed-off-by: Dimitri John Ledkov <email address hidden>
Signed-off-by: Andrea Righi <email address hidden>
(cherry picked from commit 3e44f229eef829ee3044651975512569824c4e5f)
(xnox: cherry-pick is from impish:linux)
Signed-off-by: Dimitri John Ledkov <email address hidden>

e9905dd... by Tim Gardner

UBUNTU: SAUCE: Dump stack when X.509 certificates cannot be loaded

BugLink: https://bugs.launchpad.net/bugs/1932029

Signed-off-by: Tim Gardner <email address hidden>
(cherry picked from commit b5b4085dc5547a01593cd79dbf51bd9108f84e9f)
(xnox: cherry-pick is from impish:linux SAUCE)
Signed-off-by: Dimitri John Ledkov <email address hidden>

b496c6b... by Dimitri John Ledkov

UBUNTU: SAUCE: integrity: add informational messages when revoking certs

integrity_load_cert() prints messages of the source and cert details
when adding certs as trusted. Mirror those messages in
uefi_revocation_list_x509() when adding certs as revoked.

Sample dmesg with this change:

    integrity: Platform Keyring initialized
    integrity: Loading X.509 certificate: UEFI:db
    integrity: Loaded X.509 cert 'Microsoft Corporation UEFI CA 2011: 13adbf4309bd82709c8cd54f316ed522988a1bd4'
    integrity: Revoking X.509 certificate: UEFI:MokListXRT (MOKvar table)
    blacklist: Revoked X.509 cert 'Canonical Ltd. Secure Boot Signing: 61482aa2830d0ab2ad5af10b7250da9033ddcef0'
    integrity: Loading X.509 certificate: UEFI:MokListRT (MOKvar table)
    integrity: Loaded X.509 cert 'Canonical Ltd. Master Certificate Authority: ad91990bc22ab1f517048c23b6655a268e345a63'

BugLink: https://bugs.launchpad.net/bugs/1928679
Signed-off-by: Dimitri John Ledkov <email address hidden>
Acked-by: Krzysztof Kozlowski <email address hidden>
Signed-off-by: Seth Forshee <email address hidden>
(cherry picked from commit ba9fb788f89cb81c5ed836db2355a7a3b0f8c248)
(xnox: cherry-pick is from impish:linux SAUCE)
Signed-off-by: Dimitri John Ledkov <email address hidden>

baec570... by Dimitri John Ledkov

UBUNTU: SAUCE: integrity: Load mokx certs from the EFI MOK config table

Refactor load_moklist_certs() to load either MokListRT into db, or
MokListXRT into dbx. Call load_moklist_certs() twice - first to load
mokx certs into dbx, then mok certs into db.

This thus now attempts to load mokx certs via the EFI MOKvar config
table first, and if that fails, via the EFI variable. Previously mokx
certs were only loaded via the EFI variable. Which fails when
MokListXRT is large. Instead of large MokListXRT variable, only
MokListXRT{1,2,3} are available which are not loaded. This is the case
with Ubuntu's 15.4 based shim. This patch is required to address
CVE-2020-26541 when certificates are revoked via MokListXRT.

Fixes: ebd9c2ae369a ("integrity: Load mokx variables into the blacklist keyring")
BugLink: https://bugs.launchpad.net/bugs/1928679
Signed-off-by: Dimitri John Ledkov <email address hidden>
Acked-by: Krzysztof Kozlowski <email address hidden>
Signed-off-by: Seth Forshee <email address hidden>
(cherry picked from commit a9e3aae16235d6af12509a64f1337da4485ccbae)
(xnox: cherry-pick is from impish:linux SAUCE)
Signed-off-by: Dimitri John Ledkov <email address hidden>

9f88bce... by Linus Torvalds <email address hidden>

certs: add 'x509_revocation_list' to gitignore

BugLink: https://bugs.launchpad.net/bugs/1932029

Commit d1f044103dad ("certs: Add ability to preload revocation certs")
created a new generated file for revocation certs, but didn't tell git
to ignore it. Thus causing unnecessary "git status" noise after a
kernel build with CONFIG_SYSTEM_REVOCATION_LIST enabled.

Add the proper gitignore magic.

Signed-off-by: Linus Torvalds <email address hidden>
(cherry picked from commit 81f202315856edb75a371f3376aa3a47543c16f0)
Signed-off-by: Dimitri John Ledkov <email address hidden>

5b175c0... by Eric Snowberg <email address hidden>

integrity: Load mokx variables into the blacklist keyring

BugLink: https://bugs.launchpad.net/bugs/1932029

During boot the Secure Boot Forbidden Signature Database, dbx,
is loaded into the blacklist keyring. Systems booted with shim
have an equivalent Forbidden Signature Database called mokx.
Currently mokx is only used by shim and grub, the contents are
ignored by the kernel.

Add the ability to load mokx into the blacklist keyring during boot.

Signed-off-by: Eric Snowberg <email address hidden>
Suggested-by: James Bottomley <email address hidden>
Signed-off-by: David Howells <email address hidden>
Reviewed-by: Jarkko Sakkinen <email address hidden>
cc: <email address hidden>
Link: https://<email address hidden>/
Link: https://<email address hidden>/ # v5
Link: https://<email address hidden>/
Link: https://<email address hidden>/ # v2
Link: https://<email address hidden>/ # v3
(cherry picked from commit ebd9c2ae369a45bdd9f8615484db09be58fc242b)
Signed-off-by: Dimitri John Ledkov <email address hidden>

dd15cc5... by Eric Snowberg <email address hidden>

certs: Add ability to preload revocation certs

BugLink: https://bugs.launchpad.net/bugs/1932029

Add a new Kconfig option called SYSTEM_REVOCATION_KEYS. If set,
this option should be the filename of a PEM-formated file containing
X.509 certificates to be included in the default blacklist keyring.

DH Changes:
 - Make the new Kconfig option depend on SYSTEM_REVOCATION_LIST.
 - Fix SYSTEM_REVOCATION_KEYS=n, but CONFIG_SYSTEM_REVOCATION_LIST=y[1][2].
 - Use CONFIG_SYSTEM_REVOCATION_LIST for extract-cert[3].
 - Use CONFIG_SYSTEM_REVOCATION_LIST for revocation_certificates.o[3].

Signed-off-by: Eric Snowberg <email address hidden>
Acked-by: Jarkko Sakkinen <email address hidden>
Signed-off-by: David Howells <email address hidden>
cc: Randy Dunlap <email address hidden>
cc: <email address hidden>
Link: https://<email address hidden>/ [1]
Link: https://<email address hidden>/ [2]
Link: https://<email address hidden>/ [3]
Link: https://<email address hidden>/
Link: https://<email address hidden>/ # v5
Link: https://<email address hidden>/
Link: https://<email address hidden>/ # v2
Link: https://<email address hidden>/ # v3
(cherry picked from commit d1f044103dad70c1cec0a8f3abdf00834fec8b98)
Signed-off-by: Dimitri John Ledkov <email address hidden>

618e1a9... by Lenny Szubowicz <email address hidden>

integrity: Load certs from the EFI MOK config table

BugLink: https://bugs.launchpad.net/bugs/1932029

Because of system-specific EFI firmware limitations, EFI volatile
variables may not be capable of holding the required contents of
the Machine Owner Key (MOK) certificate store when the certificate
list grows above some size. Therefore, an EFI boot loader may pass
the MOK certs via a EFI configuration table created specifically for
this purpose to avoid this firmware limitation.

An EFI configuration table is a much more primitive mechanism
compared to EFI variables and is well suited for one-way passage
of static information from a pre-OS environment to the kernel.

This patch adds the support to load certs from the MokListRT
entry in the MOK variable configuration table, if it's present.
The pre-existing support to load certs from the MokListRT EFI
variable remains and is used if the EFI MOK configuration table
isn't present or can't be successfully used.

Signed-off-by: Lenny Szubowicz <email address hidden>
Link: https://<email address hidden>
Signed-off-by: Ard Biesheuvel <email address hidden>
(cherry picked from commit 726bd8965a5f112d9601f7ce68effa1e46e02bf2)
Signed-off-by: Dimitri John Ledkov <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/Makefile b/Makefile
index 4b314dd..a2bb129 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2VERSION = 52VERSION = 5
3PATCHLEVEL = 43PATCHLEVEL = 4
4SUBLEVEL = 1434SUBLEVEL = 145
5EXTRAVERSION =5EXTRAVERSION =
6NAME = Kleptomaniac Octopus6NAME = Kleptomaniac Octopus
77
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 8383155..a9d0b53 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -29,6 +29,7 @@ config ARC
29 select GENERIC_SMP_IDLE_THREAD29 select GENERIC_SMP_IDLE_THREAD
30 select HAVE_ARCH_KGDB30 select HAVE_ARCH_KGDB
31 select HAVE_ARCH_TRACEHOOK31 select HAVE_ARCH_TRACEHOOK
32 select HAVE_COPY_THREAD_TLS
32 select HAVE_DEBUG_STACKOVERFLOW33 select HAVE_DEBUG_STACKOVERFLOW
33 select HAVE_FUTEX_CMPXCHG if FUTEX34 select HAVE_FUTEX_CMPXCHG if FUTEX
34 select HAVE_IOREMAP_PROT35 select HAVE_IOREMAP_PROT
diff --git a/arch/arc/include/asm/syscalls.h b/arch/arc/include/asm/syscalls.h
index 7ddba13..c3f4714 100644
--- a/arch/arc/include/asm/syscalls.h
+++ b/arch/arc/include/asm/syscalls.h
@@ -11,6 +11,7 @@
11#include <linux/types.h>11#include <linux/types.h>
1212
13int sys_clone_wrapper(int, int, int, int, int);13int sys_clone_wrapper(int, int, int, int, int);
14int sys_clone3_wrapper(void *, size_t);
14int sys_cacheflush(uint32_t, uint32_t uint32_t);15int sys_cacheflush(uint32_t, uint32_t uint32_t);
15int sys_arc_settls(void *);16int sys_arc_settls(void *);
16int sys_arc_gettls(void);17int sys_arc_gettls(void);
diff --git a/arch/arc/include/uapi/asm/unistd.h b/arch/arc/include/uapi/asm/unistd.h
index 5eafa11..fa2713a 100644
--- a/arch/arc/include/uapi/asm/unistd.h
+++ b/arch/arc/include/uapi/asm/unistd.h
@@ -21,6 +21,7 @@
21#define __ARCH_WANT_SET_GET_RLIMIT21#define __ARCH_WANT_SET_GET_RLIMIT
22#define __ARCH_WANT_SYS_EXECVE22#define __ARCH_WANT_SYS_EXECVE
23#define __ARCH_WANT_SYS_CLONE23#define __ARCH_WANT_SYS_CLONE
24#define __ARCH_WANT_SYS_CLONE3
24#define __ARCH_WANT_SYS_VFORK25#define __ARCH_WANT_SYS_VFORK
25#define __ARCH_WANT_SYS_FORK26#define __ARCH_WANT_SYS_FORK
26#define __ARCH_WANT_TIME32_SYSCALLS27#define __ARCH_WANT_TIME32_SYSCALLS
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index b37ca85..cef1d3f 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -35,6 +35,18 @@ ENTRY(sys_clone_wrapper)
35 b .Lret_from_system_call35 b .Lret_from_system_call
36END(sys_clone_wrapper)36END(sys_clone_wrapper)
3737
38ENTRY(sys_clone3_wrapper)
39 SAVE_CALLEE_SAVED_USER
40 bl @sys_clone3
41 DISCARD_CALLEE_SAVED_USER
42
43 GET_CURR_THR_INFO_FLAGS r10
44 btst r10, TIF_SYSCALL_TRACE
45 bnz tracesys_exit
46
47 b .Lret_from_system_call
48END(sys_clone3_wrapper)
49
38ENTRY(ret_from_fork)50ENTRY(ret_from_fork)
39 ; when the forked child comes here from the __switch_to function51 ; when the forked child comes here from the __switch_to function
40 ; r0 has the last task pointer.52 ; r0 has the last task pointer.
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index e1889ce..bfd4cbe 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -171,9 +171,8 @@ asmlinkage void ret_from_fork(void);
171 * | user_r25 |171 * | user_r25 |
172 * ------------------ <===== END of PAGE172 * ------------------ <===== END of PAGE
173 */173 */
174int copy_thread(unsigned long clone_flags,174int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
175 unsigned long usp, unsigned long kthread_arg,175 unsigned long kthread_arg, struct task_struct *p, unsigned long tls)
176 struct task_struct *p)
177{176{
178 struct pt_regs *c_regs; /* child's pt_regs */177 struct pt_regs *c_regs; /* child's pt_regs */
179 unsigned long *childksp; /* to unwind out of __switch_to() */178 unsigned long *childksp; /* to unwind out of __switch_to() */
@@ -231,7 +230,7 @@ int copy_thread(unsigned long clone_flags,
231 * set task's userland tls data ptr from 4th arg230 * set task's userland tls data ptr from 4th arg
232 * clone C-lib call is difft from clone sys-call231 * clone C-lib call is difft from clone sys-call
233 */232 */
234 task_thread_info(p)->thr_ptr = regs->r3;233 task_thread_info(p)->thr_ptr = tls;
235 } else {234 } else {
236 /* Normal fork case: set parent's TLS ptr in child */235 /* Normal fork case: set parent's TLS ptr in child */
237 task_thread_info(p)->thr_ptr =236 task_thread_info(p)->thr_ptr =
diff --git a/arch/arc/kernel/sys.c b/arch/arc/kernel/sys.c
index fddecc7..1069446 100644
--- a/arch/arc/kernel/sys.c
+++ b/arch/arc/kernel/sys.c
@@ -7,6 +7,7 @@
7#include <asm/syscalls.h>7#include <asm/syscalls.h>
88
9#define sys_clone sys_clone_wrapper9#define sys_clone sys_clone_wrapper
10#define sys_clone3 sys_clone3_wrapper
1011
11#undef __SYSCALL12#undef __SYSCALL
12#define __SYSCALL(nr, call) [nr] = (call),13#define __SYSCALL(nr, call) [nr] = (call),
diff --git a/arch/arc/kernel/vmlinux.lds.S b/arch/arc/kernel/vmlinux.lds.S
index 6c693a9..0391b82 100644
--- a/arch/arc/kernel/vmlinux.lds.S
+++ b/arch/arc/kernel/vmlinux.lds.S
@@ -88,6 +88,8 @@ SECTIONS
88 CPUIDLE_TEXT88 CPUIDLE_TEXT
89 LOCK_TEXT89 LOCK_TEXT
90 KPROBES_TEXT90 KPROBES_TEXT
91 IRQENTRY_TEXT
92 SOFTIRQENTRY_TEXT
91 *(.fixup)93 *(.fixup)
92 *(.gnu.warning)94 *(.gnu.warning)
93 }95 }
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 8cad594..8b679e2 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -17,10 +17,14 @@ CFLAGS_REMOVE_return_address.o = -pg
17# Object file lists.17# Object file lists.
1818
19obj-y := elf.o entry-common.o irq.o opcodes.o \19obj-y := elf.o entry-common.o irq.o opcodes.o \
20 process.o ptrace.o reboot.o return_address.o \20 process.o ptrace.o reboot.o \
21 setup.o signal.o sigreturn_codes.o \21 setup.o signal.o sigreturn_codes.o \
22 stacktrace.o sys_arm.o time.o traps.o22 stacktrace.o sys_arm.o time.o traps.o
2323
24ifneq ($(CONFIG_ARM_UNWIND),y)
25obj-$(CONFIG_FRAME_POINTER) += return_address.o
26endif
27
24obj-$(CONFIG_ATAGS) += atags_parse.o28obj-$(CONFIG_ATAGS) += atags_parse.o
25obj-$(CONFIG_ATAGS_PROC) += atags_proc.o29obj-$(CONFIG_ATAGS_PROC) += atags_proc.o
26obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += atags_compat.o30obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += atags_compat.o
diff --git a/arch/arm/kernel/return_address.c b/arch/arm/kernel/return_address.c
index b0d2f1f..7b42ac0 100644
--- a/arch/arm/kernel/return_address.c
+++ b/arch/arm/kernel/return_address.c
@@ -7,8 +7,6 @@
7 */7 */
8#include <linux/export.h>8#include <linux/export.h>
9#include <linux/ftrace.h>9#include <linux/ftrace.h>
10
11#if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
12#include <linux/sched.h>10#include <linux/sched.h>
1311
14#include <asm/stacktrace.h>12#include <asm/stacktrace.h>
@@ -53,6 +51,4 @@ void *return_address(unsigned int level)
53 return NULL;51 return NULL;
54}52}
5553
56#endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) */
57
58EXPORT_SYMBOL_GPL(return_address);54EXPORT_SYMBOL_GPL(return_address);
diff --git a/arch/arm64/boot/dts/qcom/msm8994-angler-rev-101.dts b/arch/arm64/boot/dts/qcom/msm8994-angler-rev-101.dts
index a5f9a6a..9b989cc 100644
--- a/arch/arm64/boot/dts/qcom/msm8994-angler-rev-101.dts
+++ b/arch/arm64/boot/dts/qcom/msm8994-angler-rev-101.dts
@@ -30,3 +30,7 @@
30 };30 };
31 };31 };
32};32};
33
34&msmgpio {
35 gpio-reserved-ranges = <85 4>;
36};
diff --git a/arch/parisc/include/asm/string.h b/arch/parisc/include/asm/string.h
index 4a0c9db..f6e1132 100644
--- a/arch/parisc/include/asm/string.h
+++ b/arch/parisc/include/asm/string.h
@@ -8,19 +8,4 @@ extern void * memset(void *, int, size_t);
8#define __HAVE_ARCH_MEMCPY8#define __HAVE_ARCH_MEMCPY
9void * memcpy(void * dest,const void *src,size_t count);9void * memcpy(void * dest,const void *src,size_t count);
1010
11#define __HAVE_ARCH_STRLEN
12extern size_t strlen(const char *s);
13
14#define __HAVE_ARCH_STRCPY
15extern char *strcpy(char *dest, const char *src);
16
17#define __HAVE_ARCH_STRNCPY
18extern char *strncpy(char *dest, const char *src, size_t count);
19
20#define __HAVE_ARCH_STRCAT
21extern char *strcat(char *dest, const char *src);
22
23#define __HAVE_ARCH_MEMSET
24extern void *memset(void *, int, size_t);
25
26#endif11#endif
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
index 8ed409e..e8a6a75 100644
--- a/arch/parisc/kernel/parisc_ksyms.c
+++ b/arch/parisc/kernel/parisc_ksyms.c
@@ -17,10 +17,6 @@
1717
18#include <linux/string.h>18#include <linux/string.h>
19EXPORT_SYMBOL(memset);19EXPORT_SYMBOL(memset);
20EXPORT_SYMBOL(strlen);
21EXPORT_SYMBOL(strcpy);
22EXPORT_SYMBOL(strncpy);
23EXPORT_SYMBOL(strcat);
2420
25#include <linux/atomic.h>21#include <linux/atomic.h>
26EXPORT_SYMBOL(__xchg8);22EXPORT_SYMBOL(__xchg8);
diff --git a/arch/parisc/lib/Makefile b/arch/parisc/lib/Makefile
index 2d7a997..7b19766 100644
--- a/arch/parisc/lib/Makefile
+++ b/arch/parisc/lib/Makefile
@@ -3,7 +3,7 @@
3# Makefile for parisc-specific library files3# Makefile for parisc-specific library files
4#4#
55
6lib-y := lusercopy.o bitops.o checksum.o io.o memcpy.o \6lib-y := lusercopy.o bitops.o checksum.o io.o memset.o memcpy.o \
7 ucmpdi2.o delay.o string.o7 ucmpdi2.o delay.o
88
9obj-y := iomap.o9obj-y := iomap.o
diff --git a/arch/parisc/lib/memset.c b/arch/parisc/lib/memset.c
10new file mode 10064410new file mode 100644
index 0000000..133e480
--- /dev/null
+++ b/arch/parisc/lib/memset.c
@@ -0,0 +1,72 @@
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#include <linux/types.h>
3#include <asm/string.h>
4
5#define OPSIZ (BITS_PER_LONG/8)
6typedef unsigned long op_t;
7
8void *
9memset (void *dstpp, int sc, size_t len)
10{
11 unsigned int c = sc;
12 long int dstp = (long int) dstpp;
13
14 if (len >= 8)
15 {
16 size_t xlen;
17 op_t cccc;
18
19 cccc = (unsigned char) c;
20 cccc |= cccc << 8;
21 cccc |= cccc << 16;
22 if (OPSIZ > 4)
23 /* Do the shift in two steps to avoid warning if long has 32 bits. */
24 cccc |= (cccc << 16) << 16;
25
26 /* There are at least some bytes to set.
27 No need to test for LEN == 0 in this alignment loop. */
28 while (dstp % OPSIZ != 0)
29 {
30 ((unsigned char *) dstp)[0] = c;
31 dstp += 1;
32 len -= 1;
33 }
34
35 /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */
36 xlen = len / (OPSIZ * 8);
37 while (xlen > 0)
38 {
39 ((op_t *) dstp)[0] = cccc;
40 ((op_t *) dstp)[1] = cccc;
41 ((op_t *) dstp)[2] = cccc;
42 ((op_t *) dstp)[3] = cccc;
43 ((op_t *) dstp)[4] = cccc;
44 ((op_t *) dstp)[5] = cccc;
45 ((op_t *) dstp)[6] = cccc;
46 ((op_t *) dstp)[7] = cccc;
47 dstp += 8 * OPSIZ;
48 xlen -= 1;
49 }
50 len %= OPSIZ * 8;
51
52 /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */
53 xlen = len / OPSIZ;
54 while (xlen > 0)
55 {
56 ((op_t *) dstp)[0] = cccc;
57 dstp += OPSIZ;
58 xlen -= 1;
59 }
60 len %= OPSIZ;
61 }
62
63 /* Write the last few bytes. */
64 while (len > 0)
65 {
66 ((unsigned char *) dstp)[0] = c;
67 dstp += 1;
68 len -= 1;
69 }
70
71 return dstpp;
72}
diff --git a/arch/parisc/lib/string.S b/arch/parisc/lib/string.S
0deleted file mode 10064473deleted file mode 100644
index 4a64264..0000000
--- a/arch/parisc/lib/string.S
+++ /dev/null
@@ -1,136 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * PA-RISC assembly string functions
4 *
5 * Copyright (C) 2019 Helge Deller <deller@gmx.de>
6 */
7
8#include <asm/assembly.h>
9#include <linux/linkage.h>
10
11 .section .text.hot
12 .level PA_ASM_LEVEL
13
14 t0 = r20
15 t1 = r21
16 t2 = r22
17
18ENTRY_CFI(strlen, frame=0,no_calls)
19 or,COND(<>) arg0,r0,ret0
20 b,l,n .Lstrlen_null_ptr,r0
21 depwi 0,31,2,ret0
22 cmpb,COND(<>) arg0,ret0,.Lstrlen_not_aligned
23 ldw,ma 4(ret0),t0
24 cmpib,tr 0,r0,.Lstrlen_loop
25 uxor,nbz r0,t0,r0
26.Lstrlen_not_aligned:
27 uaddcm arg0,ret0,t1
28 shladd t1,3,r0,t1
29 mtsar t1
30 depwi -1,%sar,32,t0
31 uxor,nbz r0,t0,r0
32.Lstrlen_loop:
33 b,l,n .Lstrlen_end_loop,r0
34 ldw,ma 4(ret0),t0
35 cmpib,tr 0,r0,.Lstrlen_loop
36 uxor,nbz r0,t0,r0
37.Lstrlen_end_loop:
38 extrw,u,<> t0,7,8,r0
39 addib,tr,n -3,ret0,.Lstrlen_out
40 extrw,u,<> t0,15,8,r0
41 addib,tr,n -2,ret0,.Lstrlen_out
42 extrw,u,<> t0,23,8,r0
43 addi -1,ret0,ret0
44.Lstrlen_out:
45 bv r0(rp)
46 uaddcm ret0,arg0,ret0
47.Lstrlen_null_ptr:
48 bv,n r0(rp)
49ENDPROC_CFI(strlen)
50
51
52ENTRY_CFI(strcpy, frame=0,no_calls)
53 ldb 0(arg1),t0
54 stb t0,0(arg0)
55 ldo 0(arg0),ret0
56 ldo 1(arg1),t1
57 cmpb,= r0,t0,2f
58 ldo 1(arg0),t2
591: ldb 0(t1),arg1
60 stb arg1,0(t2)
61 ldo 1(t1),t1
62 cmpb,<> r0,arg1,1b
63 ldo 1(t2),t2
642: bv,n r0(rp)
65ENDPROC_CFI(strcpy)
66
67
68ENTRY_CFI(strncpy, frame=0,no_calls)
69 ldb 0(arg1),t0
70 stb t0,0(arg0)
71 ldo 1(arg1),t1
72 ldo 0(arg0),ret0
73 cmpb,= r0,t0,2f
74 ldo 1(arg0),arg1
751: ldo -1(arg2),arg2
76 cmpb,COND(=),n r0,arg2,2f
77 ldb 0(t1),arg0
78 stb arg0,0(arg1)
79 ldo 1(t1),t1
80 cmpb,<> r0,arg0,1b
81 ldo 1(arg1),arg1
822: bv,n r0(rp)
83ENDPROC_CFI(strncpy)
84
85
86ENTRY_CFI(strcat, frame=0,no_calls)
87 ldb 0(arg0),t0
88 cmpb,= t0,r0,2f
89 ldo 0(arg0),ret0
90 ldo 1(arg0),arg0
911: ldb 0(arg0),t1
92 cmpb,<>,n r0,t1,1b
93 ldo 1(arg0),arg0
942: ldb 0(arg1),t2
95 stb t2,0(arg0)
96 ldo 1(arg0),arg0
97 ldb 0(arg1),t0
98 cmpb,<> r0,t0,2b
99 ldo 1(arg1),arg1
100 bv,n r0(rp)
101ENDPROC_CFI(strcat)
102
103
104ENTRY_CFI(memset, frame=0,no_calls)
105 copy arg0,ret0
106 cmpb,COND(=) r0,arg0,4f
107 copy arg0,t2
108 cmpb,COND(=) r0,arg2,4f
109 ldo -1(arg2),arg3
110 subi -1,arg3,t0
111 subi 0,t0,t1
112 cmpiclr,COND(>=) 0,t1,arg2
113 ldo -1(t1),arg2
114 extru arg2,31,2,arg0
1152: stb arg1,0(t2)
116 ldo 1(t2),t2
117 addib,>= -1,arg0,2b
118 ldo -1(arg3),arg3
119 cmpiclr,COND(<=) 4,arg2,r0
120 b,l,n 4f,r0
121#ifdef CONFIG_64BIT
122 depd,* r0,63,2,arg2
123#else
124 depw r0,31,2,arg2
125#endif
126 ldo 1(t2),t2
1273: stb arg1,-1(t2)
128 stb arg1,0(t2)
129 stb arg1,1(t2)
130 stb arg1,2(t2)
131 addib,COND(>) -4,arg2,3b
132 ldo 4(t2),t2
1334: bv,n r0(rp)
134ENDPROC_CFI(memset)
135
136 .end
diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 92608f3..1d83966 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -44,9 +44,6 @@ p_end: .long _end
44p_pstack: .long _platform_stack_top44p_pstack: .long _platform_stack_top
45#endif45#endif
4646
47 .globl _zimage_start
48 /* Clang appears to require the .weak directive to be after the symbol
49 * is defined. See https://bugs.llvm.org/show_bug.cgi?id=38921 */
50 .weak _zimage_start47 .weak _zimage_start
51_zimage_start:48_zimage_start:
52 .globl _zimage_start_lib49 .globl _zimage_start_lib
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 3916988..ff07040 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -90,6 +90,7 @@ struct perf_ibs {
90 unsigned long offset_mask[1];90 unsigned long offset_mask[1];
91 int offset_max;91 int offset_max;
92 unsigned int fetch_count_reset_broken : 1;92 unsigned int fetch_count_reset_broken : 1;
93 unsigned int fetch_ignore_if_zero_rip : 1;
93 struct cpu_perf_ibs __percpu *pcpu;94 struct cpu_perf_ibs __percpu *pcpu;
9495
95 struct attribute **format_attrs;96 struct attribute **format_attrs;
@@ -663,6 +664,10 @@ fail:
663 if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {664 if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {
664 regs.flags &= ~PERF_EFLAGS_EXACT;665 regs.flags &= ~PERF_EFLAGS_EXACT;
665 } else {666 } else {
667 /* Workaround for erratum #1197 */
668 if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
669 goto out;
670
666 set_linear_ip(&regs, ibs_data.regs[1]);671 set_linear_ip(&regs, ibs_data.regs[1]);
667 regs.flags |= PERF_EFLAGS_EXACT;672 regs.flags |= PERF_EFLAGS_EXACT;
668 }673 }
@@ -756,6 +761,9 @@ static __init void perf_event_ibs_init(void)
756 if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)761 if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
757 perf_ibs_fetch.fetch_count_reset_broken = 1;762 perf_ibs_fetch.fetch_count_reset_broken = 1;
758763
764 if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10)
765 perf_ibs_fetch.fetch_ignore_if_zero_rip = 1;
766
759 perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");767 perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
760768
761 if (ibs_caps & IBS_CAPS_OPCNT) {769 if (ibs_caps & IBS_CAPS_OPCNT) {
diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
index 6a98a76..2da6139 100644
--- a/arch/x86/events/amd/iommu.c
+++ b/arch/x86/events/amd/iommu.c
@@ -18,8 +18,6 @@
18#include "../perf_event.h"18#include "../perf_event.h"
19#include "iommu.h"19#include "iommu.h"
2020
21#define COUNTER_SHIFT 16
22
23/* iommu pmu conf masks */21/* iommu pmu conf masks */
24#define GET_CSOURCE(x) ((x)->conf & 0xFFULL)22#define GET_CSOURCE(x) ((x)->conf & 0xFFULL)
25#define GET_DEVID(x) (((x)->conf >> 8) & 0xFFFFULL)23#define GET_DEVID(x) (((x)->conf >> 8) & 0xFFFFULL)
@@ -285,22 +283,31 @@ static void perf_iommu_start(struct perf_event *event, int flags)
285 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));283 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
286 hwc->state = 0;284 hwc->state = 0;
287285
286 /*
287 * To account for power-gating, which prevents write to
288 * the counter, we need to enable the counter
289 * before setting up counter register.
290 */
291 perf_iommu_enable_event(event);
292
288 if (flags & PERF_EF_RELOAD) {293 if (flags & PERF_EF_RELOAD) {
289 u64 prev_raw_count = local64_read(&hwc->prev_count);294 u64 count = 0;
290 struct amd_iommu *iommu = perf_event_2_iommu(event);295 struct amd_iommu *iommu = perf_event_2_iommu(event);
291296
297 /*
298 * Since the IOMMU PMU only support counting mode,
299 * the counter always start with value zero.
300 */
292 amd_iommu_pc_set_reg(iommu, hwc->iommu_bank, hwc->iommu_cntr,301 amd_iommu_pc_set_reg(iommu, hwc->iommu_bank, hwc->iommu_cntr,
293 IOMMU_PC_COUNTER_REG, &prev_raw_count);302 IOMMU_PC_COUNTER_REG, &count);
294 }303 }
295304
296 perf_iommu_enable_event(event);
297 perf_event_update_userpage(event);305 perf_event_update_userpage(event);
298
299}306}
300307
301static void perf_iommu_read(struct perf_event *event)308static void perf_iommu_read(struct perf_event *event)
302{309{
303 u64 count, prev, delta;310 u64 count;
304 struct hw_perf_event *hwc = &event->hw;311 struct hw_perf_event *hwc = &event->hw;
305 struct amd_iommu *iommu = perf_event_2_iommu(event);312 struct amd_iommu *iommu = perf_event_2_iommu(event);
306313
@@ -311,14 +318,11 @@ static void perf_iommu_read(struct perf_event *event)
311 /* IOMMU pc counter register is only 48 bits */318 /* IOMMU pc counter register is only 48 bits */
312 count &= GENMASK_ULL(47, 0);319 count &= GENMASK_ULL(47, 0);
313320
314 prev = local64_read(&hwc->prev_count);321 /*
315 if (local64_cmpxchg(&hwc->prev_count, prev, count) != prev)322 * Since the counter always start with value zero,
316 return;323 * simply just accumulate the count for the event.
317324 */
318 /* Handle 48-bit counter overflow */325 local64_add(count, &event->count);
319 delta = (count << COUNTER_SHIFT) - (prev << COUNTER_SHIFT);
320 delta >>= COUNTER_SHIFT;
321 local64_add(delta, &event->count);
322}326}
323327
324static void perf_iommu_stop(struct perf_event *event, int flags)328static void perf_iommu_stop(struct perf_event *event, int flags)
@@ -328,15 +332,16 @@ static void perf_iommu_stop(struct perf_event *event, int flags)
328 if (hwc->state & PERF_HES_UPTODATE)332 if (hwc->state & PERF_HES_UPTODATE)
329 return;333 return;
330334
335 /*
336 * To account for power-gating, in which reading the counter would
337 * return zero, we need to read the register before disabling.
338 */
339 perf_iommu_read(event);
340 hwc->state |= PERF_HES_UPTODATE;
341
331 perf_iommu_disable_event(event);342 perf_iommu_disable_event(event);
332 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);343 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
333 hwc->state |= PERF_HES_STOPPED;344 hwc->state |= PERF_HES_STOPPED;
334
335 if (hwc->state & PERF_HES_UPTODATE)
336 return;
337
338 perf_iommu_read(event);
339 hwc->state |= PERF_HES_UPTODATE;
340}345}
341346
342static int perf_iommu_add(struct perf_event *event, int flags)347static int perf_iommu_add(struct perf_event *event, int flags)
diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c
index abef513..c4892b7 100644
--- a/arch/x86/events/amd/power.c
+++ b/arch/x86/events/amd/power.c
@@ -217,6 +217,7 @@ static struct pmu pmu_class = {
217 .stop = pmu_event_stop,217 .stop = pmu_event_stop,
218 .read = pmu_event_read,218 .read = pmu_event_read,
219 .capabilities = PERF_PMU_CAP_NO_EXCLUDE,219 .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
220 .module = THIS_MODULE,
220};221};
221222
222static int power_cpu_exit(unsigned int cpu)223static int power_cpu_exit(unsigned int cpu)
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 05e43d0..da289a4 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -62,7 +62,7 @@ static struct pt_cap_desc {
62 PT_CAP(single_range_output, 0, CPUID_ECX, BIT(2)),62 PT_CAP(single_range_output, 0, CPUID_ECX, BIT(2)),
63 PT_CAP(output_subsys, 0, CPUID_ECX, BIT(3)),63 PT_CAP(output_subsys, 0, CPUID_ECX, BIT(3)),
64 PT_CAP(payloads_lip, 0, CPUID_ECX, BIT(31)),64 PT_CAP(payloads_lip, 0, CPUID_ECX, BIT(31)),
65 PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x3),65 PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x7),
66 PT_CAP(mtc_periods, 1, CPUID_EAX, 0xffff0000),66 PT_CAP(mtc_periods, 1, CPUID_EAX, 0xffff0000),
67 PT_CAP(cycle_thresholds, 1, CPUID_EBX, 0xffff),67 PT_CAP(cycle_thresholds, 1, CPUID_EBX, 0xffff),
68 PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),68 PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 40751af..9096a16 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -4382,7 +4382,7 @@ static void snr_uncore_mmio_init_box(struct intel_uncore_box *box)
4382 return;4382 return;
43834383
4384 pci_read_config_dword(pdev, SNR_IMC_MMIO_BASE_OFFSET, &pci_dword);4384 pci_read_config_dword(pdev, SNR_IMC_MMIO_BASE_OFFSET, &pci_dword);
4385 addr = (pci_dword & SNR_IMC_MMIO_BASE_MASK) << 23;4385 addr = ((resource_size_t)pci_dword & SNR_IMC_MMIO_BASE_MASK) << 23;
43864386
4387 pci_read_config_dword(pdev, SNR_IMC_MMIO_MEM0_OFFSET, &pci_dword);4387 pci_read_config_dword(pdev, SNR_IMC_MMIO_MEM0_OFFSET, &pci_dword);
4388 addr |= (pci_dword & SNR_IMC_MMIO_MEM0_MASK) << 12;4388 addr |= (pci_dword & SNR_IMC_MMIO_MEM0_MASK) << 12;
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index c0a9648..cd11c07 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -389,10 +389,11 @@ static const struct dmi_system_id reboot_dmi_table[] __initconst = {
389 },389 },
390 { /* Handle problems with rebooting on the OptiPlex 990. */390 { /* Handle problems with rebooting on the OptiPlex 990. */
391 .callback = set_pci_reboot,391 .callback = set_pci_reboot,
392 .ident = "Dell OptiPlex 990",392 .ident = "Dell OptiPlex 990 BIOS A0x",
393 .matches = {393 .matches = {
394 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),394 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"),395 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"),
396 DMI_MATCH(DMI_BIOS_VERSION, "A0"),
396 },397 },
397 },398 },
398 { /* Handle problems with rebooting on Dell 300's */399 { /* Handle problems with rebooting on Dell 300's */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 0607163..d4e3804 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1134,6 +1134,7 @@ void __init setup_arch(char **cmdline_p)
1134 efi_fake_memmap();1134 efi_fake_memmap();
1135 efi_find_mirror();1135 efi_find_mirror();
1136 efi_esrt_init();1136 efi_esrt_init();
1137 efi_mokvar_table_init();
11371138
1138 /*1139 /*
1139 * The EFI specification says that boot service code won't be1140 * The EFI specification says that boot service code won't be
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 260c64c..d3877dd 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4666,7 +4666,15 @@ static void reset_rsvds_bits_mask_ept(struct kvm_vcpu *vcpu,
4666void4666void
4667reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, struct kvm_mmu *context)4667reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
4668{4668{
4669 bool uses_nx = context->nx ||4669 /*
4670 * KVM uses NX when TDP is disabled to handle a variety of scenarios,
4671 * notably for huge SPTEs if iTLB multi-hit mitigation is enabled and
4672 * to generate correct permissions for CR0.WP=0/CR4.SMEP=1/EFER.NX=0.
4673 * The iTLB multi-hit workaround can be toggled at any time, so assume
4674 * NX can be used by any non-nested shadow MMU to avoid having to reset
4675 * MMU contexts. Note, KVM forces EFER.NX=1 when TDP is disabled.
4676 */
4677 bool uses_nx = context->nx || !tdp_enabled ||
4670 context->mmu_role.base.smep_andnot_wp;4678 context->mmu_role.base.smep_andnot_wp;
4671 struct rsvd_bits_validate *shadow_zero_check;4679 struct rsvd_bits_validate *shadow_zero_check;
4672 int i;4680 int i;
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index ae1c5ba..4a83038 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -87,6 +87,9 @@ static const unsigned long * const efi_tables[] = {
87#endif87#endif
88 &efi.tpm_log,88 &efi.tpm_log,
89 &efi.tpm_final_log,89 &efi.tpm_final_log,
90#ifdef CONFIG_LOAD_UEFI_KEYS
91 &efi.mokvar_table,
92#endif
90};93};
9194
92u64 efi_setup; /* efi setup_data physical address */95u64 efi_setup; /* efi setup_data physical address */
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 8352037..499bdd1 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -27,7 +27,7 @@ config XTENSA
27 select HAVE_DMA_CONTIGUOUS27 select HAVE_DMA_CONTIGUOUS
28 select HAVE_EXIT_THREAD28 select HAVE_EXIT_THREAD
29 select HAVE_FUNCTION_TRACER29 select HAVE_FUNCTION_TRACER
30 select HAVE_FUTEX_CMPXCHG if !MMU30 select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
31 select HAVE_HW_BREAKPOINT if PERF_EVENTS31 select HAVE_HW_BREAKPOINT if PERF_EVENTS
32 select HAVE_IRQ_TIME_ACCOUNTING32 select HAVE_IRQ_TIME_ACCOUNTING
33 select HAVE_OPROFILE33 select HAVE_OPROFILE
diff --git a/certs/.gitignore b/certs/.gitignore
index f51aea4..6ce8116 100644
--- a/certs/.gitignore
+++ b/certs/.gitignore
@@ -2,3 +2,4 @@
2# Generated files2# Generated files
3#3#
4x509_certificate_list4x509_certificate_list
5x509_revocation_list
diff --git a/certs/Kconfig b/certs/Kconfig
index 76e469b..ab88d2a 100644
--- a/certs/Kconfig
+++ b/certs/Kconfig
@@ -92,4 +92,12 @@ config SYSTEM_REVOCATION_LIST
92 blacklist keyring and implements a hook whereby a PKCS#7 message can92 blacklist keyring and implements a hook whereby a PKCS#7 message can
93 be checked to see if it matches such a certificate.93 be checked to see if it matches such a certificate.
9494
95config SYSTEM_REVOCATION_KEYS
96 string "X.509 certificates to be preloaded into the system blacklist keyring"
97 depends on SYSTEM_REVOCATION_LIST
98 help
99 If set, this option should be the filename of a PEM-formatted file
100 containing X.509 certificates to be included in the default blacklist
101 keyring.
102
95endmenu103endmenu
diff --git a/certs/Makefile b/certs/Makefile
index f4b90ba..b6db52e 100644
--- a/certs/Makefile
+++ b/certs/Makefile
@@ -4,7 +4,8 @@
4#4#
55
6obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o6obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o
7obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o7obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o common.o
8obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o
8ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),"")9ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),"")
9obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o10obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o
10else11else
@@ -29,7 +30,7 @@ $(obj)/x509_certificate_list: scripts/extract-cert $(SYSTEM_TRUSTED_KEYS_SRCPREF
29 $(call if_changed,extract_certs,$(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_TRUSTED_KEYS))30 $(call if_changed,extract_certs,$(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_TRUSTED_KEYS))
30endif # CONFIG_SYSTEM_TRUSTED_KEYRING31endif # CONFIG_SYSTEM_TRUSTED_KEYRING
3132
32clean-files := x509_certificate_list .x509.list33clean-files := x509_certificate_list .x509.list x509_revocation_list
3334
34ifeq ($(CONFIG_MODULE_SIG),y)35ifeq ($(CONFIG_MODULE_SIG),y)
35###############################################################################36###############################################################################
@@ -104,3 +105,17 @@ targets += signing_key.x509
104$(obj)/signing_key.x509: scripts/extract-cert $(X509_DEP) FORCE105$(obj)/signing_key.x509: scripts/extract-cert $(X509_DEP) FORCE
105 $(call if_changed,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY))106 $(call if_changed,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY))
106endif # CONFIG_MODULE_SIG107endif # CONFIG_MODULE_SIG
108
109ifeq ($(CONFIG_SYSTEM_REVOCATION_LIST),y)
110
111$(eval $(call config_filename,SYSTEM_REVOCATION_KEYS))
112
113$(obj)/revocation_certificates.o: $(obj)/x509_revocation_list
114
115quiet_cmd_extract_certs = EXTRACT_CERTS $(patsubst "%",%,$(2))
116 cmd_extract_certs = scripts/extract-cert $(2) $@
117
118targets += x509_revocation_list
119$(obj)/x509_revocation_list: scripts/extract-cert $(SYSTEM_REVOCATION_KEYS_SRCPREFIX)$(SYSTEM_REVOCATION_KEYS_FILENAME) FORCE
120 $(call if_changed,extract_certs,$(SYSTEM_REVOCATION_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_REVOCATION_KEYS))
121endif
diff --git a/certs/blacklist.c b/certs/blacklist.c
index 59b2f10..7638dfa 100644
--- a/certs/blacklist.c
+++ b/certs/blacklist.c
@@ -16,9 +16,15 @@
16#include <linux/seq_file.h>16#include <linux/seq_file.h>
17#include <keys/system_keyring.h>17#include <keys/system_keyring.h>
18#include "blacklist.h"18#include "blacklist.h"
19#include "common.h"
1920
20static struct key *blacklist_keyring;21static struct key *blacklist_keyring;
2122
23#ifdef CONFIG_SYSTEM_REVOCATION_LIST
24extern __initconst const u8 revocation_certificate_list[];
25extern __initconst const unsigned long revocation_certificate_list_size;
26#endif
27
22/*28/*
23 * The description must be a type prefix, a colon and then an even number of29 * The description must be a type prefix, a colon and then an even number of
24 * hex digits. The hash is kept in the description.30 * hex digits. The hash is kept in the description.
@@ -165,6 +171,9 @@ int add_key_to_revocation_list(const char *data, size_t size)
165 if (IS_ERR(key)) {171 if (IS_ERR(key)) {
166 pr_err("Problem with revocation key (%ld)\n", PTR_ERR(key));172 pr_err("Problem with revocation key (%ld)\n", PTR_ERR(key));
167 return PTR_ERR(key);173 return PTR_ERR(key);
174 } else {
175 pr_notice("Revoked X.509 cert '%s'\n",
176 key_ref_to_ptr(key)->description);
168 }177 }
169178
170 return 0;179 return 0;
@@ -220,3 +229,18 @@ static int __init blacklist_init(void)
220 * Must be initialised before we try and load the keys into the keyring.229 * Must be initialised before we try and load the keys into the keyring.
221 */230 */
222device_initcall(blacklist_init);231device_initcall(blacklist_init);
232
233#ifdef CONFIG_SYSTEM_REVOCATION_LIST
234/*
235 * Load the compiled-in list of revocation X.509 certificates.
236 */
237static __init int load_revocation_certificate_list(void)
238{
239 if (revocation_certificate_list_size)
240 pr_notice("Loading compiled-in revocation X.509 certificates\n");
241
242 return load_certificate_list(revocation_certificate_list, revocation_certificate_list_size,
243 blacklist_keyring);
244}
245late_initcall(load_revocation_certificate_list);
246#endif
diff --git a/certs/common.c b/certs/common.c
index 16a2208..23af4fc 100644
--- a/certs/common.c
+++ b/certs/common.c
@@ -41,6 +41,7 @@ int load_certificate_list(const u8 cert_list[],
41 if (IS_ERR(key)) {41 if (IS_ERR(key)) {
42 pr_err("Problem loading in-kernel X.509 certificate (%ld)\n",42 pr_err("Problem loading in-kernel X.509 certificate (%ld)\n",
43 PTR_ERR(key));43 PTR_ERR(key));
44 WARN_ON_ONCE(1);
44 } else {45 } else {
45 pr_notice("Loaded X.509 cert '%s'\n",46 pr_notice("Loaded X.509 cert '%s'\n",
46 key_ref_to_ptr(key)->description);47 key_ref_to_ptr(key)->description);
diff --git a/certs/revocation_certificates.S b/certs/revocation_certificates.S
47new file mode 10064448new file mode 100644
index 0000000..f21aae8
--- /dev/null
+++ b/certs/revocation_certificates.S
@@ -0,0 +1,21 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#include <linux/export.h>
3#include <linux/init.h>
4
5 __INITRODATA
6
7 .align 8
8 .globl revocation_certificate_list
9revocation_certificate_list:
10__revocation_list_start:
11 .incbin "certs/x509_revocation_list"
12__revocation_list_end:
13
14 .align 8
15 .globl revocation_certificate_list_size
16revocation_certificate_list_size:
17#ifdef CONFIG_64BIT
18 .quad __revocation_list_end - __revocation_list_start
19#else
20 .long __revocation_list_end - __revocation_list_start
21#endif
diff --git a/debian.master/config/annotations b/debian.master/config/annotations
index b23d62d..03b21b4 100644
--- a/debian.master/config/annotations
+++ b/debian.master/config/annotations
@@ -364,6 +364,7 @@ CONFIG_SYSTEM_TRUSTED_KEYRING policy<{'amd64': 'y', 'arm64': '
364CONFIG_SYSTEM_TRUSTED_KEYS policy<{'amd64': '"debian/canonical-certs.pem"', 'arm64': '"debian/canonical-certs.pem"', 'armhf': '"debian/canonical-certs.pem"', 'i386': '"debian/canonical-certs.pem"', 'ppc64el': '"debian/canonical-certs.pem"', 's390x': '"debian/canonical-certs.pem"'}>364CONFIG_SYSTEM_TRUSTED_KEYS policy<{'amd64': '"debian/canonical-certs.pem"', 'arm64': '"debian/canonical-certs.pem"', 'armhf': '"debian/canonical-certs.pem"', 'i386': '"debian/canonical-certs.pem"', 'ppc64el': '"debian/canonical-certs.pem"', 's390x': '"debian/canonical-certs.pem"'}>
365CONFIG_SYSTEM_EXTRA_CERTIFICATE policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'i386': 'y', 'ppc64el': 'y', 's390x': 'y'}>365CONFIG_SYSTEM_EXTRA_CERTIFICATE policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'i386': 'y', 'ppc64el': 'y', 's390x': 'y'}>
366CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE policy<{'amd64': '4096', 'arm64': '4096', 'armhf': '4096', 'i386': '4096', 'ppc64el': '4096', 's390x': '4096'}>366CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE policy<{'amd64': '4096', 'arm64': '4096', 'armhf': '4096', 'i386': '4096', 'ppc64el': '4096', 's390x': '4096'}>
367CONFIG_SYSTEM_REVOCATION_KEYS policy<{'amd64': '"debian/canonical-revoked-certs.pem"', 'arm64': '"debian/canonical-revoked-certs.pem"', 'armhf': '"debian/canonical-revoked-certs.pem"', 'ppc64el': '"debian/canonical-revoked-certs.pem"', 's390x': '"debian/canonical-revoked-certs.pem"'}>
367CONFIG_SECONDARY_TRUSTED_KEYRING policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'i386': 'y', 'ppc64el': 'y', 's390x': 'y'}>368CONFIG_SECONDARY_TRUSTED_KEYRING policy<{'amd64': 'y', 'arm64': 'y', 'armhf': 'y', 'i386': 'y', 'ppc64el': 'y', 's390x': 'y'}>
368369
369# Menu: Cryptographic API >> Hardware crypto devices370# Menu: Cryptographic API >> Hardware crypto devices
diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index c6bb6db..bc171d7 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -9925,6 +9925,7 @@ CONFIG_SYSTEM_BLACKLIST_KEYRING=y
9925CONFIG_SYSTEM_DATA_VERIFICATION=y9925CONFIG_SYSTEM_DATA_VERIFICATION=y
9926CONFIG_SYSTEM_EXTRA_CERTIFICATE=y9926CONFIG_SYSTEM_EXTRA_CERTIFICATE=y
9927CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=40969927CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=4096
9928CONFIG_SYSTEM_REVOCATION_KEYS="debian/canonical-revoked-certs.pem"
9928CONFIG_SYSTEM_REVOCATION_LIST=y9929CONFIG_SYSTEM_REVOCATION_LIST=y
9929CONFIG_SYSTEM_TRUSTED_KEYRING=y9930CONFIG_SYSTEM_TRUSTED_KEYRING=y
9930CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"9931CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"
diff --git a/debian.master/upstream-stable b/debian.master/upstream-stable
index f1840cb..f2e7f82 100644
--- a/debian.master/upstream-stable
+++ b/debian.master/upstream-stable
@@ -1,3 +1,3 @@
1# The following upstream stable releases have been ported:1# The following upstream stable releases have been ported:
2[upstream-stable]2[upstream-stable]
3 linux-5.4.y = v5.4.1433 linux-5.4.y = v5.4.145
diff --git a/debian/revoked-certs/canonical-uefi-2012-all.pem b/debian/revoked-certs/canonical-uefi-2012-all.pem
4new file mode 1006444new file mode 100644
index 0000000..06c116e
--- /dev/null
+++ b/debian/revoked-certs/canonical-uefi-2012-all.pem
@@ -0,0 +1,86 @@
1Certificate:
2 Data:
3 Version: 3 (0x2)
4 Serial Number: 1 (0x1)
5 Signature Algorithm: sha256WithRSAEncryption
6 Issuer: C = GB, ST = Isle of Man, L = Douglas, O = Canonical Ltd., CN = Canonical Ltd. Master Certificate Authority
7 Validity
8 Not Before: Apr 12 11:39:08 2012 GMT
9 Not After : Apr 11 11:39:08 2042 GMT
10 Subject: C = GB, ST = Isle of Man, O = Canonical Ltd., OU = Secure Boot, CN = Canonical Ltd. Secure Boot Signing
11 Subject Public Key Info:
12 Public Key Algorithm: rsaEncryption
13 RSA Public-Key: (2048 bit)
14 Modulus:
15 00:c9:5f:9b:62:8f:0b:b0:64:82:ac:be:c9:e2:62:
16 e3:4b:d2:9f:1e:8a:d5:61:1a:2b:5d:38:f4:b7:ce:
17 b9:9a:b8:43:b8:43:97:77:ab:4f:7f:0c:70:46:0b:
18 fc:7f:6d:c6:6d:ea:80:5e:01:d2:b7:66:1e:87:de:
19 0d:6d:d0:41:97:a8:a5:af:0c:63:4f:f7:7c:c2:52:
20 cc:a0:31:a9:bb:89:5d:99:1e:46:6f:55:73:b9:76:
21 69:ec:d7:c1:fc:21:d6:c6:07:e7:4f:bd:22:de:e4:
22 a8:5b:2d:db:95:34:19:97:d6:28:4b:21:4c:ca:bb:
23 1d:79:a6:17:7f:5a:f9:67:e6:5c:78:45:3d:10:6d:
24 b0:17:59:26:11:c5:57:e3:7f:4e:82:ba:f6:2c:4e:
25 c8:37:4d:ff:85:15:84:47:e0:ed:3b:7c:7f:bc:af:
26 e9:01:05:a7:0c:6f:c3:e9:8d:a3:ce:be:a6:e3:cd:
27 3c:b5:58:2c:9e:c2:03:1c:60:22:37:39:ff:41:02:
28 c1:29:a4:65:51:ff:33:34:aa:42:15:f9:95:78:fc:
29 2d:f5:da:8a:85:7c:82:9d:fb:37:2c:6b:a5:a8:df:
30 7c:55:0b:80:2e:3c:b0:63:e1:cd:38:48:89:e8:14:
31 06:0b:82:bc:fd:d4:07:68:1b:0f:3e:d9:15:dd:94:
32 11:1b
33 Exponent: 65537 (0x10001)
34 X509v3 extensions:
35 X509v3 Basic Constraints: critical
36 CA:FALSE
37 X509v3 Extended Key Usage:
38 Code Signing, 1.3.6.1.4.1.311.10.3.6
39 Netscape Comment:
40 OpenSSL Generated Certificate
41 X509v3 Subject Key Identifier:
42 61:48:2A:A2:83:0D:0A:B2:AD:5A:F1:0B:72:50:DA:90:33:DD:CE:F0
43 X509v3 Authority Key Identifier:
44 keyid:AD:91:99:0B:C2:2A:B1:F5:17:04:8C:23:B6:65:5A:26:8E:34:5A:63
45
46 Signature Algorithm: sha256WithRSAEncryption
47 8f:8a:a1:06:1f:29:b7:0a:4a:d5:c5:fd:81:ab:25:ea:c0:7d:
48 e2:fc:6a:96:a0:79:93:67:ee:05:0e:25:12:25:e4:5a:f6:aa:
49 1a:f1:12:f3:05:8d:87:5e:f1:5a:5c:cb:8d:23:73:65:1d:15:
50 b9:de:22:6b:d6:49:67:c9:a3:c6:d7:62:4e:5c:b5:f9:03:83:
51 40:81:dc:87:9c:3c:3f:1c:0d:51:9f:94:65:0a:84:48:67:e4:
52 a2:f8:a6:4a:f0:e7:cd:cd:bd:94:e3:09:d2:5d:2d:16:1b:05:
53 15:0b:cb:44:b4:3e:61:42:22:c4:2a:5c:4e:c5:1d:a3:e2:e0:
54 52:b2:eb:f4:8b:2b:dc:38:39:5d:fb:88:a1:56:65:5f:2b:4f:
55 26:ff:06:78:10:12:eb:8c:5d:32:e3:c6:45:af:25:9b:a0:ff:
56 8e:ef:47:09:a3:e9:8b:37:92:92:69:76:7e:34:3b:92:05:67:
57 4e:b0:25:ed:bc:5e:5f:8f:b4:d6:ca:40:ff:e4:e2:31:23:0c:
58 85:25:ae:0c:55:01:ec:e5:47:5e:df:5b:bc:14:33:e3:c6:f5:
59 18:b6:d9:f7:dd:b3:b4:a1:31:d3:5a:5c:5d:7d:3e:bf:0a:e4:
60 e4:e8:b4:59:7d:3b:b4:8c:a3:1b:b5:20:a3:b9:3e:84:6f:8c:
61 21:00:c3:39
62-----BEGIN CERTIFICATE-----
63MIIEIDCCAwigAwIBAgIBATANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UEBhMCR0Ix
64FDASBgNVBAgMC0lzbGUgb2YgTWFuMRAwDgYDVQQHDAdEb3VnbGFzMRcwFQYDVQQK
65DA5DYW5vbmljYWwgTHRkLjE0MDIGA1UEAwwrQ2Fub25pY2FsIEx0ZC4gTWFzdGVy
66IENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xMjA0MTIxMTM5MDhaFw00MjA0MTEx
67MTM5MDhaMH8xCzAJBgNVBAYTAkdCMRQwEgYDVQQIDAtJc2xlIG9mIE1hbjEXMBUG
68A1UECgwOQ2Fub25pY2FsIEx0ZC4xFDASBgNVBAsMC1NlY3VyZSBCb290MSswKQYD
69VQQDDCJDYW5vbmljYWwgTHRkLiBTZWN1cmUgQm9vdCBTaWduaW5nMIIBIjANBgkq
70hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyV+bYo8LsGSCrL7J4mLjS9KfHorVYRor
71XTj0t865mrhDuEOXd6tPfwxwRgv8f23GbeqAXgHSt2Yeh94NbdBBl6ilrwxjT/d8
72wlLMoDGpu4ldmR5Gb1VzuXZp7NfB/CHWxgfnT70i3uSoWy3blTQZl9YoSyFMyrsd
73eaYXf1r5Z+ZceEU9EG2wF1kmEcVX439Ogrr2LE7IN03/hRWER+DtO3x/vK/pAQWn
74DG/D6Y2jzr6m4808tVgsnsIDHGAiNzn/QQLBKaRlUf8zNKpCFfmVePwt9dqKhXyC
75nfs3LGulqN98VQuALjywY+HNOEiJ6BQGC4K8/dQHaBsPPtkV3ZQRGwIDAQABo4Gg
76MIGdMAwGA1UdEwEB/wQCMAAwHwYDVR0lBBgwFgYIKwYBBQUHAwMGCisGAQQBgjcK
77AwYwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRl
78MB0GA1UdDgQWBBRhSCqigw0Ksq1a8QtyUNqQM93O8DAfBgNVHSMEGDAWgBStkZkL
79wiqx9RcEjCO2ZVomjjRaYzANBgkqhkiG9w0BAQsFAAOCAQEAj4qhBh8ptwpK1cX9
80gasl6sB94vxqlqB5k2fuBQ4lEiXkWvaqGvES8wWNh17xWlzLjSNzZR0Vud4ia9ZJ
81Z8mjxtdiTly1+QODQIHch5w8PxwNUZ+UZQqESGfkovimSvDnzc29lOMJ0l0tFhsF
82FQvLRLQ+YUIixCpcTsUdo+LgUrLr9Isr3Dg5XfuIoVZlXytPJv8GeBAS64xdMuPG
83Ra8lm6D/ju9HCaPpizeSkml2fjQ7kgVnTrAl7bxeX4+01spA/+TiMSMMhSWuDFUB
847OVHXt9bvBQz48b1GLbZ992ztKEx01pcXX0+vwrk5Oi0WX07tIyjG7Ugo7k+hG+M
85IQDDOQ==
86-----END CERTIFICATE-----
diff --git a/debian/rules b/debian/rules
index f8d53af..b10128a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -137,7 +137,7 @@ binary: binary-indep binary-arch
137137
138build: build-arch build-indep138build: build-arch build-indep
139139
140clean: debian/control debian/canonical-certs.pem140clean: debian/control debian/canonical-certs.pem debian/canonical-revoked-certs.pem
141 dh_testdir141 dh_testdir
142 dh_testroot142 dh_testroot
143 dh_clean143 dh_clean
@@ -247,3 +247,15 @@ debian/canonical-certs.pem: $(wildcard $(DROOT)/certs/*-all.pem) $(wildcard $(DR
247 fi; \247 fi; \
248 done; \248 done; \
249 done >"$@"249 done >"$@"
250
251debian/canonical-revoked-certs.pem: $(wildcard $(DROOT)/revoked-certs/*-all.pem) $(wildcard $(DROOT)/revoked-certs/*-$(arch).pem) $(wildcard $(DEBIAN)/revoked-certs/*-all.pem) $(wildcard $(DEBIAN)/revoked-certs/*-$(arch).pem)
252 for cert in $(sort $(notdir $^)); \
253 do \
254 for dir in $(DEBIAN) $(DROOT); \
255 do \
256 if [ -f "$$dir/revoked-certs/$$cert" ]; then \
257 cat "$$dir/revoked-certs/$$cert"; \
258 break; \
259 fi; \
260 done; \
261 done >"$@"
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 0fc27ac..9f67823 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -230,7 +230,7 @@ config BLK_DEV_LOOP_MIN_COUNT
230 dynamically allocated with the /dev/loop-control interface.230 dynamically allocated with the /dev/loop-control interface.
231231
232config BLK_DEV_CRYPTOLOOP232config BLK_DEV_CRYPTOLOOP
233 tristate "Cryptoloop Support"233 tristate "Cryptoloop Support (DEPRECATED)"
234 select CRYPTO234 select CRYPTO
235 select CRYPTO_CBC235 select CRYPTO_CBC
236 depends on BLK_DEV_LOOP236 depends on BLK_DEV_LOOP
@@ -242,7 +242,7 @@ config BLK_DEV_CRYPTOLOOP
242 WARNING: This device is not safe for journaled file systems like242 WARNING: This device is not safe for journaled file systems like
243 ext3 or Reiserfs. Please use the Device Mapper crypto module243 ext3 or Reiserfs. Please use the Device Mapper crypto module
244 instead, which can be configured to be on-disk compatible with the244 instead, which can be configured to be on-disk compatible with the
245 cryptoloop device.245 cryptoloop device. cryptoloop support will be removed in Linux 5.16.
246246
247source "drivers/block/drbd/Kconfig"247source "drivers/block/drbd/Kconfig"
248248
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 3cabc33..f0a91fa 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -189,6 +189,8 @@ init_cryptoloop(void)
189189
190 if (rc)190 if (rc)
191 printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");191 printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
192 else
193 pr_warn("the cryptoloop driver has been deprecated and will be removed in in Linux 5.16\n");
192 return rc;194 return rc;
193}195}
194196
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 40ea1a4..ac97a1e 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4063,22 +4063,21 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
4063 if (UFDCS->rawcmd == 1)4063 if (UFDCS->rawcmd == 1)
4064 UFDCS->rawcmd = 2;4064 UFDCS->rawcmd = 2;
40654065
4066 if (mode & (FMODE_READ|FMODE_WRITE)) {4066 if (!(mode & FMODE_NDELAY)) {
4067 UDRS->last_checked = 0;4067 if (mode & (FMODE_READ|FMODE_WRITE)) {
4068 clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);4068 UDRS->last_checked = 0;
4069 check_disk_change(bdev);4069 clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
4070 if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))4070 check_disk_change(bdev);
4071 goto out;4071 if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
4072 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))4072 goto out;
4073 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
4074 goto out;
4075 }
4076 res = -EROFS;
4077 if ((mode & FMODE_WRITE) &&
4078 !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
4073 goto out;4079 goto out;
4074 }4080 }
4075
4076 res = -EROFS;
4077
4078 if ((mode & FMODE_WRITE) &&
4079 !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
4080 goto out;
4081
4082 mutex_unlock(&open_lock);4081 mutex_unlock(&open_lock);
4083 mutex_unlock(&floppy_mutex);4082 mutex_unlock(&floppy_mutex);
4084 return 0;4083 return 0;
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile
index 195b078..5bb7be5 100644
--- a/drivers/firmware/efi/Makefile
+++ b/drivers/firmware/efi/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_EFI_DEV_PATH_PARSER) += dev-path-parser.o
27obj-$(CONFIG_EFI) += secureboot.o27obj-$(CONFIG_EFI) += secureboot.o
28obj-$(CONFIG_APPLE_PROPERTIES) += apple-properties.o28obj-$(CONFIG_APPLE_PROPERTIES) += apple-properties.o
29obj-$(CONFIG_EFI_RCI2_TABLE) += rci2-table.o29obj-$(CONFIG_EFI_RCI2_TABLE) += rci2-table.o
30obj-$(CONFIG_LOAD_UEFI_KEYS) += mokvar-table.o
3031
31arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o32arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o
32obj-$(CONFIG_ARM) += $(arm-obj-y)33obj-$(CONFIG_ARM) += $(arm-obj-y)
diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index a4bed96..c4848c3 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -263,6 +263,7 @@ void __init efi_init(void)
263263
264 reserve_regions();264 reserve_regions();
265 efi_esrt_init();265 efi_esrt_init();
266 efi_mokvar_table_init();
266267
267 memblock_reserve(params.mmap & PAGE_MASK,268 memblock_reserve(params.mmap & PAGE_MASK,
268 PAGE_ALIGN(params.mmap_size +269 PAGE_ALIGN(params.mmap_size +
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index e812f45..828c195 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -53,6 +53,9 @@ struct efi __read_mostly efi = {
53 .rng_seed = EFI_INVALID_TABLE_ADDR,53 .rng_seed = EFI_INVALID_TABLE_ADDR,
54 .tpm_log = EFI_INVALID_TABLE_ADDR,54 .tpm_log = EFI_INVALID_TABLE_ADDR,
55 .tpm_final_log = EFI_INVALID_TABLE_ADDR,55 .tpm_final_log = EFI_INVALID_TABLE_ADDR,
56#ifdef CONFIG_LOAD_UEFI_KEYS
57 .mokvar_table = EFI_INVALID_TABLE_ADDR,
58#endif
56 .mem_reserve = EFI_INVALID_TABLE_ADDR,59 .mem_reserve = EFI_INVALID_TABLE_ADDR,
57};60};
58EXPORT_SYMBOL(efi);61EXPORT_SYMBOL(efi);
@@ -480,6 +483,9 @@ static __initdata efi_config_table_type_t common_tables[] = {
480#ifdef CONFIG_EFI_RCI2_TABLE483#ifdef CONFIG_EFI_RCI2_TABLE
481 {DELLEMC_EFI_RCI2_TABLE_GUID, NULL, &rci2_table_phys},484 {DELLEMC_EFI_RCI2_TABLE_GUID, NULL, &rci2_table_phys},
482#endif485#endif
486#ifdef CONFIG_LOAD_UEFI_KEYS
487 {LINUX_EFI_MOK_VARIABLE_TABLE_GUID, "MOKvar", &efi.mokvar_table},
488#endif
483 {NULL_GUID, NULL, NULL},489 {NULL_GUID, NULL, NULL},
484};490};
485491
diff --git a/drivers/firmware/efi/mokvar-table.c b/drivers/firmware/efi/mokvar-table.c
486new file mode 100644492new file mode 100644
index 0000000..38722d2
--- /dev/null
+++ b/drivers/firmware/efi/mokvar-table.c
@@ -0,0 +1,362 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * mokvar-table.c
4 *
5 * Copyright (c) 2020 Red Hat
6 * Author: Lenny Szubowicz <lszubowi@redhat.com>
7 *
8 * This module contains the kernel support for the Linux EFI Machine
9 * Owner Key (MOK) variable configuration table, which is identified by
10 * the LINUX_EFI_MOK_VARIABLE_TABLE_GUID.
11 *
12 * This EFI configuration table provides a more robust alternative to
13 * EFI volatile variables by which an EFI boot loader can pass the
14 * contents of the Machine Owner Key (MOK) certificate stores to the
15 * kernel during boot. If both the EFI MOK config table and corresponding
16 * EFI MOK variables are present, the table should be considered as
17 * more authoritative.
18 *
19 * This module includes code that validates and maps the EFI MOK table,
20 * if it's presence was detected very early in boot.
21 *
22 * Kernel interface routines are provided to walk through all the
23 * entries in the MOK config table or to search for a specific named
24 * entry.
25 *
26 * The contents of the individual named MOK config table entries are
27 * made available to user space via read-only sysfs binary files under:
28 *
29 * /sys/firmware/efi/mok-variables/
30 *
31 */
32#define pr_fmt(fmt) "mokvar: " fmt
33
34#include <linux/capability.h>
35#include <linux/efi.h>
36#include <linux/init.h>
37#include <linux/io.h>
38#include <linux/kernel.h>
39#include <linux/kobject.h>
40#include <linux/list.h>
41#include <linux/slab.h>
42
43#include <asm/early_ioremap.h>
44
45/*
46 * The LINUX_EFI_MOK_VARIABLE_TABLE_GUID config table is a packed
47 * sequence of struct efi_mokvar_table_entry, one for each named
48 * MOK variable. The sequence is terminated by an entry with a
49 * completely NULL name and 0 data size.
50 *
51 * efi_mokvar_table_size is set to the computed size of the
52 * MOK config table by efi_mokvar_table_init(). This will be
53 * non-zero if and only if the table if present and has been
54 * validated by efi_mokvar_table_init().
55 */
56static size_t efi_mokvar_table_size;
57
58/*
59 * efi_mokvar_table_va is the kernel virtual address at which the
60 * EFI MOK config table has been mapped by efi_mokvar_sysfs_init().
61 */
62static struct efi_mokvar_table_entry *efi_mokvar_table_va;
63
64/*
65 * Each /sys/firmware/efi/mok-variables/ sysfs file is represented by
66 * an instance of struct efi_mokvar_sysfs_attr on efi_mokvar_sysfs_list.
67 * bin_attr.private points to the associated EFI MOK config table entry.
68 *
69 * This list is created during boot and then remains unchanged.
70 * So no synchronization is currently required to walk the list.
71 */
72struct efi_mokvar_sysfs_attr {
73 struct bin_attribute bin_attr;
74 struct list_head node;
75};
76
77static LIST_HEAD(efi_mokvar_sysfs_list);
78static struct kobject *mokvar_kobj;
79
80/*
81 * efi_mokvar_table_init() - Early boot validation of EFI MOK config table
82 *
83 * If present, validate and compute the size of the EFI MOK variable
84 * configuration table. This table may be provided by an EFI boot loader
85 * as an alternative to ordinary EFI variables, due to platform-dependent
86 * limitations. The memory occupied by this table is marked as reserved.
87 *
88 * This routine must be called before efi_free_boot_services() in order
89 * to guarantee that it can mark the table as reserved.
90 *
91 * Implicit inputs:
92 * efi.mokvar_table: Physical address of EFI MOK variable config table
93 * or special value that indicates no such table.
94 *
95 * Implicit outputs:
96 * efi_mokvar_table_size: Computed size of EFI MOK variable config table.
97 * The table is considered present and valid if this
98 * is non-zero.
99 */
100void __init efi_mokvar_table_init(void)
101{
102 efi_memory_desc_t md;
103 void *va = NULL;
104 unsigned long cur_offset = 0;
105 unsigned long offset_limit;
106 unsigned long map_size = 0;
107 unsigned long map_size_needed = 0;
108 unsigned long size;
109 struct efi_mokvar_table_entry *mokvar_entry;
110 int err;
111
112 if (!efi_enabled(EFI_MEMMAP))
113 return;
114
115 if (efi.mokvar_table == EFI_INVALID_TABLE_ADDR)
116 return;
117 /*
118 * The EFI MOK config table must fit within a single EFI memory
119 * descriptor range.
120 */
121 err = efi_mem_desc_lookup(efi.mokvar_table, &md);
122 if (err) {
123 pr_warn("EFI MOKvar config table is not within the EFI memory map\n");
124 return;
125 }
126
127 offset_limit = efi_mem_desc_end(&md) - efi.mokvar_table;
128
129 /*
130 * Validate the MOK config table. Since there is no table header
131 * from which we could get the total size of the MOK config table,
132 * we compute the total size as we validate each variably sized
133 * entry, remapping as necessary.
134 */
135 err = -EINVAL;
136 while (cur_offset + sizeof(*mokvar_entry) <= offset_limit) {
137 mokvar_entry = va + cur_offset;
138 map_size_needed = cur_offset + sizeof(*mokvar_entry);
139 if (map_size_needed > map_size) {
140 if (va)
141 early_memunmap(va, map_size);
142 /*
143 * Map a little more than the fixed size entry
144 * header, anticipating some data. It's safe to
145 * do so as long as we stay within current memory
146 * descriptor.
147 */
148 map_size = min(map_size_needed + 2*EFI_PAGE_SIZE,
149 offset_limit);
150 va = early_memremap(efi.mokvar_table, map_size);
151 if (!va) {
152 pr_err("Failed to map EFI MOKvar config table pa=0x%lx, size=%lu.\n",
153 efi.mokvar_table, map_size);
154 return;
155 }
156 mokvar_entry = va + cur_offset;
157 }
158
159 /* Check for last sentinel entry */
160 if (mokvar_entry->name[0] == '\0') {
161 if (mokvar_entry->data_size != 0)
162 break;
163 err = 0;
164 break;
165 }
166
167 /* Sanity check that the name is null terminated */
168 size = strnlen(mokvar_entry->name,
169 sizeof(mokvar_entry->name));
170 if (size >= sizeof(mokvar_entry->name))
171 break;
172
173 /* Advance to the next entry */
174 cur_offset = map_size_needed + mokvar_entry->data_size;
175 }
176
177 if (va)
178 early_memunmap(va, map_size);
179 if (err) {
180 pr_err("EFI MOKvar config table is not valid\n");
181 return;
182 }
183
184 if (md.type == EFI_BOOT_SERVICES_DATA)
185 efi_mem_reserve(efi.mokvar_table, map_size_needed);
186
187 efi_mokvar_table_size = map_size_needed;
188}
189
190/*
191 * efi_mokvar_entry_next() - Get next entry in the EFI MOK config table
192 *
193 * mokvar_entry: Pointer to current EFI MOK config table entry
194 * or null. Null indicates get first entry.
195 * Passed by reference. This is updated to the
196 * same value as the return value.
197 *
198 * Returns: Pointer to next EFI MOK config table entry
199 * or null, if there are no more entries.
200 * Same value is returned in the mokvar_entry
201 * parameter.
202 *
203 * This routine depends on the EFI MOK config table being entirely
204 * mapped with it's starting virtual address in efi_mokvar_table_va.
205 */
206struct efi_mokvar_table_entry *efi_mokvar_entry_next(
207 struct efi_mokvar_table_entry **mokvar_entry)
208{
209 struct efi_mokvar_table_entry *mokvar_cur;
210 struct efi_mokvar_table_entry *mokvar_next;
211 size_t size_cur;
212
213 mokvar_cur = *mokvar_entry;
214 *mokvar_entry = NULL;
215
216 if (efi_mokvar_table_va == NULL)
217 return NULL;
218
219 if (mokvar_cur == NULL) {
220 mokvar_next = efi_mokvar_table_va;
221 } else {
222 if (mokvar_cur->name[0] == '\0')
223 return NULL;
224 size_cur = sizeof(*mokvar_cur) + mokvar_cur->data_size;
225 mokvar_next = (void *)mokvar_cur + size_cur;
226 }
227
228 if (mokvar_next->name[0] == '\0')
229 return NULL;
230
231 *mokvar_entry = mokvar_next;
232 return mokvar_next;
233}
234
235/*
236 * efi_mokvar_entry_find() - Find EFI MOK config entry by name
237 *
238 * name: Name of the entry to look for.
239 *
240 * Returns: Pointer to EFI MOK config table entry if found;
241 * null otherwise.
242 *
243 * This routine depends on the EFI MOK config table being entirely
244 * mapped with it's starting virtual address in efi_mokvar_table_va.
245 */
246struct efi_mokvar_table_entry *efi_mokvar_entry_find(const char *name)
247{
248 struct efi_mokvar_table_entry *mokvar_entry = NULL;
249
250 while (efi_mokvar_entry_next(&mokvar_entry)) {
251 if (!strncmp(name, mokvar_entry->name,
252 sizeof(mokvar_entry->name)))
253 return mokvar_entry;
254 }
255 return NULL;
256}
257
258/*
259 * efi_mokvar_sysfs_read() - sysfs binary file read routine
260 *
261 * Returns: Count of bytes read.
262 *
263 * Copy EFI MOK config table entry data for this mokvar sysfs binary file
264 * to the supplied buffer, starting at the specified offset into mokvar table
265 * entry data, for the specified count bytes. The copy is limited by the
266 * amount of data in this mokvar config table entry.
267 */
268static ssize_t efi_mokvar_sysfs_read(struct file *file, struct kobject *kobj,
269 struct bin_attribute *bin_attr, char *buf,
270 loff_t off, size_t count)
271{
272 struct efi_mokvar_table_entry *mokvar_entry = bin_attr->private;
273
274 if (!capable(CAP_SYS_ADMIN))
275 return 0;
276
277 if (off >= mokvar_entry->data_size)
278 return 0;
279 if (count > mokvar_entry->data_size - off)
280 count = mokvar_entry->data_size - off;
281
282 memcpy(buf, mokvar_entry->data + off, count);
283 return count;
284}
285
286/*
287 * efi_mokvar_sysfs_init() - Map EFI MOK config table and create sysfs
288 *
289 * Map the EFI MOK variable config table for run-time use by the kernel
290 * and create the sysfs entries in /sys/firmware/efi/mok-variables/
291 *
292 * This routine just returns if a valid EFI MOK variable config table
293 * was not found earlier during boot.
294 *
295 * This routine must be called during a "middle" initcall phase, i.e.
296 * after efi_mokvar_table_init() but before UEFI certs are loaded
297 * during late init.
298 *
299 * Implicit inputs:
300 * efi.mokvar_table: Physical address of EFI MOK variable config table
301 * or special value that indicates no such table.
302 *
303 * efi_mokvar_table_size: Computed size of EFI MOK variable config table.
304 * The table is considered present and valid if this
305 * is non-zero.
306 *
307 * Implicit outputs:
308 * efi_mokvar_table_va: Start virtual address of the EFI MOK config table.
309 */
310static int __init efi_mokvar_sysfs_init(void)
311{
312 void *config_va;
313 struct efi_mokvar_table_entry *mokvar_entry = NULL;
314 struct efi_mokvar_sysfs_attr *mokvar_sysfs = NULL;
315 int err = 0;
316
317 if (efi_mokvar_table_size == 0)
318 return -ENOENT;
319
320 config_va = memremap(efi.mokvar_table, efi_mokvar_table_size,
321 MEMREMAP_WB);
322 if (!config_va) {
323 pr_err("Failed to map EFI MOKvar config table\n");
324 return -ENOMEM;
325 }
326 efi_mokvar_table_va = config_va;
327
328 mokvar_kobj = kobject_create_and_add("mok-variables", efi_kobj);
329 if (!mokvar_kobj) {
330 pr_err("Failed to create EFI mok-variables sysfs entry\n");
331 return -ENOMEM;
332 }
333
334 while (efi_mokvar_entry_next(&mokvar_entry)) {
335 mokvar_sysfs = kzalloc(sizeof(*mokvar_sysfs), GFP_KERNEL);
336 if (!mokvar_sysfs) {
337 err = -ENOMEM;
338 break;
339 }
340
341 sysfs_bin_attr_init(&mokvar_sysfs->bin_attr);
342 mokvar_sysfs->bin_attr.private = mokvar_entry;
343 mokvar_sysfs->bin_attr.attr.name = mokvar_entry->name;
344 mokvar_sysfs->bin_attr.attr.mode = 0400;
345 mokvar_sysfs->bin_attr.size = mokvar_entry->data_size;
346 mokvar_sysfs->bin_attr.read = efi_mokvar_sysfs_read;
347
348 err = sysfs_create_bin_file(mokvar_kobj,
349 &mokvar_sysfs->bin_attr);
350 if (err)
351 break;
352
353 list_add_tail(&mokvar_sysfs->node, &efi_mokvar_sysfs_list);
354 }
355
356 if (err) {
357 pr_err("Failed to create some EFI mok-variables sysfs entries\n");
358 kfree(mokvar_sysfs);
359 }
360 return err;
361}
362device_initcall(efi_mokvar_sysfs_init);
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 2cf053f..1c691bd 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -863,8 +863,6 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
863 req.request.sequence = req32.request.sequence;863 req.request.sequence = req32.request.sequence;
864 req.request.signal = req32.request.signal;864 req.request.signal = req32.request.signal;
865 err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED);865 err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED);
866 if (err)
867 return err;
868866
869 req32.reply.type = req.reply.type;867 req32.reply.type = req.reply.type;
870 req32.reply.sequence = req.reply.sequence;868 req32.reply.sequence = req.reply.sequence;
@@ -873,7 +871,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
873 if (copy_to_user(argp, &req32, sizeof(req32)))871 if (copy_to_user(argp, &req32, sizeof(req32)))
874 return -EFAULT;872 return -EFAULT;
875873
876 return 0;874 return err;
877}875}
878876
879#if defined(CONFIG_X86)877#if defined(CONFIG_X86)
diff --git a/drivers/gpu/drm/i915/gt/intel_timeline.c b/drivers/gpu/drm/i915/gt/intel_timeline.c
index de2ec4f..bf24fe2 100644
--- a/drivers/gpu/drm/i915/gt/intel_timeline.c
+++ b/drivers/gpu/drm/i915/gt/intel_timeline.c
@@ -290,6 +290,14 @@ void intel_timeline_fini(struct intel_timeline *timeline)
290 i915_gem_object_unpin_map(timeline->hwsp_ggtt->obj);290 i915_gem_object_unpin_map(timeline->hwsp_ggtt->obj);
291291
292 i915_vma_put(timeline->hwsp_ggtt);292 i915_vma_put(timeline->hwsp_ggtt);
293
294 /*
295 * A small race exists between intel_gt_retire_requests_timeout and
296 * intel_timeline_exit which could result in the syncmap not getting
297 * free'd. Rather than work to hard to seal this race, simply cleanup
298 * the syncmap on fini.
299 */
300 i915_syncmap_free(&timeline->sync);
293}301}
294302
295struct intel_timeline *303struct intel_timeline *
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
index 818d21b..1d2837c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c
@@ -419,7 +419,7 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps)
419 return ret;419 return ret;
420}420}
421421
422static void422void
423nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)423nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior)
424{424{
425 struct nvkm_dp *dp = nvkm_dp(outp);425 struct nvkm_dp *dp = nvkm_dp(outp);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
index 428b3f4..e484d0c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.h
@@ -32,6 +32,7 @@ struct nvkm_dp {
3232
33int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,33int nvkm_dp_new(struct nvkm_disp *, int index, struct dcb_output *,
34 struct nvkm_outp **);34 struct nvkm_outp **);
35void nvkm_dp_disable(struct nvkm_outp *, struct nvkm_ior *);
3536
36/* DPCD Receiver Capabilities */37/* DPCD Receiver Capabilities */
37#define DPCD_RC00_DPCD_REV 0x0000038#define DPCD_RC00_DPCD_REV 0x00000
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
index c62030c..4b1c72f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c
@@ -22,6 +22,7 @@
22 * Authors: Ben Skeggs22 * Authors: Ben Skeggs
23 */23 */
24#include "outp.h"24#include "outp.h"
25#include "dp.h"
25#include "ior.h"26#include "ior.h"
2627
27#include <subdev/bios.h>28#include <subdev/bios.h>
@@ -216,6 +217,14 @@ nvkm_outp_init_route(struct nvkm_outp *outp)
216 if (!ior->arm.head || ior->arm.proto != proto) {217 if (!ior->arm.head || ior->arm.proto != proto) {
217 OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,218 OUTP_DBG(outp, "no heads (%x %d %d)", ior->arm.head,
218 ior->arm.proto, proto);219 ior->arm.proto, proto);
220
221 /* The EFI GOP driver on Ampere can leave unused DP links routed,
222 * which we don't expect. The DisableLT IED script *should* get
223 * us back to where we need to be.
224 */
225 if (ior->func->route.get && !ior->arm.head && outp->info.type == DCB_OUTPUT_DP)
226 nvkm_dp_disable(outp, ior);
227
219 return;228 return;
220 }229 }
221230
diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c
index a1c85d1..82b244c 100644
--- a/drivers/gpu/ipu-v3/ipu-cpmem.c
+++ b/drivers/gpu/ipu-v3/ipu-cpmem.c
@@ -585,21 +585,21 @@ static const struct ipu_rgb def_bgra_16 = {
585 .bits_per_pixel = 16,585 .bits_per_pixel = 16,
586};586};
587587
588#define Y_OFFSET(pix, x, y) ((x) + pix->width * (y))588#define Y_OFFSET(pix, x, y) ((x) + pix->bytesperline * (y))
589#define U_OFFSET(pix, x, y) ((pix->width * pix->height) + \589#define U_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
590 (pix->width * ((y) / 2) / 2) + (x) / 2)590 (pix->bytesperline * ((y) / 2) / 2) + (x) / 2)
591#define V_OFFSET(pix, x, y) ((pix->width * pix->height) + \591#define V_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
592 (pix->width * pix->height / 4) + \592 (pix->bytesperline * pix->height / 4) + \
593 (pix->width * ((y) / 2) / 2) + (x) / 2)593 (pix->bytesperline * ((y) / 2) / 2) + (x) / 2)
594#define U2_OFFSET(pix, x, y) ((pix->width * pix->height) + \594#define U2_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
595 (pix->width * (y) / 2) + (x) / 2)595 (pix->bytesperline * (y) / 2) + (x) / 2)
596#define V2_OFFSET(pix, x, y) ((pix->width * pix->height) + \596#define V2_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
597 (pix->width * pix->height / 2) + \597 (pix->bytesperline * pix->height / 2) + \
598 (pix->width * (y) / 2) + (x) / 2)598 (pix->bytesperline * (y) / 2) + (x) / 2)
599#define UV_OFFSET(pix, x, y) ((pix->width * pix->height) + \599#define UV_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
600 (pix->width * ((y) / 2)) + (x))600 (pix->bytesperline * ((y) / 2)) + (x))
601#define UV2_OFFSET(pix, x, y) ((pix->width * pix->height) + \601#define UV2_OFFSET(pix, x, y) ((pix->bytesperline * pix->height) + \
602 (pix->width * y) + (x))602 (pix->bytesperline * y) + (x))
603603
604#define NUM_ALPHA_CHANNELS 7604#define NUM_ALPHA_CHANNELS 7
605605
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 970c259..3a439f7 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -1404,6 +1404,7 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
1404 if (nq)1404 if (nq)
1405 nq->budget++;1405 nq->budget++;
1406 atomic_inc(&rdev->srq_count);1406 atomic_inc(&rdev->srq_count);
1407 spin_lock_init(&srq->lock);
14071408
1408 return 0;1409 return 0;
14091410
diff --git a/drivers/infiniband/hw/efa/efa_main.c b/drivers/infiniband/hw/efa/efa_main.c
index 6c2e849..58be31f 100644
--- a/drivers/infiniband/hw/efa/efa_main.c
+++ b/drivers/infiniband/hw/efa/efa_main.c
@@ -342,6 +342,7 @@ static int efa_enable_msix(struct efa_dev *dev)
342 }342 }
343343
344 if (irq_num != msix_vecs) {344 if (irq_num != msix_vecs) {
345 efa_disable_msix(dev);
345 dev_err(&dev->pdev->dev,346 dev_err(&dev->pdev->dev,
346 "Allocated %d MSI-X (out of %d requested)\n",347 "Allocated %d MSI-X (out of %d requested)\n",
347 irq_num, msix_vecs);348 irq_num, msix_vecs);
diff --git a/drivers/infiniband/hw/hfi1/sdma.c b/drivers/infiniband/hw/hfi1/sdma.c
index c61b602..248be21 100644
--- a/drivers/infiniband/hw/hfi1/sdma.c
+++ b/drivers/infiniband/hw/hfi1/sdma.c
@@ -3056,6 +3056,7 @@ static void __sdma_process_event(struct sdma_engine *sde,
3056static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx)3056static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx)
3057{3057{
3058 int i;3058 int i;
3059 struct sdma_desc *descp;
30593060
3060 /* Handle last descriptor */3061 /* Handle last descriptor */
3061 if (unlikely((tx->num_desc == (MAX_DESC - 1)))) {3062 if (unlikely((tx->num_desc == (MAX_DESC - 1)))) {
@@ -3076,12 +3077,10 @@ static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx)
3076 if (unlikely(tx->num_desc == MAX_DESC))3077 if (unlikely(tx->num_desc == MAX_DESC))
3077 goto enomem;3078 goto enomem;
30783079
3079 tx->descp = kmalloc_array(3080 descp = kmalloc_array(MAX_DESC, sizeof(struct sdma_desc), GFP_ATOMIC);
3080 MAX_DESC,3081 if (!descp)
3081 sizeof(struct sdma_desc),
3082 GFP_ATOMIC);
3083 if (!tx->descp)
3084 goto enomem;3082 goto enomem;
3083 tx->descp = descp;
30853084
3086 /* reserve last descriptor for coalescing */3085 /* reserve last descriptor for coalescing */
3087 tx->desc_limit = MAX_DESC - 1;3086 tx->desc_limit = MAX_DESC - 1;
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index 21f90a8..7d6a4ff 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -1346,7 +1346,7 @@ static int stk_camera_probe(struct usb_interface *interface,
1346 if (!dev->isoc_ep) {1346 if (!dev->isoc_ep) {
1347 pr_err("Could not find isoc-in endpoint\n");1347 pr_err("Could not find isoc-in endpoint\n");
1348 err = -ENODEV;1348 err = -ENODEV;
1349 goto error;1349 goto error_put;
1350 }1350 }
1351 dev->vsettings.palette = V4L2_PIX_FMT_RGB565;1351 dev->vsettings.palette = V4L2_PIX_FMT_RGB565;
1352 dev->vsettings.mode = MODE_VGA;1352 dev->vsettings.mode = MODE_VGA;
@@ -1359,10 +1359,12 @@ static int stk_camera_probe(struct usb_interface *interface,
13591359
1360 err = stk_register_video_device(dev);1360 err = stk_register_video_device(dev);
1361 if (err)1361 if (err)
1362 goto error;1362 goto error_put;
13631363
1364 return 0;1364 return 0;
13651365
1366error_put:
1367 usb_put_intf(interface);
1366error:1368error:
1367 v4l2_ctrl_handler_free(hdl);1369 v4l2_ctrl_handler_free(hdl);
1368 v4l2_device_unregister(&dev->v4l2_dev);1370 v4l2_device_unregister(&dev->v4l2_dev);
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 8bed81c..8ab9630 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -1589,6 +1589,23 @@ out:
1589 __sdhci_msm_set_clock(host, clock);1589 __sdhci_msm_set_clock(host, clock);
1590}1590}
15911591
1592static void sdhci_msm_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
1593{
1594 u32 count, start = 15;
1595
1596 __sdhci_set_timeout(host, cmd);
1597 count = sdhci_readb(host, SDHCI_TIMEOUT_CONTROL);
1598 /*
1599 * Update software timeout value if its value is less than hardware data
1600 * timeout value. Qcom SoC hardware data timeout value was calculated
1601 * using 4 * MCLK * 2^(count + 13). where MCLK = 1 / host->clock.
1602 */
1603 if (cmd && cmd->data && host->clock > 400000 &&
1604 host->clock <= 50000000 &&
1605 ((1 << (count + start)) > (10 * host->clock)))
1606 host->data_timeout = 22LL * NSEC_PER_SEC;
1607}
1608
1592/*1609/*
1593 * Platform specific register write functions. This is so that, if any1610 * Platform specific register write functions. This is so that, if any
1594 * register write needs to be followed up by platform specific actions,1611 * register write needs to be followed up by platform specific actions,
@@ -1753,6 +1770,7 @@ static const struct sdhci_ops sdhci_msm_ops = {
1753 .set_uhs_signaling = sdhci_msm_set_uhs_signaling,1770 .set_uhs_signaling = sdhci_msm_set_uhs_signaling,
1754 .write_w = sdhci_msm_writew,1771 .write_w = sdhci_msm_writew,
1755 .write_b = sdhci_msm_writeb,1772 .write_b = sdhci_msm_writeb,
1773 .set_timeout = sdhci_msm_set_timeout,
1756};1774};
17571775
1758static const struct sdhci_pltfm_data sdhci_msm_pdata = {1776static const struct sdhci_pltfm_data sdhci_msm_pdata = {
diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index 485e20e..8847942 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -224,8 +224,8 @@ static void esd_usb2_rx_event(struct esd_usb2_net_priv *priv,
224 if (id == ESD_EV_CAN_ERROR_EXT) {224 if (id == ESD_EV_CAN_ERROR_EXT) {
225 u8 state = msg->msg.rx.data[0];225 u8 state = msg->msg.rx.data[0];
226 u8 ecc = msg->msg.rx.data[1];226 u8 ecc = msg->msg.rx.data[1];
227 u8 txerr = msg->msg.rx.data[2];227 u8 rxerr = msg->msg.rx.data[2];
228 u8 rxerr = msg->msg.rx.data[3];228 u8 txerr = msg->msg.rx.data[3];
229229
230 skb = alloc_can_err_skb(priv->netdev, &cf);230 skb = alloc_can_err_skb(priv->netdev, &cf);
231 if (skb == NULL) {231 if (skb == NULL) {
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index e1a3c33..2d8382e 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -842,11 +842,8 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
842 /* Remove this port from the port matrix of the other ports842 /* Remove this port from the port matrix of the other ports
843 * in the same bridge. If the port is disabled, port matrix843 * in the same bridge. If the port is disabled, port matrix
844 * is kept and not being setup until the port becomes enabled.844 * is kept and not being setup until the port becomes enabled.
845 * And the other port's port matrix cannot be broken when the
846 * other port is still a VLAN-aware port.
847 */845 */
848 if (dsa_is_user_port(ds, i) && i != port &&846 if (dsa_is_user_port(ds, i) && i != port) {
849 !dsa_port_is_vlan_filtering(&ds->ports[i])) {
850 if (dsa_to_port(ds, i)->bridge_dev != bridge)847 if (dsa_to_port(ds, i)->bridge_dev != bridge)
851 continue;848 continue;
852 if (priv->ports[i].enable)849 if (priv->ports[i].enable)
diff --git a/drivers/net/ethernet/apm/xgene-v2/main.c b/drivers/net/ethernet/apm/xgene-v2/main.c
index 02b4f3a..848be6b 100644
--- a/drivers/net/ethernet/apm/xgene-v2/main.c
+++ b/drivers/net/ethernet/apm/xgene-v2/main.c
@@ -677,11 +677,13 @@ static int xge_probe(struct platform_device *pdev)
677 ret = register_netdev(ndev);677 ret = register_netdev(ndev);
678 if (ret) {678 if (ret) {
679 netdev_err(ndev, "Failed to register netdev\n");679 netdev_err(ndev, "Failed to register netdev\n");
680 goto err;680 goto err_mdio_remove;
681 }681 }
682682
683 return 0;683 return 0;
684684
685err_mdio_remove:
686 xge_mdio_remove(ndev);
685err:687err:
686 free_netdev(ndev);688 free_netdev(ndev);
687689
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 43a3f0d..f5aec28 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -275,6 +275,12 @@ void gem_ptp_rxstamp(struct macb *bp, struct sk_buff *skb,
275275
276 if (GEM_BFEXT(DMA_RXVALID, desc->addr)) {276 if (GEM_BFEXT(DMA_RXVALID, desc->addr)) {
277 desc_ptp = macb_ptp_desc(bp, desc);277 desc_ptp = macb_ptp_desc(bp, desc);
278 /* Unlikely but check */
279 if (!desc_ptp) {
280 dev_warn_ratelimited(&bp->pdev->dev,
281 "Timestamp not supported in BD\n");
282 return;
283 }
278 gem_hw_timestamp(bp, desc_ptp->ts_1, desc_ptp->ts_2, &ts);284 gem_hw_timestamp(bp, desc_ptp->ts_1, desc_ptp->ts_2, &ts);
279 memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));285 memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));
280 shhwtstamps->hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);286 shhwtstamps->hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
@@ -307,8 +313,11 @@ int gem_ptp_txstamp(struct macb_queue *queue, struct sk_buff *skb,
307 if (CIRC_SPACE(head, tail, PTP_TS_BUFFER_SIZE) == 0)313 if (CIRC_SPACE(head, tail, PTP_TS_BUFFER_SIZE) == 0)
308 return -ENOMEM;314 return -ENOMEM;
309315
310 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
311 desc_ptp = macb_ptp_desc(queue->bp, desc);316 desc_ptp = macb_ptp_desc(queue->bp, desc);
317 /* Unlikely but check */
318 if (!desc_ptp)
319 return -EINVAL;
320 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
312 tx_timestamp = &queue->tx_timestamps[head];321 tx_timestamp = &queue->tx_timestamps[head];
313 tx_timestamp->skb = skb;322 tx_timestamp->skb = skb;
314 /* ensure ts_1/ts_2 is loaded after ctrl (TX_USED check) */323 /* ensure ts_1/ts_2 is loaded after ctrl (TX_USED check) */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 06bcdec..dbc11f4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -261,6 +261,9 @@ enum hclge_opcode_type {
261 /* Led command */261 /* Led command */
262 HCLGE_OPC_LED_STATUS_CFG = 0xB000,262 HCLGE_OPC_LED_STATUS_CFG = 0xB000,
263263
264 /* clear hardware resource command */
265 HCLGE_OPC_CLEAR_HW_RESOURCE = 0x700B,
266
264 /* NCL config command */267 /* NCL config command */
265 HCLGE_OPC_QUERY_NCL_CONFIG = 0x7011,268 HCLGE_OPC_QUERY_NCL_CONFIG = 0x7011,
266269
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
index d6c3952..2e82c54 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
@@ -281,21 +281,12 @@ static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
281 u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC];281 u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC];
282 struct hclge_vport *vport = hclge_get_vport(h);282 struct hclge_vport *vport = hclge_get_vport(h);
283 struct hclge_dev *hdev = vport->back;283 struct hclge_dev *hdev = vport->back;
284 u8 i, j, pfc_map, *prio_tc;
285 int ret;284 int ret;
285 u8 i;
286286
287 memset(pfc, 0, sizeof(*pfc));287 memset(pfc, 0, sizeof(*pfc));
288 pfc->pfc_cap = hdev->pfc_max;288 pfc->pfc_cap = hdev->pfc_max;
289 prio_tc = hdev->tm_info.prio_tc;289 pfc->pfc_en = hdev->tm_info.pfc_en;
290 pfc_map = hdev->tm_info.hw_pfc_map;
291
292 /* Pfc setting is based on TC */
293 for (i = 0; i < hdev->tm_info.num_tc; i++) {
294 for (j = 0; j < HNAE3_MAX_USER_PRIO; j++) {
295 if ((prio_tc[j] == i) && (pfc_map & BIT(i)))
296 pfc->pfc_en |= BIT(j);
297 }
298 }
299290
300 ret = hclge_pfc_tx_stats_get(hdev, requests);291 ret = hclge_pfc_tx_stats_get(hdev, requests);
301 if (ret)292 if (ret)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index ab44a99..3bbcd46 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -8230,7 +8230,11 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
8230static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,8230static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
8231 bool writen_to_tbl)8231 bool writen_to_tbl)
8232{8232{
8233 struct hclge_vport_vlan_cfg *vlan;8233 struct hclge_vport_vlan_cfg *vlan, *tmp;
8234
8235 list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node)
8236 if (vlan->vlan_id == vlan_id)
8237 return;
82348238
8235 vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);8239 vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
8236 if (!vlan)8240 if (!vlan)
@@ -9423,6 +9427,28 @@ static void hclge_clear_resetting_state(struct hclge_dev *hdev)
9423 }9427 }
9424}9428}
94259429
9430static int hclge_clear_hw_resource(struct hclge_dev *hdev)
9431{
9432 struct hclge_desc desc;
9433 int ret;
9434
9435 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CLEAR_HW_RESOURCE, false);
9436
9437 ret = hclge_cmd_send(&hdev->hw, &desc, 1);
9438 /* This new command is only supported by new firmware, it will
9439 * fail with older firmware. Error value -EOPNOSUPP can only be
9440 * returned by older firmware running this command, to keep code
9441 * backward compatible we will override this value and return
9442 * success.
9443 */
9444 if (ret && ret != -EOPNOTSUPP) {
9445 dev_err(&hdev->pdev->dev,
9446 "failed to clear hw resource, ret = %d\n", ret);
9447 return ret;
9448 }
9449 return 0;
9450}
9451
9426static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)9452static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
9427{9453{
9428 struct pci_dev *pdev = ae_dev->pdev;9454 struct pci_dev *pdev = ae_dev->pdev;
@@ -9466,6 +9492,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
9466 if (ret)9492 if (ret)
9467 goto err_cmd_uninit;9493 goto err_cmd_uninit;
94689494
9495 ret = hclge_clear_hw_resource(hdev);
9496 if (ret)
9497 goto err_cmd_uninit;
9498
9469 ret = hclge_get_cap(hdev);9499 ret = hclge_get_cap(hdev);
9470 if (ret) {9500 if (ret) {
9471 dev_err(&pdev->dev, "get hw capability error, ret = %d.\n",9501 dev_err(&pdev->dev, "get hw capability error, ret = %d.\n",
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index d31ba15..589c5db 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -995,6 +995,8 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
995{995{
996 u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |996 u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
997 link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;997 link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
998 u16 max_ltr_enc_d = 0; /* maximum LTR decoded by platform */
999 u16 lat_enc_d = 0; /* latency decoded */
998 u16 lat_enc = 0; /* latency encoded */1000 u16 lat_enc = 0; /* latency encoded */
9991001
1000 if (link) {1002 if (link) {
@@ -1048,7 +1050,17 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
1048 E1000_PCI_LTR_CAP_LPT + 2, &max_nosnoop);1050 E1000_PCI_LTR_CAP_LPT + 2, &max_nosnoop);
1049 max_ltr_enc = max_t(u16, max_snoop, max_nosnoop);1051 max_ltr_enc = max_t(u16, max_snoop, max_nosnoop);
10501052
1051 if (lat_enc > max_ltr_enc)1053 lat_enc_d = (lat_enc & E1000_LTRV_VALUE_MASK) *
1054 (1U << (E1000_LTRV_SCALE_FACTOR *
1055 ((lat_enc & E1000_LTRV_SCALE_MASK)
1056 >> E1000_LTRV_SCALE_SHIFT)));
1057
1058 max_ltr_enc_d = (max_ltr_enc & E1000_LTRV_VALUE_MASK) *
1059 (1U << (E1000_LTRV_SCALE_FACTOR *
1060 ((max_ltr_enc & E1000_LTRV_SCALE_MASK)
1061 >> E1000_LTRV_SCALE_SHIFT)));
1062
1063 if (lat_enc_d > max_ltr_enc_d)
1052 lat_enc = max_ltr_enc;1064 lat_enc = max_ltr_enc;
1053 }1065 }
10541066
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.h b/drivers/net/ethernet/intel/e1000e/ich8lan.h
index 1502895..e757896 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.h
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h
@@ -274,8 +274,11 @@
274274
275/* Latency Tolerance Reporting */275/* Latency Tolerance Reporting */
276#define E1000_LTRV 0x000F8276#define E1000_LTRV 0x000F8
277#define E1000_LTRV_VALUE_MASK 0x000003FF
277#define E1000_LTRV_SCALE_MAX 5278#define E1000_LTRV_SCALE_MAX 5
278#define E1000_LTRV_SCALE_FACTOR 5279#define E1000_LTRV_SCALE_FACTOR 5
280#define E1000_LTRV_SCALE_SHIFT 10
281#define E1000_LTRV_SCALE_MASK 0x00001C00
279#define E1000_LTRV_REQ_SHIFT 15282#define E1000_LTRV_REQ_SHIFT 15
280#define E1000_LTRV_NOSNOOP_SHIFT 16283#define E1000_LTRV_NOSNOOP_SHIFT 16
281#define E1000_LTRV_SEND (1 << 30)284#define E1000_LTRV_SEND (1 << 30)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 7b05430..64aa551 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -101,7 +101,7 @@
101#define MVNETA_DESC_SWAP BIT(6)101#define MVNETA_DESC_SWAP BIT(6)
102#define MVNETA_TX_BRST_SZ_MASK(burst) ((burst) << 22)102#define MVNETA_TX_BRST_SZ_MASK(burst) ((burst) << 22)
103#define MVNETA_PORT_STATUS 0x2444103#define MVNETA_PORT_STATUS 0x2444
104#define MVNETA_TX_IN_PRGRS BIT(1)104#define MVNETA_TX_IN_PRGRS BIT(0)
105#define MVNETA_TX_FIFO_EMPTY BIT(8)105#define MVNETA_TX_FIFO_EMPTY BIT(8)
106#define MVNETA_RX_MIN_FRAME_SIZE 0x247c106#define MVNETA_RX_MIN_FRAME_SIZE 0x247c
107/* Only exists on Armada XP and Armada 370 */107/* Only exists on Armada XP and Armada 370 */
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 19a1a58..c449ecc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -353,6 +353,9 @@ static int qed_ll2_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
353 unsigned long flags;353 unsigned long flags;
354 int rc = -EINVAL;354 int rc = -EINVAL;
355355
356 if (!p_ll2_conn)
357 return rc;
358
356 spin_lock_irqsave(&p_tx->lock, flags);359 spin_lock_irqsave(&p_tx->lock, flags);
357 if (p_tx->b_completing_packet) {360 if (p_tx->b_completing_packet) {
358 rc = -EBUSY;361 rc = -EBUSY;
@@ -526,7 +529,16 @@ static int qed_ll2_rxq_completion(struct qed_hwfn *p_hwfn, void *cookie)
526 unsigned long flags = 0;529 unsigned long flags = 0;
527 int rc = 0;530 int rc = 0;
528531
532 if (!p_ll2_conn)
533 return rc;
534
529 spin_lock_irqsave(&p_rx->lock, flags);535 spin_lock_irqsave(&p_rx->lock, flags);
536
537 if (!QED_LL2_RX_REGISTERED(p_ll2_conn)) {
538 spin_unlock_irqrestore(&p_rx->lock, flags);
539 return 0;
540 }
541
530 cq_new_idx = le16_to_cpu(*p_rx->p_fw_cons);542 cq_new_idx = le16_to_cpu(*p_rx->p_fw_cons);
531 cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain);543 cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain);
532544
@@ -847,6 +859,9 @@ static int qed_ll2_lb_rxq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
847 struct qed_ll2_info *p_ll2_conn = (struct qed_ll2_info *)p_cookie;859 struct qed_ll2_info *p_ll2_conn = (struct qed_ll2_info *)p_cookie;
848 int rc;860 int rc;
849861
862 if (!p_ll2_conn)
863 return 0;
864
850 if (!QED_LL2_RX_REGISTERED(p_ll2_conn))865 if (!QED_LL2_RX_REGISTERED(p_ll2_conn))
851 return 0;866 return 0;
852867
@@ -870,6 +885,9 @@ static int qed_ll2_lb_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie)
870 u16 new_idx = 0, num_bds = 0;885 u16 new_idx = 0, num_bds = 0;
871 int rc;886 int rc;
872887
888 if (!p_ll2_conn)
889 return 0;
890
873 if (!QED_LL2_TX_REGISTERED(p_ll2_conn))891 if (!QED_LL2_TX_REGISTERED(p_ll2_conn))
874 return 0;892 return 0;
875893
@@ -1642,6 +1660,8 @@ int qed_ll2_post_rx_buffer(void *cxt,
1642 if (!p_ll2_conn)1660 if (!p_ll2_conn)
1643 return -EINVAL;1661 return -EINVAL;
1644 p_rx = &p_ll2_conn->rx_queue;1662 p_rx = &p_ll2_conn->rx_queue;
1663 if (!p_rx->set_prod_addr)
1664 return -EIO;
16451665
1646 spin_lock_irqsave(&p_rx->lock, flags);1666 spin_lock_irqsave(&p_rx->lock, flags);
1647 if (!list_empty(&p_rx->free_descq))1667 if (!list_empty(&p_rx->free_descq))
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index bc1f5b3..1db4942 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -559,7 +559,12 @@ static int qed_enable_msix(struct qed_dev *cdev,
559 rc = cnt;559 rc = cnt;
560 }560 }
561561
562 if (rc > 0) {562 /* For VFs, we should return with an error in case we didn't get the
563 * exact number of msix vectors as we requested.
564 * Not doing that will lead to a crash when starting queues for
565 * this VF.
566 */
567 if ((IS_PF(cdev) && rc > 0) || (IS_VF(cdev) && rc == cnt)) {
563 /* MSI-x configuration was achieved */568 /* MSI-x configuration was achieved */
564 int_params->out.int_mode = QED_INT_MODE_MSIX;569 int_params->out.int_mode = QED_INT_MODE_MSIX;
565 int_params->out.num_vectors = rc;570 int_params->out.num_vectors = rc;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
index 38b1f40..b291971 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
@@ -1245,8 +1245,7 @@ qed_rdma_create_qp(void *rdma_cxt,
12451245
1246 if (!rdma_cxt || !in_params || !out_params ||1246 if (!rdma_cxt || !in_params || !out_params ||
1247 !p_hwfn->p_rdma_info->active) {1247 !p_hwfn->p_rdma_info->active) {
1248 DP_ERR(p_hwfn->cdev,1248 pr_err("qed roce create qp failed due to NULL entry (rdma_cxt=%p, in=%p, out=%p, roce_info=?\n",
1249 "qed roce create qp failed due to NULL entry (rdma_cxt=%p, in=%p, out=%p, roce_info=?\n",
1250 rdma_cxt, in_params, out_params);1249 rdma_cxt, in_params, out_params);
1251 return NULL;1250 return NULL;
1252 }1251 }
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index ce3e62e..1133f6f 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -1773,6 +1773,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev)
1773 }1773 }
17741774
1775 edev->int_info.used_cnt = 0;1775 edev->int_info.used_cnt = 0;
1776 edev->int_info.msix_cnt = 0;
1776}1777}
17771778
1778static int qede_req_msix_irqs(struct qede_dev *edev)1779static int qede_req_msix_irqs(struct qede_dev *edev)
@@ -2317,7 +2318,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode,
2317 goto out;2318 goto out;
2318err4:2319err4:
2319 qede_sync_free_irqs(edev);2320 qede_sync_free_irqs(edev);
2320 memset(&edev->int_info.msix_cnt, 0, sizeof(struct qed_int_info));
2321err3:2321err3:
2322 qede_napi_disable_remove(edev);2322 qede_napi_disable_remove(edev);
2323err2:2323err2:
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 6ab8e35..a4793dd 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4684,6 +4684,7 @@ static void rtl_hw_start_8168g(struct rtl8169_private *tp)
4684 rtl_eri_clear_bits(tp, 0x1b0, ERIAR_MASK_0011, BIT(12));4684 rtl_eri_clear_bits(tp, 0x1b0, ERIAR_MASK_0011, BIT(12));
46854685
4686 rtl_pcie_state_l2l3_disable(tp);4686 rtl_pcie_state_l2l3_disable(tp);
4687 rtl_hw_aspm_clkreq_enable(tp, true);
4687}4688}
46884689
4689static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)4690static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index e85be21..dbd753b 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -939,10 +939,8 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
939 wmb();939 wmb();
940 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */940 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
941941
942 if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {942 if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1))
943 netdev_info(ndev, "%s -> netif_stop_queue\n", __func__);
944 netif_stop_queue(ndev);943 netif_stop_queue(ndev);
945 }
946944
947 return NETDEV_TX_OK;945 return NETDEV_TX_OK;
948}946}
diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 249738e..603c688 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -682,8 +682,9 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
682 }682 }
683 }683 }
684684
685 /* There should be one of more OPP defined */685 /* There should be one or more OPPs defined */
686 if (WARN_ON(!count)) {686 if (!count) {
687 dev_err(dev, "%s: no supported OPPs", __func__);
687 ret = -ENOENT;688 ret = -ENOENT;
688 goto remove_static_opp;689 goto remove_static_opp;
689 }690 }
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 4c9d9a5..2b3ff18 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3261,12 +3261,12 @@ static void fixup_mpss_256(struct pci_dev *dev)
3261{3261{
3262 dev->pcie_mpss = 1; /* 256 bytes */3262 dev->pcie_mpss = 1; /* 256 bytes */
3263}3263}
3264DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,3264DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
3265 PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);3265 PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
3266DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,3266DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
3267 PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);3267 PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
3268DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,3268DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
3269 PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);3269 PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
32703270
3271/*3271/*
3272 * Intel 5000 and 5100 Memory controllers have an erratum with read completion3272 * Intel 5000 and 5100 Memory controllers have an erratum with read completion
diff --git a/drivers/reset/reset-zynqmp.c b/drivers/reset/reset-zynqmp.c
index 99e75d9..8a7473b 100644
--- a/drivers/reset/reset-zynqmp.c
+++ b/drivers/reset/reset-zynqmp.c
@@ -46,7 +46,8 @@ static int zynqmp_reset_status(struct reset_controller_dev *rcdev,
46 unsigned long id)46 unsigned long id)
47{47{
48 struct zynqmp_reset_data *priv = to_zynqmp_reset_data(rcdev);48 struct zynqmp_reset_data *priv = to_zynqmp_reset_data(rcdev);
49 int val, err;49 int err;
50 u32 val;
5051
51 err = priv->eemi_ops->reset_get_status(ZYNQMP_RESET_ID + id, &val);52 err = priv->eemi_ops->reset_get_status(ZYNQMP_RESET_ID + id, &val);
52 if (err)53 if (err)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 11592ec..6aeb79e 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -788,12 +788,15 @@ store_state_field(struct device *dev, struct device_attribute *attr,
788 ret = scsi_device_set_state(sdev, state);788 ret = scsi_device_set_state(sdev, state);
789 /*789 /*
790 * If the device state changes to SDEV_RUNNING, we need to790 * If the device state changes to SDEV_RUNNING, we need to
791 * rescan the device to revalidate it, and run the queue to791 * run the queue to avoid I/O hang, and rescan the device
792 * avoid I/O hang.792 * to revalidate it. Running the queue first is necessary
793 * because another thread may be waiting inside
794 * blk_mq_freeze_queue_wait() and because that call may be
795 * waiting for pending I/O to finish.
793 */796 */
794 if (ret == 0 && state == SDEV_RUNNING) {797 if (ret == 0 && state == SDEV_RUNNING) {
795 scsi_rescan_device(dev);
796 blk_mq_run_hw_queues(sdev->request_queue, true);798 blk_mq_run_hw_queues(sdev->request_queue, true);
799 scsi_rescan_device(dev);
797 }800 }
798 mutex_unlock(&sdev->state_mutex);801 mutex_unlock(&sdev->state_mutex);
799802
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 8989f28..e0853db 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -484,16 +484,19 @@ int vt_ioctl(struct tty_struct *tty,
484 ret = -EINVAL;484 ret = -EINVAL;
485 goto out;485 goto out;
486 }486 }
487 /* FIXME: this needs the console lock extending */487 console_lock();
488 if (vc->vc_mode == (unsigned char) arg)488 if (vc->vc_mode == (unsigned char) arg) {
489 console_unlock();
489 break;490 break;
491 }
490 vc->vc_mode = (unsigned char) arg;492 vc->vc_mode = (unsigned char) arg;
491 if (console != fg_console)493 if (console != fg_console) {
494 console_unlock();
492 break;495 break;
496 }
493 /*497 /*
494 * explicitly blank/unblank the screen if switching modes498 * explicitly blank/unblank the screen if switching modes
495 */499 */
496 console_lock();
497 if (arg == KD_TEXT)500 if (arg == KD_TEXT)
498 do_unblank_screen(1);501 do_unblank_screen(1);
499 else502 else
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 8a3752f..39a9ad1 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -894,19 +894,19 @@ static struct dwc3_trb *dwc3_ep_prev_trb(struct dwc3_ep *dep, u8 index)
894894
895static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)895static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
896{896{
897 struct dwc3_trb *tmp;
898 u8 trbs_left;897 u8 trbs_left;
899898
900 /*899 /*
901 * If enqueue & dequeue are equal than it is either full or empty.900 * If the enqueue & dequeue are equal then the TRB ring is either full
902 *901 * or empty. It's considered full when there are DWC3_TRB_NUM-1 of TRBs
903 * One way to know for sure is if the TRB right before us has HWO bit902 * pending to be processed by the driver.
904 * set or not. If it has, then we're definitely full and can't fit any
905 * more transfers in our ring.
906 */903 */
907 if (dep->trb_enqueue == dep->trb_dequeue) {904 if (dep->trb_enqueue == dep->trb_dequeue) {
908 tmp = dwc3_ep_prev_trb(dep, dep->trb_enqueue);905 /*
909 if (tmp->ctrl & DWC3_TRB_CTRL_HWO)906 * If there is any request remained in the started_list at
907 * this point, that means there is no TRB available.
908 */
909 if (!list_empty(&dep->started_list))
910 return 0;910 return 0;
911911
912 return DWC3_TRB_NUM - 1;912 return DWC3_TRB_NUM - 1;
@@ -2012,10 +2012,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
20122012
2013 ret = wait_for_completion_timeout(&dwc->ep0_in_setup,2013 ret = wait_for_completion_timeout(&dwc->ep0_in_setup,
2014 msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT));2014 msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT));
2015 if (ret == 0) {2015 if (ret == 0)
2016 dev_err(dwc->dev, "timed out waiting for SETUP phase\n");2016 dev_warn(dwc->dev, "timed out waiting for SETUP phase\n");
2017 return -ETIMEDOUT;
2018 }
2019 }2017 }
20202018
2021 /*2019 /*
@@ -2217,6 +2215,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
2217 /* begin to receive SETUP packets */2215 /* begin to receive SETUP packets */
2218 dwc->ep0state = EP0_SETUP_PHASE;2216 dwc->ep0state = EP0_SETUP_PHASE;
2219 dwc->link_state = DWC3_LINK_STATE_SS_DIS;2217 dwc->link_state = DWC3_LINK_STATE_SS_DIS;
2218 dwc->delayed_status = false;
2220 dwc3_ep0_out_start(dwc);2219 dwc3_ep0_out_start(dwc);
22212220
2222 dwc3_gadget_enable_irq(dwc);2221 dwc3_gadget_enable_irq(dwc);
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 223029f..4e01ba0 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -349,8 +349,6 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
349 if (!prm->ep_enabled)349 if (!prm->ep_enabled)
350 return;350 return;
351351
352 prm->ep_enabled = false;
353
354 audio_dev = uac->audio_dev;352 audio_dev = uac->audio_dev;
355 params = &audio_dev->params;353 params = &audio_dev->params;
356354
@@ -368,11 +366,12 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
368 }366 }
369 }367 }
370368
369 prm->ep_enabled = false;
370
371 if (usb_ep_disable(ep))371 if (usb_ep_disable(ep))
372 dev_err(uac->card->dev, "%s:%d Error!\n", __func__, __LINE__);372 dev_err(uac->card->dev, "%s:%d Error!\n", __func__, __LINE__);
373}373}
374374
375
376int u_audio_start_capture(struct g_audio *audio_dev)375int u_audio_start_capture(struct g_audio *audio_dev)
377{376{
378 struct snd_uac_chip *uac = audio_dev->uac;377 struct snd_uac_chip *uac = audio_dev->uac;
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index 448d7b1..f5c8e4e 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -197,12 +197,13 @@ static void xhci_ring_dump_segment(struct seq_file *s,
197 int i;197 int i;
198 dma_addr_t dma;198 dma_addr_t dma;
199 union xhci_trb *trb;199 union xhci_trb *trb;
200 char str[XHCI_MSG_MAX];
200201
201 for (i = 0; i < TRBS_PER_SEGMENT; i++) {202 for (i = 0; i < TRBS_PER_SEGMENT; i++) {
202 trb = &seg->trbs[i];203 trb = &seg->trbs[i];
203 dma = seg->dma + i * sizeof(*trb);204 dma = seg->dma + i * sizeof(*trb);
204 seq_printf(s, "%pad: %s\n", &dma,205 seq_printf(s, "%pad: %s\n", &dma,
205 xhci_decode_trb(le32_to_cpu(trb->generic.field[0]),206 xhci_decode_trb(str, XHCI_MSG_MAX, le32_to_cpu(trb->generic.field[0]),
206 le32_to_cpu(trb->generic.field[1]),207 le32_to_cpu(trb->generic.field[1]),
207 le32_to_cpu(trb->generic.field[2]),208 le32_to_cpu(trb->generic.field[2]),
208 le32_to_cpu(trb->generic.field[3])));209 le32_to_cpu(trb->generic.field[3])));
@@ -340,9 +341,10 @@ static int xhci_portsc_show(struct seq_file *s, void *unused)
340{341{
341 struct xhci_port *port = s->private;342 struct xhci_port *port = s->private;
342 u32 portsc;343 u32 portsc;
344 char str[XHCI_MSG_MAX];
343345
344 portsc = readl(port->addr);346 portsc = readl(port->addr);
345 seq_printf(s, "%s\n", xhci_decode_portsc(portsc));347 seq_printf(s, "%s\n", xhci_decode_portsc(str, portsc));
346348
347 return 0;349 return 0;
348}350}
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
index c1025d3..3da75b3 100644
--- a/drivers/usb/host/xhci-rcar.c
+++ b/drivers/usb/host/xhci-rcar.c
@@ -134,6 +134,13 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd)
134 const struct soc_device_attribute *attr;134 const struct soc_device_attribute *attr;
135 const char *firmware_name;135 const char *firmware_name;
136136
137 /*
138 * According to the datasheet, "Upon the completion of FW Download,
139 * there is no need to write or reload FW".
140 */
141 if (readl(regs + RCAR_USB3_DL_CTRL) & RCAR_USB3_DL_CTRL_FW_SUCCESS)
142 return 0;
143
137 attr = soc_device_match(rcar_quirks_match);144 attr = soc_device_match(rcar_quirks_match);
138 if (attr)145 if (attr)
139 quirks = (uintptr_t)attr->data;146 quirks = (uintptr_t)attr->data;
diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index 87da909..dab2af3 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -25,8 +25,6 @@
25#include "xhci.h"25#include "xhci.h"
26#include "xhci-dbgcap.h"26#include "xhci-dbgcap.h"
2727
28#define XHCI_MSG_MAX 500
29
30DECLARE_EVENT_CLASS(xhci_log_msg,28DECLARE_EVENT_CLASS(xhci_log_msg,
31 TP_PROTO(struct va_format *vaf),29 TP_PROTO(struct va_format *vaf),
32 TP_ARGS(vaf),30 TP_ARGS(vaf),
@@ -122,6 +120,7 @@ DECLARE_EVENT_CLASS(xhci_log_trb,
122 __field(u32, field1)120 __field(u32, field1)
123 __field(u32, field2)121 __field(u32, field2)
124 __field(u32, field3)122 __field(u32, field3)
123 __dynamic_array(char, str, XHCI_MSG_MAX)
125 ),124 ),
126 TP_fast_assign(125 TP_fast_assign(
127 __entry->type = ring->type;126 __entry->type = ring->type;
@@ -131,7 +130,7 @@ DECLARE_EVENT_CLASS(xhci_log_trb,
131 __entry->field3 = le32_to_cpu(trb->field[3]);130 __entry->field3 = le32_to_cpu(trb->field[3]);
132 ),131 ),
133 TP_printk("%s: %s", xhci_ring_type_string(__entry->type),132 TP_printk("%s: %s", xhci_ring_type_string(__entry->type),
134 xhci_decode_trb(__entry->field0, __entry->field1,133 xhci_decode_trb(__get_str(str), XHCI_MSG_MAX, __entry->field0, __entry->field1,
135 __entry->field2, __entry->field3)134 __entry->field2, __entry->field3)
136 )135 )
137);136);
@@ -523,6 +522,7 @@ DECLARE_EVENT_CLASS(xhci_log_portsc,
523 TP_STRUCT__entry(522 TP_STRUCT__entry(
524 __field(u32, portnum)523 __field(u32, portnum)
525 __field(u32, portsc)524 __field(u32, portsc)
525 __dynamic_array(char, str, XHCI_MSG_MAX)
526 ),526 ),
527 TP_fast_assign(527 TP_fast_assign(
528 __entry->portnum = portnum;528 __entry->portnum = portnum;
@@ -530,7 +530,7 @@ DECLARE_EVENT_CLASS(xhci_log_portsc,
530 ),530 ),
531 TP_printk("port-%d: %s",531 TP_printk("port-%d: %s",
532 __entry->portnum,532 __entry->portnum,
533 xhci_decode_portsc(__entry->portsc)533 xhci_decode_portsc(__get_str(str), __entry->portsc)
534 )534 )
535);535);
536536
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 834f32f..02df309 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -22,6 +22,9 @@
22#include "xhci-ext-caps.h"22#include "xhci-ext-caps.h"
23#include "pci-quirks.h"23#include "pci-quirks.h"
2424
25/* max buffer size for trace and debug messages */
26#define XHCI_MSG_MAX 500
27
25/* xHCI PCI Configuration Registers */28/* xHCI PCI Configuration Registers */
26#define XHCI_SBRN_OFFSET (0x60)29#define XHCI_SBRN_OFFSET (0x60)
2730
@@ -2217,15 +2220,14 @@ static inline char *xhci_slot_state_string(u32 state)
2217 }2220 }
2218}2221}
22192222
2220static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,2223static inline const char *xhci_decode_trb(char *str, size_t size,
2221 u32 field3)2224 u32 field0, u32 field1, u32 field2, u32 field3)
2222{2225{
2223 static char str[256];
2224 int type = TRB_FIELD_TO_TYPE(field3);2226 int type = TRB_FIELD_TO_TYPE(field3);
22252227
2226 switch (type) {2228 switch (type) {
2227 case TRB_LINK:2229 case TRB_LINK:
2228 sprintf(str,2230 snprintf(str, size,
2229 "LINK %08x%08x intr %d type '%s' flags %c:%c:%c:%c",2231 "LINK %08x%08x intr %d type '%s' flags %c:%c:%c:%c",
2230 field1, field0, GET_INTR_TARGET(field2),2232 field1, field0, GET_INTR_TARGET(field2),
2231 xhci_trb_type_string(type),2233 xhci_trb_type_string(type),
@@ -2242,7 +2244,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2242 case TRB_HC_EVENT:2244 case TRB_HC_EVENT:
2243 case TRB_DEV_NOTE:2245 case TRB_DEV_NOTE:
2244 case TRB_MFINDEX_WRAP:2246 case TRB_MFINDEX_WRAP:
2245 sprintf(str,2247 snprintf(str, size,
2246 "TRB %08x%08x status '%s' len %d slot %d ep %d type '%s' flags %c:%c",2248 "TRB %08x%08x status '%s' len %d slot %d ep %d type '%s' flags %c:%c",
2247 field1, field0,2249 field1, field0,
2248 xhci_trb_comp_code_string(GET_COMP_CODE(field2)),2250 xhci_trb_comp_code_string(GET_COMP_CODE(field2)),
@@ -2255,7 +2257,8 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
22552257
2256 break;2258 break;
2257 case TRB_SETUP:2259 case TRB_SETUP:
2258 sprintf(str, "bRequestType %02x bRequest %02x wValue %02x%02x wIndex %02x%02x wLength %d length %d TD size %d intr %d type '%s' flags %c:%c:%c",2260 snprintf(str, size,
2261 "bRequestType %02x bRequest %02x wValue %02x%02x wIndex %02x%02x wLength %d length %d TD size %d intr %d type '%s' flags %c:%c:%c",
2259 field0 & 0xff,2262 field0 & 0xff,
2260 (field0 & 0xff00) >> 8,2263 (field0 & 0xff00) >> 8,
2261 (field0 & 0xff000000) >> 24,2264 (field0 & 0xff000000) >> 24,
@@ -2272,7 +2275,8 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2272 field3 & TRB_CYCLE ? 'C' : 'c');2275 field3 & TRB_CYCLE ? 'C' : 'c');
2273 break;2276 break;
2274 case TRB_DATA:2277 case TRB_DATA:
2275 sprintf(str, "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c",2278 snprintf(str, size,
2279 "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c",
2276 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),2280 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),
2277 GET_INTR_TARGET(field2),2281 GET_INTR_TARGET(field2),
2278 xhci_trb_type_string(type),2282 xhci_trb_type_string(type),
@@ -2285,7 +2289,8 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2285 field3 & TRB_CYCLE ? 'C' : 'c');2289 field3 & TRB_CYCLE ? 'C' : 'c');
2286 break;2290 break;
2287 case TRB_STATUS:2291 case TRB_STATUS:
2288 sprintf(str, "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c",2292 snprintf(str, size,
2293 "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c",
2289 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),2294 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),
2290 GET_INTR_TARGET(field2),2295 GET_INTR_TARGET(field2),
2291 xhci_trb_type_string(type),2296 xhci_trb_type_string(type),
@@ -2298,7 +2303,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2298 case TRB_ISOC:2303 case TRB_ISOC:
2299 case TRB_EVENT_DATA:2304 case TRB_EVENT_DATA:
2300 case TRB_TR_NOOP:2305 case TRB_TR_NOOP:
2301 sprintf(str,2306 snprintf(str, size,
2302 "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c:%c",2307 "Buffer %08x%08x length %d TD size %d intr %d type '%s' flags %c:%c:%c:%c:%c:%c:%c:%c",
2303 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),2308 field1, field0, TRB_LEN(field2), GET_TD_SIZE(field2),
2304 GET_INTR_TARGET(field2),2309 GET_INTR_TARGET(field2),
@@ -2315,21 +2320,21 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
23152320
2316 case TRB_CMD_NOOP:2321 case TRB_CMD_NOOP:
2317 case TRB_ENABLE_SLOT:2322 case TRB_ENABLE_SLOT:
2318 sprintf(str,2323 snprintf(str, size,
2319 "%s: flags %c",2324 "%s: flags %c",
2320 xhci_trb_type_string(type),2325 xhci_trb_type_string(type),
2321 field3 & TRB_CYCLE ? 'C' : 'c');2326 field3 & TRB_CYCLE ? 'C' : 'c');
2322 break;2327 break;
2323 case TRB_DISABLE_SLOT:2328 case TRB_DISABLE_SLOT:
2324 case TRB_NEG_BANDWIDTH:2329 case TRB_NEG_BANDWIDTH:
2325 sprintf(str,2330 snprintf(str, size,
2326 "%s: slot %d flags %c",2331 "%s: slot %d flags %c",
2327 xhci_trb_type_string(type),2332 xhci_trb_type_string(type),
2328 TRB_TO_SLOT_ID(field3),2333 TRB_TO_SLOT_ID(field3),
2329 field3 & TRB_CYCLE ? 'C' : 'c');2334 field3 & TRB_CYCLE ? 'C' : 'c');
2330 break;2335 break;
2331 case TRB_ADDR_DEV:2336 case TRB_ADDR_DEV:
2332 sprintf(str,2337 snprintf(str, size,
2333 "%s: ctx %08x%08x slot %d flags %c:%c",2338 "%s: ctx %08x%08x slot %d flags %c:%c",
2334 xhci_trb_type_string(type),2339 xhci_trb_type_string(type),
2335 field1, field0,2340 field1, field0,
@@ -2338,7 +2343,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2338 field3 & TRB_CYCLE ? 'C' : 'c');2343 field3 & TRB_CYCLE ? 'C' : 'c');
2339 break;2344 break;
2340 case TRB_CONFIG_EP:2345 case TRB_CONFIG_EP:
2341 sprintf(str,2346 snprintf(str, size,
2342 "%s: ctx %08x%08x slot %d flags %c:%c",2347 "%s: ctx %08x%08x slot %d flags %c:%c",
2343 xhci_trb_type_string(type),2348 xhci_trb_type_string(type),
2344 field1, field0,2349 field1, field0,
@@ -2347,7 +2352,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2347 field3 & TRB_CYCLE ? 'C' : 'c');2352 field3 & TRB_CYCLE ? 'C' : 'c');
2348 break;2353 break;
2349 case TRB_EVAL_CONTEXT:2354 case TRB_EVAL_CONTEXT:
2350 sprintf(str,2355 snprintf(str, size,
2351 "%s: ctx %08x%08x slot %d flags %c",2356 "%s: ctx %08x%08x slot %d flags %c",
2352 xhci_trb_type_string(type),2357 xhci_trb_type_string(type),
2353 field1, field0,2358 field1, field0,
@@ -2355,7 +2360,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2355 field3 & TRB_CYCLE ? 'C' : 'c');2360 field3 & TRB_CYCLE ? 'C' : 'c');
2356 break;2361 break;
2357 case TRB_RESET_EP:2362 case TRB_RESET_EP:
2358 sprintf(str,2363 snprintf(str, size,
2359 "%s: ctx %08x%08x slot %d ep %d flags %c:%c",2364 "%s: ctx %08x%08x slot %d ep %d flags %c:%c",
2360 xhci_trb_type_string(type),2365 xhci_trb_type_string(type),
2361 field1, field0,2366 field1, field0,
@@ -2376,7 +2381,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2376 field3 & TRB_CYCLE ? 'C' : 'c');2381 field3 & TRB_CYCLE ? 'C' : 'c');
2377 break;2382 break;
2378 case TRB_SET_DEQ:2383 case TRB_SET_DEQ:
2379 sprintf(str,2384 snprintf(str, size,
2380 "%s: deq %08x%08x stream %d slot %d ep %d flags %c",2385 "%s: deq %08x%08x stream %d slot %d ep %d flags %c",
2381 xhci_trb_type_string(type),2386 xhci_trb_type_string(type),
2382 field1, field0,2387 field1, field0,
@@ -2387,14 +2392,14 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2387 field3 & TRB_CYCLE ? 'C' : 'c');2392 field3 & TRB_CYCLE ? 'C' : 'c');
2388 break;2393 break;
2389 case TRB_RESET_DEV:2394 case TRB_RESET_DEV:
2390 sprintf(str,2395 snprintf(str, size,
2391 "%s: slot %d flags %c",2396 "%s: slot %d flags %c",
2392 xhci_trb_type_string(type),2397 xhci_trb_type_string(type),
2393 TRB_TO_SLOT_ID(field3),2398 TRB_TO_SLOT_ID(field3),
2394 field3 & TRB_CYCLE ? 'C' : 'c');2399 field3 & TRB_CYCLE ? 'C' : 'c');
2395 break;2400 break;
2396 case TRB_FORCE_EVENT:2401 case TRB_FORCE_EVENT:
2397 sprintf(str,2402 snprintf(str, size,
2398 "%s: event %08x%08x vf intr %d vf id %d flags %c",2403 "%s: event %08x%08x vf intr %d vf id %d flags %c",
2399 xhci_trb_type_string(type),2404 xhci_trb_type_string(type),
2400 field1, field0,2405 field1, field0,
@@ -2403,14 +2408,14 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2403 field3 & TRB_CYCLE ? 'C' : 'c');2408 field3 & TRB_CYCLE ? 'C' : 'c');
2404 break;2409 break;
2405 case TRB_SET_LT:2410 case TRB_SET_LT:
2406 sprintf(str,2411 snprintf(str, size,
2407 "%s: belt %d flags %c",2412 "%s: belt %d flags %c",
2408 xhci_trb_type_string(type),2413 xhci_trb_type_string(type),
2409 TRB_TO_BELT(field3),2414 TRB_TO_BELT(field3),
2410 field3 & TRB_CYCLE ? 'C' : 'c');2415 field3 & TRB_CYCLE ? 'C' : 'c');
2411 break;2416 break;
2412 case TRB_GET_BW:2417 case TRB_GET_BW:
2413 sprintf(str,2418 snprintf(str, size,
2414 "%s: ctx %08x%08x slot %d speed %d flags %c",2419 "%s: ctx %08x%08x slot %d speed %d flags %c",
2415 xhci_trb_type_string(type),2420 xhci_trb_type_string(type),
2416 field1, field0,2421 field1, field0,
@@ -2419,7 +2424,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2419 field3 & TRB_CYCLE ? 'C' : 'c');2424 field3 & TRB_CYCLE ? 'C' : 'c');
2420 break;2425 break;
2421 case TRB_FORCE_HEADER:2426 case TRB_FORCE_HEADER:
2422 sprintf(str,2427 snprintf(str, size,
2423 "%s: info %08x%08x%08x pkt type %d roothub port %d flags %c",2428 "%s: info %08x%08x%08x pkt type %d roothub port %d flags %c",
2424 xhci_trb_type_string(type),2429 xhci_trb_type_string(type),
2425 field2, field1, field0 & 0xffffffe0,2430 field2, field1, field0 & 0xffffffe0,
@@ -2428,7 +2433,7 @@ static inline const char *xhci_decode_trb(u32 field0, u32 field1, u32 field2,
2428 field3 & TRB_CYCLE ? 'C' : 'c');2433 field3 & TRB_CYCLE ? 'C' : 'c');
2429 break;2434 break;
2430 default:2435 default:
2431 sprintf(str,2436 snprintf(str, size,
2432 "type '%s' -> raw %08x %08x %08x %08x",2437 "type '%s' -> raw %08x %08x %08x %08x",
2433 xhci_trb_type_string(type),2438 xhci_trb_type_string(type),
2434 field0, field1, field2, field3);2439 field0, field1, field2, field3);
@@ -2553,9 +2558,8 @@ static inline const char *xhci_portsc_link_state_string(u32 portsc)
2553 return "Unknown";2558 return "Unknown";
2554}2559}
25552560
2556static inline const char *xhci_decode_portsc(u32 portsc)2561static inline const char *xhci_decode_portsc(char *str, u32 portsc)
2557{2562{
2558 static char str[256];
2559 int ret;2563 int ret;
25602564
2561 ret = sprintf(str, "%s %s %s Link:%s PortSpeed:%d ",2565 ret = sprintf(str, "%s %s %s Link:%s PortSpeed:%d ",
diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
index 08db02f..619c459 100644
--- a/drivers/usb/mtu3/mtu3_gadget.c
+++ b/drivers/usb/mtu3/mtu3_gadget.c
@@ -72,14 +72,12 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
72 u32 interval = 0;72 u32 interval = 0;
73 u32 mult = 0;73 u32 mult = 0;
74 u32 burst = 0;74 u32 burst = 0;
75 int max_packet;
76 int ret;75 int ret;
7776
78 desc = mep->desc;77 desc = mep->desc;
79 comp_desc = mep->comp_desc;78 comp_desc = mep->comp_desc;
80 mep->type = usb_endpoint_type(desc);79 mep->type = usb_endpoint_type(desc);
81 max_packet = usb_endpoint_maxp(desc);80 mep->maxp = usb_endpoint_maxp(desc);
82 mep->maxp = max_packet & GENMASK(10, 0);
8381
84 switch (mtu->g.speed) {82 switch (mtu->g.speed) {
85 case USB_SPEED_SUPER:83 case USB_SPEED_SUPER:
@@ -100,7 +98,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
100 usb_endpoint_xfer_int(desc)) {98 usb_endpoint_xfer_int(desc)) {
101 interval = desc->bInterval;99 interval = desc->bInterval;
102 interval = clamp_val(interval, 1, 16) - 1;100 interval = clamp_val(interval, 1, 16) - 1;
103 burst = (max_packet & GENMASK(12, 11)) >> 11;101 mult = usb_endpoint_maxp_mult(desc) - 1;
104 }102 }
105 break;103 break;
106 default:104 default:
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index e9c39a4..a82ba9c 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -678,7 +678,6 @@ static struct usb_serial_driver ch341_device = {
678 .owner = THIS_MODULE,678 .owner = THIS_MODULE,
679 .name = "ch341-uart",679 .name = "ch341-uart",
680 },680 },
681 .bulk_in_size = 512,
682 .id_table = id_table,681 .id_table = id_table,
683 .num_ports = 1,682 .num_ports = 1,
684 .open = ch341_open,683 .open = ch341_open,
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index aefc1b5..f5caf38 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -226,8 +226,10 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
226 int status;226 int status;
227227
228 buf = kmalloc(1, GFP_KERNEL);228 buf = kmalloc(1, GFP_KERNEL);
229 if (!buf)229 if (!buf) {
230 *data = 0;
230 return -ENOMEM;231 return -ENOMEM;
232 }
231233
232 status = usb_control_msg(usbdev, pipe, request, requesttype, value,234 status = usb_control_msg(usbdev, pipe, request, requesttype, value,
233 index, buf, 1, MOS_WDR_TIMEOUT);235 index, buf, 1, MOS_WDR_TIMEOUT);
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 793530f..d42ca13 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -2074,6 +2074,8 @@ static const struct usb_device_id option_ids[] = {
2074 .driver_info = RSVD(4) | RSVD(5) },2074 .driver_info = RSVD(4) | RSVD(5) },
2075 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */2075 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */
2076 .driver_info = RSVD(6) },2076 .driver_info = RSVD(6) },
2077 { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0xff, 0x30) }, /* Fibocom FG150 Diag */
2078 { USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0, 0) }, /* Fibocom FG150 AT */
2077 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a0, 0xff) }, /* Fibocom NL668-AM/NL652-EU (laptop MBIM) */2079 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a0, 0xff) }, /* Fibocom NL668-AM/NL652-EU (laptop MBIM) */
2078 { USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */2080 { USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */
2079 { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */2081 { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 026a37e..4653de0 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -331,7 +331,7 @@ __vringh_iov(struct vringh *vrh, u16 i,
331 iov = wiov;331 iov = wiov;
332 else {332 else {
333 iov = riov;333 iov = riov;
334 if (unlikely(wiov && wiov->i)) {334 if (unlikely(wiov && wiov->used)) {
335 vringh_bad("Readable desc %p after writable",335 vringh_bad("Readable desc %p after writable",
336 &descs[i]);336 &descs[i]);
337 err = -EINVAL;337 err = -EINVAL;
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 222d630..b35bb2d 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -576,6 +576,13 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
576 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);576 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
577 struct device *dev = get_device(&vp_dev->vdev.dev);577 struct device *dev = get_device(&vp_dev->vdev.dev);
578578
579 /*
580 * Device is marked broken on surprise removal so that virtio upper
581 * layers can abort any ongoing operation.
582 */
583 if (!pci_device_is_present(pci_dev))
584 virtio_break_device(&vp_dev->vdev);
585
579 pci_disable_sriov(pci_dev);586 pci_disable_sriov(pci_dev);
580587
581 unregister_virtio_device(&vp_dev->vdev);588 unregister_virtio_device(&vp_dev->vdev);
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index f6011c9..e442d40 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2268,7 +2268,7 @@ bool virtqueue_is_broken(struct virtqueue *_vq)
2268{2268{
2269 struct vring_virtqueue *vq = to_vvq(_vq);2269 struct vring_virtqueue *vq = to_vvq(_vq);
22702270
2271 return vq->broken;2271 return READ_ONCE(vq->broken);
2272}2272}
2273EXPORT_SYMBOL_GPL(virtqueue_is_broken);2273EXPORT_SYMBOL_GPL(virtqueue_is_broken);
22742274
@@ -2283,7 +2283,9 @@ void virtio_break_device(struct virtio_device *dev)
2283 spin_lock(&dev->vqs_list_lock);2283 spin_lock(&dev->vqs_list_lock);
2284 list_for_each_entry(_vq, &dev->vqs, list) {2284 list_for_each_entry(_vq, &dev->vqs, list) {
2285 struct vring_virtqueue *vq = to_vvq(_vq);2285 struct vring_virtqueue *vq = to_vvq(_vq);
2286 vq->broken = true;2286
2287 /* Pairs with READ_ONCE() in virtqueue_is_broken(). */
2288 WRITE_ONCE(vq->broken, true);
2287 }2289 }
2288 spin_unlock(&dev->vqs_list_lock);2290 spin_unlock(&dev->vqs_list_lock);
2289}2291}
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index f853835..f3ff57b 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -268,6 +268,21 @@ static inline void btrfs_mod_outstanding_extents(struct btrfs_inode *inode,
268 mod);268 mod);
269}269}
270270
271/*
272 * Called every time after doing a buffered, direct IO or memory mapped write.
273 *
274 * This is to ensure that if we write to a file that was previously fsynced in
275 * the current transaction, then try to fsync it again in the same transaction,
276 * we will know that there were changes in the file and that it needs to be
277 * logged.
278 */
279static inline void btrfs_set_inode_last_sub_trans(struct btrfs_inode *inode)
280{
281 spin_lock(&inode->lock);
282 inode->last_sub_trans = inode->root->log_transid;
283 spin_unlock(&inode->lock);
284}
285
271static inline int btrfs_inode_in_log(struct btrfs_inode *inode, u64 generation)286static inline int btrfs_inode_in_log(struct btrfs_inode *inode, u64 generation)
272{287{
273 int ret = 0;288 int ret = 0;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 400b071..1279359 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2004,14 +2004,8 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
20042004
2005 inode_unlock(inode);2005 inode_unlock(inode);
20062006
2007 /*2007 btrfs_set_inode_last_sub_trans(BTRFS_I(inode));
2008 * We also have to set last_sub_trans to the current log transid,2008
2009 * otherwise subsequent syncs to a file that's been synced in this
2010 * transaction will appear to have already occurred.
2011 */
2012 spin_lock(&BTRFS_I(inode)->lock);
2013 BTRFS_I(inode)->last_sub_trans = root->log_transid;
2014 spin_unlock(&BTRFS_I(inode)->lock);
2015 if (num_written > 0)2009 if (num_written > 0)
2016 num_written = generic_write_sync(iocb, num_written);2010 num_written = generic_write_sync(iocb, num_written);
20172011
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 54b607a..33b8fed 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -543,7 +543,7 @@ again:
543 * inode has not been flagged as nocompress. This flag can543 * inode has not been flagged as nocompress. This flag can
544 * change at any time if we discover bad compression ratios.544 * change at any time if we discover bad compression ratios.
545 */545 */
546 if (nr_pages > 1 && inode_need_compress(inode, start, end)) {546 if (inode_need_compress(inode, start, end)) {
547 WARN_ON(pages);547 WARN_ON(pages);
548 pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);548 pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
549 if (!pages) {549 if (!pages) {
@@ -9250,9 +9250,7 @@ again:
9250 set_page_dirty(page);9250 set_page_dirty(page);
9251 SetPageUptodate(page);9251 SetPageUptodate(page);
92529252
9253 BTRFS_I(inode)->last_trans = fs_info->generation;9253 btrfs_set_inode_last_sub_trans(BTRFS_I(inode));
9254 BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid;
9255 BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->root->last_log_commit;
92569254
9257 unlock_extent_cached(io_tree, page_start, page_end, &cached_state);9255 unlock_extent_cached(io_tree, page_start, page_end, &cached_state);
92589256
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index d8a7d46..cbede32 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -160,7 +160,7 @@ static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans,
160 spin_lock(&BTRFS_I(inode)->lock);160 spin_lock(&BTRFS_I(inode)->lock);
161 BTRFS_I(inode)->last_trans = trans->transaction->transid;161 BTRFS_I(inode)->last_trans = trans->transaction->transid;
162 BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid;162 BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid;
163 BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->root->last_log_commit;163 BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->last_sub_trans - 1;
164 spin_unlock(&BTRFS_I(inode)->lock);164 spin_unlock(&BTRFS_I(inode)->lock);
165}165}
166166
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3e3529c..e882c79 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2168,7 +2168,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
21682168
2169 if (IS_ERR(device)) {2169 if (IS_ERR(device)) {
2170 if (PTR_ERR(device) == -ENOENT &&2170 if (PTR_ERR(device) == -ENOENT &&
2171 strcmp(device_path, "missing") == 0)2171 device_path && strcmp(device_path, "missing") == 0)
2172 ret = BTRFS_ERROR_DEV_MISSING_NOT_FOUND;2172 ret = BTRFS_ERROR_DEV_MISSING_NOT_FOUND;
2173 else2173 else
2174 ret = PTR_ERR(device);2174 ret = PTR_ERR(device);
diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c
index a5a40a7..82575cf 100644
--- a/fs/crypto/hooks.c
+++ b/fs/crypto/hooks.c
@@ -305,3 +305,47 @@ err_kfree:
305 return ERR_PTR(err);305 return ERR_PTR(err);
306}306}
307EXPORT_SYMBOL_GPL(fscrypt_get_symlink);307EXPORT_SYMBOL_GPL(fscrypt_get_symlink);
308
309/**
310 * fscrypt_symlink_getattr() - set the correct st_size for encrypted symlinks
311 * @path: the path for the encrypted symlink being queried
312 * @stat: the struct being filled with the symlink's attributes
313 *
314 * Override st_size of encrypted symlinks to be the length of the decrypted
315 * symlink target (or the no-key encoded symlink target, if the key is
316 * unavailable) rather than the length of the encrypted symlink target. This is
317 * necessary for st_size to match the symlink target that userspace actually
318 * sees. POSIX requires this, and some userspace programs depend on it.
319 *
320 * This requires reading the symlink target from disk if needed, setting up the
321 * inode's encryption key if possible, and then decrypting or encoding the
322 * symlink target. This makes lstat() more heavyweight than is normally the
323 * case. However, decrypted symlink targets will be cached in ->i_link, so
324 * usually the symlink won't have to be read and decrypted again later if/when
325 * it is actually followed, readlink() is called, or lstat() is called again.
326 *
327 * Return: 0 on success, -errno on failure
328 */
329int fscrypt_symlink_getattr(const struct path *path, struct kstat *stat)
330{
331 struct dentry *dentry = path->dentry;
332 struct inode *inode = d_inode(dentry);
333 const char *link;
334 DEFINE_DELAYED_CALL(done);
335
336 /*
337 * To get the symlink target that userspace will see (whether it's the
338 * decrypted target or the no-key encoded target), we can just get it in
339 * the same way the VFS does during path resolution and readlink().
340 */
341 link = READ_ONCE(inode->i_link);
342 if (!link) {
343 link = inode->i_op->get_link(dentry, inode, &done);
344 if (IS_ERR(link))
345 return PTR_ERR(link);
346 }
347 stat->size = strlen(link);
348 do_delayed_call(&done);
349 return 0;
350}
351EXPORT_SYMBOL_GPL(fscrypt_symlink_getattr);
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index dd05af9..a9457fe 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -52,10 +52,19 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
52 return paddr;52 return paddr;
53}53}
5454
55static int ext4_encrypted_symlink_getattr(const struct path *path,
56 struct kstat *stat, u32 request_mask,
57 unsigned int query_flags)
58{
59 ext4_getattr(path, stat, request_mask, query_flags);
60
61 return fscrypt_symlink_getattr(path, stat);
62}
63
55const struct inode_operations ext4_encrypted_symlink_inode_operations = {64const struct inode_operations ext4_encrypted_symlink_inode_operations = {
56 .get_link = ext4_encrypted_get_link,65 .get_link = ext4_encrypted_get_link,
57 .setattr = ext4_setattr,66 .setattr = ext4_setattr,
58 .getattr = ext4_getattr,67 .getattr = ext4_encrypted_symlink_getattr,
59 .listxattr = ext4_listxattr,68 .listxattr = ext4_listxattr,
60};69};
6170
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 3a97ac5..81a18ba 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1256,9 +1256,18 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
1256 return target;1256 return target;
1257}1257}
12581258
1259static int f2fs_encrypted_symlink_getattr(const struct path *path,
1260 struct kstat *stat, u32 request_mask,
1261 unsigned int query_flags)
1262{
1263 f2fs_getattr(path, stat, request_mask, query_flags);
1264
1265 return fscrypt_symlink_getattr(path, stat);
1266}
1267
1259const struct inode_operations f2fs_encrypted_symlink_inode_operations = {1268const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
1260 .get_link = f2fs_encrypted_get_link,1269 .get_link = f2fs_encrypted_get_link,
1261 .getattr = f2fs_getattr,1270 .getattr = f2fs_encrypted_symlink_getattr,
1262 .setattr = f2fs_setattr,1271 .setattr = f2fs_setattr,
1263#ifdef CONFIG_F2FS_FS_XATTR1272#ifdef CONFIG_F2FS_FS_XATTR
1264 .listxattr = f2fs_listxattr,1273 .listxattr = f2fs_listxattr,
diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index 11dd817..19574ef 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -395,6 +395,7 @@ static struct dentry *ovl_lookup_real_one(struct dentry *connected,
395 */395 */
396 take_dentry_name_snapshot(&name, real);396 take_dentry_name_snapshot(&name, real);
397 this = lookup_one_len(name.name.name, connected, name.name.len);397 this = lookup_one_len(name.name.name, connected, name.name.len);
398 release_dentry_name_snapshot(&name);
398 err = PTR_ERR(this);399 err = PTR_ERR(this);
399 if (IS_ERR(this)) {400 if (IS_ERR(this)) {
400 goto fail;401 goto fail;
@@ -409,7 +410,6 @@ static struct dentry *ovl_lookup_real_one(struct dentry *connected,
409 }410 }
410411
411out:412out:
412 release_dentry_name_snapshot(&name);
413 dput(parent);413 dput(parent);
414 inode_unlock(dir);414 inode_unlock(dir);
415 return this;415 return this;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 7bbe0ee..b90db1d 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -549,8 +549,17 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
549{549{
550 unsigned long totalpages = totalram_pages() + total_swap_pages;550 unsigned long totalpages = totalram_pages() + total_swap_pages;
551 unsigned long points = 0;551 unsigned long points = 0;
552 long badness;
553
554 badness = oom_badness(task, totalpages);
555 /*
556 * Special case OOM_SCORE_ADJ_MIN for all others scale the
557 * badness value into [0, 2000] range which we have been
558 * exporting for a long time so userspace might depend on it.
559 */
560 if (badness != LONG_MIN)
561 points = (1000 + badness * 1000 / (long)totalpages) * 2 / 3;
552562
553 points = oom_badness(task, totalpages) * 1000 / totalpages;
554 seq_printf(m, "%lu\n", points);563 seq_printf(m, "%lu\n", points);
555564
556 return 0;565 return 0;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 8dada89..6069c63 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1629,6 +1629,16 @@ static const char *ubifs_get_link(struct dentry *dentry,
1629 return fscrypt_get_symlink(inode, ui->data, ui->data_len, done);1629 return fscrypt_get_symlink(inode, ui->data, ui->data_len, done);
1630}1630}
16311631
1632static int ubifs_symlink_getattr(const struct path *path, struct kstat *stat,
1633 u32 request_mask, unsigned int query_flags)
1634{
1635 ubifs_getattr(path, stat, request_mask, query_flags);
1636
1637 if (IS_ENCRYPTED(d_inode(path->dentry)))
1638 return fscrypt_symlink_getattr(path, stat);
1639 return 0;
1640}
1641
1632const struct address_space_operations ubifs_file_address_operations = {1642const struct address_space_operations ubifs_file_address_operations = {
1633 .readpage = ubifs_readpage,1643 .readpage = ubifs_readpage,
1634 .writepage = ubifs_writepage,1644 .writepage = ubifs_writepage,
@@ -1654,7 +1664,7 @@ const struct inode_operations ubifs_file_inode_operations = {
1654const struct inode_operations ubifs_symlink_inode_operations = {1664const struct inode_operations ubifs_symlink_inode_operations = {
1655 .get_link = ubifs_get_link,1665 .get_link = ubifs_get_link,
1656 .setattr = ubifs_setattr,1666 .setattr = ubifs_setattr,
1657 .getattr = ubifs_getattr,1667 .getattr = ubifs_symlink_getattr,
1658#ifdef CONFIG_UBIFS_FS_XATTR1668#ifdef CONFIG_UBIFS_FS_XATTR
1659 .listxattr = ubifs_listxattr,1669 .listxattr = ubifs_listxattr,
1660#endif1670#endif
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 695c959..70e89ae 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -695,6 +695,7 @@ void efi_native_runtime_setup(void);
695#define LINUX_EFI_TPM_EVENT_LOG_GUID EFI_GUID(0xb7799cb0, 0xeca2, 0x4943, 0x96, 0x67, 0x1f, 0xae, 0x07, 0xb7, 0x47, 0xfa)695#define LINUX_EFI_TPM_EVENT_LOG_GUID EFI_GUID(0xb7799cb0, 0xeca2, 0x4943, 0x96, 0x67, 0x1f, 0xae, 0x07, 0xb7, 0x47, 0xfa)
696#define LINUX_EFI_TPM_FINAL_LOG_GUID EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)696#define LINUX_EFI_TPM_FINAL_LOG_GUID EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
697#define LINUX_EFI_MEMRESERVE_TABLE_GUID EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5, 0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2)697#define LINUX_EFI_MEMRESERVE_TABLE_GUID EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5, 0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2)
698#define LINUX_EFI_MOK_VARIABLE_TABLE_GUID EFI_GUID(0xc451ed2b, 0x9694, 0x45d3, 0xba, 0xba, 0xed, 0x9f, 0x89, 0x88, 0xa3, 0x89)
698699
699/* OEM GUIDs */700/* OEM GUIDs */
700#define DELLEMC_EFI_RCI2_TABLE_GUID EFI_GUID(0x2d9f28a2, 0xa886, 0x456a, 0x97, 0xa8, 0xf1, 0x1e, 0xf2, 0x4f, 0xf4, 0x55)701#define DELLEMC_EFI_RCI2_TABLE_GUID EFI_GUID(0x2d9f28a2, 0xa886, 0x456a, 0x97, 0xa8, 0xf1, 0x1e, 0xf2, 0x4f, 0xf4, 0x55)
@@ -1004,6 +1005,7 @@ extern struct efi {
1004 unsigned long rng_seed; /* UEFI firmware random seed */1005 unsigned long rng_seed; /* UEFI firmware random seed */
1005 unsigned long tpm_log; /* TPM2 Event Log table */1006 unsigned long tpm_log; /* TPM2 Event Log table */
1006 unsigned long tpm_final_log; /* TPM2 Final Events Log table */1007 unsigned long tpm_final_log; /* TPM2 Final Events Log table */
1008 unsigned long mokvar_table; /* MOK variable config table */
1007 unsigned long mem_reserve; /* Linux EFI memreserve table */1009 unsigned long mem_reserve; /* Linux EFI memreserve table */
1008 efi_get_time_t *get_time;1010 efi_get_time_t *get_time;
1009 efi_set_time_t *set_time;1011 efi_set_time_t *set_time;
@@ -1809,4 +1811,36 @@ struct linux_efi_memreserve {
1809#define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \1811#define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \
1810 / sizeof(((struct linux_efi_memreserve *)0)->entry[0]))1812 / sizeof(((struct linux_efi_memreserve *)0)->entry[0]))
18111813
1814/*
1815 * The LINUX_EFI_MOK_VARIABLE_TABLE_GUID config table can be provided
1816 * to the kernel by an EFI boot loader. The table contains a packed
1817 * sequence of these entries, one for each named MOK variable.
1818 * The sequence is terminated by an entry with a completely NULL
1819 * name and 0 data size.
1820 */
1821struct efi_mokvar_table_entry {
1822 char name[256];
1823 u64 data_size;
1824 u8 data[];
1825} __attribute((packed));
1826
1827#ifdef CONFIG_LOAD_UEFI_KEYS
1828extern void __init efi_mokvar_table_init(void);
1829extern struct efi_mokvar_table_entry *efi_mokvar_entry_next(
1830 struct efi_mokvar_table_entry **mokvar_entry);
1831extern struct efi_mokvar_table_entry *efi_mokvar_entry_find(const char *name);
1832#else
1833static inline void efi_mokvar_table_init(void) { }
1834static inline struct efi_mokvar_table_entry *efi_mokvar_entry_next(
1835 struct efi_mokvar_table_entry **mokvar_entry)
1836{
1837 return NULL;
1838}
1839static inline struct efi_mokvar_table_entry *efi_mokvar_entry_find(
1840 const char *name)
1841{
1842 return NULL;
1843}
1844#endif
1845
1812#endif /* _LINUX_EFI_H */1846#endif /* _LINUX_EFI_H */
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index 032e5bc..0d1a53d 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -298,6 +298,7 @@ extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
298extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,298extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
299 unsigned int max_size,299 unsigned int max_size,
300 struct delayed_call *done);300 struct delayed_call *done);
301int fscrypt_symlink_getattr(const struct path *path, struct kstat *stat);
301static inline void fscrypt_set_ops(struct super_block *sb,302static inline void fscrypt_set_ops(struct super_block *sb,
302 const struct fscrypt_operations *s_cop)303 const struct fscrypt_operations *s_cop)
303{304{
@@ -585,6 +586,12 @@ static inline const char *fscrypt_get_symlink(struct inode *inode,
585 return ERR_PTR(-EOPNOTSUPP);586 return ERR_PTR(-EOPNOTSUPP);
586}587}
587588
589static inline int fscrypt_symlink_getattr(const struct path *path,
590 struct kstat *stat)
591{
592 return -EOPNOTSUPP;
593}
594
588static inline void fscrypt_set_ops(struct super_block *sb,595static inline void fscrypt_set_ops(struct super_block *sb,
589 const struct fscrypt_operations *s_cop)596 const struct fscrypt_operations *s_cop)
590{597{
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index edd3806..8f2cd0f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3684,6 +3684,10 @@ int netdev_rx_handler_register(struct net_device *dev,
3684void netdev_rx_handler_unregister(struct net_device *dev);3684void netdev_rx_handler_unregister(struct net_device *dev);
36853685
3686bool dev_valid_name(const char *name);3686bool dev_valid_name(const char *name);
3687static inline bool is_socket_ioctl_cmd(unsigned int cmd)
3688{
3689 return _IOC_TYPE(cmd) == SOCK_IOC_TYPE;
3690}
3687int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr,3691int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr,
3688 bool *need_copyout);3692 bool *need_copyout);
3689int dev_ifconf(struct net *net, struct ifconf *, int);3693int dev_ifconf(struct net *net, struct ifconf *, int);
diff --git a/include/linux/once.h b/include/linux/once.h
index 9225ee6..ae6f4eb 100644
--- a/include/linux/once.h
+++ b/include/linux/once.h
@@ -7,7 +7,7 @@
77
8bool __do_once_start(bool *done, unsigned long *flags);8bool __do_once_start(bool *done, unsigned long *flags);
9void __do_once_done(bool *done, struct static_key_true *once_key,9void __do_once_done(bool *done, struct static_key_true *once_key,
10 unsigned long *flags);10 unsigned long *flags, struct module *mod);
1111
12/* Call a function exactly once. The idea of DO_ONCE() is to perform12/* Call a function exactly once. The idea of DO_ONCE() is to perform
13 * a function call such as initialization of random seeds, etc, only13 * a function call such as initialization of random seeds, etc, only
@@ -46,7 +46,7 @@ void __do_once_done(bool *done, struct static_key_true *once_key,
46 if (unlikely(___ret)) { \46 if (unlikely(___ret)) { \
47 func(__VA_ARGS__); \47 func(__VA_ARGS__); \
48 __do_once_done(&___done, &___once_key, \48 __do_once_done(&___done, &___once_key, \
49 &___flags); \49 &___flags, THIS_MODULE); \
50 } \50 } \
51 } \51 } \
52 ___ret; \52 ___ret; \
diff --git a/include/linux/oom.h b/include/linux/oom.h
index b9df343..2db9a14 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -48,7 +48,7 @@ struct oom_control {
48 /* Used by oom implementation, do not set */48 /* Used by oom implementation, do not set */
49 unsigned long totalpages;49 unsigned long totalpages;
50 struct task_struct *chosen;50 struct task_struct *chosen;
51 unsigned long chosen_points;51 long chosen_points;
5252
53 /* Used to print the constraint info. */53 /* Used to print the constraint info. */
54 enum oom_constraint constraint;54 enum oom_constraint constraint;
@@ -108,7 +108,7 @@ static inline vm_fault_t check_stable_address_space(struct mm_struct *mm)
108108
109bool __oom_reap_task_mm(struct mm_struct *mm);109bool __oom_reap_task_mm(struct mm_struct *mm);
110110
111extern unsigned long oom_badness(struct task_struct *p,111long oom_badness(struct task_struct *p,
112 unsigned long totalpages);112 unsigned long totalpages);
113113
114extern bool out_of_memory(struct oom_control *oc);114extern bool out_of_memory(struct oom_control *oc);
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index e49c912..9dec631 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -595,7 +595,6 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged)
595 spin_lock(&hash_lock);595 spin_lock(&hash_lock);
596 }596 }
597 spin_unlock(&hash_lock);597 spin_unlock(&hash_lock);
598 put_tree(victim);
599}598}
600599
601/*600/*
@@ -604,6 +603,7 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged)
604static void prune_one(struct audit_tree *victim)603static void prune_one(struct audit_tree *victim)
605{604{
606 prune_tree_chunks(victim, false);605 prune_tree_chunks(victim, false);
606 put_tree(victim);
607}607}
608608
609/* trim the uncommitted chunks from tree */609/* trim the uncommitted chunks from tree */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 0b5a446..4deaf15 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2778,6 +2778,41 @@ static void coerce_reg_to_size(struct bpf_reg_state *reg, int size)
2778 reg->smax_value = reg->umax_value;2778 reg->smax_value = reg->umax_value;
2779}2779}
27802780
2781static bool bpf_map_is_rdonly(const struct bpf_map *map)
2782{
2783 return (map->map_flags & BPF_F_RDONLY_PROG) && map->frozen;
2784}
2785
2786static int bpf_map_direct_read(struct bpf_map *map, int off, int size, u64 *val)
2787{
2788 void *ptr;
2789 u64 addr;
2790 int err;
2791
2792 err = map->ops->map_direct_value_addr(map, &addr, off);
2793 if (err)
2794 return err;
2795 ptr = (void *)(long)addr + off;
2796
2797 switch (size) {
2798 case sizeof(u8):
2799 *val = (u64)*(u8 *)ptr;
2800 break;
2801 case sizeof(u16):
2802 *val = (u64)*(u16 *)ptr;
2803 break;
2804 case sizeof(u32):
2805 *val = (u64)*(u32 *)ptr;
2806 break;
2807 case sizeof(u64):
2808 *val = *(u64 *)ptr;
2809 break;
2810 default:
2811 return -EINVAL;
2812 }
2813 return 0;
2814}
2815
2781/* check whether memory at (regno + off) is accessible for t = (read | write)2816/* check whether memory at (regno + off) is accessible for t = (read | write)
2782 * if t==write, value_regno is a register which value is stored into memory2817 * if t==write, value_regno is a register which value is stored into memory
2783 * if t==read, value_regno is a register which will receive the value from memory2818 * if t==read, value_regno is a register which will receive the value from memory
@@ -2815,9 +2850,27 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
2815 if (err)2850 if (err)
2816 return err;2851 return err;
2817 err = check_map_access(env, regno, off, size, false);2852 err = check_map_access(env, regno, off, size, false);
2818 if (!err && t == BPF_READ && value_regno >= 0)2853 if (!err && t == BPF_READ && value_regno >= 0) {
2819 mark_reg_unknown(env, regs, value_regno);2854 struct bpf_map *map = reg->map_ptr;
2855
2856 /* if map is read-only, track its contents as scalars */
2857 if (tnum_is_const(reg->var_off) &&
2858 bpf_map_is_rdonly(map) &&
2859 map->ops->map_direct_value_addr) {
2860 int map_off = off + reg->var_off.value;
2861 u64 val = 0;
28202862
2863 err = bpf_map_direct_read(map, map_off, size,
2864 &val);
2865 if (err)
2866 return err;
2867
2868 regs[value_regno].type = SCALAR_VALUE;
2869 __mark_reg_known(&regs[value_regno], val);
2870 } else {
2871 mark_reg_unknown(env, regs, value_regno);
2872 }
2873 }
2821 } else if (reg->type == PTR_TO_CTX) {2874 } else if (reg->type == PTR_TO_CTX) {
2822 enum bpf_reg_type reg_type = SCALAR_VALUE;2875 enum bpf_reg_type reg_type = SCALAR_VALUE;
28232876
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 3086f2a..1d53f19 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -76,6 +76,25 @@ static inline struct kthread *to_kthread(struct task_struct *k)
76 return (__force void *)k->set_child_tid;76 return (__force void *)k->set_child_tid;
77}77}
7878
79/*
80 * Variant of to_kthread() that doesn't assume @p is a kthread.
81 *
82 * Per construction; when:
83 *
84 * (p->flags & PF_KTHREAD) && p->set_child_tid
85 *
86 * the task is both a kthread and struct kthread is persistent. However
87 * PF_KTHREAD on it's own is not, kernel_thread() can exec() (See umh.c and
88 * begin_new_exec()).
89 */
90static inline struct kthread *__to_kthread(struct task_struct *p)
91{
92 void *kthread = (__force void *)p->set_child_tid;
93 if (kthread && !(p->flags & PF_KTHREAD))
94 kthread = NULL;
95 return kthread;
96}
97
79void free_kthread_struct(struct task_struct *k)98void free_kthread_struct(struct task_struct *k)
80{99{
81 struct kthread *kthread;100 struct kthread *kthread;
@@ -176,10 +195,11 @@ void *kthread_data(struct task_struct *task)
176 */195 */
177void *kthread_probe_data(struct task_struct *task)196void *kthread_probe_data(struct task_struct *task)
178{197{
179 struct kthread *kthread = to_kthread(task);198 struct kthread *kthread = __to_kthread(task);
180 void *data = NULL;199 void *data = NULL;
181200
182 probe_kernel_read(&data, &kthread->data, sizeof(data));201 if (kthread)
202 probe_kernel_read(&data, &kthread->data, sizeof(data));
183 return data;203 return data;
184}204}
185205
@@ -502,9 +522,9 @@ void kthread_set_per_cpu(struct task_struct *k, int cpu)
502 set_bit(KTHREAD_IS_PER_CPU, &kthread->flags);522 set_bit(KTHREAD_IS_PER_CPU, &kthread->flags);
503}523}
504524
505bool kthread_is_per_cpu(struct task_struct *k)525bool kthread_is_per_cpu(struct task_struct *p)
506{526{
507 struct kthread *kthread = to_kthread(k);527 struct kthread *kthread = __to_kthread(p);
508 if (!kthread)528 if (!kthread)
509 return false;529 return false;
510530
@@ -1284,11 +1304,9 @@ EXPORT_SYMBOL(kthread_destroy_worker);
1284 */1304 */
1285void kthread_associate_blkcg(struct cgroup_subsys_state *css)1305void kthread_associate_blkcg(struct cgroup_subsys_state *css)
1286{1306{
1287 struct kthread *kthread;1307 struct kthread *kthread = __to_kthread(current);
1308
12881309
1289 if (!(current->flags & PF_KTHREAD))
1290 return;
1291 kthread = to_kthread(current);
1292 if (!kthread)1310 if (!kthread)
1293 return;1311 return;
12941312
@@ -1310,13 +1328,10 @@ EXPORT_SYMBOL(kthread_associate_blkcg);
1310 */1328 */
1311struct cgroup_subsys_state *kthread_blkcg(void)1329struct cgroup_subsys_state *kthread_blkcg(void)
1312{1330{
1313 struct kthread *kthread;1331 struct kthread *kthread = __to_kthread(current);
13141332
1315 if (current->flags & PF_KTHREAD) {1333 if (kthread)
1316 kthread = to_kthread(current);1334 return kthread->blkcg_css;
1317 if (kthread)
1318 return kthread->blkcg_css;
1319 }
1320 return NULL;1335 return NULL;
1321}1336}
1322EXPORT_SYMBOL(kthread_blkcg);1337EXPORT_SYMBOL(kthread_blkcg);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 74cb20f..87d9fad 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7301,7 +7301,7 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
7301 return 0;7301 return 0;
73027302
7303 /* Disregard pcpu kthreads; they are where they need to be. */7303 /* Disregard pcpu kthreads; they are where they need to be. */
7304 if ((p->flags & PF_KTHREAD) && kthread_is_per_cpu(p))7304 if (kthread_is_per_cpu(p))
7305 return 0;7305 return 0;
73067306
7307 if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) {7307 if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) {
diff --git a/lib/once.c b/lib/once.c
index 8b7d623..59149bf 100644
--- a/lib/once.c
+++ b/lib/once.c
@@ -3,10 +3,12 @@
3#include <linux/spinlock.h>3#include <linux/spinlock.h>
4#include <linux/once.h>4#include <linux/once.h>
5#include <linux/random.h>5#include <linux/random.h>
6#include <linux/module.h>
67
7struct once_work {8struct once_work {
8 struct work_struct work;9 struct work_struct work;
9 struct static_key_true *key;10 struct static_key_true *key;
11 struct module *module;
10};12};
1113
12static void once_deferred(struct work_struct *w)14static void once_deferred(struct work_struct *w)
@@ -16,10 +18,11 @@ static void once_deferred(struct work_struct *w)
16 work = container_of(w, struct once_work, work);18 work = container_of(w, struct once_work, work);
17 BUG_ON(!static_key_enabled(work->key));19 BUG_ON(!static_key_enabled(work->key));
18 static_branch_disable(work->key);20 static_branch_disable(work->key);
21 module_put(work->module);
19 kfree(work);22 kfree(work);
20}23}
2124
22static void once_disable_jump(struct static_key_true *key)25static void once_disable_jump(struct static_key_true *key, struct module *mod)
23{26{
24 struct once_work *w;27 struct once_work *w;
2528
@@ -29,6 +32,8 @@ static void once_disable_jump(struct static_key_true *key)
2932
30 INIT_WORK(&w->work, once_deferred);33 INIT_WORK(&w->work, once_deferred);
31 w->key = key;34 w->key = key;
35 w->module = mod;
36 __module_get(mod);
32 schedule_work(&w->work);37 schedule_work(&w->work);
33}38}
3439
@@ -53,11 +58,11 @@ bool __do_once_start(bool *done, unsigned long *flags)
53EXPORT_SYMBOL(__do_once_start);58EXPORT_SYMBOL(__do_once_start);
5459
55void __do_once_done(bool *done, struct static_key_true *once_key,60void __do_once_done(bool *done, struct static_key_true *once_key,
56 unsigned long *flags)61 unsigned long *flags, struct module *mod)
57 __releases(once_lock)62 __releases(once_lock)
58{63{
59 *done = true;64 *done = true;
60 spin_unlock_irqrestore(&once_lock, *flags);65 spin_unlock_irqrestore(&once_lock, *flags);
61 once_disable_jump(once_key);66 once_disable_jump(once_key, mod);
62}67}
63EXPORT_SYMBOL(__do_once_done);68EXPORT_SYMBOL(__do_once_done);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 212e718..f1b810d 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -197,17 +197,17 @@ static bool is_dump_unreclaim_slabs(void)
197 * predictable as possible. The goal is to return the highest value for the197 * predictable as possible. The goal is to return the highest value for the
198 * task consuming the most memory to avoid subsequent oom failures.198 * task consuming the most memory to avoid subsequent oom failures.
199 */199 */
200unsigned long oom_badness(struct task_struct *p, unsigned long totalpages)200long oom_badness(struct task_struct *p, unsigned long totalpages)
201{201{
202 long points;202 long points;
203 long adj;203 long adj;
204204
205 if (oom_unkillable_task(p))205 if (oom_unkillable_task(p))
206 return 0;206 return LONG_MIN;
207207
208 p = find_lock_task_mm(p);208 p = find_lock_task_mm(p);
209 if (!p)209 if (!p)
210 return 0;210 return LONG_MIN;
211211
212 /*212 /*
213 * Do not even consider tasks which are explicitly marked oom213 * Do not even consider tasks which are explicitly marked oom
@@ -219,7 +219,7 @@ unsigned long oom_badness(struct task_struct *p, unsigned long totalpages)
219 test_bit(MMF_OOM_SKIP, &p->mm->flags) ||219 test_bit(MMF_OOM_SKIP, &p->mm->flags) ||
220 in_vfork(p)) {220 in_vfork(p)) {
221 task_unlock(p);221 task_unlock(p);
222 return 0;222 return LONG_MIN;
223 }223 }
224224
225 /*225 /*
@@ -234,11 +234,7 @@ unsigned long oom_badness(struct task_struct *p, unsigned long totalpages)
234 adj *= totalpages / 1000;234 adj *= totalpages / 1000;
235 points += adj;235 points += adj;
236236
237 /*237 return points;
238 * Never return 0 for an eligible task regardless of the root bonus and
239 * oom_score_adj (oom_score_adj can't be OOM_SCORE_ADJ_MIN here).
240 */
241 return points > 0 ? points : 1;
242}238}
243239
244static const char * const oom_constraint_text[] = {240static const char * const oom_constraint_text[] = {
@@ -311,7 +307,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
311static int oom_evaluate_task(struct task_struct *task, void *arg)307static int oom_evaluate_task(struct task_struct *task, void *arg)
312{308{
313 struct oom_control *oc = arg;309 struct oom_control *oc = arg;
314 unsigned long points;310 long points;
315311
316 if (oom_unkillable_task(task))312 if (oom_unkillable_task(task))
317 goto next;313 goto next;
@@ -337,12 +333,12 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)
337 * killed first if it triggers an oom, then select it.333 * killed first if it triggers an oom, then select it.
338 */334 */
339 if (oom_task_origin(task)) {335 if (oom_task_origin(task)) {
340 points = ULONG_MAX;336 points = LONG_MAX;
341 goto select;337 goto select;
342 }338 }
343339
344 points = oom_badness(task, oc->totalpages);340 points = oom_badness(task, oc->totalpages);
345 if (!points || points < oc->chosen_points)341 if (points == LONG_MIN || points < oc->chosen_points)
346 goto next;342 goto next;
347343
348select:344select:
@@ -366,6 +362,8 @@ abort:
366 */362 */
367static void select_bad_process(struct oom_control *oc)363static void select_bad_process(struct oom_control *oc)
368{364{
365 oc->chosen_points = LONG_MIN;
366
369 if (is_memcg_oom(oc))367 if (is_memcg_oom(oc))
370 mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc);368 mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc);
371 else {369 else {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ac669d4..c6fb178 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -893,7 +893,7 @@ static inline void __free_one_page(struct page *page,
893 unsigned int max_order;893 unsigned int max_order;
894 struct capture_control *capc = task_capc(zone);894 struct capture_control *capc = task_capc(zone);
895895
896 max_order = min_t(unsigned int, MAX_ORDER, pageblock_order + 1);896 max_order = min_t(unsigned int, MAX_ORDER - 1, pageblock_order);
897897
898 VM_BUG_ON(!zone_is_initialized(zone));898 VM_BUG_ON(!zone_is_initialized(zone));
899 VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page);899 VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page);
@@ -906,7 +906,7 @@ static inline void __free_one_page(struct page *page,
906 VM_BUG_ON_PAGE(bad_range(zone, page), page);906 VM_BUG_ON_PAGE(bad_range(zone, page), page);
907907
908continue_merging:908continue_merging:
909 while (order < max_order - 1) {909 while (order < max_order) {
910 if (compaction_capture(capc, page, order, migratetype)) {910 if (compaction_capture(capc, page, order, migratetype)) {
911 __mod_zone_freepage_state(zone, -(1 << order),911 __mod_zone_freepage_state(zone, -(1 << order),
912 migratetype);912 migratetype);
@@ -932,7 +932,7 @@ continue_merging:
932 pfn = combined_pfn;932 pfn = combined_pfn;
933 order++;933 order++;
934 }934 }
935 if (max_order < MAX_ORDER) {935 if (order < MAX_ORDER - 1) {
936 /* If we are here, it means order is >= pageblock_order.936 /* If we are here, it means order is >= pageblock_order.
937 * We want to prevent merge between freepages on isolate937 * We want to prevent merge between freepages on isolate
938 * pageblock and normal pageblock. Without this, pageblock938 * pageblock and normal pageblock. Without this, pageblock
@@ -953,7 +953,7 @@ continue_merging:
953 is_migrate_isolate(buddy_mt)))953 is_migrate_isolate(buddy_mt)))
954 goto done_merging;954 goto done_merging;
955 }955 }
956 max_order++;956 max_order = order + 1;
957 goto continue_merging;957 goto continue_merging;
958 }958 }
959959
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 0bad5db..6fbc9cb 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2414,6 +2414,7 @@ static int do_setlink(const struct sk_buff *skb,
2414 return err;2414 return err;
24152415
2416 if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD] || tb[IFLA_TARGET_NETNSID]) {2416 if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD] || tb[IFLA_TARGET_NETNSID]) {
2417 const char *pat = ifname && ifname[0] ? ifname : NULL;
2417 struct net *net = rtnl_link_get_net_capable(skb, dev_net(dev),2418 struct net *net = rtnl_link_get_net_capable(skb, dev_net(dev),
2418 tb, CAP_NET_ADMIN);2419 tb, CAP_NET_ADMIN);
2419 if (IS_ERR(net)) {2420 if (IS_ERR(net)) {
@@ -2421,7 +2422,7 @@ static int do_setlink(const struct sk_buff *skb,
2421 goto errout;2422 goto errout;
2422 }2423 }
24232424
2424 err = dev_change_net_namespace(dev, net, ifname);2425 err = dev_change_net_namespace(dev, net, pat);
2425 put_net(net);2426 put_net(net);
2426 if (err)2427 if (err)
2427 goto errout;2428 goto errout;
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index c886122..f86f948 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -460,6 +460,23 @@ out_bh_enable:
460 local_bh_enable();460 local_bh_enable();
461}461}
462462
463/*
464 * The device used for looking up which routing table to use for sending an ICMP
465 * error is preferably the source whenever it is set, which should ensure the
466 * icmp error can be sent to the source host, else lookup using the routing
467 * table of the destination device, else use the main routing table (index 0).
468 */
469static struct net_device *icmp_get_route_lookup_dev(struct sk_buff *skb)
470{
471 struct net_device *route_lookup_dev = NULL;
472
473 if (skb->dev)
474 route_lookup_dev = skb->dev;
475 else if (skb_dst(skb))
476 route_lookup_dev = skb_dst(skb)->dev;
477 return route_lookup_dev;
478}
479
463static struct rtable *icmp_route_lookup(struct net *net,480static struct rtable *icmp_route_lookup(struct net *net,
464 struct flowi4 *fl4,481 struct flowi4 *fl4,
465 struct sk_buff *skb_in,482 struct sk_buff *skb_in,
@@ -468,6 +485,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
468 int type, int code,485 int type, int code,
469 struct icmp_bxm *param)486 struct icmp_bxm *param)
470{487{
488 struct net_device *route_lookup_dev;
471 struct rtable *rt, *rt2;489 struct rtable *rt, *rt2;
472 struct flowi4 fl4_dec;490 struct flowi4 fl4_dec;
473 int err;491 int err;
@@ -482,7 +500,8 @@ static struct rtable *icmp_route_lookup(struct net *net,
482 fl4->flowi4_proto = IPPROTO_ICMP;500 fl4->flowi4_proto = IPPROTO_ICMP;
483 fl4->fl4_icmp_type = type;501 fl4->fl4_icmp_type = type;
484 fl4->fl4_icmp_code = code;502 fl4->fl4_icmp_code = code;
485 fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);503 route_lookup_dev = icmp_get_route_lookup_dev(skb_in);
504 fl4->flowi4_oif = l3mdev_master_ifindex(route_lookup_dev);
486505
487 security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));506 security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
488 rt = ip_route_output_key_hash(net, fl4, skb_in);507 rt = ip_route_output_key_hash(net, fl4, skb_in);
@@ -506,7 +525,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
506 if (err)525 if (err)
507 goto relookup_failed;526 goto relookup_failed;
508527
509 if (inet_addr_type_dev_table(net, skb_dst(skb_in)->dev,528 if (inet_addr_type_dev_table(net, route_lookup_dev,
510 fl4_dec.saddr) == RTN_LOCAL) {529 fl4_dec.saddr) == RTN_LOCAL) {
511 rt2 = __ip_route_output_key(net, &fl4_dec);530 rt2 = __ip_route_output_key(net, &fl4_dec);
512 if (IS_ERR(rt2))531 if (IS_ERR(rt2))
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d2b1ae8..b1ecc91 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2730,6 +2730,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
2730 rv = 1;2730 rv = 1;
2731 } else if (im) {2731 } else if (im) {
2732 if (src_addr) {2732 if (src_addr) {
2733 spin_lock_bh(&im->lock);
2733 for (psf = im->sources; psf; psf = psf->sf_next) {2734 for (psf = im->sources; psf; psf = psf->sf_next) {
2734 if (psf->sf_inaddr == src_addr)2735 if (psf->sf_inaddr == src_addr)
2735 break;2736 break;
@@ -2740,6 +2741,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
2740 im->sfcount[MCAST_EXCLUDE];2741 im->sfcount[MCAST_EXCLUDE];
2741 else2742 else
2742 rv = im->sfcount[MCAST_EXCLUDE] != 0;2743 rv = im->sfcount[MCAST_EXCLUDE] != 0;
2744 spin_unlock_bh(&im->lock);
2743 } else2745 } else
2744 rv = 1; /* unspecified source; tentatively allow */2746 rv = 1; /* unspecified source; tentatively allow */
2745 }2747 }
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index fedad3a..fd8298b 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -446,6 +446,8 @@ static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
446446
447static int gre_handle_offloads(struct sk_buff *skb, bool csum)447static int gre_handle_offloads(struct sk_buff *skb, bool csum)
448{448{
449 if (csum && skb_checksum_start(skb) < skb->data)
450 return -EINVAL;
449 return iptunnel_handle_offloads(skb, csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);451 return iptunnel_handle_offloads(skb, csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);
450}452}
451453
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 4a988ce..4bcc36e 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -66,22 +66,17 @@ EXPORT_SYMBOL_GPL(nf_conntrack_hash);
6666
67struct conntrack_gc_work {67struct conntrack_gc_work {
68 struct delayed_work dwork;68 struct delayed_work dwork;
69 u32 last_bucket;69 u32 next_bucket;
70 bool exiting;70 bool exiting;
71 bool early_drop;71 bool early_drop;
72 long next_gc_run;
73};72};
7473
75static __read_mostly struct kmem_cache *nf_conntrack_cachep;74static __read_mostly struct kmem_cache *nf_conntrack_cachep;
76static DEFINE_SPINLOCK(nf_conntrack_locks_all_lock);75static DEFINE_SPINLOCK(nf_conntrack_locks_all_lock);
77static __read_mostly bool nf_conntrack_locks_all;76static __read_mostly bool nf_conntrack_locks_all;
7877
79/* every gc cycle scans at most 1/GC_MAX_BUCKETS_DIV part of table */78#define GC_SCAN_INTERVAL (120u * HZ)
80#define GC_MAX_BUCKETS_DIV 128u79#define GC_SCAN_MAX_DURATION msecs_to_jiffies(10)
81/* upper bound of full table scan */
82#define GC_MAX_SCAN_JIFFIES (16u * HZ)
83/* desired ratio of entries found to be expired */
84#define GC_EVICT_RATIO 50u
8580
86static struct conntrack_gc_work conntrack_gc_work;81static struct conntrack_gc_work conntrack_gc_work;
8782
@@ -1226,17 +1221,13 @@ static void nf_ct_offload_timeout(struct nf_conn *ct)
12261221
1227static void gc_worker(struct work_struct *work)1222static void gc_worker(struct work_struct *work)
1228{1223{
1229 unsigned int min_interval = max(HZ / GC_MAX_BUCKETS_DIV, 1u);1224 unsigned long end_time = jiffies + GC_SCAN_MAX_DURATION;
1230 unsigned int i, goal, buckets = 0, expired_count = 0;1225 unsigned int i, hashsz, nf_conntrack_max95 = 0;
1231 unsigned int nf_conntrack_max95 = 0;1226 unsigned long next_run = GC_SCAN_INTERVAL;
1232 struct conntrack_gc_work *gc_work;1227 struct conntrack_gc_work *gc_work;
1233 unsigned int ratio, scanned = 0;
1234 unsigned long next_run;
1235
1236 gc_work = container_of(work, struct conntrack_gc_work, dwork.work);1228 gc_work = container_of(work, struct conntrack_gc_work, dwork.work);
12371229
1238 goal = nf_conntrack_htable_size / GC_MAX_BUCKETS_DIV;1230 i = gc_work->next_bucket;
1239 i = gc_work->last_bucket;
1240 if (gc_work->early_drop)1231 if (gc_work->early_drop)
1241 nf_conntrack_max95 = nf_conntrack_max / 100u * 95u;1232 nf_conntrack_max95 = nf_conntrack_max / 100u * 95u;
12421233
@@ -1244,22 +1235,21 @@ static void gc_worker(struct work_struct *work)
1244 struct nf_conntrack_tuple_hash *h;1235 struct nf_conntrack_tuple_hash *h;
1245 struct hlist_nulls_head *ct_hash;1236 struct hlist_nulls_head *ct_hash;
1246 struct hlist_nulls_node *n;1237 struct hlist_nulls_node *n;
1247 unsigned int hashsz;
1248 struct nf_conn *tmp;1238 struct nf_conn *tmp;
12491239
1250 i++;
1251 rcu_read_lock();1240 rcu_read_lock();
12521241
1253 nf_conntrack_get_ht(&ct_hash, &hashsz);1242 nf_conntrack_get_ht(&ct_hash, &hashsz);
1254 if (i >= hashsz)1243 if (i >= hashsz) {
1255 i = 0;1244 rcu_read_unlock();
1245 break;
1246 }
12561247
1257 hlist_nulls_for_each_entry_rcu(h, n, &ct_hash[i], hnnode) {1248 hlist_nulls_for_each_entry_rcu(h, n, &ct_hash[i], hnnode) {
1258 struct net *net;1249 struct net *net;
12591250
1260 tmp = nf_ct_tuplehash_to_ctrack(h);1251 tmp = nf_ct_tuplehash_to_ctrack(h);
12611252
1262 scanned++;
1263 if (test_bit(IPS_OFFLOAD_BIT, &tmp->status)) {1253 if (test_bit(IPS_OFFLOAD_BIT, &tmp->status)) {
1264 nf_ct_offload_timeout(tmp);1254 nf_ct_offload_timeout(tmp);
1265 continue;1255 continue;
@@ -1267,7 +1257,6 @@ static void gc_worker(struct work_struct *work)
12671257
1268 if (nf_ct_is_expired(tmp)) {1258 if (nf_ct_is_expired(tmp)) {
1269 nf_ct_gc_expired(tmp);1259 nf_ct_gc_expired(tmp);
1270 expired_count++;
1271 continue;1260 continue;
1272 }1261 }
12731262
@@ -1299,7 +1288,14 @@ static void gc_worker(struct work_struct *work)
1299 */1288 */
1300 rcu_read_unlock();1289 rcu_read_unlock();
1301 cond_resched();1290 cond_resched();
1302 } while (++buckets < goal);1291 i++;
1292
1293 if (time_after(jiffies, end_time) && i < hashsz) {
1294 gc_work->next_bucket = i;
1295 next_run = 0;
1296 break;
1297 }
1298 } while (i < hashsz);
13031299
1304 if (gc_work->exiting)1300 if (gc_work->exiting)
1305 return;1301 return;
@@ -1310,40 +1306,17 @@ static void gc_worker(struct work_struct *work)
1310 *1306 *
1311 * This worker is only here to reap expired entries when system went1307 * This worker is only here to reap expired entries when system went
1312 * idle after a busy period.1308 * idle after a busy period.
1313 *
1314 * The heuristics below are supposed to balance conflicting goals:
1315 *
1316 * 1. Minimize time until we notice a stale entry
1317 * 2. Maximize scan intervals to not waste cycles
1318 *
1319 * Normally, expire ratio will be close to 0.
1320 *
1321 * As soon as a sizeable fraction of the entries have expired
1322 * increase scan frequency.
1323 */1309 */
1324 ratio = scanned ? expired_count * 100 / scanned : 0;1310 if (next_run) {
1325 if (ratio > GC_EVICT_RATIO) {1311 gc_work->early_drop = false;
1326 gc_work->next_gc_run = min_interval;1312 gc_work->next_bucket = 0;
1327 } else {
1328 unsigned int max = GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV;
1329
1330 BUILD_BUG_ON((GC_MAX_SCAN_JIFFIES / GC_MAX_BUCKETS_DIV) == 0);
1331
1332 gc_work->next_gc_run += min_interval;
1333 if (gc_work->next_gc_run > max)
1334 gc_work->next_gc_run = max;
1335 }1313 }
1336
1337 next_run = gc_work->next_gc_run;
1338 gc_work->last_bucket = i;
1339 gc_work->early_drop = false;
1340 queue_delayed_work(system_power_efficient_wq, &gc_work->dwork, next_run);1314 queue_delayed_work(system_power_efficient_wq, &gc_work->dwork, next_run);
1341}1315}
13421316
1343static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work)1317static void conntrack_gc_work_init(struct conntrack_gc_work *gc_work)
1344{1318{
1345 INIT_DEFERRABLE_WORK(&gc_work->dwork, gc_worker);1319 INIT_DEFERRABLE_WORK(&gc_work->dwork, gc_worker);
1346 gc_work->next_gc_run = HZ;
1347 gc_work->exiting = false;1320 gc_work->exiting = false;
1348}1321}
13491322
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index faea2ce..b97a786 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -314,7 +314,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
314 goto err;314 goto err;
315 }315 }
316316
317 if (len != ALIGN(size, 4) + hdrlen)317 if (!size || len != ALIGN(size, 4) + hdrlen)
318 goto err;318 goto err;
319319
320 if (cb->dst_port != QRTR_PORT_CTRL && cb->type != QRTR_TYPE_DATA)320 if (cb->dst_port != QRTR_PORT_CTRL && cb->type != QRTR_TYPE_DATA)
diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index 06ecf9d..ef6acd7 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -131,9 +131,9 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
131 cpu_relax();131 cpu_relax();
132 }132 }
133133
134 ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_len,134 ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_dma_len,
135 &off, PAGE_SIZE);135 &off, PAGE_SIZE);
136 if (unlikely(ret != ibmr->sg_len))136 if (unlikely(ret != ibmr->sg_dma_len))
137 return ret < 0 ? ret : -EINVAL;137 return ret < 0 ? ret : -EINVAL;
138138
139 if (cmpxchg(&frmr->fr_state,139 if (cmpxchg(&frmr->fr_state,
diff --git a/net/socket.c b/net/socket.c
index b14917d..9435856 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1053,7 +1053,7 @@ static long sock_do_ioctl(struct net *net, struct socket *sock,
1053 rtnl_unlock();1053 rtnl_unlock();
1054 if (!err && copy_to_user(argp, &ifc, sizeof(struct ifconf)))1054 if (!err && copy_to_user(argp, &ifc, sizeof(struct ifconf)))
1055 err = -EFAULT;1055 err = -EFAULT;
1056 } else {1056 } else if (is_socket_ioctl_cmd(cmd)) {
1057 struct ifreq ifr;1057 struct ifreq ifr;
1058 bool need_copyout;1058 bool need_copyout;
1059 if (copy_from_user(&ifr, argp, sizeof(struct ifreq)))1059 if (copy_from_user(&ifr, argp, sizeof(struct ifreq)))
@@ -1062,6 +1062,8 @@ static long sock_do_ioctl(struct net *net, struct socket *sock,
1062 if (!err && need_copyout)1062 if (!err && need_copyout)
1063 if (copy_to_user(argp, &ifr, sizeof(struct ifreq)))1063 if (copy_to_user(argp, &ifr, sizeof(struct ifreq)))
1064 return -EFAULT;1064 return -EFAULT;
1065 } else {
1066 err = -ENOTTY;
1065 }1067 }
1066 return err;1068 return err;
1067}1069}
@@ -3228,6 +3230,8 @@ static int compat_ifr_data_ioctl(struct net *net, unsigned int cmd,
3228 struct ifreq ifreq;3230 struct ifreq ifreq;
3229 u32 data32;3231 u32 data32;
32303232
3233 if (!is_socket_ioctl_cmd(cmd))
3234 return -ENOTTY;
3231 if (copy_from_user(ifreq.ifr_name, u_ifreq32->ifr_name, IFNAMSIZ))3235 if (copy_from_user(ifreq.ifr_name, u_ifreq32->ifr_name, IFNAMSIZ))
3232 return -EFAULT;3236 return -EFAULT;
3233 if (get_user(data32, &u_ifreq32->ifr_data))3237 if (get_user(data32, &u_ifreq32->ifr_data))
diff --git a/scripts/Makefile b/scripts/Makefile
index b4b7d8b..cd3fb08 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -23,6 +23,7 @@ hostprogs-$(CONFIG_ASN1) += asn1_compiler
23hostprogs-$(CONFIG_MODULE_SIG_FORMAT) += sign-file23hostprogs-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
24hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert24hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
25hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert25hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
26hostprogs-$(CONFIG_SYSTEM_REVOCATION_LIST) += extract-cert
2627
27HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include28HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include
28HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include29HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
diff --git a/security/integrity/platform_certs/keyring_handler.c b/security/integrity/platform_certs/keyring_handler.c
index 5604bd5..9f85626 100644
--- a/security/integrity/platform_certs/keyring_handler.c
+++ b/security/integrity/platform_certs/keyring_handler.c
@@ -61,6 +61,7 @@ static __init void uefi_blacklist_binary(const char *source,
61static __init void uefi_revocation_list_x509(const char *source,61static __init void uefi_revocation_list_x509(const char *source,
62 const void *data, size_t len)62 const void *data, size_t len)
63{63{
64 pr_info("Revoking X.509 certificate: %s\n", source);
64 add_key_to_revocation_list(data, len);65 add_key_to_revocation_list(data, len);
65}66}
6667
diff --git a/security/integrity/platform_certs/load_uefi.c b/security/integrity/platform_certs/load_uefi.c
index 9eaf3a3..12a1f63 100644
--- a/security/integrity/platform_certs/load_uefi.c
+++ b/security/integrity/platform_certs/load_uefi.c
@@ -34,45 +34,114 @@ static __init bool uefi_check_ignore_db(void)
34/*34/*
35 * Get a certificate list blob from the named EFI variable.35 * Get a certificate list blob from the named EFI variable.
36 */36 */
37static __init int get_cert_list(efi_char16_t *name, efi_guid_t *guid,37static __init void *get_cert_list(efi_char16_t *name, efi_guid_t *guid,
38 unsigned long *size , void **cert_list,38 unsigned long *size, efi_status_t *status)
39 efi_status_t *status)
40{39{
41 unsigned long lsize = 4;40 unsigned long lsize = 4;
42 unsigned long tmpdb[4];41 unsigned long tmpdb[4];
43 void *db;42 void *db;
4443
45 *status = efi.get_variable(name, guid, NULL, &lsize, &tmpdb);44 *status = efi.get_variable(name, guid, NULL, &lsize, &tmpdb);
46 if (*status == EFI_NOT_FOUND) {45 if (*status == EFI_NOT_FOUND)
47 *size = 0;46 return NULL;
48 *cert_list = NULL;
49 return 0;
50 }
5147
52 if (*status != EFI_BUFFER_TOO_SMALL) {48 if (*status != EFI_BUFFER_TOO_SMALL) {
53 pr_err("Couldn't get size: %s (0x%lx)\n",49 pr_err("Couldn't get size: %s (0x%lx)\n",
54 efi_status_to_str(*status), *status);50 efi_status_to_str(*status), *status);
55 return efi_status_to_err(*status);51 return NULL;
56 }52 }
5753
58 db = kmalloc(lsize, GFP_KERNEL);54 db = kmalloc(lsize, GFP_KERNEL);
59 if (!db)55 if (!db)
60 return -ENOMEM;56 return NULL;
6157
62 *status = efi.get_variable(name, guid, NULL, &lsize, db);58 *status = efi.get_variable(name, guid, NULL, &lsize, db);
63 if (*status != EFI_SUCCESS) {59 if (*status != EFI_SUCCESS) {
64 kfree(db);60 kfree(db);
65 pr_err("Error reading db var: %s (0x%lx)\n",61 pr_err("Error reading db var: %s (0x%lx)\n",
66 efi_status_to_str(*status), *status);62 efi_status_to_str(*status), *status);
67 return efi_status_to_err(*status);63 return NULL;
68 }64 }
6965
70 *size = lsize;66 *size = lsize;
71 *cert_list = db;67 return db;
68}
69
70/*
71 * load_moklist_certs() - Load Mok(X)List certs
72 * @load_db: Load MokListRT into db when true; MokListXRT into dbx when false
73 *
74 * Load the certs contained in the UEFI MokList(X)RT database into the
75 * platform trusted/denied keyring.
76 *
77 * This routine checks the EFI MOK config table first. If and only if
78 * that fails, this routine uses the MokList(X)RT ordinary UEFI variable.
79 *
80 * Return: Status
81 */
82static int __init load_moklist_certs(const bool load_db)
83{
84 struct efi_mokvar_table_entry *mokvar_entry;
85 efi_guid_t mok_var = EFI_SHIM_LOCK_GUID;
86 void *mok;
87 unsigned long moksize;
88 efi_status_t status;
89 int rc;
90 const char *mokvar_name = "MokListRT";
91 /* Should be const, but get_cert_list() doesn't have it as const yet */
92 efi_char16_t *efivar_name = L"MokListRT";
93 const char *parse_mokvar_name = "UEFI:MokListRT (MOKvar table)";
94 const char *parse_efivar_name = "UEFI:MokListRT";
95 efi_element_handler_t (*get_handler_for_guid)(const efi_guid_t *) = get_handler_for_db;
96
97 if (!load_db) {
98 mokvar_name = "MokListXRT";
99 efivar_name = L"MokListXRT";
100 parse_mokvar_name = "UEFI:MokListXRT (MOKvar table)";
101 parse_efivar_name = "UEFI:MokListXRT";
102 get_handler_for_guid = get_handler_for_dbx;
103 }
104
105 /* First try to load certs from the EFI MOKvar config table.
106 * It's not an error if the MOKvar config table doesn't exist
107 * or the MokListRT entry is not found in it.
108 */
109 mokvar_entry = efi_mokvar_entry_find(mokvar_name);
110 if (mokvar_entry) {
111 rc = parse_efi_signature_list(parse_mokvar_name,
112 mokvar_entry->data,
113 mokvar_entry->data_size,
114 get_handler_for_guid);
115 /* All done if that worked. */
116 if (!rc)
117 return rc;
118
119 pr_err("Couldn't parse %s signatures from EFI MOKvar config table: %d\n",
120 mokvar_name, rc);
121 }
122
123 /* Get MokListRT. It might not exist, so it isn't an error
124 * if we can't get it.
125 */
126 mok = get_cert_list(efivar_name, &mok_var, &moksize, &status);
127 if (mok) {
128 rc = parse_efi_signature_list(parse_efivar_name,
129 mok, moksize, get_handler_for_guid);
130 kfree(mok);
131 if (rc)
132 pr_err("Couldn't parse %s signatures: %d\n", mokvar_name, rc);
133 return rc;
134 }
135 if (status == EFI_NOT_FOUND)
136 pr_debug("%s variable wasn't found\n", mokvar_name);
137 else
138 pr_info("Couldn't get UEFI %s\n", mokvar_name);
72 return 0;139 return 0;
73}140}
74141
75/*142/*
143 * load_uefi_certs() - Load certs from UEFI sources
144 *
76 * Load the certs contained in the UEFI databases into the platform trusted145 * Load the certs contained in the UEFI databases into the platform trusted
77 * keyring and the UEFI blacklisted X.509 cert SHA256 hashes into the blacklist146 * keyring and the UEFI blacklisted X.509 cert SHA256 hashes into the blacklist
78 * keyring.147 * keyring.
@@ -80,26 +149,25 @@ static __init int get_cert_list(efi_char16_t *name, efi_guid_t *guid,
80static int __init load_uefi_certs(void)149static int __init load_uefi_certs(void)
81{150{
82 efi_guid_t secure_var = EFI_IMAGE_SECURITY_DATABASE_GUID;151 efi_guid_t secure_var = EFI_IMAGE_SECURITY_DATABASE_GUID;
83 efi_guid_t mok_var = EFI_SHIM_LOCK_GUID;152 void *db = NULL, *dbx = NULL;
84 void *db = NULL, *dbx = NULL, *mok = NULL;153 unsigned long dbsize = 0, dbxsize = 0;
85 unsigned long dbsize = 0, dbxsize = 0, moksize = 0;
86 efi_status_t status;154 efi_status_t status;
87 int rc = 0;155 int rc = 0;
88156
89 if (!efi.get_variable)157 if (!efi.get_variable)
90 return false;158 return false;
91159
92 /* Get db, MokListRT, and dbx. They might not exist, so it isn't160 /* Get db and dbx. They might not exist, so it isn't an error
93 * an error if we can't get them.161 * if we can't get them.
94 */162 */
95 if (!uefi_check_ignore_db()) {163 if (!uefi_check_ignore_db()) {
96 rc = get_cert_list(L"db", &secure_var, &dbsize, &db, &status);164 db = get_cert_list(L"db", &secure_var, &dbsize, &status);
97 if (rc < 0) {165 if (!db) {
98 if (status == EFI_NOT_FOUND)166 if (status == EFI_NOT_FOUND)
99 pr_debug("MODSIGN: db variable wasn't found\n");167 pr_debug("MODSIGN: db variable wasn't found\n");
100 else168 else
101 pr_err("MODSIGN: Couldn't get UEFI db list\n");169 pr_err("MODSIGN: Couldn't get UEFI db list\n");
102 } else if (dbsize != 0) {170 } else {
103 rc = parse_efi_signature_list("UEFI:db",171 rc = parse_efi_signature_list("UEFI:db",
104 db, dbsize, get_handler_for_db);172 db, dbsize, get_handler_for_db);
105 if (rc)173 if (rc)
@@ -109,27 +177,13 @@ static int __init load_uefi_certs(void)
109 }177 }
110 }178 }
111179
112 rc = get_cert_list(L"MokListRT", &mok_var, &moksize, &mok, &status);180 dbx = get_cert_list(L"dbx", &secure_var, &dbxsize, &status);
113 if (rc < 0) {181 if (!dbx) {
114 if (status == EFI_NOT_FOUND)
115 pr_debug("MokListRT variable wasn't found\n");
116 else
117 pr_info("Couldn't get UEFI MokListRT\n");
118 } else if (moksize != 0) {
119 rc = parse_efi_signature_list("UEFI:MokListRT",
120 mok, moksize, get_handler_for_db);
121 if (rc)
122 pr_err("Couldn't parse MokListRT signatures: %d\n", rc);
123 kfree(mok);
124 }
125
126 rc = get_cert_list(L"dbx", &secure_var, &dbxsize, &dbx, &status);
127 if (rc < 0) {
128 if (status == EFI_NOT_FOUND)182 if (status == EFI_NOT_FOUND)
129 pr_debug("dbx variable wasn't found\n");183 pr_debug("dbx variable wasn't found\n");
130 else184 else
131 pr_info("Couldn't get UEFI dbx list\n");185 pr_info("Couldn't get UEFI dbx list\n");
132 } else if (dbxsize != 0) {186 } else {
133 rc = parse_efi_signature_list("UEFI:dbx",187 rc = parse_efi_signature_list("UEFI:dbx",
134 dbx, dbxsize,188 dbx, dbxsize,
135 get_handler_for_dbx);189 get_handler_for_dbx);
@@ -138,6 +192,16 @@ static int __init load_uefi_certs(void)
138 kfree(dbx);192 kfree(dbx);
139 }193 }
140194
195 /* Load the MokListXRT certs */
196 rc = load_moklist_certs(false);
197 if (rc)
198 pr_err("Couldn't parse mokx signatures: %d\n", rc);
199
200 /* Load the MokListRT certs */
201 rc = load_moklist_certs(true);
202 if (rc)
203 pr_err("Couldn't parse mok signatures: %d\n", rc);
204
141 return rc;205 return rc;
142}206}
143late_initcall(load_uefi_certs);207late_initcall(load_uefi_certs);
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 1662573..fd300c3 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1736,7 +1736,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
1736 channels = params_channels(params);1736 channels = params_channels(params);
1737 frame_size = snd_pcm_format_size(format, channels);1737 frame_size = snd_pcm_format_size(format, channels);
1738 if (frame_size > 0)1738 if (frame_size > 0)
1739 params->fifo_size /= (unsigned)frame_size;1739 params->fifo_size /= frame_size;
1740 }1740 }
1741 return 0;1741 return 0;
1742}1742}
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index dcf3545..59f88b3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -9199,6 +9199,16 @@ static int patch_alc269(struct hda_codec *codec)
91999199
9200 snd_hda_pick_fixup(codec, alc269_fixup_models,9200 snd_hda_pick_fixup(codec, alc269_fixup_models,
9201 alc269_fixup_tbl, alc269_fixups);9201 alc269_fixup_tbl, alc269_fixups);
9202 /* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
9203 * the quirk breaks the latter (bko#214101).
9204 * Clear the wrong entry.
9205 */
9206 if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
9207 codec->core.vendor_id == 0x10ec0294) {
9208 codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
9209 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
9210 }
9211
9202 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);9212 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
9203 snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);9213 snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
9204 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,9214 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 4d20f3f..d5d8288 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1841,6 +1841,7 @@ static const struct registration_quirk registration_quirks[] = {
1841 REG_QUIRK_ENTRY(0x0951, 0x16ed, 2), /* Kingston HyperX Cloud Alpha S */1841 REG_QUIRK_ENTRY(0x0951, 0x16ed, 2), /* Kingston HyperX Cloud Alpha S */
1842 REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */1842 REG_QUIRK_ENTRY(0x0951, 0x16ea, 2), /* Kingston HyperX Cloud Flight S */
1843 REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2), /* JBL Quantum 600 */1843 REG_QUIRK_ENTRY(0x0ecb, 0x1f46, 2), /* JBL Quantum 600 */
1844 REG_QUIRK_ENTRY(0x0ecb, 0x1f47, 2), /* JBL Quantum 800 */
1844 REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2), /* JBL Quantum 400 */1845 REG_QUIRK_ENTRY(0x0ecb, 0x2039, 2), /* JBL Quantum 400 */
1845 REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2), /* JBL Quantum 600 */1846 REG_QUIRK_ENTRY(0x0ecb, 0x203c, 2), /* JBL Quantum 600 */
1846 REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2), /* JBL Quantum 800 */1847 REG_QUIRK_ENTRY(0x0ecb, 0x203e, 2), /* JBL Quantum 800 */

Subscribers

People subscribed via source and target branches