5.10.239-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 143/355 MIPS: Prefer cc-option for additions to cflags
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 337ff6bb8960fdc128cabd264aaea3d42ca27a32 upstream.
A future change will switch as-option to use KBUILD_AFLAGS instead of KBUILD_CFLAGS to allow clang to drop -Qunused-arguments, which may cause issues if the flag being tested requires a flag previously added to KBUILD_CFLAGS but not KBUILD_AFLAGS. Use cc-option for cflags additions so that the flags are tested properly.
--- arch/mips/Makefile | 2 +- arch/mips/loongson2ef/Platform | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/mips/Makefile +1 -1
@@ -153,7 +153,7 @@ cflags-y += -fno-stack-check # # Avoid this by explicitly disabling that assembler behaviour. # -cflags-y += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) +cflags-y += $(call cc-option,-Wa$(comma)-mno-fix-loongson3-llsc,) # # CPU-dependent compiler/assembler options for optimization.
arch/mips/loongson2ef/Platform +1 -1
@@ -28,7 +28,7 @@ cflags-$(CONFIG_CPU_LOONGSON2F) += \ # binutils does not merge support for the flag then we can revisit & remove # this later - for now it ensures vendor toolchains don't cause problems. # -cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) +cflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-Wa$(comma)-mno-fix-loongson3-llsc,) # Enable the workarounds for Loongson2f ifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS
Greg Kroah-Hartman
maintainerPATCH 144/355 kbuild: Update assembler calls to use proper flags and language target
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nick Desaulniers <[email protected]>
commit d5c8d6e0fa61401a729e9eb6a9c7077b2d3aebb0 upstream.
as-instr uses KBUILD_AFLAGS, but as-option uses KBUILD_CFLAGS. This can cause as-option to fail unexpectedly when CONFIG_WERROR is set, because clang will emit -Werror,-Wunused-command-line-argument for various -m and -f flags in KBUILD_CFLAGS for assembler sources.
Callers of as-option and as-instr should be adding flags to KBUILD_AFLAGS / aflags-y, not KBUILD_CFLAGS / cflags-y. Use KBUILD_AFLAGS in all macros to clear up the initial problem.
Unfortunately, -Wunused-command-line-argument can still be triggered with clang by the presence of warning flags or macro definitions because '-x assembler' is used, instead of '-x assembler-with-cpp', which will consume these flags. Switch to '-x assembler-with-cpp' in places where '-x assembler' is used, as the compiler is always used as the driver for out of line assembler sources in the kernel.
Finally, add -Werror to these macros so that they behave consistently whether or not CONFIG_WERROR is set.
[nathan: Reworded and expanded on problems in commit message
Use '-x assembler-with-cpp' in a couple more places]
--- scripts/Kbuild.include | 8 ++++---- scripts/Kconfig.include | 2 +- scripts/as-version.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
scripts/Kbuild.include +4 -4
@@ -101,16 +101,16 @@ try-run = $(shell set -e; \ fi) # as-option -# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) +# Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) as-option = $(call try-run,\ - $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) + $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) # as-instr -# Usage: cflags-y += $(call as-instr,instr,option1,option2) +# Usage: aflags-y += $(call as-instr,instr,option1,option2) as-instr = $(call try-run,\ - printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) + printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) # __cc-option # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
scripts/Kconfig.include +1 -1
@@ -33,7 +33,7 @@ ld-option = $(success,$(LD) -v $(1)) # $(as-instr,<instr>) # Return y if the assembler supports <instr>, n otherwise -as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -) +as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler-with-cpp -o /dev/null -) # check if $(CC) and $(LD) exist $(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
scripts/as-version.sh +1 -1
@@ -45,7 +45,7 @@ orig_args="$@" # Get the first line of the --version output. IFS=' ' -set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler /dev/null -o /dev/null 2>/dev/null) +set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler-with-cpp /dev/null -o /dev/null 2>/dev/null) # Split the line on spaces. IFS=' '
Greg Kroah-Hartman
maintainerPATCH 145/355 drm/amd/display: Do not add -mhard-float to dml_ccflags for clang
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 7db038d9790eda558dd6c1dde4cdd58b64789c47 upstream.
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it warns:
clang-16: error: argument unused during compilation: '-mhard-float' [-Werror,-Wunused-command-line-argument]
Similar to commit 84edc2eff827 ("selftest/fpu: avoid clang warning"), just add this flag to GCC builds. Commit 0f0727d971f6 ("drm/amd/display:
readd -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines") added '-msse2' to prevent clang from emitting software floating point routines.
--- drivers/gpu/drm/amd/display/dc/dml/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dml/Makefile +2 -1
@@ -26,7 +26,8 @@ # subcomponents. ifdef CONFIG_X86 -dml_ccflags := -mhard-float -msse +dml_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float +dml_ccflags := $(dml_ccflags-y) -msse endif ifdef CONFIG_PPC64
Greg Kroah-Hartman
maintainerPATCH 146/355 mips: Include KBUILD_CPPFLAGS in CHECKFLAGS invocation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 08f6554ff90ef189e6b8f0303e57005bddfdd6a7 upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following error appears when building ARCH=mips with clang (tip of tree error shown):
clang: error: unsupported option '-mabi=' for target 'x86_64-pc-linux-gnu'
Add KBUILD_CPPFLAGS in the CHECKFLAGS invocation to keep everything working after the move.
--- arch/mips/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Makefile +1 -1
@@ -319,7 +319,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwin KBUILD_LDFLAGS += -m $(ld-emul) ifdef CONFIG_MIPS -CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ +CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ egrep -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') endif
Greg Kroah-Hartman
maintainerPATCH 147/355 kbuild: Add CLANG_FLAGS to as-instr
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit cff6e7f50bd315e5b39c4e46c704ac587ceb965f upstream.
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following errors appear multiple times when building ARCH=powerpc powernv_defconfig:
ld.lld: error: vmlinux.a(arch/powerpc/kernel/head_64.o):(.text+0x12d4): relocation R_PPC64_ADDR16_HI out of range: -4611686018409717520 is not in [-2147483648, 2147483647]; references '__start___soft_mask_table' ld.lld: error: vmlinux.a(arch/powerpc/kernel/head_64.o):(.text+0x12e8): relocation R_PPC64_ADDR16_HI out of range: -4611686018409717392 is not in [-2147483648, 2147483647]; references '__stop___soft_mask_table'
Diffing the .o.cmd files reveals that -DHAVE_AS_ATHIGH=1 is not present anymore, because as-instr only uses KBUILD_AFLAGS, which will no longer contain '--target'.
Mirror Kconfig's as-instr and add CLANG_FLAGS explicitly to the invocation to ensure the target information is always present.
--- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Kbuild.include +1 -1
@@ -110,7 +110,7 @@ as-option = $(call try-run,\ # Usage: aflags-y += $(call as-instr,instr,option1,option2) as-instr = $(call try-run,\ - printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) + printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) # __cc-option # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
Greg Kroah-Hartman
maintainerPATCH 148/355 kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit feb843a469fb0ab00d2d23cfb9bcc379791011bb upstream.
When preprocessing arch/*/kernel/vmlinux.lds.S, the target triple is not passed to $(CPP) because we add it only to KBUILD_{C,A}FLAGS.
As a result, the linker script is preprocessed with predefined macros for the build host instead of the target.
Assuming you use an x86 build machine, compare the following:
$ clang -dM -E -x c /dev/null $ clang -dM -E -x c /dev/null -target aarch64-linux-gnu
There is no actual problem presumably because our linker scripts do not rely on such predefined macros, but it is better to define correct ones.
Move $(CLANG_FLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *.lds.S will be processed with the proper target triple.
[Note]
After the patch submission, we got an actual problem that needs this commit. (CBL issue 1859)
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -586,8 +586,7 @@ else CLANG_FLAGS += -fno-integrated-as endif CLANG_FLAGS += -Werror=unknown-warning-option -KBUILD_CFLAGS += $(CLANG_FLAGS) -KBUILD_AFLAGS += $(CLANG_FLAGS) +KBUILD_CPPFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS endif
Greg Kroah-Hartman
maintainerPATCH 149/355 kbuild: Add KBUILD_CPPFLAGS to as-option invocation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 43fc0a99906e04792786edf8534d8d58d1e9de0c upstream.
After commit feb843a469fb ("kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS"), there is an error while building certain PowerPC assembly files with clang:
arch/powerpc/lib/copypage_power7.S: Assembler messages:
arch/powerpc/lib/copypage_power7.S:34: Error: junk at end of line: 0b01000' arch/powerpc/lib/copypage_power7.S:35: Error: junk at end of line: 0b01010' arch/powerpc/lib/copypage_power7.S:37: Error: junk at end of line: 0b01000' arch/powerpc/lib/copypage_power7.S:38: Error: junk at end of line: 0b01010' arch/powerpc/lib/copypage_power7.S:40: Error: junk at end of line: `0b01010'
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
as-option only uses KBUILD_AFLAGS, so after removing CLANG_FLAGS from KBUILD_AFLAGS, there is no more '--target=' or '--prefix=' flags. As a result of those missing flags, the host target
will be tested during as-option calls and likely fail, meaning necessary flags may not get added when building assembly files, resulting in errors like seen above.
Add KBUILD_CPPFLAGS to as-option invocations to clear up the errors. This should have been done in commit d5c8d6e0fa61 ("kbuild: Update assembler calls to use proper flags and language target"), which switched from using the assembler target to the assembler-with-cpp target, so flags that affect preprocessing are passed along in all relevant tests. as-option now mirrors cc-option.
--- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Kbuild.include +1 -1
@@ -104,7 +104,7 @@ try-run = $(shell set -e; \ # Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) as-option = $(call try-run,\ - $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) + $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) # as-instr # Usage: aflags-y += $(call as-instr,instr,option1,option2)
Greg Kroah-Hartman
maintainerPATCH 150/355 drm/amd/display: Do not add -mhard-float to dcn2{1,0}_resource.o for clang
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
This patch is for linux-5.15.y and earlier only. It is functionally equivalent to upstream commit 7db038d9790e ("drm/amd/display: Do not add '-mhard-float' to dml_ccflags for clang"), which was created after all files that require '-mhard-float' were moved under the dml folder. In kernels older than 5.18, which do not contain upstream commits
22f87d998326 ("drm/amd/display: move FPU operations from dcn21 to dml/dcn20 folder") cf689e869cf0 ("drm/amd/display: move FPU-related code from dcn20 to dml folder")
newer versions of clang error with
clang: error: unsupported option '-mhard-float' for target 'x86_64-linux-gnu'
make[6]: *** [scripts/Makefile.build:289: drivers/gpu/drm/amd/amdgpu/../display/dc/dcn20/dcn20_resource.o] Error 1
clang: error: unsupported option '-mhard-float' for target 'x86_64-linux-gnu'
make[6]: *** [scripts/Makefile.build:289: drivers/gpu/drm/amd/amdgpu/../display/dc/dcn21/dcn21_resource.o] Error 1
Apply a functionally equivalent change to prevent adding '-mhard-float' with clang for these files.
--- drivers/gpu/drm/amd/display/dc/dcn20/Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dcn21/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/Makefile +1 -1
@@ -10,7 +10,7 @@ DCN20 = dcn20_resource.o dcn20_init.o dc DCN20 += dcn20_dsc.o ifdef CONFIG_X86 -CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse +CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := $(if $(CONFIG_CC_IS_GCC), -mhard-float) -msse endif ifdef CONFIG_PPC64
drivers/gpu/drm/amd/display/dc/dcn21/Makefile +1 -1
@@ -6,7 +6,7 @@ DCN21 = dcn21_init.o dcn21_hubp.o dcn21_ dcn21_hwseq.o dcn21_link_encoder.o ifdef CONFIG_X86 -CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := -mhard-float -msse +CFLAGS_$(AMDDALPATH)/dc/dcn21/dcn21_resource.o := $(if $(CONFIG_CC_IS_GCC), -mhard-float) -msse endif ifdef CONFIG_PPC64
Greg Kroah-Hartman
maintainerPATCH 151/355 usb: Flush altsetting 0 endpoints before reinitializating them after reset.
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 89bb3dc13ac29a563f4e4c555e422882f64742bd upstream.
usb core avoids sending a Set-Interface altsetting 0 request after device reset, and instead relies on calling usb_disable_interface() and usb_enable_interface() to flush and reset host-side of those endpoints.
xHCI hosts allocate and set up endpoint ring buffers and host_ep->hcpriv during usb_hcd_alloc_bandwidth() callback, which in this case is called before flushing the endpoint in usb_disable_interface().
Call usb_disable_interface() before usb_hcd_alloc_bandwidth() to ensure URBs are flushed before new ring buffers for the endpoints are allocated.
Otherwise host driver will attempt to find and remove old stale URBs from a freshly allocated new ringbuffer.
--- drivers/usb/core/hub.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/usb/core/hub.c +14 -2
@@ -6014,6 +6014,7 @@ static int usb_reset_and_verify_device(sstruct usb_hub *parent_hub;struct usb_hcd *hcd =bus_to_hcd (udev->bus);struct usb_device_descriptor descriptor; +struct usb_interface *intf;struct usb_host_bos *bos;int i, j, ret =0 ;int port1 = udev->portnum;
@@ -6074,6 +6075,18 @@ static int usb_reset_and_verify_device(sif (!udev->actconfig) goto done; +/* +* Some devices can't handle setting default altsetting 0 with a +* Set-Interface request. Disable host-side endpoints of those +* interfaces here. Enable and reset them back after host has set +* its internal endpoint structures during usb_hcd_alloc_bandwith() +*/ +for (i =0 ; i < udev->actconfig->desc.bNumInterfaces; i++) { + intf = udev->actconfig->interface[i]; +if (intf->cur_altsetting->desc.bAlternateSetting ==0 ) +usb_disable_interface (udev, intf, true); + } +mutex_lock (hcd->bandwidth_mutex); ret =usb_hcd_alloc_bandwidth (udev, udev->actconfig,NULL ,NULL );if (ret <0 ) {
@@ -6105,12 +6118,11 @@ static int usb_reset_and_verify_device(s*/ for (i =0 ; i < udev->actconfig->desc.bNumInterfaces; i++) {struct usb_host_config *config = udev->actconfig; -struct usb_interface *intf = config->interface[i];struct usb_interface_descriptor *desc; + intf = config->interface[i]; desc = &intf->cur_altsetting->desc;if (desc->bAlternateSetting ==0 ) { -usb_disable_interface (udev, intf, true);usb_enable_interface (udev, intf, true); ret =0 ; }else {
Greg Kroah-Hartman
maintainerPATCH 152/355 xen/arm: call uaccess_ttbr0_enable for dm_op hypercall
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Stabellini <[email protected]>
commit 7f9bbc1140ff8796230bc2634055763e271fd692 upstream.
dm_op hypercalls might come from userspace and pass memory addresses as parameters. The memory addresses typically correspond to buffers allocated in userspace to hold extra hypercall parameters.
On ARM, when CONFIG_ARM64_SW_TTBR0_PAN is enabled, they might not be accessible by Xen, as a result ioreq hypercalls might fail. See the existing comment in arch/arm64/xen/hypercall.S regarding privcmd_call for reference.
For privcmd_call, Linux calls uaccess_ttbr0_enable before issuing the hypercall thanks to commit 9cf09d68b89a. We need to do the same for dm_op. This resolves the problem.
Message-ID: <alpine.DEB.2.22.394.2505121446370.8380@ubuntu-linux-20-04-desktop>
--- arch/arm64/xen/hypercall.S | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
arch/arm64/xen/hypercall.S +20 -1
@@ -84,7 +84,26 @@ HYPERCALL1(tmem_op); HYPERCALL1(platform_op_raw); HYPERCALL2(multicall); HYPERCALL2(vm_assist); -HYPERCALL3(dm_op); + +SYM_FUNC_START(HYPERVISOR_dm_op) + mov x16, #__HYPERVISOR_dm_op; \ + /* + * dm_op hypercalls are issued by the userspace. The kernel needs to + * enable access to TTBR0_EL1 as the hypervisor would issue stage 1 + * translations to user memory via AT instructions. Since AT + * instructions are not affected by the PAN bit (ARMv8.1), we only + * need the explicit uaccess_enable/disable if the TTBR0 PAN emulation + * is enabled (it implies that hardware UAO and PAN disabled). + */ + uaccess_ttbr0_enable x6, x7, x8 + hvc XEN_IMM + + /* + * Disable userspace access from kernel once the hyp call completed. + */ + uaccess_ttbr0_disable x6, x7 + ret +SYM_FUNC_END(HYPERVISOR_dm_op); SYM_FUNC_START(privcmd_call) mov x16, x0
Greg Kroah-Hartman
maintainerPATCH 154/355 calipso: unlock rcu before returning -EAFNOSUPPORT
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 3cae906e1a6184cdc9e4d260e4dbdf9a118d94ad upstream.
syzbot reported that a recent patch forgot to unlock rcu in the error path.
Adopt the convention that netlbl_conn_setattr() is already using.
--- net/netlabel/netlabel_kapi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/netlabel/netlabel_kapi.c +4 -2
@@ -1140,8 +1140,10 @@ int netlbl_conn_setattr(struct sock *sk,break ;#if IS_ENABLED (CONFIG_IPV6 )case AF_INET6 : -if (sk->sk_family !=AF_INET6 ) -return -EAFNOSUPPORT ; +if (sk->sk_family !=AF_INET6 ) { + ret_val = -EAFNOSUPPORT ; + goto conn_setattr_return; + } addr6 = (struct sockaddr_in6 *)addr; entry = netlbl_domhsh_getentry_af6(secattr->domain,
Greg Kroah-Hartman
maintainerPATCH 155/355 net: usb: aqc111: debug info before sanitation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit d3faab9b5a6a0477d69c38bd11c43aa5e936f929 upstream.
If we sanitize error returns, the debug statements need to come before that so that we don't lose information.
--- drivers/net/usb/aqc111.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/usb/aqc111.c +4 -4
@@ -31,11 +31,11 @@ static int aqc111_read_cmd_nopm(struct u USB_RECIP_DEVICE, value, index, data, size);if (unlikely (ret < size)) { - ret = ret <0 ? ret : -ENODATA ; -netdev_warn (dev->net,"Failed to read(0x%x) reg index 0x%04x: %d\n" , cmd, index, ret); + + ret = ret <0 ? ret : -ENODATA ; }return ret;
@@ -50,11 +50,11 @@ static int aqc111_read_cmd(struct usbnet USB_RECIP_DEVICE, value, index, data, size);if (unlikely (ret < size)) { - ret = ret <0 ? ret : -ENODATA ; -netdev_warn (dev->net,"Failed to read(0x%x) reg index 0x%04x: %d\n" , cmd, index, ret); + + ret = ret <0 ? ret : -ENODATA ; }return ret;
Greg Kroah-Hartman
maintainerPATCH 156/355 kbuild: userprogs: fix bitsize and target detection on clang
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
commit 1b71c2fb04e7a713abc6edde4a412416ff3158f2 upstream.
scripts/Makefile.clang was changed in the linked commit to move --target from KBUILD_CFLAGS to KBUILD_CPPFLAGS, as that generally has a broader scope. However that variable is not inspected by the userprogs logic, breaking cross compilation on clang.
Use both variables to detect bitsize and target arguments for userprogs.
--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1033,8 +1033,8 @@ LDFLAGS_vmlinux += --orphan-handling=war endif # Align the bit size of userspace programs with the kernel -KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) -KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) +KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) +KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) # userspace programs are linked via the compiler, use the correct linker ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_LD_IS_LLD),yy)
Greg Kroah-Hartman
maintainerPATCH 157/355 kbuild: hdrcheck: fix cross build with clang
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 02e9a22ceef0227175e391902d8760425fa072c6 upstream.
The headercheck tries to call clang with a mix of compiler arguments that don't include the target architecture. When building e.g. x86 headers on arm64, this produces a warning like
clang: warning: unknown platform, assuming -mfloat-abi=soft
Add in the KBUILD_CPPFLAGS, which contain the target, in order to make it build properly.
See also 1b71c2fb04e7 ("kbuild: userprogs: fix bitsize and target detection on clang").
--- usr/include/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
usr/include/Makefile +1 -1
@@ -10,7 +10,7 @@ UAPI_CFLAGS := -std=c90 -Wall -Werror=im # In theory, we do not care -m32 or -m64 for header compile tests. # It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64. -UAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS)) +UAPI_CFLAGS += $(filter -m32 -m64, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
Greg Kroah-Hartman
maintainerPATCH 158/355 tcp: tcp_data_ready() must look at SOCK_DONE
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 39354eb29f597aa01b3d51ccc8169cf183c4367f upstream.
My prior cleanup missed that tcp_data_ready() has to look at SOCK_DONE. Otherwise, an application using SO_RCVLOWAT will not get EPOLLIN event if a FIN is received in the middle of expected payload.
The reason SOCK_DONE is not examined in tcp_epollin_ready() is that tcp_poll() catches the FIN because tcp_fin() is also setting RCV_SHUTDOWN into sk->sk_shutdown
--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
@@ -5028,7 +5028,7 @@ err:void tcp_data_ready (struct sock *sk) { -if (tcp_epollin_ready (sk, sk->sk_rcvlowat)) +if (tcp_epollin_ready (sk, sk->sk_rcvlowat) ||sock_flag (sk,SOCK_DONE )) sk->sk_data_ready (sk); }
Greg Kroah-Hartman
maintainerPATCH 160/355 crypto: marvell/cesa - Do not chain submitted requests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit 0413bcf0fc460a68a2a7a8354aee833293d7d693 upstream.
This driver tries to chain requests together before submitting them to hardware in order to reduce completion interrupts.
However, it even extends chains that have already been submitted to hardware. This is dangerous because there is no way of knowing whether the hardware has already read the DMA memory in question or not.
Fix this by splitting the chain list into two. One for submitted requests and one for requests that have not yet been submitted. Only extend the latter.
--- drivers/crypto/marvell/cesa/cesa.c | 2 - drivers/crypto/marvell/cesa/cesa.h | 9 ++++-- drivers/crypto/marvell/cesa/tdma.c | 53 ++++++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 25 deletions(-)
drivers/crypto/marvell/cesa/cesa.c +1 -1
@@ -94,7 +94,7 @@ static int mv_cesa_std_process(struct mvstatic int mv_cesa_int_process (struct mv_cesa_engine *engine,u32 status) { -if (engine->chain.first && engine->chain.last) +if (engine->chain_hw.first && engine->chain_hw.last)return mv_cesa_tdma_process (engine, status);return mv_cesa_std_process (engine, status);
drivers/crypto/marvell/cesa/cesa.h +6 -3
@@ -439,8 +439,10 @@ struct mv_cesa_dev {* SRAM * @queue: fifo of the pending crypto requests * @load: engine load counter, useful for load balancing -* @chain: list of the current tdma descriptors being processed -* by this engine. +* @chain_hw: list of the current tdma descriptors being processed +* by the hardware. +* @chain_sw: list of the current tdma descriptors that will be +* submitted to the hardware. * @complete_queue: fifo of the processed requests by the engine * * Structure storing CESA engine information.
@@ -459,7 +461,8 @@ struct mv_cesa_engine {struct gen_pool *pool;struct crypto_queue queue;atomic_t load; -struct mv_cesa_tdma_chain chain; +struct mv_cesa_tdma_chain chain_hw; +struct mv_cesa_tdma_chain chain_sw;struct list_head complete_queue;int irq; };
drivers/crypto/marvell/cesa/tdma.c +32 -21
82 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 161/355 gfs2: move msleep to sleepable context
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Aring <[email protected]>
commit ac5ee087d31ed93b6e45d2968a66828c6f621d8c upstream.
This patch moves the msleep_interruptible() out of the non-sleepable context by moving the ls->ls_recover_spin spinlock around so msleep_interruptible() will be called in a sleepable context.
--- fs/gfs2/lock_dlm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/lock_dlm.c +2 -1
@@ -939,14 +939,15 @@ locks_done:if (sdp->sd_args.ar_spectator) {fs_info (sdp,"Recovery is required. Waiting for a " "non-spectator to mount.\n" ); +spin_unlock (&ls->ls_recover_spin);msleep_interruptible (1000 ); }else {fs_info (sdp,"control_mount wait1 block %u start %u " "mount %u lvb %u flags %lx\n" , block_gen, start_gen, mount_gen, lvb_gen, ls->ls_recover_flags); +spin_unlock (&ls->ls_recover_spin); } -spin_unlock (&ls->ls_recover_spin); goto restart; }
Greg Kroah-Hartman
maintainerPATCH 163/355 ASoC: meson: meson-card-utils: use of_property_present() for DT parsing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
commit 171eb6f71e9e3ba6a7410a1d93f3ac213f39dae2 upstream.
Commit c141ecc3cecd ("of: Warn when of_property_read_bool() is used on non-boolean properties") added a warning when trying to parse a property with a value (boolean properties are defined as: absent = false, present without any value = true). This causes a warning from meson-card-utils.
meson-card-utils needs to know about the existence of the "audio-routing" and/or "audio-widgets" properties in order to properly parse them. Switch to of_property_present() in order to silence the following warning messages during boot:
OF: /sound: Read of boolean property 'audio-routing' with a value.
OF: /sound: Read of boolean property 'audio-widgets' with a value.
--- sound/soc/meson/meson-card-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/meson/meson-card-utils.c +1 -1
@@ -245,7 +245,7 @@ static int meson_card_parse_of_optional( const char *p)) {/* If property is not provided, don't fail ... */ -if (!of_property_read_bool (card->dev->of_node, propname)) +if (!of_property_present (card->dev->of_node, propname))return 0 ;/* ... but do fail if it is provided and the parsing fails */
Greg Kroah-Hartman
maintainerPATCH 164/355 net/mlx5_core: Add error handling inmlx5_query_nic_vport_qkey_viol_cntr()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit f0b50730bdd8f2734e548de541e845c0d40dceb6 upstream.
The function mlx5_query_nic_vport_qkey_viol_cntr() calls the function mlx5_query_nic_vport_context() but does not check its return value. This could lead to undefined behavior if the query fails. A proper implementation can be found in mlx5_nic_vport_query_local_lb().
Add error handling for mlx5_query_nic_vport_context(). If it fails, free the out buffer via kvfree() and return error code.
--- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/vport.c +6 -3
@@ -494,19 +494,22 @@ int mlx5_query_nic_vport_qkey_viol_cntr( {u32 *out;int outlen =MLX5_ST_SZ_BYTES (query_nic_vport_context_out); +int err; out =kvzalloc (outlen,GFP_KERNEL );if (!out)return -ENOMEM ; -mlx5_query_nic_vport_context (mdev,0 , out); + err =mlx5_query_nic_vport_context (mdev,0 , out); +if (err) + goto out; *qkey_viol_cntr =MLX5_GET (query_nic_vport_context_out, out, nic_vport_context.qkey_violation_counter); - +out:kvfree (out); -return 0 ; +return err; }EXPORT_SYMBOL_GPL (mlx5_query_nic_vport_qkey_viol_cntr);
Greg Kroah-Hartman
maintainerPATCH 165/355 net/mlx5: Add error handling in mlx5_query_nic_vport_node_guid()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit c6bb8a21cdad8c975a3a646b9e5c8df01ad29783 upstream.
The function mlx5_query_nic_vport_node_guid() calls the function mlx5_query_nic_vport_context() but does not check its return value. A proper implementation can be found in mlx5_nic_vport_query_local_lb().
Add error handling for mlx5_query_nic_vport_context(). If it fails, free the out buffer via kvfree() and return error code.
--- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/vport.c +6 -3
@@ -440,19 +440,22 @@ int mlx5_query_nic_vport_node_guid(struc {u32 *out;int outlen =MLX5_ST_SZ_BYTES (query_nic_vport_context_out); +int err; out =kvzalloc (outlen,GFP_KERNEL );if (!out)return -ENOMEM ; -mlx5_query_nic_vport_context (mdev,0 , out); + err =mlx5_query_nic_vport_context (mdev,0 , out); +if (err) + goto out; *node_guid =MLX5_GET64 (query_nic_vport_context_out, out, nic_vport_context.node_guid); - +out:kvfree (out); -return 0 ; +return err; }EXPORT_SYMBOL_GPL (mlx5_query_nic_vport_node_guid);
Greg Kroah-Hartman
maintainerPATCH 167/355 nfsd: nfsd4_spo_must_allow() must check this is a v4 compound request
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 1244f0b2c3cecd3f349a877006e67c9492b41807 upstream.
If the request being processed is not a v4 compound request, then examining the cstate can have undefined results.
This patch adds a check that the rpc procedure being executed (rq_procinfo) is the NFSPROC4_COMPOUND procedure.
--- fs/nfsd/nfs4proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4proc.c +2 -1
@@ -3537,7 +3537,8 @@ bool nfsd4_spo_must_allow(struct svc_rqsstruct nfs4_op_map *allow = &cstate->clp->cl_spo_must_allow;u32 opiter; -if (!cstate->minorversion) +if (rqstp->rq_procinfo != &nfsd_version4.vs_proc[NFSPROC4_COMPOUND ] || + cstate->minorversion ==0 )return false;if (cstate->spo_must_allowed)
Greg Kroah-Hartman
maintainerPATCH 168/355 nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Lingfeng <[email protected]>
commit b31da62889e6d610114d81dc7a6edbcaa503fcf8 upstream.
In nfs4_state_start_net(), laundromat_work may access nfsd_ssc through nfs4_laundromat -> nfsd4_ssc_expire_umount. If nfsd_ssc isn't initialized, this can cause NULL pointer dereference.
Normally the delayed start of laundromat_work allows sufficient time for nfsd_ssc initialization to complete. However, when the kernel waits too long for userspace responses (e.g. in nfs4_state_start_net -> nfsd4_end_grace -> nfsd4_record_grace_done -> nfsd4_cld_grace_done -> cld_pipe_upcall -> __cld_pipe_upcall -> wait_for_completion path), the delayed work may start before nfsd_ssc initialization finishes.
Fix this by moving nfsd_ssc initialization before starting laundromat_work.
--- fs/nfsd/nfssvc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfsd/nfssvc.c +3 -3
@@ -427,13 +427,13 @@ static int nfsd_startup_net(struct net *if (ret) goto out_filecache; +#ifdef CONFIG_NFSD_V4_2_INTER_SSC +nfsd4_ssc_init_umount_work (nn); +#endif ret =nfs4_state_start_net (net);if (ret) goto out_reply_cache; -#ifdef CONFIG_NFSD_V4_2_INTER_SSC -nfsd4_ssc_init_umount_work (nn); -#endif nn->nfsd_net_up = true;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 169/355 jbd2: fix data-race and null-ptr-deref in jbd2_journal_dirty_metadata()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit af98b0157adf6504fade79b3e6cb260c4ff68e37 upstream.
Since handle->h_transaction may be a NULL pointer, so we should change it to call is_handle_aborted(handle) first before dereferencing it.
And the following data-race was reported in my fuzzer:
==================================================================
BUG: KCSAN: data-race in jbd2_journal_dirty_metadata / jbd2_journal_dirty_metadata
write to 0xffff888011024104 of 4 bytes by task 10881 on cpu 1:
jbd2_journal_dirty_metadata+0x2a5/0x770 fs/jbd2/transaction.c:1556 __ext4_handle_dirty_metadata+0xe7/0x4b0 fs/ext4/ext4_jbd2.c:358 ext4_do_update_inode fs/ext4/inode.c:5220 [inline] ext4_mark_iloc_dirty+0x32c/0xd50 fs/ext4/inode.c:5869 __ext4_mark_inode_dirty+0xe1/0x450 fs/ext4/inode.c:6074 ext4_dirty_inode+0x98/0xc0 fs/ext4/inode.c:6103
....
read to 0xffff888011024104 of 4 bytes by task 10880 on cpu 0:
jbd2_journal_dirty_metadata+0xf2/0x770 fs/jbd2/transaction.c:1512 __ext4_handle_dirty_metadata+0xe7/0x4b0 fs/ext4/ext4_jbd2.c:358 ext4_do_update_inode fs/ext4/inode.c:5220 [inline] ext4_mark_iloc_dirty+0x32c/0xd50 fs/ext4/inode.c:5869 __ext4_mark_inode_dirty+0xe1/0x450 fs/ext4/inode.c:6074 ext4_dirty_inode+0x98/0xc0 fs/ext4/inode.c:6103
....
value changed: 0x00000000 -> 0x00000001
==================================================================
This issue is caused by missing data-race annotation for jh->b_modified. Therefore, the missing annotation needs to be added.
--- fs/jbd2/transaction.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/jbd2/transaction.c +3 -2
@@ -1492,7 +1492,7 @@ int jbd2_journal_dirty_metadata(handle_t jh->b_next_transaction == transaction);spin_unlock (&jh->b_state_lock); } -if (jh->b_modified ==1 ) { +if (data_race (jh->b_modified ==1 )) {/* If it's in our transaction it must be in BJ_Metadata list. */ if (data_race (jh->b_transaction == transaction && jh->b_jlist != BJ_Metadata)) {
@@ -1511,7 +1511,6 @@ int jbd2_journal_dirty_metadata(handle_t goto out; } - journal = transaction->t_journal;spin_lock (&jh->b_state_lock);if (is_handle_aborted (handle)) {
@@ -1526,6 +1525,8 @@ int jbd2_journal_dirty_metadata(handle_t goto out_unlock_bh; } + journal = transaction->t_journal; +if (jh->b_modified ==0 ) {/* * This buffer's got modified and becoming part
Greg Kroah-Hartman
maintainerPATCH 170/355 wifi: rtlwifi: disable ASPM for RTL8723BE with subsystem ID 11ad:1723
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingcong Bai <[email protected]>
commit 77a6407c6ab240527166fb19ee96e95f5be4d3cd upstream.
RTL8723BE found on some ASUSTek laptops, such as F441U and X555UQ with subsystem ID 11ad:1723 are known to output large amounts of PCIe AER errors during and after boot up, causing heavy lags and at times lock-ups:
pcieport 0000:00:1c.5: AER: Correctable error message received from 0000:00:1c.5 pcieport 0000:00:1c.5: PCIe Bus Error: severity=Correctable, type=Physical Layer, (Receiver ID)
pcieport 0000:00:1c.5: device [8086:9d15] error status/mask=00000001/00002000
pcieport 0000:00:1c.5: [ 0] RxErr
Disable ASPM on this combo as a quirk.
This patch is a revision of a previous patch (linked below) which attempted to disable ASPM for RTL8723BE on all Intel Skylake and Kaby Lake PCIe bridges. I take a more conservative approach as all known reports point to ASUSTek laptops of these two generations with this particular wireless card.
Please note, however, before the rtl8723be finishes probing, the AER errors remained. After the module finishes probing, all AER errors would indeed be eliminated, along with heavy lags, poor network throughput, and/or occasional lock-ups.
--- drivers/net/wireless/realtek/rtlwifi/pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/realtek/rtlwifi/pci.c +10 -0
@@ -155,6 +155,16 @@ static void _rtl_pci_update_default_settif (rtlpriv->rtlhal.hw_type ==HARDWARE_TYPE_RTL8192SE && init_aspm ==0x43 ) ppsc->support_aspm = false; + +/* RTL8723BE found on some ASUSTek laptops, such as F441U and +* X555UQ with subsystem ID 11ad:1723 are known to output large +* amounts of PCIe AER errors during and after boot up, causing +* heavy lags, poor network throughput, and occasional lock-ups. +*/ +if (rtlpriv->rtlhal.hw_type ==HARDWARE_TYPE_RTL8723BE && + (rtlpci->pdev->subsystem_vendor ==0x11ad && + rtlpci->pdev->subsystem_device ==0x1723 )) + ppsc->support_aspm = false; } static bool _rtl_pci_platform_switch_device_pci_aspm(
Greg Kroah-Hartman
maintainerPATCH 171/355 media: ov8856: suppress probe deferral errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit e3d86847fba58cf71f66e81b6a2515e07039ae17 upstream.
Probe deferral should not be logged as an error:
ov8856 24-0010: failed to get HW configuration: -517
Use dev_err_probe() for the clock lookup and drop the (mostly) redundant dev_err() from sensor probe() to suppress it.
Note that errors during regulator lookup is already correctly logged using dev_err_probe().
--- drivers/media/i2c/ov8856.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/media/i2c/ov8856.c +3 -6
@@ -1663,8 +1663,8 @@ static int ov8856_get_hwcfg(struct ov885if (!is_acpi_node (fwnode)) { ov8856->xvclk =devm_clk_get (dev,"xvclk" );if (IS_ERR (ov8856->xvclk)) { -dev_err (dev,"could not get xvclk clock (%pe)\n" , - ov8856->xvclk); +dev_err_probe (dev,PTR_ERR (ov8856->xvclk), +"could not get xvclk clock\n" );return PTR_ERR (ov8856->xvclk); }
@@ -1758,11 +1758,8 @@ static int ov8856_probe(struct i2c_clienreturn -ENOMEM ; ret =ov8856_get_hwcfg (ov8856, &client->dev); -if (ret) { -dev_err (&client->dev,"failed to get HW configuration: %d" , - ret); +if (ret)return ret; - }v4l2_i2c_subdev_init (&ov8856->sd, client, &ov8856_subdev_ops);
Greg Kroah-Hartman
maintainerPATCH 172/355 media: cxusb: no longer judge rbuf when the write fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
commit 73fb3b92da84637e3817580fa205d48065924e15 upstream.
syzbot reported a uninit-value in cxusb_i2c_xfer. [1]
Only when the write operation of usb_bulk_msg() in dvb_usb_generic_rw() succeeds and rlen is greater than 0, the read operation of usb_bulk_msg() will be executed to read rlen bytes of data from the dvb device into the rbuf.
In this case, although rlen is 1, the write operation failed which resulted in the dvb read operation not being executed, and ultimately variable i was not initialized.
[1]
BUG: KMSAN: uninit-value in cxusb_gpio_tuner drivers/media/usb/dvb-usb/cxusb.c:124 [inline] BUG: KMSAN: uninit-value in cxusb_i2c_xfer+0x153a/0x1a60 drivers/media/usb/dvb-usb/cxusb.c:196 cxusb_gpio_tuner drivers/media/usb/dvb-usb/cxusb.c:124 [inline] cxusb_i2c_xfer+0x153a/0x1a60 drivers/media/usb/dvb-usb/cxusb.c:196 __i2c_transfer+0xe25/0x3150 drivers/i2c/i2c-core-base.c:-1 i2c_transfer+0x317/0x4a0 drivers/i2c/i2c-core-base.c:2315 i2c_transfer_buffer_flags+0x125/0x1e0 drivers/i2c/i2c-core-base.c:2343 i2c_master_send include/linux/i2c.h:109 [inline] i2cdev_write+0x210/0x280 drivers/i2c/i2c-dev.c:183 do_loop_readv_writev fs/read_write.c:848 [inline] vfs_writev+0x963/0x14e0 fs/read_write.c:1057 do_writev+0x247/0x5c0 fs/read_write.c:1101 __do_sys_writev fs/read_write.c:1169 [inline] __se_sys_writev fs/read_write.c:1166 [inline] __x64_sys_writev+0x98/0xe0 fs/read_write.c:1166 x64_sys_call+0x2229/0x3c80 arch/x86/include/generated/asm/syscalls_64.h:21 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- drivers/media/usb/dvb-usb/cxusb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/usb/dvb-usb/cxusb.c +1 -2
@@ -119,9 +119,8 @@ static void cxusb_gpio_tuner(struct dvb_ o[0 ] =GPIO_TUNER ; o[1 ] = onoff; -cxusb_ctrl_msg (d,CMD_GPIO_WRITE , o,2 , &i,1 ); -if (i !=0x01 ) +if (!cxusb_ctrl_msg (d,CMD_GPIO_WRITE , o,2 , &i,1 ) && i !=0x01 )dev_info (&d->udev->dev,"gpio_write failed.\n" ); st->gpio_write_state[GPIO_TUNER ] = onoff;
Greg Kroah-Hartman
maintainerPATCH 173/355 media: gspca: Add error handling for stv06xx_read_sensor()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 398a1b33f1479af35ca915c5efc9b00d6204f8fa upstream.
In hdcs_init(), the return value of stv06xx_read_sensor() needs to be checked. A proper implementation can be found in vv6410_dump(). Add a check in loop condition and propergate error code to fix this issue.
--- drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c +4 -3
@@ -520,12 +520,13 @@ static int hdcs_init(struct sd *sd)static int hdcs_dump (struct sd *sd) {u16 reg, val; +int err =0 ;pr_info ("Dumping sensor registers:\n" ); -for (reg =HDCS_IDENT ; reg <=HDCS_ROWEXPH ; reg++) { -stv06xx_read_sensor (sd, reg, &val); +for (reg =HDCS_IDENT ; reg <=HDCS_ROWEXPH && !err; reg++) { + err =stv06xx_read_sensor (sd, reg, &val);pr_info ("reg 0x%02x = 0x%02x\n" , reg, val); } -return 0 ; +return (err <0 ) ? err :0 ; }
Greg Kroah-Hartman
maintainerPATCH 174/355 media: v4l2-dev: fix error handling in __video_register_device()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 2a934fdb01db6458288fc9386d3d8ceba6dd551a upstream.
Once device_register() failed, we should call put_device() to decrement reference count for cleanup. Or it could cause memory leak. And move callback function v4l2_device_release() and v4l2_device_get() before put_device().
As comment of device_register() says, 'NOTE: _Never_ directly free @dev after calling this function, even if it returned an error! Always use put_device() to give up the reference initialized in this function instead.'
Found by code review.
--- drivers/media/v4l2-core/v4l2-dev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/v4l2-core/v4l2-dev.c +7 -7
@@ -1029,25 +1029,25 @@ int __video_register_device(struct video vdev->dev.class = &video_class; vdev->dev.devt =MKDEV (VIDEO_MAJOR , vdev->minor); vdev->dev.parent = vdev->dev_parent; + vdev->dev.release = v4l2_device_release;dev_set_name (&vdev->dev,"%s%d" , name_base, vdev->num); + +/* Increase v4l2_device refcount */ +v4l2_device_get (vdev->v4l2_dev); +mutex_lock (&videodev_lock); ret =device_register (&vdev->dev);if (ret <0 ) {mutex_unlock (&videodev_lock);pr_err ("%s: device_register failed\n" , __func__); - goto cleanup; +put_device (&vdev->dev); +return ret; } -/* Register the release callback that will be called when the last -reference to the device goes away. */ - vdev->dev.release = v4l2_device_release;if (nr !=-1 && nr != vdev->num && warn_if_nr_in_use)pr_warn ("%s: requested %s%d, got %s\n" , __func__, name_base, nr,video_device_node_name (vdev)); -/* Increase v4l2_device refcount */ -v4l2_device_get (vdev->v4l2_dev); -/* Part 5: Register the entity. */ ret =video_register_media_controller (vdev);
Greg Kroah-Hartman
maintainerPATCH 175/355 media: venus: Fix probe error handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
commit 523cea3a19f0b3b020a4745344c136a636e6ffd7 upstream.
Video device registering has been moved earlier in the probe function, but the new order has not been propagated to error handling. This means we can end with unreleased resources on error (e.g dangling video device on missing firmware probe aborting).
--- drivers/media/platform/qcom/venus/core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/media/platform/qcom/venus/core.c +8 -8
@@ -290,7 +290,7 @@ static int venus_probe(struct platform_d ret =v4l2_device_register (dev, &core->v4l2_dev);if (ret) - goto err_core_deinit; + goto err_hfi_destroy;platform_set_drvdata (pdev, core);
@@ -322,24 +322,24 @@ static int venus_probe(struct platform_d ret =venus_enumerate_codecs (core,VIDC_SESSION_TYPE_DEC );if (ret) - goto err_venus_shutdown; + goto err_core_deinit; ret =venus_enumerate_codecs (core,VIDC_SESSION_TYPE_ENC );if (ret) - goto err_venus_shutdown; + goto err_core_deinit; ret =pm_runtime_put_sync (dev);if (ret) {pm_runtime_get_noresume (dev); - goto err_dev_unregister; + goto err_core_deinit; }venus_dbgfs_init (core);return 0 ; -err_dev_unregister: -v4l2_device_unregister (&core->v4l2_dev); +err_core_deinit: +hfi_core_deinit (core, false); err_venus_shutdown:venus_shutdown (core); err_firmware_deinit:
@@ -350,9 +350,9 @@ err_runtime_disable:pm_runtime_put_noidle (dev);pm_runtime_disable (dev);pm_runtime_set_suspended (dev); +v4l2_device_unregister (&core->v4l2_dev); +err_hfi_destroy:hfi_destroy (core); -err_core_deinit: -hfi_core_deinit (core, false); err_core_put:if (core->pm_ops->core_put) core->pm_ops->core_put (core);
Greg Kroah-Hartman
maintainerPATCH 176/355 media: videobuf2: use sgtable-based scatterlist wrappers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit a704a3c503ae1cfd9de8a2e2d16a0c9430e98162 upstream.
Use common wrappers operating directly on the struct sg_table objects to fix incorrect use of scatterlists sync calls. dma_sync_sg_for_*() functions have to be called with the number of elements originally passed to dma_map_sg_*() function, not the one returned in sgt->nents.
--- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/common/videobuf2/videobuf2-dma-sg.c +2 -2
@@ -465,7 +465,7 @@ vb2_dma_sg_dmabuf_ops_begin_cpu_access(sstruct vb2_dma_sg_buf *buf = dbuf->priv;struct sg_table *sgt = buf->dma_sgt; -dma_sync_sg_for_cpu (buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); +dma_sync_sgtable_for_cpu (buf->dev, sgt, buf->dma_dir);return 0 ; }
@@ -476,7 +476,7 @@ vb2_dma_sg_dmabuf_ops_end_cpu_access(strstruct vb2_dma_sg_buf *buf = dbuf->priv;struct sg_table *sgt = buf->dma_sgt; -dma_sync_sg_for_device (buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); +dma_sync_sgtable_for_device (buf->dev, sgt, buf->dma_dir);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 177/355 media: vidtv: Terminating the subsequent process of initialization failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
commit 1d5f88f053480326873115092bc116b7d14916ba upstream.
syzbot reported a slab-use-after-free Read in vidtv_mux_init. [1]
After PSI initialization fails, the si member is accessed again, resulting in this uaf.
After si initialization fails, the subsequent process needs to be exited.
[1]
BUG: KASAN: slab-use-after-free in vidtv_mux_pid_ctx_init drivers/media/test-drivers/vidtv/vidtv_mux.c:78 [inline] BUG: KASAN: slab-use-after-free in vidtv_mux_init+0xac2/0xbe0 drivers/media/test-drivers/vidtv/vidtv_mux.c:524 Read of size 8 at addr ffff88802fa42acc by task syz.2.37/6059 CPU: 0 UID: 0 PID: 6059 Comm: syz.2.37 Not tainted 6.14.0-rc5-syzkaller #0 Hardware name: Google Compute Engine, BIOS Google 02/12/2025 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xc3/0x670 mm/kasan/report.c:521 kasan_report+0xd9/0x110 mm/kasan/report.c:634 vidtv_mux_pid_ctx_init drivers/media/test-drivers/vidtv/vidtv_mux.c:78 vidtv_mux_init+0xac2/0xbe0 drivers/media/test-drivers/vidtv/vidtv_mux.c:524 vidtv_start_streaming drivers/media/test-drivers/vidtv/vidtv_bridge.c:194 vidtv_start_feed drivers/media/test-drivers/vidtv/vidtv_bridge.c:239 dmx_section_feed_start_filtering drivers/media/dvb-core/dvb_demux.c:973 dvb_dmxdev_feed_start drivers/media/dvb-core/dmxdev.c:508 [inline] dvb_dmxdev_feed_restart.isra.0 drivers/media/dvb-core/dmxdev.c:537 dvb_dmxdev_filter_stop+0x2b4/0x3a0 drivers/media/dvb-core/dmxdev.c:564 dvb_dmxdev_filter_free drivers/media/dvb-core/dmxdev.c:840 [inline] dvb_demux_release+0x92/0x550 drivers/media/dvb-core/dmxdev.c:1246 __fput+0x3ff/0xb70 fs/file_table.c:464 task_work_run+0x14e/0x250 kernel/task_work.c:227 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0xad8/0x2d70 kernel/exit.c:938 do_group_exit+0xd3/0x2a0 kernel/exit.c:1087 __do_sys_exit_group kernel/exit.c:1098 [inline] __se_sys_exit_group kernel/exit.c:1096 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1096 x64_sys_call+0x151f/0x1720 arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f871d58d169 Code: Unable to access opcode bytes at 0x7f871d58d13f. RSP: 002b:00007fff4b19a788 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f871d58d169 RDX: 0000000000000064 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 00007fff4b19a7ec R08: 0000000b4b19a87f R09: 00000000000927c0 R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000003 R13: 00000000000927c0 R14: 000000000001d553 R15: 00007fff4b19a840 </TASK> Allocated by task 6059: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394 kmalloc_noprof include/linux/slab.h:901 [inline] kzalloc_noprof include/linux/slab.h:1037 [inline] vidtv_psi_pat_table_init drivers/media/test-drivers/vidtv/vidtv_psi.c:970 vidtv_channel_si_init drivers/media/test-drivers/vidtv/vidtv_channel.c:423 vidtv_mux_init drivers/media/test-drivers/vidtv/vidtv_mux.c:519 vidtv_start_streaming drivers/media/test-drivers/vidtv/vidtv_bridge.c:194 vidtv_start_feed drivers/media/test-drivers/vidtv/vidtv_bridge.c:239 dmx_section_feed_start_filtering drivers/media/dvb-core/dvb_demux.c:973 dvb_dmxdev_feed_start drivers/media/dvb-core/dmxdev.c:508 [inline] dvb_dmxdev_feed_restart.isra.0 drivers/media/dvb-core/dmxdev.c:537 dvb_dmxdev_filter_stop+0x2b4/0x3a0 drivers/media/dvb-core/dmxdev.c:564 dvb_dmxdev_filter_free drivers/media/dvb-core/dmxdev.c:840 [inline] dvb_demux_release+0x92/0x550 drivers/media/dvb-core/dmxdev.c:1246 __fput+0x3ff/0xb70 fs/file_table.c:464 task_work_run+0x14e/0x250 kernel/task_work.c:227 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0xad8/0x2d70 kernel/exit.c:938 do_group_exit+0xd3/0x2a0 kernel/exit.c:1087 __do_sys_exit_group kernel/exit.c:1098 [inline] __se_sys_exit_group kernel/exit.c:1096 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1096 x64_sys_call arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 6059: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2353 [inline] slab_free mm/slub.c:4609 [inline] kfree+0x2c4/0x4d0 mm/slub.c:4757 vidtv_channel_si_init drivers/media/test-drivers/vidtv/vidtv_channel.c:499 vidtv_mux_init drivers/media/test-drivers/vidtv/vidtv_mux.c:519 vidtv_start_streaming drivers/media/test-drivers/vidtv/vidtv_bridge.c:194 vidtv_start_feed drivers/media/test-drivers/vidtv/vidtv_bridge.c:239 dmx_section_feed_start_filtering drivers/media/dvb-core/dvb_demux.c:973 dvb_dmxdev_feed_start drivers/media/dvb-core/dmxdev.c:508 [inline] dvb_dmxdev_feed_restart.isra.0 drivers/media/dvb-core/dmxdev.c:537 dvb_dmxdev_filter_stop+0x2b4/0x3a0 drivers/media/dvb-core/dmxdev.c:564 dvb_dmxdev_filter_free drivers/media/dvb-core/dmxdev.c:840 [inline] dvb_demux_release+0x92/0x550 drivers/media/dvb-core/dmxdev.c:1246 __fput+0x3ff/0xb70 fs/file_table.c:464 task_work_run+0x14e/0x250 kernel/task_work.c:227 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0xad8/0x2d70 kernel/exit.c:938 do_group_exit+0xd3/0x2a0 kernel/exit.c:1087 __do_sys_exit_group kernel/exit.c:1098 [inline] __se_sys_exit_group kernel/exit.c:1096 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1096 x64_sys_call arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- drivers/media/test-drivers/vidtv/vidtv_channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/test-drivers/vidtv/vidtv_channel.c +1 -1
@@ -497,7 +497,7 @@ free_sdt:vidtv_psi_sdt_table_destroy (m->si.sdt); free_pat:vidtv_psi_pat_table_destroy (m->si.pat); -return 0 ; +return -EINVAL ; }void vidtv_channel_si_destroy (struct vidtv_mux *m)
Greg Kroah-Hartman
maintainerPATCH 178/355 media: vivid: Change the siize of the composing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
commit f83ac8d30c43fd902af7c84c480f216157b60ef0 upstream.
syzkaller found a bug:
BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_pattern drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2608 [inline] BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_buffer+0x1a9c/0x5af0 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2705 Write of size 1440 at addr ffffc9000d0ffda0 by task vivid-000-vid-c/5304 CPU: 0 UID: 0 PID: 5304 Comm: vivid-000-vid-c Not tainted 6.14.0-rc2-syzkaller-00039-g09fbf3d50205 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x169/0x550 mm/kasan/report.c:489 kasan_report+0x143/0x180 mm/kasan/report.c:602 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106 tpg_fill_plane_pattern drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2608 [inline] tpg_fill_plane_buffer+0x1a9c/0x5af0 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2705 vivid_fillbuff drivers/media/test-drivers/vivid/vivid-kthread-cap.c:470 [inline] vivid_thread_vid_cap_tick+0xf8e/0x60d0 drivers/media/test-drivers/vivid/vivid-kthread-cap.c:629 vivid_thread_vid_cap+0x8aa/0xf30 drivers/media/test-drivers/vivid/vivid-kthread-cap.c:767 kthread+0x7a9/0x920 kernel/kthread.c:464 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK>
The composition size cannot be larger than the size of fmt_cap_rect. So execute v4l2_rect_map_inside() even if has_compose_cap == 0.
--- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/test-drivers/vivid/vivid-vid-cap.c +1 -1
@@ -962,8 +962,8 @@ int vivid_vid_cap_s_selection(struct filif (dev->has_compose_cap) {v4l2_rect_set_min_size (compose, &min_rect);v4l2_rect_set_max_size (compose, &max_rect); -v4l2_rect_map_inside (compose, &fmt); } +v4l2_rect_map_inside (compose, &fmt); dev->fmt_cap_rect = fmt;tpg_s_buf_height (&dev->tpg, fmt.height); }else if (dev->has_compose_cap) {
Greg Kroah-Hartman
maintainerPATCH 179/355 ARM: 9447/1: arm/memremap: fix arch_memremap_can_ram_remap()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ross Stutterheim <[email protected]>
commit 96e0b355883006554a0bee3697da475971d6bba8 upstream.
arm/memremap: fix arch_memremap_can_ram_remap()
commit 260364d112bc ("arm[64]/memremap: don't abuse pfn_valid() to ensure presence of linear map") added the definition of arch_memremap_can_ram_remap() for arm[64] specific filtering of what pages can be used from the linear mapping. memblock_is_map_memory() was called with the pfn of the address given to arch_memremap_can_ram_remap(); however, memblock_is_map_memory() expects to be given an address for arm, not a pfn.
This results in calls to memremap() returning a newly mapped area when it should return an address in the existing linear mapping.
Fix this by removing the address to pfn translation and pass the address directly.
--- arch/arm/mm/ioremap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arm/mm/ioremap.c +1 -3
@@ -483,7 +483,5 @@ void __init early_ioremap_init(void)bool arch_memremap_can_ram_remap (resource_size_t offset,size_t size,unsigned long flags) { -unsigned long pfn =PHYS_PFN (offset); - -return memblock_is_map_memory (pfn); +return memblock_is_map_memory (offset); }
Greg Kroah-Hartman
maintainerPATCH 180/355 ARM: omap: pmic-cpcap: do not mess around without CPCAP or OMAP4
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Kemnade <[email protected]>
commit 7397daf1029d5bfd3415ec8622f5179603d5702d upstream.
The late init call just writes to omap4 registers as soon as CONFIG_MFD_CPCAP is enabled without checking whether the cpcap driver is actually there or the SoC is indeed an OMAP4.
Rather do these things only with the right device combination.
Fixes booting the BT200 with said configuration enabled and non-factory X-Loader and probably also some surprising behavior on other devices.
--- arch/arm/mach-omap2/pmic-cpcap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/pmic-cpcap.c +5 -1
@@ -264,7 +264,11 @@ int __init omap4_cpcap_init(void)static int __init cpcap_late_init (void ) { -omap4_vc_set_pmic_signaling (PWRDM_POWER_RET ); +if (!of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" )) +return 0 ; + +if (soc_is_omap443x () ||soc_is_omap446x () ||soc_is_omap447x ()) +omap4_vc_set_pmic_signaling (PWRDM_POWER_RET );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 181/355 bus: mhi: host: Fix conflict between power_up and SYSERR
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Hugo <[email protected]>
commit 4d92e7c5ccadc79764674ffc2c88d329aabbb7e0 upstream.
When mhi_async_power_up() enables IRQs, it is possible that we could receive a SYSERR notification from the device if the firmware has crashed for some reason. Then the SYSERR notification queues a work item that cannot execute until the pm_mutex is released by mhi_async_power_up().
So the SYSERR work item will be pending. If mhi_async_power_up() detects the SYSERR, it will handle it. If the device is in PBL, then the PBL state transition event will be queued, resulting in a work item after the pending SYSERR work item. Once mhi_async_power_up() releases the pm_mutex, the SYSERR work item can run. It will blindly attempt to reset the MHI state machine, which is the recovery action for SYSERR. PBL/SBL are not interrupt driven and will ignore the MHI Reset unless SYSERR is actively advertised. This will cause the SYSERR work item to timeout waiting for reset to be cleared, and will leave the host state in SYSERR processing. The PBL transition work item will then run, and immediately fail because SYSERR processing is not a valid state for PBL transition.
This leaves the device uninitialized.
This issue has a fairly unique signature in the kernel log:
mhi mhi3: Requested to power ON
Qualcomm Cloud AI 100 0000:36:00.0: Fatal error received from device. Attempting to recover
mhi mhi3: Power on setup success
mhi mhi3: Device failed to exit MHI Reset state mhi mhi3: Device MHI is not in valid state
We cannot remove the SYSERR handling from mhi_async_power_up() because the device may be in the SYSERR state, but we missed the notification as the irq was fired before irqs were enabled. We also can't queue the SYSERR work item from mhi_async_power_up() if SYSERR is detected because that may result in a duplicate work item, and cause the same issue since the duplicate item will blindly issue MHI reset even if SYSERR is no longer active.
Instead, add a check in the SYSERR work item to make sure that MHI reset is only issued if the device is in SYSERR state for PBL or SBL EEs.
--- drivers/bus/mhi/host/pm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/bus/mhi/host/pm.c +17 -1
@@ -454,6 +454,7 @@ static void mhi_pm_disable_transition(ststruct mhi_cmd *mhi_cmd;struct mhi_event_ctxt *er_ctxt;struct device *dev = &mhi_cntrl->mhi_dev->dev; +bool reset_device = false;int ret, i; dev_dbg(dev, "Transitioning from PM state: %s to: %s\n",
@@ -485,8 +486,23 @@ static void mhi_pm_disable_transition(streturn ; } -/* Trigger MHI RESET so that the device will not access host memory */ if (MHI_REG_ACCESS_VALID (prev_state)) { +/* +* If the device is in PBL or SBL, it will only respond to +* RESET if the device is in SYSERR state. SYSERR might +* already be cleared at this point. +*/ +enum mhi_state cur_state =mhi_get_mhi_state (mhi_cntrl); +enum mhi_ee_type cur_ee =mhi_get_exec_env (mhi_cntrl); + +if (cur_state ==MHI_STATE_SYS_ERR ) + reset_device = true; +else if (cur_ee !=MHI_EE_PBL && cur_ee !=MHI_EE_SBL ) + reset_device = true; + } + +/* Trigger MHI RESET so that the device will not access host memory */ +if (reset_device) {u32 in_reset =-1 ;unsigned long timeout =msecs_to_jiffies (mhi_cntrl->timeout_ms);
Greg Kroah-Hartman
maintainerPATCH 182/355 ata: pata_via: Force PIO for ATAPI devices on VT6415/VT6330
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tasos Sahanidis <[email protected]>
commit d29fc02caad7f94b62d56ee1b01c954f9c961ba7 upstream.
The controller has a hardware bug that can hard hang the system when doing ATAPI DMAs without any trace of what happened. Depending on the device attached, it can also prevent the system from booting.
In this case, the system hangs when reading the ATIP from optical media with cdrecord -vvv -atip on an _NEC DVD_RW ND-4571A 1-01 and an Optiarc DVD RW AD-7200A 1.06 attached to an ASRock 990FX Extreme 4, running at UDMA/33.
The issue can be reproduced by running the same command with a cygwin build of cdrecord on WinXP, although it requires more attempts to cause it. The hang in that case is also resolved by forcing PIO. It doesn't appear that VIA has produced any drivers for that OS, thus no known workaround exists.
HDDs attached to the controller do not suffer from any DMA issues.
--- drivers/ata/pata_via.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ata/pata_via.c +2 -1
@@ -368,7 +368,8 @@ static unsigned long via_mode_filter(str }if (dev->class ==ATA_DEV_ATAPI && -dmi_check_system (no_atapi_dma_dmi_table)) { + (dmi_check_system (no_atapi_dma_dmi_table) || + config->id ==PCI_DEVICE_ID_VIA_6415 )) {ata_dev_warn (dev,"controller locks up on ATAPI DMA, forcing PIO\n" ); mask &=ATA_MASK_PIO ; }
Greg Kroah-Hartman
maintainerPATCH 183/355 bus: fsl-mc: do not add a device-link for the UAPI used DPMCP device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ioana Ciornei <[email protected]>
commit dd7d8e012b23de158ca0188239c7a1f2a83b4484 upstream.
The fsl-mc bus associated to the root DPRC in a DPAA2 system exports a device file for userspace access to the MC firmware. In case the DPRC's local MC portal (DPMCP) is currently in use, a new DPMCP device is allocated through the fsl_mc_portal_allocate() function.
In this case, the call to fsl_mc_portal_allocate() will fail with -EINVAL when trying to add a device link between the root DPRC (consumer) and the newly allocated DPMCP device (supplier). This is because the DPMCP is a dependent of the DPRC device (the bus).
Fix this by not adding a device link in case the DPMCP is allocated for the root DPRC's usage.
--- drivers/bus/fsl-mc/mc-io.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/bus/fsl-mc/mc-io.c +13 -6
@@ -214,12 +214,19 @@ int __must_check fsl_mc_portal_allocate(if (error <0 ) goto error_cleanup_resource; - dpmcp_dev->consumer_link =device_link_add (&mc_dev->dev, - &dpmcp_dev->dev, -DL_FLAG_AUTOREMOVE_CONSUMER ); -if (!dpmcp_dev->consumer_link) { - error = -EINVAL ; - goto error_cleanup_mc_io; +/* If the DPRC device itself tries to allocate a portal (usually for +* UAPI interaction), don't add a device link between them since the +* DPMCP device is an actual child device of the DPRC and a reverse +* dependency is not allowed. +*/ +if (mc_dev != mc_bus_dev) { + dpmcp_dev->consumer_link =device_link_add (&mc_dev->dev, + &dpmcp_dev->dev, +DL_FLAG_AUTOREMOVE_CONSUMER ); +if (!dpmcp_dev->consumer_link) { + error = -EINVAL ; + goto error_cleanup_mc_io; + } } *new_mc_io = mc_io;
Greg Kroah-Hartman
maintainerPATCH 184/355 ext4: inline: fix len overflow in ext4_prepare_inline_data
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit 227cb4ca5a6502164f850d22aec3104d7888b270 upstream.
When running the following code on an ext4 filesystem with inline_data feature enabled, it will lead to the bug below.
fd = open("file1", O_RDWR | O_CREAT | O_TRUNC, 0666);
ftruncate(fd, 30);
pwrite(fd, "a", 1, (1UL << 40) + 5UL);That happens because write_begin will succeed as when ext4_generic_write_inline_data calls ext4_prepare_inline_data, pos + len will be truncated, leading to ext4_prepare_inline_data parameter to be 6 instead of 0x10000000006.
Then, later when write_end is called, we hit:
BUG_ON(pos + len > EXT4_I(inode)->i_inline_size);
at ext4_write_inline_data.
Fix it by using a loff_t type for the len parameter in ext4_prepare_inline_data instead of an unsigned int.
[ 44.545164] ------------[ cut here ]------------ [ 44.545530] kernel BUG at fs/ext4/inline.c:240! [ 44.545834] Oops: invalid opcode: 0000 [#1] SMP NOPTI [ 44.546172] CPU: 3 UID: 0 PID: 343 Comm: test Not tainted 6.15.0-rc2-00003-g9080916f4863 #45 PREEMPT(full) 112853fcebfdb93254270a7959841d2c6aa2c8bb [ 44.546523] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 44.546523] RIP: 0010:ext4_write_inline_data+0xfe/0x100 [ 44.546523] Code: 3c 0e 48 83 c7 48 48 89 de 5b 41 5c 41 5d 41 5e 41 5f 5d e9 e4 fa 43 01 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc cc 0f 0b <0f> 0b 0f 1f 44 00 00 55 41 57 41 56 41 55 41 54 53 48 83 ec 20 49 [ 44.546523] RSP: 0018:ffffb342008b79a8 EFLAGS: 00010216 [ 44.546523] RAX: 0000000000000001 RBX: ffff9329c579c000 RCX: 0000010000000006 [ 44.546523] RDX: 000000000000003c RSI: ffffb342008b79f0 RDI: ffff9329c158e738 [ 44.546523] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000 [ 44.546523] R10: 00007ffffffff000 R11: ffffffff9bd0d910 R12: 0000006210000000 [ 44.546523] R13: fffffc7e4015e700 R14: 0000010000000005 R15: ffff9329c158e738 [ 44.546523] FS: 00007f4299934740(0000) GS:ffff932a60179000(0000) knlGS:0000000000000000 [ 44.546523] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 44.546523] CR2: 00007f4299a1ec90 CR3: 0000000002886002 CR4: 0000000000770eb0 [ 44.546523] PKRU: 55555554 [ 44.546523] Call Trace: [ 44.546523] <TASK> [ 44.546523] ext4_write_inline_data_end+0x126/0x2d0 [ 44.546523] generic_perform_write+0x17e/0x270 [ 44.546523] ext4_buffered_write_iter+0xc8/0x170 [ 44.546523] vfs_write+0x2be/0x3e0 [ 44.546523] __x64_sys_pwrite64+0x6d/0xc0 [ 44.546523] do_syscall_64+0x6a/0xf0 [ 44.546523] ? __wake_up+0x89/0xb0 [ 44.546523] ? xas_find+0x72/0x1c0 [ 44.546523] ? next_uptodate_folio+0x317/0x330 [ 44.546523] ? set_pte_range+0x1a6/0x270 [ 44.546523] ? filemap_map_pages+0x6ee/0x840 [ 44.546523] ? ext4_setattr+0x2fa/0x750 [ 44.546523] ? do_pte_missing+0x128/0xf70 [ 44.546523] ? security_inode_post_setattr+0x3e/0xd0 [ 44.546523] ? ___pte_offset_map+0x19/0x100 [ 44.546523] ? handle_mm_fault+0x721/0xa10 [ 44.546523] ? do_user_addr_fault+0x197/0x730 [ 44.546523] ? do_syscall_64+0x76/0xf0 [ 44.546523] ? arch_exit_to_user_mode_prepare+0x1e/0x60 [ 44.546523] ? irqentry_exit_to_user_mode+0x79/0x90 [ 44.546523] entry_SYSCALL_64_after_hwframe+0x55/0x5d [ 44.546523] RIP: 0033:0x7f42999c6687 [ 44.546523] Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff [ 44.546523] RSP: 002b:00007ffeae4a7930 EFLAGS: 00000202 ORIG_RAX: 0000000000000012 [ 44.546523] RAX: ffffffffffffffda RBX: 00007f4299934740 RCX: 00007f42999c6687 [ 44.546523] RDX: 0000000000000001 RSI: 000055ea6149200f RDI: 0000000000000003 [ 44.546523] RBP: 00007ffeae4a79a0 R08: 0000000000000000 R09: 0000000000000000 [ 44.546523] R10: 0000010000000005 R11: 0000000000000202 R12: 0000000000000000 [ 44.546523] R13: 00007ffeae4a7ac8 R14: 00007f4299b86000 R15: 000055ea61493dd8 [ 44.546523] </TASK> [ 44.546523] Modules linked in: [ 44.568501] ---[ end trace 0000000000000000 ]--- [ 44.568889] RIP: 0010:ext4_write_inline_data+0xfe/0x100 [ 44.569328] Code: 3c 0e 48 83 c7 48 48 89 de 5b 41 5c 41 5d 41 5e 41 5f 5d e9 e4 fa 43 01 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc cc 0f 0b <0f> 0b 0f 1f 44 00 00 55 41 57 41 56 41 55 41 54 53 48 83 ec 20 49 [ 44.570931] RSP: 0018:ffffb342008b79a8 EFLAGS: 00010216 [ 44.571356] RAX: 0000000000000001 RBX: ffff9329c579c000 RCX: 0000010000000006 [ 44.571959] RDX: 000000000000003c RSI: ffffb342008b79f0 RDI: ffff9329c158e738 [ 44.572571] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000 [ 44.573148] R10: 00007ffffffff000 R11: ffffffff9bd0d910 R12: 0000006210000000 [ 44.573748] R13: fffffc7e4015e700 R14: 0000010000000005 R15: ffff9329c158e738 [ 44.574335] FS: 00007f4299934740(0000) GS:ffff932a60179000(0000) knlGS:0000000000000000 [ 44.575027] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 44.575520] CR2: 00007f4299a1ec90 CR3: 0000000002886002 CR4: 0000000000770eb0 [ 44.576112] PKRU: 55555554 [ 44.576338] Kernel panic - not syncing: Fatal exception [ 44.576517] Kernel Offset: 0x1a600000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
--- fs/ext4/inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inline.c +1 -1
@@ -389,7 +389,7 @@ out: }static int ext4_prepare_inline_data (handle_t *handle,struct inode *inode, -unsigned int len) +loff_t len) {int ret, size, no_expand;struct ext4_inode_info *ei =EXT4_I (inode);
Greg Kroah-Hartman
maintainerPATCH 185/355 ext4: fix calculation of credits for extent tree modification
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 32a93f5bc9b9812fc710f43a4d8a6830f91e4988 upstream.
Luis and David are reporting that after running generic/750 test for 90+ hours on 2k ext4 filesystem, they are able to trigger a warning in jbd2_journal_dirty_metadata() complaining that there are not enough credits in the running transaction started in ext4_do_writepages().
Indeed the code in ext4_do_writepages() is racy and the extent tree can change between the time we compute credits necessary for extent tree computation and the time we actually modify the extent tree. Thus it may happen that the number of credits actually needed is higher. Modify ext4_ext_index_trans_blocks() to count with the worst case of maximum tree depth. This can reduce the possible number of writers that can operate in the system in parallel (because the credit estimates now won't fit in one transaction) but for reasonably sized journals this shouldn't really be an issue. So just go with a safe and simple fix.
--- fs/ext4/extents.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/extents.c +6 -5
@@ -2367,18 +2367,19 @@ int ext4_ext_calc_credits_for_single_extint ext4_ext_index_trans_blocks (struct inode *inode,int extents) {int index; -int depth;/* If we are converting the inline data, only one is needed here. */ if (ext4_has_inline_data (inode))return 1 ; - depth =ext_depth (inode); - +/* +* Extent tree can change between the time we estimate credits and +* the time we actually modify the tree. Assume the worst case. +*/ if (extents <=1 ) - index = depth *2 ; + index =EXT4_MAX_EXTENT_DEPTH *2 ;else - index = depth *3 ; + index =EXT4_MAX_EXTENT_DEPTH *3 ;return index; }
Greg Kroah-Hartman
maintainerPATCH 186/355 ext4: factor out ext4_get_maxbytes()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
commit dbe27f06fa38b9bfc598f8864ae1c5d5831d9992 upstream.
There are several locations that get the correct maxbytes value based on the inode's block type. It would be beneficial to extract a common helper function to make the code more clear.
--- fs/ext4/ext4.h | 7 +++++++ fs/ext4/extents.c | 7 +------ fs/ext4/file.c | 7 +------ 3 files changed, 9 insertions(+), 12 deletions(-)
fs/ext4/ext4.h +7 -0
@@ -3229,6 +3229,13 @@ static inline unsigned int ext4_flex_bg_return 1 << sbi->s_log_groups_per_flex; } +static inline loff_t ext4_get_maxbytes (struct inode *inode) +{ +if (ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS )) +return inode->i_sb->s_maxbytes; +return EXT4_SB (inode->i_sb)->s_bitmap_maxbytes; +} +#define ext4_std_error (sb, errno) \ do { \ if ((errno)) \
fs/ext4/extents.c +1 -6
@@ -4970,12 +4970,7 @@ static const struct iomap_ops ext4_iomapstatic int ext4_fiemap_check_ranges (struct inode *inode,u64 start,u64 *len) { -u64 maxbytes; - -if (ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS )) - maxbytes = inode->i_sb->s_maxbytes; -else - maxbytes =EXT4_SB (inode->i_sb)->s_bitmap_maxbytes; +u64 maxbytes =ext4_get_maxbytes (inode);if (*len ==0 )return -EINVAL ;
fs/ext4/file.c +1 -6
@@ -858,12 +858,7 @@ static int ext4_file_open(struct inode *loff_t ext4_llseek (struct file *file,loff_t offset,int whence) {struct inode *inode = file->f_mapping->host; -loff_t maxbytes; - -if (!(ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS ))) - maxbytes =EXT4_SB (inode->i_sb)->s_bitmap_maxbytes; -else - maxbytes = inode->i_sb->s_maxbytes; +loff_t maxbytes =ext4_get_maxbytes (inode);switch (whence) {default :
Greg Kroah-Hartman
maintainerPATCH 187/355 ext4: ensure i_size is smaller than maxbytes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
commit 1a77a028a392fab66dd637cdfac3f888450d00af upstream.
The inode i_size cannot be larger than maxbytes, check it while loading inode from the disk.
--- fs/ext4/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
@@ -4868,7 +4868,8 @@ struct inode *__ext4_iget(struct super_b ei->i_file_acl |= ((__u64 )le16_to_cpu (raw_inode->i_file_acl_high)) <<32 ; inode->i_size =ext4_isize (sb, raw_inode); -if ((size =i_size_read (inode)) <0 ) { + size =i_size_read (inode); +if (size <0 || size >ext4_get_maxbytes (inode)) {ext4_error_inode (inode, function, line,0 ,"iget: bad i_size value: %lld" , size); ret = -EFSCORRUPTED ;
Greg Kroah-Hartman
maintainerPATCH 188/355 Input: ims-pcu - check record size in ims_pcu_flash_firmware()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit a95ef0199e80f3384eb992889322957d26c00102 upstream.
The "len" variable comes from the firmware and we generally do trust firmware, but it's always better to double check. If the "len" is too large it could result in memory corruption when we do "memcpy(fragment->data, rec->data, len);"
--- drivers/input/misc/ims-pcu.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/input/misc/ims-pcu.c +6 -0
@@ -845,6 +845,12 @@ static int ims_pcu_flash_firmware(struct addr =be32_to_cpu (rec->addr) /2 ; len =be16_to_cpu (rec->len); +if (len >sizeof (pcu->cmd_buf) -1 -sizeof (*fragment)) { +dev_err (pcu->dev, +"Invalid record length in firmware: %d\n" , len); +return -EINVAL ; + } + fragment = (void *)&pcu->cmd_buf[1 ];put_unaligned_le32 (addr, &fragment->addr); fragment->len = len;
Greg Kroah-Hartman
maintainerPATCH 189/355 f2fs: prevent kernel warning due to negative i_nlink from corrupted image
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
commit 42cb74a92adaf88061039601ddf7c874f58b554e upstream.
WARNING: CPU: 1 PID: 9426 at fs/inode.c:417 drop_nlink+0xac/0xd0 home/cc/linux/fs/inode.c:417 Modules linked in: CPU: 1 UID: 0 PID: 9426 Comm: syz-executor568 Not tainted 6.14.0-12627-g94d471a4f428 #2 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:drop_nlink+0xac/0xd0 home/cc/linux/fs/inode.c:417 Code: 48 8b 5d 28 be 08 00 00 00 48 8d bb 70 07 00 00 e8 f9 67 e6 ff f0 48 ff 83 70 07 00 00 5b 5d e9 9a 12 82 ff e8 95 12 82 ff 90 <0f> 0b 90 c7 45 48 ff ff ff ff 5b 5d e9 83 12 82 ff e8 fe 5f e6 ff RSP: 0018:ffffc900026b7c28 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff8239710f RDX: ffff888041345a00 RSI: ffffffff8239717b RDI: 0000000000000005 RBP: ffff888054509ad0 R08: 0000000000000005 R09: 0000000000000000 R10: 0000000000000000 R11: ffffffff9ab36f08 R12: ffff88804bb40000 R13: ffff8880545091e0 R14: 0000000000008000 R15: ffff8880545091e0 FS: 000055555d0c5880(0000) GS:ffff8880eb3e3000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f915c55b178 CR3: 0000000050d20000 CR4: 0000000000352ef0 Call Trace: <task> f2fs_i_links_write home/cc/linux/fs/f2fs/f2fs.h:3194 [inline] f2fs_drop_nlink+0xd1/0x3c0 home/cc/linux/fs/f2fs/dir.c:845 f2fs_delete_entry+0x542/0x1450 home/cc/linux/fs/f2fs/dir.c:909 f2fs_unlink+0x45c/0x890 home/cc/linux/fs/f2fs/namei.c:581 vfs_unlink+0x2fb/0x9b0 home/cc/linux/fs/namei.c:4544 do_unlinkat+0x4c5/0x6a0 home/cc/linux/fs/namei.c:4608 __do_sys_unlink home/cc/linux/fs/namei.c:4654 [inline] __se_sys_unlink home/cc/linux/fs/namei.c:4652 [inline] __x64_sys_unlink+0xc5/0x110 home/cc/linux/fs/namei.c:4652 do_syscall_x64 home/cc/linux/arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc7/0x250 home/cc/linux/arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fb3d092324b Code: 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66
2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 57 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdc232d938 EFLAGS: 00000206 ORIG_RAX: 0000000000000057
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fb3d092324b
RDX: 00007ffdc232d960 RSI: 00007ffdc232d960 RDI: 00007ffdc232d9f0
RBP: 00007ffdc232d9f0 R08: 0000000000000001 R09: 00007ffdc232d7c0
R10: 00000000fffffffd R11: 0000000000000206 R12: 00007ffdc232eaf0
R13: 000055555d0cebb0 R14: 00007ffdc232d958 R15: 0000000000000001
</task>
--- fs/f2fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/f2fs/namei.c +9 -0
@@ -606,6 +606,15 @@ static int f2fs_unlink(struct inode *dir goto fail; } +if (unlikely (inode->i_nlink ==0 )) { +f2fs_warn (F2FS_I_SB (inode),"%s: inode (ino=%lx) has zero i_nlink" , + __func__, inode->i_ino); + err = -EFSCORRUPTED ; +set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_FSCK ); +f2fs_put_page (page,0 ); + goto fail; + } +f2fs_balance_fs (sbi, true);f2fs_lock_op (sbi);
Greg Kroah-Hartman
maintainerPATCH 190/355 f2fs: fix to do sanity check on sit_bitmap_size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 5db0d252c64e91ba1929c70112352e85dc5751e7 upstream.
w/ below testcase, resize will generate a corrupted image which contains inconsistent metadata, so when mounting such image, it will trigger kernel panic:
touch img
truncate -s $((512*1024*1024*1024)) img
mkfs.f2fs -f img $((256*1024*1024))
resize.f2fs -s -i img -t $((1024*1024*1024))
mount img /mnt/f2fs
------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.h:863! Oops: invalid opcode: 0000 [#1] SMP PTI CPU: 11 UID: 0 PID: 3922 Comm: mount Not tainted 6.15.0-rc1+ #191 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:f2fs_ra_meta_pages+0x47c/0x490 Call Trace: f2fs_build_segment_manager+0x11c3/0x2600 f2fs_fill_super+0xe97/0x2840 mount_bdev+0xf4/0x140 legacy_get_tree+0x2b/0x50 vfs_get_tree+0x29/0xd0 path_mount+0x487/0xaf0 __x64_sys_mount+0x116/0x150 do_syscall_64+0x82/0x190 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7fdbfde1bcfe
The reaseon is:
sit_i->bitmap_size is 192, so size of sit bitmap is 192*8=1536, at maximum there are 1536 sit blocks, however MAIN_SEGS is 261893, so that sit_blk_cnt is 4762, build_sit_entries() -> current_sit_addr() tries to access out-of-boundary in sit_bitmap at offset from [1536, 4762), once sit_bitmap and sit_bitmap_mirror is not the same, it will trigger f2fs_bug_on().
Let's add sanity check in f2fs_sanity_check_ckpt() to avoid panic.
--- fs/f2fs/super.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/f2fs/super.c +8 -0
@@ -3017,6 +3017,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sblock_t user_block_count, valid_user_blocks;block_t avail_node_count, valid_node_count;unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks; +unsigned int sit_blk_cnt;int i, j; total =le32_to_cpu (raw_super->segment_count);
@@ -3118,6 +3119,13 @@ int f2fs_sanity_check_ckpt(struct f2fs_sreturn 1 ; } + sit_blk_cnt =DIV_ROUND_UP (main_segs,SIT_ENTRY_PER_BLOCK ); +if (sit_bitmap_size *8 < sit_blk_cnt) { +f2fs_err (sbi,"Wrong bitmap size: sit: %u, sit_blk_cnt:%u" , + sit_bitmap_size, sit_blk_cnt); +return 1 ; + } + cp_pack_start_sum =__start_sum_addr (sbi); cp_payload =__cp_payload (sbi); if (cp_pack_start_sum < cp_payload + 1 ||
Greg Kroah-Hartman
maintainerPATCH 191/355 NFC: nci: uart: Set tty->disc_data only in success path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit fc27ab48904ceb7e4792f0c400f1ef175edf16fe upstream.
Setting tty->disc_data before opening the NCI device means we need to clean it up on error paths. This also opens some short window if device starts sending data, even before NCIUARTSETDRIVER IOCTL succeeded (broken hardware?). Close the window by exposing tty->disc_data only on the success path, when opening of the NCI device and try_module_get() succeeds.
The code differs in error path in one aspect: tty->disc_data won't be ever assigned thus NULL-ified. This however should not be relevant difference, because of "tty->disc_data=NULL" in nci_uart_tty_open().
--- net/nfc/nci/uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/nfc/nci/uart.c +4 -4
@@ -131,22 +131,22 @@ static int nci_uart_set_driver(struct ttmemcpy (nu, nci_uart_drivers[driver],sizeof (struct nci_uart )); nu->tty = tty; - tty->disc_data = nu;skb_queue_head_init (&nu->tx_q);INIT_WORK (&nu->write_work, nci_uart_write_work);spin_lock_init (&nu->rx_lock); ret = nu->ops.open (nu);if (ret) { - tty->disc_data =NULL ;kfree (nu); +return ret; }else if (!try_module_get (nu->owner)) { nu->ops.close (nu); - tty->disc_data =NULL ;kfree (nu);return -ENOENT ; } -return ret; + tty->disc_data = nu; + +return 0 ; }/* ------ LDISC part ------ */
Greg Kroah-Hartman
maintainerPATCH 192/355 EDAC/altera: Use correct write width with the INTTEST register
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niravkumar L Rabara <[email protected]>
commit e5ef4cd2a47f27c0c9d8ff6c0f63a18937c071a3 upstream.
On the SoCFPGA platform, the INTTEST register supports only 16-bit writes. A 32-bit write triggers an SError to the CPU so do 16-bit accesses only.
[ bp: AI-massage the commit message. ]
--- drivers/edac/altera_edac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/edac/altera_edac.c +3 -3
@@ -1704,9 +1704,9 @@ static ssize_t altr_edac_a10_device_triglocal_irq_save (flags);if (trig_type ==ALTR_UE_TRIGGER_CHAR ) -writel (priv->ue_set_mask, set_addr); +writew (priv->ue_set_mask, set_addr);else -writel (priv->ce_set_mask, set_addr); +writew (priv->ce_set_mask, set_addr);/* Ensure the interrupt test bits are set */ wmb ();
@@ -1736,7 +1736,7 @@ static ssize_t altr_edac_a10_device_triglocal_irq_save (flags);if (trig_type ==ALTR_UE_TRIGGER_CHAR ) { -writel (priv->ue_set_mask, set_addr); +writew (priv->ue_set_mask, set_addr); }else {/* Setup read/write of 4 bytes */ writel (ECC_WORD_WRITE , drvdata->base +ECC_BLK_DBYTECTRL_OFST );
Greg Kroah-Hartman
maintainerPATCH 193/355 fbdev: Fix fb_set_var to prevent null-ptr-deref in fb_videomode_to_var
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
commit 05f6e183879d9785a3cdf2f08a498bc31b7a20aa upstream.
If fb_add_videomode() in fb_set_var() fails to allocate memory for fb_videomode, later it may lead to a null-ptr dereference in fb_videomode_to_var(), as the fb_info is registered while not having the mode in modelist that is expected to be there, i.e. the one that is described in fb_info->var.
================================================================
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 1 PID: 30371 Comm: syz-executor.1 Not tainted 5.10.226-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:fb_videomode_to_var+0x24/0x610 drivers/video/fbdev/core/modedb.c:901 Call Trace: display_to_var+0x3a/0x7c0 drivers/video/fbdev/core/fbcon.c:929 fbcon_resize+0x3e2/0x8f0 drivers/video/fbdev/core/fbcon.c:2071 resize_screen drivers/tty/vt/vt.c:1176 [inline] vc_do_resize+0x53a/0x1170 drivers/tty/vt/vt.c:1263 fbcon_modechanged+0x3ac/0x6e0 drivers/video/fbdev/core/fbcon.c:2720 fbcon_update_vcs+0x43/0x60 drivers/video/fbdev/core/fbcon.c:2776 do_fb_ioctl+0x6d2/0x740 drivers/video/fbdev/core/fbmem.c:1128 fb_ioctl+0xe7/0x150 drivers/video/fbdev/core/fbmem.c:1203 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl fs/ioctl.c:739 [inline] __x64_sys_ioctl+0x19a/0x210 fs/ioctl.c:739 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x67/0xd1 ================================================================
The reason is that fb_info->var is being modified in fb_set_var(), and then fb_videomode_to_var() is called. If it fails to add the mode to fb_info->modelist, fb_set_var() returns error, but does not restore the old value of fb_info->var. Restore fb_info->var on failure the same way it is done earlier in the function.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/video/fbdev/core/fbmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fbmem.c +3 -1
@@ -1062,8 +1062,10 @@ fb_set_var(struct fb_info *info, struct !list_empty(&info->modelist)) ret =fb_add_videomode (&mode, &info->modelist); -if (ret) +if (ret) { + info->var = old_var;return ret; + } event.info = info; event.data = &mode;
Greg Kroah-Hartman
maintainerPATCH 194/355 vgacon: Add check for vc_origin address range in vgacon_scroll()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: GONG Ruiqi <[email protected]>
commit 864f9963ec6b4b76d104d595ba28110b87158003 upstream.
Our in-house Syzkaller reported the following BUG (twice), which we believed was the same issue with [1]:
==================================================================
BUG: KASAN: slab-out-of-bounds in vcs_scr_readw+0xc2/0xd0 drivers/tty/vt/vt.c:4740 Read of size 2 at addr ffff88800f5bef60 by task syz.7.2620/12393 ... Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x72/0xa0 lib/dump_stack.c:106 print_address_description.constprop.0+0x6b/0x3d0 mm/kasan/report.c:364 print_report+0xba/0x280 mm/kasan/report.c:475 kasan_report+0xa9/0xe0 mm/kasan/report.c:588 vcs_scr_readw+0xc2/0xd0 drivers/tty/vt/vt.c:4740 vcs_write_buf_noattr drivers/tty/vt/vc_screen.c:493 [inline] vcs_write+0x586/0x840 drivers/tty/vt/vc_screen.c:690 vfs_write+0x219/0x960 fs/read_write.c:584 ksys_write+0x12e/0x260 fs/read_write.c:639 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x59/0x110 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x78/0xe2 ... </TASK> Allocated by task 5614: kasan_save_stack+0x20/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x8f/0xa0 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:201 [inline] __do_kmalloc_node mm/slab_common.c:1007 [inline] __kmalloc+0x62/0x140 mm/slab_common.c:1020 kmalloc include/linux/slab.h:604 [inline] kzalloc include/linux/slab.h:721 [inline] vc_do_resize+0x235/0xf40 drivers/tty/vt/vt.c:1193 vgacon_adjust_height+0x2d4/0x350 drivers/video/console/vgacon.c:1007 vgacon_font_set+0x1f7/0x240 drivers/video/console/vgacon.c:1031 con_font_set drivers/tty/vt/vt.c:4628 [inline] con_font_op+0x4da/0xa20 drivers/tty/vt/vt.c:4675 vt_k_ioctl+0xa10/0xb30 drivers/tty/vt/vt_ioctl.c:474 vt_ioctl+0x14c/0x1870 drivers/tty/vt/vt_ioctl.c:752 tty_ioctl+0x655/0x1510 drivers/tty/tty_io.c:2779 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:871 [inline] __se_sys_ioctl+0x12d/0x190 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x59/0x110 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x78/0xe2 Last potentially related work creation: kasan_save_stack+0x20/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0x94/0xa0 mm/kasan/generic.c:492 __call_rcu_common.constprop.0+0xc3/0xa10 kernel/rcu/tree.c:2713 netlink_release+0x620/0xc20 net/netlink/af_netlink.c:802 __sock_release+0xb5/0x270 net/socket.c:663 sock_close+0x1e/0x30 net/socket.c:1425 __fput+0x408/0xab0 fs/file_table.c:384 __fput_sync+0x4c/0x60 fs/file_table.c:465 __do_sys_close fs/open.c:1580 [inline] __se_sys_close+0x68/0xd0 fs/open.c:1565 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x59/0x110 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x78/0xe2 Second to last potentially related work creation: kasan_save_stack+0x20/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0x94/0xa0 mm/kasan/generic.c:492 __call_rcu_common.constprop.0+0xc3/0xa10 kernel/rcu/tree.c:2713 netlink_release+0x620/0xc20 net/netlink/af_netlink.c:802 __sock_release+0xb5/0x270 net/socket.c:663 sock_close+0x1e/0x30 net/socket.c:1425 __fput+0x408/0xab0 fs/file_table.c:384 task_work_run+0x154/0x240 kernel/task_work.c:239 exit_task_work include/linux/task_work.h:45 [inline] do_exit+0x8e5/0x1320 kernel/exit.c:874 do_group_exit+0xcd/0x280 kernel/exit.c:1023 get_signal+0x1675/0x1850 kernel/signal.c:2905 arch_do_signal_or_restart+0x80/0x3b0 arch/x86/kernel/signal.c:310 exit_to_user_mode_loop kernel/entry/common.c:111 [inline] exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline] syscall_exit_to_user_mode+0x1b3/0x1e0 kernel/entry/common.c:218 do_syscall_64+0x66/0x110 arch/x86/entry/common.c:87 entry_SYSCALL_64_after_hwframe+0x78/0xe2 The buggy address belongs to the object at ffff88800f5be000 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 2656 bytes to the right of
allocated 1280-byte region [ffff88800f5be000, ffff88800f5be500)
...
Memory state around the buggy address:
ffff88800f5bee00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800f5bee80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88800f5bef00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff88800f5bef80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800f5bf000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================By analyzing the vmcore, we found that vc->vc_origin was somehow placed one line prior to vc->vc_screenbuf when vc was in KD_TEXT mode, and further writings to /dev/vcs caused out-of-bounds reads (and writes right after) in vcs_write_buf_noattr().
Our further experiments show that in most cases, vc->vc_origin equals to vga_vram_base when the console is in KD_TEXT mode, and it's around vc->vc_screenbuf for the KD_GRAPHICS mode. But via triggerring a TIOCL_SETVESABLANK ioctl beforehand, we can make vc->vc_origin be around vc->vc_screenbuf while the console is in KD_TEXT mode, and then by writing the special 'ESC M' control sequence to the tty certain times (depends on the value of vc->state.y - vc->vc_top), we can eventually move vc->vc_origin prior to vc->vc_screenbuf. Here's the PoC, tested on QEMU:
```
int main() {
const int RI_NUM = 10; // should be greater than `vc->state.y - vc->vc_top`
int tty_fd, vcs_fd;
const char *tty_path = "/dev/tty0";
const char *vcs_path = "/dev/vcs";
const char escape_seq[] = "\x1bM"; // ESC + M
const char trigger_seq[] = "Let's trigger an OOB write.";
struct vt_sizes vt_size = { 70, 2 };
int blank = TIOCL_BLANKSCREEN;
tty_fd = open(tty_path, O_RDWR);
char vesa_mode[] = { TIOCL_SETVESABLANK, 1 };
ioctl(tty_fd, TIOCLINUX, vesa_mode);
ioctl(tty_fd, TIOCLINUX, &blank);
ioctl(tty_fd, VT_RESIZE, &vt_size);
for (int i = 0; i < RI_NUM; ++i)
write(tty_fd, escape_seq, sizeof(escape_seq) - 1);
vcs_fd = open(vcs_path, O_RDWR);
write(vcs_fd, trigger_seq, sizeof(trigger_seq));
close(vcs_fd);
close(tty_fd);
return 0;
}
```To solve this problem, add an address range validation check in vgacon_scroll(), ensuring vc->vc_origin never precedes vc_screenbuf.
--- drivers/video/console/vgacon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/console/vgacon.c +1 -1
@@ -1200,7 +1200,7 @@ static bool vgacon_scroll(struct vc_data c->vc_screenbuf_size - delta); c->vc_origin = vga_vram_end - c->vc_screenbuf_size; vga_rolled_over =0 ; - }else + }else if (oldo - delta >= (unsigned long )c->vc_screenbuf) c->vc_origin -= delta; c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; scr_memsetw((u16 *) (c->vc_origin), c->vc_video_erase_char,
Greg Kroah-Hartman
maintainerPATCH 195/355 parisc: fix building with gcc-15
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 7cbb015e2d3d6f180256cde0c908eab21268e7b9 upstream.
The decompressor is built with the default C dialect, which is now gnu23 on gcc-15, and this clashes with the kernel's bool type definition:
In file included from include/uapi/linux/posix_types.h:5,
from arch/parisc/boot/compressed/misc.c:7:include/linux/stddef.h:11:9: error: cannot use keyword 'false' as enumeration constant
11 | false = 0,
Add the -std=gnu11 argument here, as we do for all other architectures.
--- arch/parisc/boot/compressed/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/parisc/boot/compressed/Makefile +1 -0
@@ -22,6 +22,7 @@ KBUILD_CFLAGS += -fno-PIE -mno-space-reg ifndef CONFIG_64BIT KBUILD_CFLAGS += -mfast-indirect-calls endif +KBUILD_CFLAGS += -std=gnu11 OBJECTS += $(obj)/head.o $(obj)/real2.o $(obj)/firmware.o $(obj)/misc.o $(obj)/piggy.o
Greg Kroah-Hartman
maintainerPATCH 196/355 clk: meson-g12a: add missing fclk_div2 to spicc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Da Xue <[email protected]>
commit daf004f87c3520c414992893e2eadd5db5f86a5a upstream.
SPICC is missing fclk_div2, which means fclk_div5 and fclk_div7 indexes are wrong on this clock. This causes the spicc module to output sclk at 2.5x the expected rate when clock index 3 is picked.
Adding the missing fclk_div2 resolves this.
--- drivers/clk/meson/g12a.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/meson/g12a.c +1 -0
@@ -3906,6 +3906,7 @@ static const struct clk_parent_data spic { .hw = &g12a_clk81.hw }, { .hw = &g12a_fclk_div4.hw }, { .hw = &g12a_fclk_div3.hw }, + { .hw = &g12a_fclk_div2.hw }, { .hw = &g12a_fclk_div5.hw }, { .hw = &g12a_fclk_div7.hw }, };
Greg Kroah-Hartman
maintainerPATCH 197/355 ipc: fix to protect IPCS lookups using RCU
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit d66adabe91803ef34a8b90613c81267b5ded1472 upstream.
syzbot reported that it discovered a use-after-free vulnerability, [0]
[0]: https://lore.kernel.org/all/[email protected]/
idr_for_each() is protected by rwsem, but this is not enough. If it is not protected by RCU read-critical region, when idr_for_each() calls radix_tree_node_free() through call_rcu() to free the radix_tree_node structure, the node will be freed immediately, and when reading the next node in radix_tree_for_each_slot(), the already freed memory may be read.
Therefore, we need to add code to make sure that idr_for_each() is protected within the RCU read-critical region when we call it in shm_destroy_orphaned().
--- ipc/shm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
ipc/shm.c +4 -1
@@ -417,8 +417,11 @@ static int shm_try_destroy_orphaned(intvoid shm_destroy_orphaned (struct ipc_namespace *ns) {down_write (&shm_ids (ns).rwsem); -if (shm_ids (ns).in_use) +if (shm_ids (ns).in_use) { +rcu_read_lock ();idr_for_each (&shm_ids (ns).ipcs_idr, &shm_try_destroy_orphaned, ns); +rcu_read_unlock (); + }up_write (&shm_ids (ns).rwsem); }
Greg Kroah-Hartman
maintainerPATCH 198/355 mm: fix ratelimit_pages update error in dirty_ratio_handler()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinliang Zheng <[email protected]>
commit f83f362d40ccceb647f7d80eb92206733d76a36b upstream.
In dirty_ratio_handler(), vm_dirty_bytes must be set to zero before calling writeback_set_ratelimit(), as global_dirty_limits() always prioritizes the value of vm_dirty_bytes.
It's domain_dirty_limits() that's relevant here, not node_dirty_ok:
dirty_ratio_handler
writeback_set_ratelimit
global_dirty_limits(&dirty_thresh) <- ratelimit_pages based on dirty_thresh
domain_dirty_limits
if (bytes) <- bytes = vm_dirty_bytes <--------+
thresh = f1(bytes) <- prioritizes vm_dirty_bytes |
else |
thresh = f2(ratio) |
ratelimit_pages = f3(dirty_thresh) |
vm_dirty_bytes = 0 <- it's late! ---------------------+
This causes ratelimit_pages to still use the value calculated based on vm_dirty_bytes, which is wrong now.
The impact visible to userspace is difficult to capture directly because there is no procfs/sysfs interface exported to user space. However, it will have a real impact on the balance of dirty pages.
For example:
1. On default, we have vm_dirty_ratio=40, vm_dirty_bytes=0
2. echo 8192 > dirty_bytes, then vm_dirty_bytes=8192, vm_dirty_ratio=0, and ratelimit_pages is calculated based on vm_dirty_bytes now.
3. echo 20 > dirty_ratio, then since vm_dirty_bytes is not reset to zero when writeback_set_ratelimit() -> global_dirty_limits() -> domain_dirty_limits() is called, reallimit_pages is still calculated based on vm_dirty_bytes instead of vm_dirty_ratio. This does not conform to the actual intent of the user.
--- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page-writeback.c +1 -1
@@ -557,8 +557,8 @@ int dirty_ratio_handler(struct ctl_table ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos);if (ret ==0 && write && vm_dirty_ratio != old_ratio) { -writeback_set_ratelimit (); vm_dirty_bytes =0 ; +writeback_set_ratelimit (); }return ret; }
Greg Kroah-Hartman
maintainerPATCH 199/355 mtd: rawnand: sunxi: Add randomizer configuration in sunxi_nfc_hw_ecc_write_chunk
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 44ed1f5ff73e9e115b6f5411744d5a22ea1c855b upstream.
The function sunxi_nfc_hw_ecc_write_chunk() calls the sunxi_nfc_hw_ecc_write_chunk(), but does not call the configuration function sunxi_nfc_randomizer_config(). Consequently, the randomization might not conduct correctly, which will affect the lifespan of NAND flash. A proper implementation can be found in sunxi_nfc_hw_ecc_write_page_dma().
Add the sunxi_nfc_randomizer_config() to config randomizer.
--- drivers/mtd/nand/raw/sunxi_nand.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/sunxi_nand.c +1 -0
@@ -1045,6 +1045,7 @@ static int sunxi_nfc_hw_ecc_write_chunk(if (ret)return ret; +sunxi_nfc_randomizer_config (nand, page, false);sunxi_nfc_randomizer_enable (nand);sunxi_nfc_hw_ecc_set_prot_oob_bytes (nand, oob,0 , bbm, page);
Greg Kroah-Hartman
maintainerPATCH 200/355 mtd: nand: sunxi: Add randomizer configuration before randomizer enable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 4a5a99bc79cdc4be63933653682b0261a67a0c9f upstream.
In sunxi_nfc_hw_ecc_read_chunk(), the sunxi_nfc_randomizer_enable() is called without the config of randomizer. A proper implementation can be found in sunxi_nfc_hw_ecc_read_chunks_dma().
Add sunxi_nfc_randomizer_config() before the start of randomization.
--- drivers/mtd/nand/raw/sunxi_nand.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/sunxi_nand.c +1 -0
@@ -818,6 +818,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(sif (ret)return ret; +sunxi_nfc_randomizer_config (nand, page, false);sunxi_nfc_randomizer_enable (nand);writel (NFC_DATA_TRANS |NFC_DATA_SWAP_METHOD |NFC_ECC_OP , nfc->regs +NFC_REG_CMD );
Greg Kroah-Hartman
maintainerPATCH 201/355 dm-mirror: fix a tiny race condition
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 829451beaed6165eb11d7a9fb4e28eb17f489980 upstream.
There's a tiny race condition in dm-mirror. The functions queue_bio and write_callback grab a spinlock, add a bio to the list, drop the spinlock and wake up the mirrord thread that processes bios in the list.
It may be possible that the mirrord thread processes the bio just after spin_unlock_irqrestore is called, before wakeup_mirrord. This spurious wake-up is normally harmless, however if the device mapper device is unloaded just after the bio was processed, it may be possible that wakeup_mirrord(ms) uses invalid "ms" pointer.
Fix this bug by moving wakeup_mirrord inside the spinlock.
--- drivers/md/dm-raid1.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm-raid1.c +2 -3
@@ -128,10 +128,9 @@ static void queue_bio(struct mirror_setspin_lock_irqsave (&ms->lock, flags); should_wake = !(bl->head);bio_list_add (bl, bio); -spin_unlock_irqrestore (&ms->lock, flags); -if (should_wake)wakeup_mirrord (ms); +spin_unlock_irqrestore (&ms->lock, flags); }static void dispatch_bios (void *context,struct bio_list *bio_list)
@@ -638,9 +637,9 @@ static void write_callback(unsigned longif (!ms->failures.head) should_wake =1 ;bio_list_add (&ms->failures, bio); -spin_unlock_irqrestore (&ms->lock, flags);if (should_wake)wakeup_mirrord (ms); +spin_unlock_irqrestore (&ms->lock, flags); }static void do_write (struct mirror_set *ms,struct bio *bio)
Greg Kroah-Hartman
maintainerPATCH 202/355 ftrace: Fix UAF when lookup kallsym after ftrace disabled
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
commit f914b52c379c12288b7623bb814d0508dbe7481d upstream.
The following issue happens with a buggy module:
BUG: unable to handle page fault for address: ffffffffc05d0218 PGD 1bd66f067 P4D 1bd66f067 PUD 1bd671067 PMD 101808067 PTE 0 Oops: Oops: 0000 [#1] SMP KASAN PTI Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS RIP: 0010:sized_strscpy+0x81/0x2f0 RSP: 0018:ffff88812d76fa08 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffffffffc0601010 RCX: dffffc0000000000 RDX: 0000000000000038 RSI: dffffc0000000000 RDI: ffff88812608da2d RBP: 8080808080808080 R08: ffff88812608da2d R09: ffff88812608da68 R10: ffff88812608d82d R11: ffff88812608d810 R12: 0000000000000038 R13: ffff88812608da2d R14: ffffffffc05d0218 R15: fefefefefefefeff FS: 00007fef552de740(0000) GS:ffff8884251c7000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffc05d0218 CR3: 00000001146f0000 CR4: 00000000000006f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> ftrace_mod_get_kallsym+0x1ac/0x590 update_iter_mod+0x239/0x5b0 s_next+0x5b/0xa0 seq_read_iter+0x8c9/0x1070 seq_read+0x249/0x3b0 proc_reg_read+0x1b0/0x280 vfs_read+0x17f/0x920 ksys_read+0xf3/0x1c0 do_syscall_64+0x5f/0x2e0 entry_SYSCALL_64_after_hwframe+0x76/0x7e
The above issue may happen as follows:
(1) Add kprobe tracepoint;
(2) insmod test.ko;
(3) Module triggers ftrace disabled;
(4) rmmod test.ko;
(5) cat /proc/kallsyms; --> Will trigger UAF as test.ko already removed; ftrace_mod_get_kallsym()
...strscpy(module_name, mod_map->mod->name, MODULE_NAME_LEN);
...
The problem is when a module triggers an issue with ftrace and sets ftrace_disable. The ftrace_disable is set when an anomaly is discovered and to prevent any more damage, ftrace stops all text modification. The issue that happened was that the ftrace_disable stops more than just the text modification.
When a module is loaded, its init functions can also be traced. Because kallsyms deletes the init functions after a module has loaded, ftrace saves them when the module is loaded and function tracing is enabled. This allows the output of the function trace to show the init function names instead of just their raw memory addresses.
When a module is removed, ftrace_release_mod() is called, and if ftrace_disable is set, it just returns without doing anything more. The problem here is that it leaves the mod_list still around and if kallsyms is called, it will call into this code and access the module memory that has already been freed as it will return:
strscpy(module_name, mod_map->mod->name, MODULE_NAME_LEN);
Where the "mod" no longer exists and triggers a UAF bug.
--- kernel/trace/ftrace.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +7 -3
@@ -6474,9 +6474,10 @@ void ftrace_release_mod(struct module *mmutex_lock (&ftrace_lock); -if (ftrace_disabled) - goto out_unlock; - +/* +* To avoid the UAF problem after the module is unloaded, the +* 'mod_map' resource needs to be released unconditionally. +*/ list_for_each_entry_safe (mod_map, n, &ftrace_mod_maps, list) {if (mod_map->mod == mod) {list_del_rcu (&mod_map->list);
@@ -6485,6 +6486,9 @@ void ftrace_release_mod(struct module *m } } +if (ftrace_disabled) + goto out_unlock; +/* * Each module has its own ftrace_pages, remove * them from the list.
Greg Kroah-Hartman
maintainerPATCH 203/355 net: ch9200: fix uninitialised access during mii_nway_restart
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qasim Ijaz <[email protected]>
commit 9ad0452c0277b816a435433cca601304cfac7c21 upstream.
In mii_nway_restart() the code attempts to call mii->mdio_read which is ch9200_mdio_read(). ch9200_mdio_read() utilises a local buffer called "buff", which is initialised with control_read(). However "buff" is conditionally initialised inside control_read():
if (err == size) {
memcpy(data, buf, size);
}If the condition of "err == size" is not met, then "buff" remains uninitialised. Once this happens the uninitialised "buff" is accessed and returned during ch9200_mdio_read():
return (buff[0] | buff[1] << 8);
The problem stems from the fact that ch9200_mdio_read() ignores the return value of control_read(), leading to uinit-access of "buff".
To fix this we should check the return value ofcontrol_read() and return early on error.
--- drivers/net/usb/ch9200.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/usb/ch9200.c +5 -2
@@ -178,6 +178,7 @@ static int ch9200_mdio_read(struct net_d {struct usbnet *dev =netdev_priv (netdev);unsigned char buff[2 ]; +int ret;netdev_dbg (netdev,"%s phy_id:%02x loc:%02x\n" , __func__, phy_id, loc);
@@ -185,8 +186,10 @@ static int ch9200_mdio_read(struct net_dif (phy_id !=0 )return -ENODEV ; -control_read (dev,REQUEST_READ ,0 , loc *2 , buff,0x02 , -CONTROL_TIMEOUT_MS ); + ret =control_read (dev,REQUEST_READ ,0 , loc *2 , buff,0x02 , +CONTROL_TIMEOUT_MS ); +if (ret <0 ) +return ret;return (buff[0 ] | buff[1 ] <<8 ); }
Greg Kroah-Hartman
maintainerPATCH 204/355 staging: iio: ad5933: Correct settling cycles encoding per datasheet
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriel Shahrouzi <[email protected]>
commit 60638e2a2d4bc03798f00d5ab65ce9b83cb8b03b upstream.
The AD5933 datasheet (Table 13) lists the maximum cycles to be 0x7FC (2044).
Clamp the user input to the maximum effective value of 0x7FC cycles.
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +1 -1
@@ -412,7 +412,7 @@ static ssize_t ad5933_store(struct devic ret =ad5933_cmd (st,0 );break ;case AD5933_OUT_SETTLING_CYCLES : - val =clamp (val, (u16 )0 , (u16 )0x7FF ); + val =clamp (val, (u16 )0 , (u16 )0x7FC ); st->settling_cycles = val;/* 2x, 4x handling, see datasheet */
Greg Kroah-Hartman
maintainerPATCH 205/355 mips: Add -std= flag specified in KBUILD_CFLAGS to vdso CFLAGS
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Khem Raj <[email protected]>
commit 0f4ae7c6ecb89bfda026d210dcf8216fb67d2333 upstream.
GCC 15 changed the default C standard dialect from gnu17 to gnu23, which should not have impacted the kernel because it explicitly requests the gnu11 standard in the main Makefile. However, mips/vdso code uses its own CFLAGS without a '-std=' value, which break with this dialect change because of the kernel's own definitions of bool, false, and true conflicting with the C23 reserved keywords.
include/linux/stddef.h:11:9: error: cannot use keyword 'false' as enumeration constant
11 | false = 0,
| ^~~~~
include/linux/stddef.h:11:9: note: 'false' is a keyword with '-std=c23' onwards
include/linux/types.h:35:33: error: 'bool' cannot be defined via 'typedef'
35 | typedef _Bool bool;
| ^~~~ include/linux/types.h:35:33: note: 'bool' is a keyword with '-std=c23' onwards
Add -std as specified in KBUILD_CFLAGS to the decompressor and purgatory CFLAGS to eliminate these errors and make the C standard version of these areas match the rest of the kernel.
--- arch/mips/vdso/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/mips/vdso/Makefile +1 -0
@@ -29,6 +29,7 @@ endif # offsets. cflags-vdso := $(ccflags-vdso) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ + $(filter -std=%,$(KBUILD_CFLAGS)) \ -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
Greg Kroah-Hartman
maintainerPATCH 206/355 regulator: max14577: Add error check for max14577_read_reg()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 65271f868cb1dca709ff69e45939bbef8d6d0b70 upstream.
The function max14577_reg_get_current_limit() calls the function max14577_read_reg(), but does not check its return value. A proper implementation can be found in max14577_get_online().
Add a error check for the max14577_read_reg() and return error code if the function fails.
--- drivers/regulator/max14577-regulator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/max14577-regulator.c +4 -1
@@ -40,11 +40,14 @@ static int max14577_reg_get_current_limistruct max14577 *max14577 =rdev_get_drvdata (rdev);const struct maxim_charger_current *limits = &maxim_charger_currents[max14577->dev_type]; +int ret;if (rdev_get_id (rdev) !=MAX14577_CHARGER )return -EINVAL ; -max14577_read_reg (rmap,MAX14577_CHG_REG_CHG_CTRL4 , ®_data); + ret =max14577_read_reg (rmap,MAX14577_CHG_REG_CHG_CTRL4 , ®_data); +if (ret <0 ) +return ret;if ((reg_data &CHGCTRL4_MBCICHWRCL_MASK ) ==0 )return limits->min;
Greg Kroah-Hartman
maintainerPATCH 207/355 uio_hv_generic: Use correct size for interrupt and monitor pages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
commit c951ab8fd3589cf6991ed4111d2130816f2e3ac2 upstream.
Interrupt and monitor pages should be in Hyper-V page size (4k bytes). This can be different from the system page size.
This size is read and used by the user-mode program to determine the mapped data region. An example of such user-mode program is the VMBus driver in DPDK.
Message-ID: <[email protected]>
--- drivers/uio/uio_hv_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/uio/uio_hv_generic.c +2 -2
@@ -288,13 +288,13 @@ hv_uio_probe(struct hv_device *dev, pdata->info.mem[INT_PAGE_MAP ].name ="int_page" ; pdata->info.mem[INT_PAGE_MAP ].addr = (uintptr_t )vmbus_connection.int_page; - pdata->info.mem[INT_PAGE_MAP ].size =PAGE_SIZE ; + pdata->info.mem[INT_PAGE_MAP ].size =HV_HYP_PAGE_SIZE ; pdata->info.mem[INT_PAGE_MAP ].memtype =UIO_MEM_LOGICAL ; pdata->info.mem[MON_PAGE_MAP ].name ="monitor_page" ; pdata->info.mem[MON_PAGE_MAP ].addr = (uintptr_t )vmbus_connection.monitor_pages[1 ]; - pdata->info.mem[MON_PAGE_MAP ].size =PAGE_SIZE ; + pdata->info.mem[MON_PAGE_MAP ].size =HV_HYP_PAGE_SIZE ; pdata->info.mem[MON_PAGE_MAP ].memtype =UIO_MEM_LOGICAL ; pdata->recv_buf =vzalloc (RECV_BUFFER_SIZE );
Greg Kroah-Hartman
maintainerPATCH 208/355 PCI: Add ACS quirk for Loongson PCIe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit 1f3303aa92e15fa273779acac2d0023609de30f1 upstream.
Loongson PCIe Root Ports don't advertise an ACS capability, but they do not allow peer-to-peer transactions between Root Ports. Add an ACS quirk so each Root Port can be in a separate IOMMU group.
--- drivers/pci/quirks.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/pci/quirks.c +23 -0
@@ -4828,6 +4828,18 @@ static int pci_quirk_brcm_acs(struct pci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); } +static int pci_quirk_loongson_acs (struct pci_dev *dev,u16 acs_flags) +{ +/* +* Loongson PCIe Root Ports don't advertise an ACS capability, but +* they do not allow peer-to-peer transactions between Root Ports. +* Allow each Root Port to be in a separate IOMMU group by masking +* SV/RR/CR/UF bits. +*/ +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); +} +/* * Wangxun 40G/25G/10G/1G NICs have no ACS capability, but on * multi-function devices, the hardware isolates the functions by
@@ -4961,6 +4973,17 @@ static const struct pci_dev_acs_enabled { PCI_VENDOR_ID_BROADCOM, 0x1762, pci_quirk_mf_endpoint_acs }, { PCI_VENDOR_ID_BROADCOM, 0x1763, pci_quirk_mf_endpoint_acs }, { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs }, +/* Loongson PCIe Root Ports */ + { PCI_VENDOR_ID_LOONGSON, 0x3C09, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x3C19, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x3C29, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A09, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A19, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A29, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A39, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A49, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A59, pci_quirk_loongson_acs }, + { PCI_VENDOR_ID_LOONGSON, 0x7A69, pci_quirk_loongson_acs },/* Amazon Annapurna Labs */ { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs }, /* Zhaoxin multi-function devices */
Greg Kroah-Hartman
maintainerPATCH 209/355 PCI: Fix lock symmetry in pci_slot_unlock()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit f3efb9569b4a21354ef2caf7ab0608a3e14cc6e4 upstream.
The commit a4e772898f8b ("PCI: Add missing bridge lock to pci_bus_lock()") made the lock function to call depend on dev->subordinate but left pci_slot_unlock() unmodified creating locking asymmetry compared with pci_slot_lock().
Because of the asymmetric lock handling, the same bridge device is unlocked twice. First pci_bus_unlock() unlocks bus->self and then pci_slot_unlock() will unconditionally unlock the same bridge device.
Move pci_dev_unlock() inside an else branch to match the logic in pci_slot_lock().
--- drivers/pci/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci.c +2 -1
@@ -5356,7 +5356,8 @@ static void pci_slot_unlock(struct pci_scontinue ;if (dev->subordinate)pci_bus_unlock (dev->subordinate); -pci_dev_unlock (dev); +else +pci_dev_unlock (dev); } }
Greg Kroah-Hartman
maintainerPATCH 210/355 iio: imu: inv_icm42600: Fix temperature calculation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Nyekjaer <[email protected]>
commit e2f820014239df9360064079ae93f838ff3b7f8c upstream.
Quoted 1 line
From the documentation:
"offset to be added to <type>[Y]_raw prior toscaling by <type>[Y]_scale" Offset should be applied before multiplying scale, so divide offset by scale to make this correct.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c +5 -3
@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iireturn IIO_VAL_INT ;/* * T°C = (temp / 132.48) + 25 -* Tm°C = 1000 * ((temp * 100 / 13248) + 25) +* Tm°C = 1000 * ((temp / 132.48) + 25) +* Tm°C = 7.548309 * temp + 25000 +* Tm°C = (temp + 3312) * 7.548309 * scale: 100000 / 13248 ~= 7.548309 -* offset: 25000 +* offset: 3312 */ case IIO_CHAN_INFO_SCALE : *val =7 ; *val2 =548309 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_OFFSET : - *val =25000 ; + *val =3312 ;return IIO_VAL_INT ;default :return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 211/355 iio: adc: ad7606_spi: fix reg write value mask
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lechner <[email protected]>
commit 89944d88f8795c6c89b9514cb365998145511cd4 upstream.
Fix incorrect value mask for register write. Register values are 8-bit, not 9. If this function was called with a value > 0xFF and an even addr, it would cause writing to the next register.
--- drivers/iio/adc/ad7606_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7606_spi.c +1 -1
@@ -151,7 +151,7 @@ static int ad7606_spi_reg_write(struct astruct spi_device *spi =to_spi_device (st->dev); st->d16[0 ] =cpu_to_be16 ((st->bops->rd_wr_cmd (addr,1 ) <<8 ) | - (val &0x1FF )); + (val &0xFF ));return spi_write (spi, &st->d16[0 ],sizeof (st->d16[0 ])); }
Greg Kroah-Hartman
maintainerPATCH 212/355 ACPICA: fix acpi operand cache leak in dswstate.c
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seunghun Han <[email protected]>
[ Upstream commit 156fd20a41e776bbf334bd5e45c4f78dfc90ce1c ]
ACPICA commit 987a3b5cf7175916e2a4b6ea5b8e70f830dfe732
I found an ACPI cache leak in ACPI early termination and boot continuing case.
When early termination occurs due to malicious ACPI table, Linux kernel terminates ACPI function and continues to boot process. While kernel terminates ACPI function, kmem_cache_destroy() reports Acpi-Operand cache leak.
Boot log of ACPI operand cache leak is as follows:
Quoted 32 lines
[ 0.585957] ACPI: Added _OSI(Module Device) [ 0.587218] ACPI: Added _OSI(Processor Device) [ 0.588530] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.589790] ACPI: Added _OSI(Processor Aggregator Device) [ 0.591534] ACPI Error: Illegal I/O port address/length above 64K: C806E00000004002/0x2 (20170303/hwvalid-155) [ 0.594351] ACPI Exception: AE_LIMIT, Unable to initialize fixed events (20170303/evevent-88) [ 0.597858] ACPI: Unable to start the ACPI Interpreter [ 0.599162] ACPI Error: Could not remove SCI handler (20170303/evmisc-281) [ 0.601836] kmem_cache_destroy Acpi-Operand: Slab cache still has objects [ 0.603556] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc5 #26 [ 0.605159] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS virtual_box 12/01/2006 [ 0.609177] Call Trace: [ 0.610063] ? dump_stack+0x5c/0x81 [ 0.611118] ? kmem_cache_destroy+0x1aa/0x1c0 [ 0.612632] ? acpi_sleep_proc_init+0x27/0x27 [ 0.613906] ? acpi_os_delete_cache+0xa/0x10 [ 0.617986] ? acpi_ut_delete_caches+0x3f/0x7b [ 0.619293] ? acpi_terminate+0xa/0x14 [ 0.620394] ? acpi_init+0x2af/0x34f [ 0.621616] ? __class_create+0x4c/0x80 [ 0.623412] ? video_setup+0x7f/0x7f [ 0.624585] ? acpi_sleep_proc_init+0x27/0x27 [ 0.625861] ? do_one_initcall+0x4e/0x1a0 [ 0.627513] ? kernel_init_freeable+0x19e/0x21f [ 0.628972] ? rest_init+0x80/0x80 [ 0.630043] ? kernel_init+0xa/0x100 [ 0.631084] ? ret_from_fork+0x25/0x30 [ 0.633343] vgaarb: loaded [ 0.635036] EDAC MC: Ver: 3.0.0 [ 0.638601] PCI: Probing PCI hardware [ 0.639833] PCI host bridge to bus 0000:00 [ 0.641031] pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
Quoted 1 line
... Continue to boot and log is omitted ...
I analyzed this memory leak in detail and found acpi_ds_obj_stack_pop_and_ delete() function miscalculated the top of the stack. acpi_ds_obj_stack_push() function uses walk_state->operand_index for start position of the top, but acpi_ds_obj_stack_pop_and_delete() function considers index 0 for it. Therefore, this causes acpi operand memory leak.
This cache leak causes a security threat because an old kernel (<= 4.9) shows memory locations of kernel functions in stack dump. Some malicious users could use this information to neutralize kernel ASLR.
I made a patch to fix ACPI operand cache leak.
--- drivers/acpi/acpica/dsutils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/acpi/acpica/dsutils.c +8 -1
@@ -668,6 +668,8 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,union acpi_parse_object *arguments[ACPI_OBJ_NUM_OPERANDS ];u32 arg_count =0 ;u32 index = walk_state->num_operands; +u32 prev_num_operands = walk_state->num_operands; +u32 new_num_operands;u32 i;ACPI_FUNCTION_TRACE_PTR (ds_create_operands, first_arg);
@@ -696,6 +698,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,/* Create the interpreter arguments, in reverse order */ + new_num_operands = index; index--;for (i =0 ; i < arg_count; i++) { arg = arguments[index];
@@ -720,7 +723,11 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,* pop everything off of the operand stack and delete those * objects */ -acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state); + walk_state->num_operands = i; +acpi_ds_obj_stack_pop_and_delete (new_num_operands, walk_state); + +/* Restore operand count */ + walk_state->num_operands = prev_num_operands;ACPI_EXCEPTION ((AE_INFO , status,"While creating Arg %u" , index));return_ACPI_STATUS (status);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 213/355 clocksource: Fix the CPUs choice in the watchdog per CPU verification
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guilherme G. Piccoli <[email protected]>
[ Upstream commit 08d7becc1a6b8c936e25d827becabfe3bff72a36 ]
Right now, if the clocksource watchdog detects a clocksource skew, it might perform a per CPU check, for example in the TSC case on x86. In other
words: supposing TSC is detected as unstable by the clocksource watchdog running at CPU1, as part of marking TSC unstable the kernel will also run a check of TSC readings on some CPUs to be sure it is synced between them all.
But that check happens only on some CPUs, not all of them; this choice is based on the parameter "verify_n_cpus" and in some random cpumask calculation. So, the watchdog runs such per CPU checks on up to "verify_n_cpus" random CPUs among all online CPUs, with the risk of repeating CPUs (that aren't double checked) in the cpumask random calculation.
But if "verify_n_cpus" > num_online_cpus(), it should skip the random calculation and just go ahead and check the clocksource sync between all online CPUs, without the risk of skipping some CPUs due to duplicity in the random cpumask calculation.
Tests in a 4 CPU laptop with TSC skew detected led to some cases of the per CPU verification skipping some CPU even with verify_n_cpus=8, due to the duplicity on random cpumask generation. Skipping the randomization when the number of online CPUs is smaller than verify_n_cpus, solves that.
--- kernel/time/clocksource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/clocksource.c +1 -1
@@ -273,7 +273,7 @@ static void clocksource_verify_choose_cpus(void) {int cpu, i, n = verify_n_cpus; -if (n <0 ) { +if (n <0 || n >=num_online_cpus ()) {/* Check all of the CPUs. */ cpumask_copy (&cpus_chosen, cpu_online_mask);cpumask_clear_cpu (smp_processor_id (), &cpus_chosen);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 214/355 ACPICA: Avoid sequence overread in call to strncmp()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmed Salem <[email protected]>
[ Upstream commit 64b9dfd0776e9c38d733094859a09f13282ce6f8 ]
ACPICA commit 8b83a8d88dfec59ea147fad35fc6deea8859c58c
ap_get_table_length() checks if tables are valid by calling ap_is_valid_header(). The latter then calls ACPI_VALIDATE_RSDP_SIG(Table->Signature).
ap_is_valid_header() accepts struct acpi_table_header as an argument, so the signature size is always fixed to 4 bytes.
The problem is when the string comparison is between ACPI-defined table signature and ACPI_SIG_RSDP. Common ACPI table header specifies the Signature field to be 4 bytes long[1], with the exception of the RSDP structure whose signature is 8 bytes long "RSD PTR " (including the trailing blank character)[2]. Calling strncmp(sig, rsdp_sig, 8) would then result in a sequence overread[3] as sig would be smaller (4 bytes) than the specified bound (8 bytes).
As a workaround, pass the bound conditionally based on the size of the signature being passed.
--- include/acpi/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/actypes.h +1 -1
@@ -524,7 +524,7 @@ typedef u64 acpi_integer;/* Support for the special RSDP signature (8 characters) */ -#define ACPI_VALIDATE_RSDP_SIG (a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8)) +#define ACPI_VALIDATE_RSDP_SIG (a) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, (sizeof(a) < 8) ? ACPI_NAMESEG_SIZE : 8))#define ACPI_MAKE_RSDP_SIG (dest) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8))/* Support for OEMx signature (x can be any character) */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 215/355 ASoC: tas2770: Power cycle amp on ISENSE/VSENSE change
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hector Martin <[email protected]>
[ Upstream commit f529c91be8a34ac12e7599bf87c65b6f4a2c9f5c ]
The ISENSE/VSENSE blocks are only powered up when the amplifier transitions from shutdown to active. This means that if those controls are flipped on while the amplifier is already playing back audio, they will have no effect.
Fix this by forcing a power cycle around transitions in those controls.
--- sound/soc/codecs/tas2770.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
sound/soc/codecs/tas2770.c +28 -2
@@ -158,11 +158,37 @@ static const struct snd_kcontrol_new isense_switch =static const struct snd_kcontrol_new vsense_switch =SOC_DAPM_SINGLE ("Switch" ,TAS2770_PWR_CTRL ,2 ,1 ,1 ); +static int sense_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm); +struct tas2770_priv *tas2770 =snd_soc_component_get_drvdata (component); + +/* +* Powering up ISENSE/VSENSE requires a trip through the shutdown state. +* Do that here to ensure that our changes are applied properly, otherwise +* we might end up with non-functional IVSENSE if playback started earlier, +* which would break software speaker protection. +*/ +switch (event) { +case SND_SOC_DAPM_PRE_REG : +return snd_soc_component_update_bits (component,TAS2770_PWR_CTRL , +TAS2770_PWR_CTRL_MASK , +TAS2770_PWR_CTRL_SHUTDOWN ); +case SND_SOC_DAPM_POST_REG : +return tas2770_update_pwr_ctrl (tas2770); +default : +return 0 ; + } +} +static const struct snd_soc_dapm_widget tas2770_dapm_widgets[] = {SND_SOC_DAPM_AIF_IN ("ASI1" ,"ASI1 Playback" ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_MUX ("ASI1 Sel" ,SND_SOC_NOPM ,0 ,0 , &tas2770_asi1_mux), -SND_SOC_DAPM_SWITCH ("ISENSE" ,TAS2770_PWR_CTRL ,3 ,1 , &isense_switch), -SND_SOC_DAPM_SWITCH ("VSENSE" ,TAS2770_PWR_CTRL ,2 ,1 , &vsense_switch), +SND_SOC_DAPM_SWITCH_E ("ISENSE" ,TAS2770_PWR_CTRL ,3 ,1 , &isense_switch, + sense_event,SND_SOC_DAPM_PRE_REG |SND_SOC_DAPM_POST_REG ), +SND_SOC_DAPM_SWITCH_E ("VSENSE" ,TAS2770_PWR_CTRL ,2 ,1 , &vsense_switch, + sense_event,SND_SOC_DAPM_PRE_REG |SND_SOC_DAPM_POST_REG ),SND_SOC_DAPM_DAC_E ("DAC" ,NULL ,SND_SOC_NOPM ,0 ,0 , tas2770_dac_event,SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ),SND_SOC_DAPM_OUTPUT ("OUT" ),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 216/355 ACPICA: fix acpi parse and parseext cache leaks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seunghun Han <[email protected]>
[ Upstream commit bed18f0bdcd6737a938264a59d67923688696fc4 ]
ACPICA commit 8829e70e1360c81e7a5a901b5d4f48330e021ea5
I'm Seunghun Han, and I work for National Security Research Institute of South Korea.
I have been doing a research on ACPI and found an ACPI cache leak in ACPI early abort cases.
Boot log of ACPI cache leak is as follows:
[ 0.352414] ACPI: Added _OSI(Module Device) [ 0.353182] ACPI: Added _OSI(Processor Device) [ 0.353182] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.353182] ACPI: Added _OSI(Processor Aggregator Device) [ 0.356028] ACPI: Unable to start the ACPI Interpreter [ 0.356799] ACPI Error: Could not remove SCI handler (20170303/evmisc-281) [ 0.360215] kmem_cache_destroy Acpi-State: Slab cache still has objects [ 0.360648] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.12.0-rc4-next-20170608+ #10 [ 0.361273] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS virtual_box 12/01/2006 [ 0.361873] Call Trace: [ 0.362243] ? dump_stack+0x5c/0x81 [ 0.362591] ? kmem_cache_destroy+0x1aa/0x1c0 [ 0.362944] ? acpi_sleep_proc_init+0x27/0x27 [ 0.363296] ? acpi_os_delete_cache+0xa/0x10 [ 0.363646] ? acpi_ut_delete_caches+0x6d/0x7b [ 0.364000] ? acpi_terminate+0xa/0x14 [ 0.364000] ? acpi_init+0x2af/0x34f [ 0.364000] ? __class_create+0x4c/0x80 [ 0.364000] ? video_setup+0x7f/0x7f [ 0.364000] ? acpi_sleep_proc_init+0x27/0x27 [ 0.364000] ? do_one_initcall+0x4e/0x1a0 [ 0.364000] ? kernel_init_freeable+0x189/0x20a [ 0.364000] ? rest_init+0xc0/0xc0 [ 0.364000] ? kernel_init+0xa/0x100 [ 0.364000] ? ret_from_fork+0x25/0x30
I analyzed this memory leak in detail. I found that “Acpi-State” cache and “Acpi-Parse” cache were merged because the size of cache objects was same slab cache size.
I finally found “Acpi-Parse” cache and “Acpi-parse_ext” cache were leaked using SLAB_NEVER_MERGE flag in kmem_cache_create() function.
Real ACPI cache leak point is as follows:
[ 0.360101] ACPI: Added _OSI(Module Device) [ 0.360101] ACPI: Added _OSI(Processor Device) [ 0.360101] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.361043] ACPI: Added _OSI(Processor Aggregator Device) [ 0.364016] ACPI: Unable to start the ACPI Interpreter [ 0.365061] ACPI Error: Could not remove SCI handler (20170303/evmisc-281) [ 0.368174] kmem_cache_destroy Acpi-Parse: Slab cache still has objects [ 0.369332] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 4.12.0-rc4-next-20170608+ #8 [ 0.371256] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS virtual_box 12/01/2006 [ 0.372000] Call Trace: [ 0.372000] ? dump_stack+0x5c/0x81 [ 0.372000] ? kmem_cache_destroy+0x1aa/0x1c0 [ 0.372000] ? acpi_sleep_proc_init+0x27/0x27 [ 0.372000] ? acpi_os_delete_cache+0xa/0x10 [ 0.372000] ? acpi_ut_delete_caches+0x56/0x7b [ 0.372000] ? acpi_terminate+0xa/0x14 [ 0.372000] ? acpi_init+0x2af/0x34f [ 0.372000] ? __class_create+0x4c/0x80 [ 0.372000] ? video_setup+0x7f/0x7f [ 0.372000] ? acpi_sleep_proc_init+0x27/0x27 [ 0.372000] ? do_one_initcall+0x4e/0x1a0 [ 0.372000] ? kernel_init_freeable+0x189/0x20a [ 0.372000] ? rest_init+0xc0/0xc0 [ 0.372000] ? kernel_init+0xa/0x100 [ 0.372000] ? ret_from_fork+0x25/0x30 [ 0.388039] kmem_cache_destroy Acpi-parse_ext: Slab cache still has objects [ 0.389063] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 4.12.0-rc4-next-20170608+ #8 [ 0.390557] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS virtual_box 12/01/2006 [ 0.392000] Call Trace: [ 0.392000] ? dump_stack+0x5c/0x81 [ 0.392000] ? kmem_cache_destroy+0x1aa/0x1c0 [ 0.392000] ? acpi_sleep_proc_init+0x27/0x27 [ 0.392000] ? acpi_os_delete_cache+0xa/0x10 [ 0.392000] ? acpi_ut_delete_caches+0x6d/0x7b [ 0.392000] ? acpi_terminate+0xa/0x14 [ 0.392000] ? acpi_init+0x2af/0x34f [ 0.392000] ? __class_create+0x4c/0x80 [ 0.392000] ? video_setup+0x7f/0x7f [ 0.392000] ? acpi_sleep_proc_init+0x27/0x27 [ 0.392000] ? do_one_initcall+0x4e/0x1a0 [ 0.392000] ? kernel_init_freeable+0x189/0x20a [ 0.392000] ? rest_init+0xc0/0xc0 [ 0.392000] ? kernel_init+0xa/0x100 [ 0.392000] ? ret_from_fork+0x25/0x30
When early abort is occurred due to invalid ACPI information, Linux kernel terminates ACPI by calling acpi_terminate() function. The function calls acpi_ut_delete_caches() function to delete local caches (acpi_gbl_namespace_ cache, state_cache, operand_cache, ps_node_cache, ps_node_ext_cache).
But the deletion codes in acpi_ut_delete_caches() function only delete slab caches using kmem_cache_destroy() function, therefore the cache objects should be flushed before acpi_ut_delete_caches() function.
"Acpi-Parse" cache and "Acpi-ParseExt" cache are used in an AML parse function, acpi_ps_parse_loop(). The function should complete all ops using acpi_ps_complete_final_op() when an error occurs due to invalid AML codes.
However, the current implementation of acpi_ps_complete_final_op() does not complete all ops when it meets some errors and this cause cache leak.
This cache leak has a security threat because an old kernel (<= 4.9) shows memory locations of kernel functions in stack dump. Some malicious users could use this information to neutralize kernel ASLR.
To fix ACPI cache leak for enhancing security, I made a patch to complete all ops unconditionally for acpi_ps_complete_final_op() function.
I hope that this patch improves the security of Linux kernel.
Thank you.
--- drivers/acpi/acpica/psobject.c | 52 ++++++++++------------------------ 1 file changed, 15 insertions(+), 37 deletions(-)
drivers/acpi/acpica/psobject.c +15 -37
@@ -636,7 +636,8 @@ acpi_status acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, union acpi_parse_object *op, acpi_status status) { - acpi_status status2; + acpi_status return_status = status; +u8 ascending = TRUE;ACPI_FUNCTION_TRACE_PTR (ps_complete_final_op, walk_state);
@@ -650,7 +651,7 @@ acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, op)); do { if (op) { - if (walk_state->ascending_callback != NULL) { + if (ascending && walk_state->ascending_callback != NULL) { walk_state->op = op; walk_state->op_info = acpi_ps_get_opcode_info(op->common.
@@ -672,49 +673,26 @@ acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, }if (status ==AE_CTRL_TERMINATE ) { - status =AE_OK ; - -/* Clean up */ -do { -if (op) { - status2 = -acpi_ps_complete_this_op - (walk_state, op); -if (ACPI_FAILURE - (status2)) { -return_ACPI_STATUS - (status2); - } - } - -acpi_ps_pop_scope (& - (walk_state-> - parser_state), - &op, - &walk_state-> - arg_types, - &walk_state-> - arg_count); - - }while (op); - -return_ACPI_STATUS (status); + ascending = FALSE; + return_status =AE_CTRL_TERMINATE ; }else if (ACPI_FAILURE (status)) {/* First error is most important */ - (void ) -acpi_ps_complete_this_op (walk_state, - op); -return_ACPI_STATUS (status); + ascending = FALSE; + return_status = status; } } - status2 =acpi_ps_complete_this_op (walk_state, op); -if (ACPI_FAILURE (status2)) { -return_ACPI_STATUS (status2); + status =acpi_ps_complete_this_op (walk_state, op); +if (ACPI_FAILURE (status)) { + ascending = FALSE; +if (ACPI_SUCCESS (return_status) || + return_status ==AE_CTRL_TERMINATE ) { + return_status = status; + } } }
@@ -724,5 +702,5 @@ acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, }while (op); -return_ACPI_STATUS (status); +return_ACPI_STATUS (return_status); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 217/355 power: supply: bq27xxx: Retrieve again when busy
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerry Lv <[email protected]>
[ Upstream commit f16d9fb6cf03fdbdefa41a8b32ba1e57afb7ae3d ]
Multiple applications may access the battery gauge at the same time, so the gauge may be busy and EBUSY will be returned. The driver will set a flag to record the EBUSY state, and this flag will be kept until the next periodic update. When this flag is set, bq27xxx_battery_get_property() will just return ENODEV until the flag is updated.
Even if the gauge was busy during the last accessing attempt, returning ENODEV is not ideal, and can cause confusion in the applications layer.
Instead, retry accessing the I2C to update the flag is as expected, for the gauge typically recovers from busy state within a few milliseconds. If still failed to access the gauge, the real error code would be returned instead of ENODEV (as suggested by Pali Rohár).
--- drivers/power/supply/bq27xxx_battery.c | 2 +- drivers/power/supply/bq27xxx_battery_i2c.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -2000,7 +2000,7 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,mutex_unlock (&di->lock);if (psp !=POWER_SUPPLY_PROP_PRESENT && di->cache.flags <0 ) -return -ENODEV ; +return di->cache.flags;switch (psp) {case POWER_SUPPLY_PROP_STATUS :
drivers/power/supply/bq27xxx_battery_i2c.c +12 -1
@@ -6,6 +6,7 @@* Andrew F. Davis <[email protected]> */ +#include <linux/delay.h> #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/module.h>
@@ -32,6 +33,7 @@ static int bq27xxx_battery_i2c_read(struct bq27xxx_device_info *di, u8 reg,struct i2c_msg msg[2 ];u8 data[2 ];int ret; +int retry =0 ;if (!client->adapter)return -ENODEV ;
@@ -48,7 +50,16 @@ static int bq27xxx_battery_i2c_read(struct bq27xxx_device_info *di, u8 reg,else msg[1 ].len =2 ; - ret =i2c_transfer (client->adapter, msg,ARRAY_SIZE (msg)); +do { + ret =i2c_transfer (client->adapter, msg,ARRAY_SIZE (msg)); +if (ret == -EBUSY && ++retry <3 ) { +/* sleep 10 milliseconds when busy */ +usleep_range (10000 ,11000 ); +continue ; + } +break ; + }while (1 ); +if (ret <0 )return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 218/355 ACPICA: utilities: Fix overflow check in vsnprintf()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: gldrk <[email protected]>
[ Upstream commit 12b660251007e00a3e4d47ec62dbe3a7ace7023e ]
ACPICA commit d9d59b7918514ae55063b93f3ec041b1a569bf49
The old version breaks sprintf on 64-bit systems for buffers outside [0..UINT32_MAX].
--- drivers/acpi/acpica/utprint.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/acpi/acpica/utprint.c +2 -5
@@ -333,11 +333,8 @@ int vsnprintf(char *string, acpi_size size, const char *format, va_list args) pos = string; -if (size !=ACPI_UINT32_MAX ) { - end = string + size; - }else { - end =ACPI_CAST_PTR (char,ACPI_UINT32_MAX ); - } + size =ACPI_MIN (size,ACPI_PTR_DIFF (ACPI_MAX_PTR , string)); + end = string + size;for (; *format; ++format) {if (*format !='%' ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 219/355 ASoC: tegra210_ahub: Add check to of_device_get_match_data()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanjun Gong <[email protected]>
[ Upstream commit 04cb269c204398763a620d426cbee43064854000 ]
In tegra_ahub_probe(), check the result of function of_device_get_match_data(), return an error code in case it fails.
--- sound/soc/tegra/tegra210_ahub.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/tegra/tegra210_ahub.c +2 -0
@@ -607,6 +607,8 @@ static int tegra_ahub_probe(struct platform_device *pdev)return -ENOMEM ; ahub->soc_data =of_device_get_match_data (&pdev->dev); +if (!ahub->soc_data) +return -ENODEV ;platform_set_drvdata (pdev, ahub);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 220/355 PM: runtime: fix denying of auto suspend in pm_suspend_timer_fn()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charan Teja Kalla <[email protected]>
[ Upstream commit 40d3b40dce375d6f1c1dbf08d79eed3aed6c691d ]
pm_runtime_put_autosuspend() schedules a hrtimer to expire at "dev->power.timer_expires". If the hrtimer's callback, pm_suspend_timer_fn(), observes that the current time equals "dev->power.timer_expires", it unexpectedly bails out instead of proceeding with runtime suspend.
pm_suspend_timer_fn():
if (expires > 0 && expires < ktime_get_mono_fast_ns()) {
dev->power.timer_expires = 0; rpm_suspend(..)
}
Additionally, as ->timer_expires is not cleared, all the future auto suspend requests will not schedule hrtimer to perform auto suspend.
rpm_suspend():
if ((rpmflags & RPM_AUTO) &&...) {
if (!(dev->power.timer_expires && ...) { <-- this will fail.
hrtimer_start_range_ns(&dev->power.suspend_timer,...);
}
}
Fix this by as well checking if current time reaches the set expiration.
--- drivers/base/power/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/runtime.c +1 -1
@@ -998,7 +998,7 @@ static enum hrtimer_restart pm_suspend_timer_fn(struct hrtimer *timer)* If 'expires' is after the current time, we've been called * too early. */ -if (expires >0 && expires <ktime_get_mono_fast_ns ()) { +if (expires >0 && expires <=ktime_get_mono_fast_ns ()) { dev->power.timer_expires =0 ;rpm_suspend (dev, dev->power.timer_autosuspends ? (RPM_ASYNC |RPM_AUTO ) :RPM_ASYNC );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 221/355 ACPI: battery: negate current when discharging
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Marheine <[email protected]>
[ Upstream commit 234f71555019d308c6bc6f98c78c5551cb8cd56a ]
The ACPI specification requires that battery rate is always positive, but the kernel ABI for POWER_SUPPLY_PROP_CURRENT_NOW (Documentation/ABI/testing/sysfs-class-power) specifies that it should be negative when a battery is discharging. When reporting CURRENT_NOW, massage the value to match the documented ABI.
This only changes the sign of current_now and not power_now because documentation doesn't describe any particular meaning for power_now so leaving power_now unchanged is less likely to confuse userspace unnecessarily, whereas becoming consistent with the documented ABI is worth potentially confusing clients that read current_now.
--- drivers/acpi/battery.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/acpi/battery.c +16 -3
@@ -255,10 +255,23 @@ static int acpi_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_CURRENT_NOW :case POWER_SUPPLY_PROP_POWER_NOW : -if (battery->rate_now ==ACPI_BATTERY_VALUE_UNKNOWN ) +if (battery->rate_now ==ACPI_BATTERY_VALUE_UNKNOWN ) { ret = -ENODEV ; -else - val->intval = battery->rate_now *1000 ; +break ; + } + + val->intval = battery->rate_now *1000 ; +/* +* When discharging, the current should be reported as a +* negative number as per the power supply class interface +* definition. +*/ +if (psp ==POWER_SUPPLY_PROP_CURRENT_NOW && + (battery->state &ACPI_BATTERY_STATE_DISCHARGING ) && +acpi_battery_handle_discharging (battery) + ==POWER_SUPPLY_STATUS_DISCHARGING ) + val->intval = -val->intval; +break ;case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN :case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 222/355 drm/amdgpu/gfx6: fix CSIB handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit 8307ebc15c1ea98a8a0b7837af1faa6c01514577 ]
We shouldn't return after the last section.
We need to update the rest of the CSIB.
--- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +0 -2
@@ -2896,8 +2896,6 @@ static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev, buffer[count++] =cpu_to_le32 (ext->reg_index -0xa000 );for (i =0 ; i < ext->reg_count; i++) buffer[count++] =cpu_to_le32 (ext->extent[i]); - }else { -return ; } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 223/355 sunrpc: update nextcheck time when adding new cache entries
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
[ Upstream commit 5ca00634c8bbb2979c73465588f486b9632f5ed5 ]
The cache_detail structure uses a "nextcheck" field to control hash table scanning intervals. When a table scan begins, nextcheck is set to current time plus 1800 seconds. During scanning, if cache_detail is not empty and a cache entry's expiry time is earlier than the current nextcheck, the nextcheck is updated to that expiry time.
This mechanism ensures that:
1) Empty cache_details are scanned every 1800 seconds to avoid unnecessary scans
2) Non-empty cache_details are scanned based on the earliest expiry time found
However, when adding a new cache entry to an empty cache_detail, the nextcheck time was not being updated, remaining at 1800 seconds. This could delay cache cleanup for up to 1800 seconds, potentially blocking threads(such as nfsd) that are waiting for cache cleanup.
Fix this by updating the nextcheck time whenever a new cache entry is added.
--- net/sunrpc/cache.c | 2 ++ 1 file changed, 2 insertions(+)
net/sunrpc/cache.c +2 -0
@@ -133,6 +133,8 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,hlist_add_head_rcu (&new->cache_list, head); detail->entries++; +if (detail->nextcheck > new->expiry_time) + detail->nextcheck = new->expiry_time +1 ;cache_get (new);spin_unlock (&detail->hash_lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 224/355 drm/bridge: analogix_dp: Add irq flag IRQF_NO_AUTOEN instead of calling disable_irq()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damon Ding <[email protected]>
[ Upstream commit efab13e7d13a641a22c7508cde6e1a5285161944 ]
The IRQF_NO_AUTOEN can be used for the drivers that don't want interrupts to be enabled automatically via devm_request_threaded_irq(). Using this flag can provide be more robust compared to the way of calling disable_irq() after devm_request_threaded_irq() without the IRQF_NO_AUTOEN flag.
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2 -3
@@ -1778,10 +1778,10 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)* that we can get the current state of the GPIO. */ dp->irq =gpiod_to_irq (dp->hpd_gpiod); - irq_flags =IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING ; + irq_flags =IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING |IRQF_NO_AUTOEN ; }else { dp->irq =platform_get_irq (pdev,0 ); - irq_flags =0 ; + irq_flags =IRQF_NO_AUTOEN ; }if (dp->irq == -ENXIO ) {
@@ -1798,7 +1798,6 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)dev_err (&pdev->dev,"failed to request irq\n" ); goto err_disable_clk; } -disable_irq (dp->irq);return dp;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 225/355 exfat: fix double free in delayed_free
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 1f3d9724e16d62c7d42c67d6613b8512f2887c22 ]
The double free could happen in the following path.
exfat_create_upcase_table()
exfat_create_upcase_table() : return error
exfat_free_upcase_table() : free ->vol_utbl
exfat_load_default_upcase_table : return error
exfat_kill_sb()
delayed_free()
exfat_free_upcase_table() <--------- double freeThis patch set ->vol_util as NULL after freeing it.
--- fs/exfat/nls.c | 1 + 1 file changed, 1 insertion(+)
fs/exfat/nls.c +1 -0
@@ -804,4 +804,5 @@ int exfat_create_upcase_table(struct super_block *sb)void exfat_free_upcase_table (struct exfat_sb_info *sbi) {kvfree (sbi->vol_utbl); + sbi->vol_utbl =NULL ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 226/355 drm/msm/hdmi: add runtime PM calls to DDC transfer function
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 531b4e2c206e5f7dead04d9da84dfa693ac57481 ]
We must be sure that the HDMI controller is powered on, while performing the DDC transfer. Add corresponding runtime PM calls to msm_hdmi_i2c_xfer().
Patchwork: https://patchwork.freedesktop.org/patch/651727/
--- drivers/gpu/drm/msm/hdmi/hdmi_i2c.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi_i2c.c +12 -2
@@ -107,11 +107,15 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,if (num ==0 )return num; + ret =pm_runtime_resume_and_get (&hdmi->pdev->dev); +if (ret) +return ret; +init_ddc (hdmi_i2c); ret =ddc_clear_irq (hdmi_i2c);if (ret) -return ret; + goto fail;for (i =0 ; i < num; i++) {struct i2c_msg *p = &msgs[i];
@@ -169,7 +173,7 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,hdmi_read (hdmi,REG_HDMI_DDC_SW_STATUS ),hdmi_read (hdmi,REG_HDMI_DDC_HW_STATUS ), hdmi_read(hdmi, REG_HDMI_DDC_INT_CTRL)); -return ret; + goto fail; } ddc_status =hdmi_read (hdmi,REG_HDMI_DDC_SW_STATUS );
@@ -202,7 +206,13 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c, } } +pm_runtime_put (&hdmi->pdev->dev); +return i; + +fail: +pm_runtime_put (&hdmi->pdev->dev); +return ret; }static u32 msm_hdmi_i2c_func (struct i2c_adapter *adapter)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 227/355 media: uapi: v4l: Fix V4L2_TYPE_IS_OUTPUT condition
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nas Chung <[email protected]>
[ Upstream commit f81f69a0e3da141bdd73a16b8676f4e542533d87 ]
V4L2_TYPE_IS_OUTPUT() returns true for V4L2_BUF_TYPE_VIDEO_OVERLAY which definitely belongs to CAPTURE.
--- include/uapi/linux/videodev2.h | 1 - 1 file changed, 1 deletion(-)
include/uapi/linux/videodev2.h +0 -1
@@ -164,7 +164,6 @@ enum v4l2_buf_type {#define V4L2_TYPE_IS_OUTPUT (type) \ ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \ - || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \ || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \ || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT \
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 228/355 drm/amd/display: Add NULL pointer checks in dm_force_atomic_commit()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 3f397cd203f247879c2f1a061e90d4c8d23655de ]
This commit updates the dm_force_atomic_commit function to replace the usage of PTR_ERR_OR_ZERO with IS_ERR for checking error states after retrieving the Connector (drm_atomic_get_connector_state), CRTC (drm_atomic_get_crtc_state), and Plane (drm_atomic_get_plane_state) states.
The function utilized PTR_ERR_OR_ZERO for error checking. However, this approach is inappropriate in this context because the respective functions do not return NULL; they return pointers that encode errors.
This change ensures that error pointers are properly checked using IS_ERR before attempting to dereference.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +12 -6
@@ -8098,16 +8098,20 @@ static int dm_force_atomic_commit(struct drm_connector *connector)*/ conn_state =drm_atomic_get_connector_state (state, connector); - ret =PTR_ERR_OR_ZERO (conn_state); -if (ret) +/* Check for error in getting connector state */ +if (IS_ERR (conn_state)) { + ret =PTR_ERR (conn_state); goto out; + }/* Attach crtc to drm_atomic_state*/ crtc_state =drm_atomic_get_crtc_state (state, &disconnected_acrtc->base); - ret =PTR_ERR_OR_ZERO (crtc_state); -if (ret) +/* Check for error in getting crtc state */ +if (IS_ERR (crtc_state)) { + ret =PTR_ERR (crtc_state); goto out; + }/* force a restore */ crtc_state->mode_changed = true;
@@ -8115,9 +8119,11 @@ static int dm_force_atomic_commit(struct drm_connector *connector)/* Attach plane to drm_atomic_state */ plane_state =drm_atomic_get_plane_state (state, plane); - ret =PTR_ERR_OR_ZERO (plane_state); -if (ret) +/* Check for error in getting plane state */ +if (IS_ERR (plane_state)) { + ret =PTR_ERR (plane_state); goto out; + }/* Call commit internally with the state we just constructed */ ret =drm_atomic_commit (state);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 229/355 drm/msm/a6xx: Increase HFI response timeout
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhil P Oommen <[email protected]>
[ Upstream commit 5f02f5e78ec9688e29b6857813185b1181796abe ]
When ACD feature is enabled, it triggers some internal calibrations which result in a pretty long delay during the first HFI perf vote. So, increase the HFI response timeout to match the downstream driver.
Patchwork: https://patchwork.freedesktop.org/patch/649344/
--- drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +1 -1
@@ -102,7 +102,7 @@ static int a6xx_hfi_wait_for_ack(struct a6xx_gmu *gmu, u32 id, u32 seqnum,/* Wait for a response */ ret =gmu_poll_timeout (gmu,REG_A6XX_GMU_GMU2HOST_INTR_INFO , val, - val &A6XX_GMU_GMU2HOST_INTR_INFO_MSGQ ,100 ,5000 ); + val &A6XX_GMU_GMU2HOST_INTR_INFO_MSGQ ,100 ,1000000 );if (ret) { DRM_DEV_ERROR(gmu->dev,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 230/355 drm/amdgpu/gfx10: fix CSIB handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit 683308af030cd9b8d3f1de5cbc1ee51788878feb ]
We shouldn't return after the last section.
We need to update the rest of the CSIB.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0 -2
@@ -4002,8 +4002,6 @@ static void gfx_v10_0_get_csb_buffer(struct amdgpu_device *adev, PACKET3_SET_CONTEXT_REG_START);for (i =0 ; i < ext->reg_count; i++) buffer[count++] =cpu_to_le32 (ext->extent[i]); - }else { -return ; } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 231/355 media: uapi: v4l: Change V4L2_TYPE_IS_CAPTURE condition
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nas Chung <[email protected]>
[ Upstream commit ad2698efce37e910dcf3c3914263e6cb3e86f8cd ]
Explicitly compare a buffer type only with valid buffer types, to avoid matching a buffer type outside of the valid buffer type set.
--- include/uapi/linux/videodev2.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
include/uapi/linux/videodev2.h +10 -1
@@ -153,10 +153,18 @@ enum v4l2_buf_type {V4L2_BUF_TYPE_SDR_OUTPUT =12 ,V4L2_BUF_TYPE_META_CAPTURE =13 ,V4L2_BUF_TYPE_META_OUTPUT =14 , +/* +* Note: V4L2_TYPE_IS_VALID and V4L2_TYPE_IS_OUTPUT must +* be updated if a new type is added. +*/ /* Deprecated, do not use */ V4L2_BUF_TYPE_PRIVATE = 0x80, }; +#define V4L2_TYPE_IS_VALID (type) \ + ((type) >= V4L2_BUF_TYPE_VIDEO_CAPTURE &&\ + (type) <= V4L2_BUF_TYPE_META_OUTPUT) +#define V4L2_TYPE_IS_MULTIPLANAR (type) \ ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -170,7 +178,8 @@ enum v4l2_buf_type { || (type) == V4L2_BUF_TYPE_SDR_OUTPUT \ || (type) == V4L2_BUF_TYPE_META_OUTPUT) -#define V4L2_TYPE_IS_CAPTURE (type) (!V4L2_TYPE_IS_OUTPUT(type)) +#define V4L2_TYPE_IS_CAPTURE (type) \ + (V4L2_TYPE_IS_VALID(type) && !V4L2_TYPE_IS_OUTPUT(type))enum v4l2_tuner_type {V4L2_TUNER_RADIO =1 ,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 232/355 drm/amdgpu/gfx7: fix CSIB handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit be7652c23d833d1ab2c67b16e173b1a4e69d1ae6 ]
We shouldn't return after the last section.
We need to update the rest of the CSIB.
--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -2
@@ -4000,8 +4000,6 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev, buffer[count++] =cpu_to_le32 (ext->reg_index -PACKET3_SET_CONTEXT_REG_START );for (i =0 ; i < ext->reg_count; i++) buffer[count++] =cpu_to_le32 (ext->extent[i]); - }else { -return ; } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 233/355 ext4: ext4: unify EXT4_EX_NOCACHE|NOFAIL flags in ext4_ext_remove_space()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 53ce42accd2002cc490fc86000ac532530507a74 ]
When removing space, we should use EXT4_EX_NOCACHE because we don't need to cache extents, and we should also use EXT4_EX_NOFAIL to prevent metadata inconsistencies that may arise from memory allocation failures. While ext4_ext_remove_space() already uses these two flags in most places, they are missing in ext4_ext_search_right() and read_extent_tree_block() calls. Unify the flags to ensure consistent behavior throughout the extent removal process.
--- fs/ext4/extents.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
fs/ext4/extents.c +10 -9
@@ -1526,7 +1526,7 @@ static int ext4_ext_search_left(struct inode *inode,static int ext4_ext_search_right (struct inode *inode,struct ext4_ext_path *path,ext4_lblk_t *logical,ext4_fsblk_t *phys, -struct ext4_extent *ret_ex) +struct ext4_extent *ret_ex,int flags) {struct buffer_head *bh =NULL ;struct ext4_extent_header *eh;
@@ -1600,7 +1600,8 @@ static int ext4_ext_search_right(struct inode *inode, ix++;while (++depth < path->p_depth) {/* subtract from p_depth to get proper eh_depth */ - bh =read_extent_tree_block (inode, ix, path->p_depth - depth,0 ); + bh =read_extent_tree_block (inode, ix, path->p_depth - depth, + flags);if (IS_ERR (bh))return PTR_ERR (bh); eh =ext_block_hdr (bh);
@@ -1608,7 +1609,7 @@ static int ext4_ext_search_right(struct inode *inode,put_bh (bh); } - bh =read_extent_tree_block (inode, ix, path->p_depth - depth,0 ); + bh =read_extent_tree_block (inode, ix, path->p_depth - depth, flags);if (IS_ERR (bh))return PTR_ERR (bh); eh =ext_block_hdr (bh);
@@ -2794,6 +2795,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,struct partial_cluster partial;handle_t *handle;int i =0 , err =0 ; +int flags =EXT4_EX_NOCACHE |EXT4_EX_NOFAIL ; partial.pclu =0 ; partial.lblk =0 ;
@@ -2824,8 +2826,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,ext4_fsblk_t pblk;/* find extent for or closest extent to this block */ - path =ext4_find_extent (inode, end,NULL , -EXT4_EX_NOCACHE |EXT4_EX_NOFAIL ); + path =ext4_find_extent (inode, end,NULL , flags);if (IS_ERR (path)) {ext4_journal_stop (handle);return PTR_ERR (path);
@@ -2890,7 +2891,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,*/ lblk = ex_end +1 ; err =ext4_ext_search_right (inode, path, &lblk, &pblk, -NULL ); +NULL , flags);if (err <0 ) goto out;if (pblk) {
@@ -2967,8 +2968,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start, i + 1, ext4_idx_pblock(path[i].p_idx));memset (path + i +1 ,0 ,sizeof (*path)); bh =read_extent_tree_block (inode, path[i].p_idx, - depth - i -1 , -EXT4_EX_NOCACHE ); + depth - i -1 , flags);if (IS_ERR (bh)) {/* should we reset i_size? */ err =PTR_ERR (bh);
@@ -4270,7 +4270,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,if (err) goto out; ar.lright = map->m_lblk; - err =ext4_ext_search_right (inode, path, &ar.lright, &ar.pright, &ex2); + err =ext4_ext_search_right (inode, path, &ar.lright, &ar.pright, + &ex2,0 );if (err <0 ) goto out;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 234/355 jfs: fix array-index-out-of-bounds read in add_missing_indices
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Dutt <[email protected]>
[ Upstream commit 5dff41a86377563f7a2b968aae00d25b4ceb37c9 ]
stbl is s8 but it must contain offsets into slot which can go from 0 to 127.
Added a bound check for that error and return -EIO if the check fails. Also make jfs_readdir return with error if add_missing_indices returns with an error.
--- fs/jfs/jfs_dtree.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
fs/jfs/jfs_dtree.c +15 -3
@@ -2909,7 +2909,7 @@ void dtInitRoot(tid_t tid, struct inode *ip, u32 idotdot)* fsck.jfs should really fix this, but it currently does not. * Called from jfs_readdir when bad index is detected. */ -static void add_missing_indices (struct inode *inode,s64 bn) +static int add_missing_indices (struct inode *inode,s64 bn) {struct ldtentry *d;struct dt_lock *dtlck;
@@ -2918,7 +2918,7 @@ static void add_missing_indices(struct inode *inode, s64 bn)struct lv *lv;struct metapage *mp;dtpage_t *p; -int rc; +int rc =0 ;s8 *stbl;tid_t tid;struct tlock *tlck;
@@ -2943,6 +2943,16 @@ static void add_missing_indices(struct inode *inode, s64 bn) stbl =DT_GETSTBL (p);for (i =0 ; i < p->header.nextindex; i++) { +if (stbl[i] <0 ) { +jfs_err ("jfs: add_missing_indices: Invalid stbl[%d] = %d for inode %ld, block = %lld" , + i, stbl[i], (long )inode->i_ino, (long long )bn); + rc = -EIO ; + +DT_PUTPAGE (mp); +txAbort (tid,0 ); + goto end; + } + d = (struct ldtentry *) &p->slot[stbl[i]]; index =le32_to_cpu (d->index);if ((index <2 ) || (index >=JFS_IP (inode)->next_index)) {
@@ -2960,6 +2970,7 @@ static void add_missing_indices(struct inode *inode, s64 bn) (void )txCommit (tid,1 , &inode,0 ); end:txEnd (tid); +return rc; }/*
@@ -3313,7 +3324,8 @@ int jfs_readdir(struct file *file, struct dir_context *ctx) }if (fix_page) { -add_missing_indices (ip, bn); +if ((rc =add_missing_indices (ip, bn))) + goto out; page_fixed =1 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 235/355 media: rkvdec: Initialize the m2m context before the controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dufresne <[email protected]>
[ Upstream commit d43d7db3c8a1868dcbc6cb8de90a3cdf309d6cbb ]
Setting up the control handler calls into .s_ctrl ops. While validating the controls the ops may need to access some of the context state, which could lead to a crash if not properly initialized.
--- drivers/staging/media/rkvdec/rkvdec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/media/rkvdec/rkvdec.c +7 -7
@@ -827,24 +827,24 @@ static int rkvdec_open(struct file *filp)rkvdec_reset_decoded_fmt (ctx);v4l2_fh_init (&ctx->fh,video_devdata (filp)); - ret =rkvdec_init_ctrls (ctx); -if (ret) - goto err_free_ctx; - ctx->fh.m2m_ctx =v4l2_m2m_ctx_init (rkvdec->m2m_dev, ctx, rkvdec_queue_init);if (IS_ERR (ctx->fh.m2m_ctx)) { ret =PTR_ERR (ctx->fh.m2m_ctx); - goto err_cleanup_ctrls; + goto err_free_ctx; } + ret =rkvdec_init_ctrls (ctx); +if (ret) + goto err_cleanup_m2m_ctx; + filp->private_data = &ctx->fh;v4l2_fh_add (&ctx->fh);return 0 ; -err_cleanup_ctrls: -v4l2_ctrl_handler_free (&ctx->ctrl_hdl); +err_cleanup_m2m_ctx: +v4l2_m2m_ctx_release (ctx->fh.m2m_ctx); err_free_ctx:kfree (ctx);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 236/355 sunrpc: fix race in cache cleanup causing stale nextcheck time
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Li <[email protected]>
[ Upstream commit 2298abcbe11e9b553d03c0f1d084da786f7eff88 ]
When cache cleanup runs concurrently with cache entry removal, a race condition can occur that leads to incorrect nextcheck times. This can delay cache cleanup for the cache_detail by up to 1800 seconds:
1. cache_clean() sets nextcheck to current time plus 1800 seconds
2. While scanning a non-empty bucket, concurrent cache entry removal can empty that bucket
3. cache_clean() finds no cache entries in the now-empty bucket to update the nextcheck time
4. This maybe delays the next scan of the cache_detail by up to 1800 seconds even when it should be scanned earlier based on remaining entries
Fix this by moving the hash_lock acquisition earlier in cache_clean(). This ensures bucket emptiness checks and nextcheck updates happen atomically, preventing the race between cleanup and entry removal.
--- net/sunrpc/cache.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
net/sunrpc/cache.c +7 -8
@@ -451,24 +451,21 @@ static int cache_clean(void) } } +spin_lock (¤t_detail->hash_lock); +/* find a non-empty bucket in the table */ -while (current_detail && - current_index < current_detail->hash_size && +while (current_index < current_detail->hash_size &&hlist_empty (¤t_detail->hash_table[current_index])) current_index++;/* find a cleanable entry in the bucket and clean it, or set to next bucket */ - -if (current_detail && current_index < current_detail->hash_size) { +if (current_index < current_detail->hash_size) {struct cache_head *ch =NULL ;struct cache_detail *d;struct hlist_head *head;struct hlist_node *tmp; -spin_lock (¤t_detail->hash_lock); -/* Ok, now to clean this strand */ - head = ¤t_detail->hash_table[current_index];hlist_for_each_entry_safe (ch, tmp, head, cache_list) {if (current_detail->nextcheck > ch->expiry_time)
@@ -489,8 +486,10 @@ static int cache_clean(void)spin_unlock (&cache_list_lock);if (ch)sunrpc_end_cache_remove_entry (ch, d); - }else + }else { +spin_unlock (¤t_detail->hash_lock);spin_unlock (&cache_list_lock); + }return rv; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 237/355 ext4: prevent stale extent cache entries caused by concurrent get es_cache
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit f22a0ef2231a7d8374bb021eb86404d0e9de5a02 ]
The EXT4_IOC_GET_ES_CACHE and EXT4_IOC_PRECACHE_EXTENTS currently invokes ext4_ext_precache() to preload the extent cache without holding the inode's i_rwsem. This can result in stale extent cache entries when competing with operations such as ext4_collapse_range() which calls ext4_ext_remove_space() or ext4_ext_shift_extents().
The problem arises when ext4_ext_remove_space() temporarily releases i_data_sem due to insufficient journal credits. During this interval, a concurrent EXT4_IOC_GET_ES_CACHE or EXT4_IOC_PRECACHE_EXTENTS may cache extent entries that are about to be deleted. As a result, these cached entries become stale and inconsistent with the actual extents.
Loading the extents cache without holding the inode's i_rwsem or the mapping's invalidate_lock is not permitted besides during the writeback. Fix this by holding the i_rwsem during EXT4_IOC_GET_ES_CACHE and EXT4_IOC_PRECACHE_EXTENTS.
--- fs/ext4/extents.c | 2 ++ fs/ext4/ioctl.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
fs/ext4/extents.c +2 -0
@@ -5034,7 +5034,9 @@ int ext4_get_es_cache(struct inode *inode, struct fiemap_extent_info *fieinfo, }if (fieinfo->fi_flags &FIEMAP_FLAG_CACHE ) { +inode_lock_shared (inode); error =ext4_ext_precache (inode); +inode_unlock_shared (inode);if (error)return error; fieinfo->fi_flags &= ~FIEMAP_FLAG_CACHE ;
fs/ext4/ioctl.c +7 -1
@@ -1139,8 +1139,14 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)return 0 ; }case EXT4_IOC_PRECACHE_EXTENTS : -return ext4_ext_precache (inode); + { +int ret; +inode_lock_shared (inode); + ret =ext4_ext_precache (inode); +inode_unlock_shared (inode); +return ret; + }case FS_IOC_SET_ENCRYPTION_POLICY :if (!ext4_has_feature_encrypt (sb))return -EOPNOTSUPP ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 238/355 drm/amdgpu/gfx8: fix CSIB handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit c8b8d7a4f1c5cdfbd61d75302fb3e3cdefb1a7ab ]
We shouldn't return after the last section.
We need to update the rest of the CSIB.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -2
@@ -1268,8 +1268,6 @@ static void gfx_v8_0_get_csb_buffer(struct amdgpu_device *adev, PACKET3_SET_CONTEXT_REG_START);for (i =0 ; i < ext->reg_count; i++) buffer[count++] =cpu_to_le32 (ext->extent[i]); - }else { -return ; } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 239/355 drm/amdgpu/gfx9: fix CSIB handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit a4a4c0ae6742ec7d6bf1548d2c6828de440814a0 ]
We shouldn't return after the last section.
We need to update the rest of the CSIB.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -2
@@ -1741,8 +1741,6 @@ static void gfx_v9_0_get_csb_buffer(struct amdgpu_device *adev, PACKET3_SET_CONTEXT_REG_START);for (i =0 ; i < ext->reg_count; i++) buffer[count++] =cpu_to_le32 (ext->extent[i]); - }else { -return ; } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 240/355 jfs: Fix null-ptr-deref in jfs_ioc_trim
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dylan Wolff <[email protected]>
[ Upstream commit a4685408ff6c3e2af366ad9a7274f45ff3f394ee ]
[ Syzkaller Report ]
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000087: 0000 [#1 KASAN: null-ptr-deref in range [0x0000000000000438-0x000000000000043f] CPU: 2 UID: 0 PID: 10614 Comm: syz-executor.0 Not tainted 6.13.0-rc6-gfbfd64d25c7a-dirty #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Sched_ext: serialise (enabled+all), task: runnable_at=-30ms RIP: 0010:jfs_ioc_trim+0x34b/0x8f0 Code: e7 e8 59 a4 87 fe 4d 8b 24 24 4d 8d bc 24 38 04 00 00 48 8d 93 90 82 fe ff 4c 89 ff 31 f6 RSP: 0018:ffffc900055f7cd0 EFLAGS: 00010206 RAX: 0000000000000087 RBX: 00005866a9e67ff8 RCX: 000000000000000a RDX: 0000000000000001 RSI: 0000000000000004 RDI: 0000000000000001 RBP: dffffc0000000000 R08: ffff88807c180003 R09: 1ffff1100f830000 R10: dffffc0000000000 R11: ffffed100f830001 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000438 FS: 00007fe520225640(0000) GS:ffff8880b7e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005593c91b2c88 CR3: 000000014927c000 CR4: 00000000000006f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> ? __die_body+0x61/0xb0 ? die_addr+0xb1/0xe0 ? exc_general_protection+0x333/0x510 ? asm_exc_general_protection+0x26/0x30 ? jfs_ioc_trim+0x34b/0x8f0 jfs_ioctl+0x3c8/0x4f0 ? __pfx_jfs_ioctl+0x10/0x10 ? __pfx_jfs_ioctl+0x10/0x10 __se_sys_ioctl+0x269/0x350 ? __pfx___se_sys_ioctl+0x10/0x10 ? do_syscall_64+0xfb/0x210 do_syscall_64+0xee/0x210 ? syscall_exit_to_user_mode+0x1e0/0x330 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fe51f4903ad Code: c3 e8 a7 2b 00 00 0f 1f 80 00 00 00 00 f3 0f 1e fa 48 89 f8 48
89 f7 48 89 d6 48 89 ca 4d
RSP: 002b:00007fe5202250c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fe51f5cbf80 RCX: 00007fe51f4903ad
RDX: 0000000020000680 RSI: 00000000c0185879 RDI: 0000000000000005
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe520225640
R13: 000000000000000e R14: 00007fe51f44fca0 R15: 00007fe52021d000
</TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:jfs_ioc_trim+0x34b/0x8f0 Code: e7 e8 59 a4 87 fe 4d 8b 24 24 4d 8d bc 24 38 04 00 00 48 8d 93 90 82 fe ff 4c 89 ff 31 f6 RSP: 0018:ffffc900055f7cd0 EFLAGS: 00010206 RAX: 0000000000000087 RBX: 00005866a9e67ff8 RCX: 000000000000000a RDX: 0000000000000001 RSI: 0000000000000004 RDI: 0000000000000001 RBP: dffffc0000000000 R08: ffff88807c180003 R09: 1ffff1100f830000 R10: dffffc0000000000 R11: ffffed100f830001 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000438 FS: 00007fe520225640(0000) GS:ffff8880b7e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005593c91b2c88 CR3: 000000014927c000 CR4: 00000000000006f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Kernel panic - not syncing: Fatal exception
[ Analysis ]
We believe that we have found a concurrency bug in the fs/jfs module that results in a null pointer dereference. There is a closely related issue which has been fixed:
... but, unfortunately, the accepted patch appears to still be susceptible to a null pointer dereference under some interleavings.
To trigger the bug, we think that JFS_SBI(ipbmap->i_sb)->bmap is set to NULL in dbFreeBits and then dereferenced in jfs_ioc_trim. This bug manifests quite rarely under normal circumstances, but is triggereable from a syz-program.
--- fs/jfs/jfs_discard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jfs/jfs_discard.c +2 -1
@@ -86,7 +86,8 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)down_read (&sb->s_umount); bmp =JFS_SBI (ip->i_sb)->bmap; -if (minlen > bmp->db_agsize || +if (bmp ==NULL || + minlen > bmp->db_agsize || start >= bmp->db_mapsize || range->len < sb->s_blocksize) {up_read (&sb->s_umount);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 241/355 drm/msm/dpu: dont select single flush for active CTL blocks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e93eee524bb78f3ee4b78654d0083382f98b3d23 ]
In case of ACTIVE CTLs, a single CTL is being used for flushing all INTF blocks. Don't skip programming the CTL on those targets.
Patchwork: https://patchwork.freedesktop.org/patch/641585/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +2 -1
@@ -353,7 +353,8 @@ static void dpu_encoder_phys_vid_underrun_irq(void *arg, int irq_idx)static bool dpu_encoder_phys_vid_needs_single_flush (struct dpu_encoder_phys *phys_enc) { -return phys_enc->split_role !=ENC_ROLE_SOLO ; +return !(phys_enc->hw_ctl->caps->features &BIT (DPU_CTL_ACTIVE_CFG )) && + phys_enc->split_role !=ENC_ROLE_SOLO ; } static void _dpu_encoder_phys_vid_setup_irq_hw_idx(
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 242/355 drm/amdkfd: Set SDMA_RLCx_IB_CNTL/SWITCH_INSIDE_IB
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amber Lin <[email protected]>
[ Upstream commit ab9fcc6362e0699fc1150aa1d8503c40fce2c1e1 ]
When submitting MQD to CP, set SDMA_RLCx_IB_CNTL/SWITCH_INSIDE_IB bit so it'll allow SDMA preemption if there is a massive command buffer of long-running SDMA commands.
--- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +4 -0
@@ -396,6 +396,10 @@ static void update_mqd_sdma(struct mqd_manager *mm, void *mqd, m->sdma_engine_id = q->sdma_engine_id; m->sdma_queue_id = q->sdma_queue_id; m->sdmax_rlcx_dummy_reg =SDMA_RLC_DUMMY_DEFAULT ; +/* Allow context switch so we don't cross-process starve with a massive +* command buffer of long-running SDMA commands +*/ + m->sdmax_rlcx_ib_cntl |=SDMA0_GFX_IB_CNTL__SWITCH_INSIDE_IB_MASK ; q->is_active =QUEUE_IS_ACTIVE (*q); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 243/355 media: tc358743: ignore video while HPD is low
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 6829c5b5d26b1be31880d74ec24cb32d2d75f1ae ]
If the HPD is low (happens if there is no EDID or the EDID is being updated), then return -ENOLINK in tc358743_get_detected_timings() instead of detecting video.
This avoids userspace thinking that it can start streaming when the HPD is low.
--- drivers/media/i2c/tc358743.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/tc358743.c +4 -0
@@ -309,6 +309,10 @@ static int tc358743_get_detected_timings(struct v4l2_subdev *sd,memset (timings,0 ,sizeof (struct v4l2_dv_timings )); +/* if HPD is low, ignore any video */ +if (!(i2c_rd8 (sd,HPD_CTL ) &MASK_HPD_OUT0 )) +return -ENOLINK ; +if (no_signal (sd)) {v4l2_dbg (1 , debug, sd,"%s: no valid signal\n" , __func__);return -ENOLINK ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 244/355 media: platform: exynos4-is: Add hardware sync wait to fimc_is_hw_change_mode()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit bd9f6ce7d512fa21249415c16af801a4ed5d97b6 ]
In fimc_is_hw_change_mode(), the function changes camera modes without waiting for hardware completion, risking corrupted data or system hangs if subsequent operations proceed before the hardware is ready.
Add fimc_is_hw_wait_intmsr0_intmsd0() after mode configuration, ensuring hardware state synchronization and stable interrupt handling.
--- drivers/media/platform/exynos4-is/fimc-is-regs.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/exynos4-is/fimc-is-regs.c +1 -0
@@ -164,6 +164,7 @@ int fimc_is_hw_change_mode(struct fimc_is *is)if (WARN_ON (is->config_index >=ARRAY_SIZE (cmd)))return -EINVAL ; +fimc_is_hw_wait_intmsr0_intmsd0 (is);mcuctl_write (cmd[is->config_index], is,MCUCTL_REG_ISSR (0 ));mcuctl_write (is->sensor_index, is,MCUCTL_REG_ISSR (1 ));mcuctl_write (is->setfile.sub_index, is,MCUCTL_REG_ISSR (2 ));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 245/355 nios2: force update_mmu_cache on spurious tlb-permission--related pagefaults
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Schuster <[email protected]>
[ Upstream commit 2d8a3179ea035f9341b6a73e5ba4029fc67e983d ]
NIOS2 uses a software-managed TLB for virtual address translation. To flush a cache line, the original mapping is replaced by one to physical address 0x0 with no permissions (rwx mapped to 0) set. This can lead to TLB-permission--related traps when such a nominally flushed entry is encountered as a mapping for an otherwise valid virtual address within a process (e.g. due to an MMU-PID-namespace rollover that previously flushed the complete TLB including entries of existing, running processes).
The default ptep_set_access_flags implementation from mm/pgtable-generic.c only forces a TLB-update when the page-table entry has changed within the page table:
/*
* [...] We return whether the PTE actually changed, which in turn
* instructs the caller to do things like update__mmu_cache. [...]
*/
int ptep_set_access_flags(struct vm_area_struct *vma,
unsigned long address, pte_t *ptep,
pte_t entry, int dirty)
{
int changed = !pte_same(*ptep, entry);
if (changed) {
set_pte_at(vma->vm_mm, address, ptep, entry);
flush_tlb_fix_spurious_fault(vma, address);
}
return changed;
}However, no cross-referencing with the TLB-state occurs, so the flushing-induced pseudo entries that are responsible for the pagefault in the first place are never pre-empted from TLB on this code path.
This commit fixes this behaviour by always requesting a TLB-update in this part of the pagefault handling, fixing spurious page-faults on the way. The handling is a straightforward port of the logic from the MIPS architecture via an arch-specific ptep_set_access_flags function ported from arch/mips/include/asm/pgtable.h.
--- arch/nios2/include/asm/pgtable.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/nios2/include/asm/pgtable.h +16 -0
@@ -277,4 +277,20 @@ extern void __init mmu_init(void);extern void update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *pte); +static inline int pte_same (pte_t pte_a,pte_t pte_b); + +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS +static inline int ptep_set_access_flags (struct vm_area_struct *vma, +unsigned long address,pte_t *ptep, +pte_t entry,int dirty) +{ +if (!pte_same (*ptep, entry)) +set_ptes (vma->vm_mm, address, ptep, entry,1 ); +/* +* update_mmu_cache will unconditionally execute, handling both +* the case that the PTE changed and the spurious fault case. +*/ +return true; +} +#endif /* _ASM_NIOS2_PGTABLE_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 246/355 thermal/drivers/qcom/tsens: Update conditions to strictly evaluate for IP v2+
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Moussalem <[email protected]>
[ Upstream commit e3f90f167a49902cda2408f7e91cca0dcfd5040a ]
TSENS v2.0+ leverage features not available to prior versions such as updated interrupts init routine, masked interrupts, and watchdog. Currently, the checks in place evaluate whether the IP version is greater than v1 which invalidates when updates to v1 or v1 minor versions are implemented. As such, update the conditional statements to strictly evaluate whether the version is greater than or equal to v2 (inclusive).
--- drivers/thermal/qcom/tsens.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/qcom/tsens.c +5 -5
@@ -264,7 +264,7 @@ static void tsens_set_interrupt(struct tsens_priv *priv, u32 hw_id,dev_dbg (priv->dev,"[%u] %s: %s -> %s\n" , hw_id, __func__, irq_type ? ((irq_type ==1 ) ?"UP" :"CRITICAL" ) :"LOW" , enable ?"en" :"dis" ); -if (tsens_version (priv) >VER_1_X ) +if (tsens_version (priv) >=VER_2_X )tsens_set_interrupt_v2 (priv, hw_id, irq_type, enable);else tsens_set_interrupt_v1 (priv, hw_id, irq_type, enable);
@@ -316,7 +316,7 @@ static int tsens_read_irq_state(struct tsens_priv *priv, u32 hw_id, ret =regmap_field_read (priv->rf[LOW_INT_CLEAR_0 + hw_id], &d->low_irq_clear);if (ret)return ret; -if (tsens_version (priv) >VER_1_X ) { +if (tsens_version (priv) >=VER_2_X ) { ret =regmap_field_read (priv->rf[UP_INT_MASK_0 + hw_id], &d->up_irq_mask);if (ret)return ret;
@@ -360,7 +360,7 @@ static int tsens_read_irq_state(struct tsens_priv *priv, u32 hw_id,static inline u32 masked_irq (u32 hw_id,u32 mask,enum tsens_ver ver) { -if (ver >VER_1_X ) +if (ver >=VER_2_X )return mask & (1 << hw_id);/* v1, v0.1 don't have a irq mask register */
@@ -560,7 +560,7 @@ static int tsens_set_trips(void *_sensor, int low, int high)static int tsens_enable_irq (struct tsens_priv *priv) {int ret; -int val =tsens_version (priv) >VER_1_X ?7 :1 ; +int val =tsens_version (priv) >=VER_2_X ?7 :1 ; ret =regmap_field_write (priv->rf[INT_EN ], val);if (ret <0 )
@@ -826,7 +826,7 @@ int __init init_common(struct tsens_priv *priv) } } -if (tsens_version (priv) >VER_1_X && ver_minor >2 ) { +if (tsens_version (priv) >=VER_2_X && ver_minor >2 ) {/* Watchdog is present only on v2.3+ */ priv->feat->has_watchdog =1 ;for (i =WDOG_BARK_STATUS ; i <=CC_MON_MASK ; i++) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 247/355 cpufreq: Force sync policy boost with global boost on sysfs update
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
[ Upstream commit 121baab7b88ed865532dadb7ef1aee6e2bea86f5 ]
If the global boost flag is enabled and policy boost flag is disabled, a call to cpufreq_boost_trigger_state(true) must enable the policy's boost state.
The current code misses that because of an optimization. Fix it.
--- drivers/cpufreq/cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +4 -2
@@ -2637,8 +2637,10 @@ int cpufreq_boost_trigger_state(int state)unsigned long flags;int ret =0 ; -if (cpufreq_driver->boost_enabled == state) -return 0 ; +/* +* Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to +* make sure all policies are in sync with global boost flag. +*/ write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver->boost_enabled = state;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 248/355 net: macb: Check return value of dma_set_mask_and_coherent()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Perez Gonzalez <[email protected]>
[ Upstream commit 3920a758800762917177a6b5ab39707d8e376fe6 ]
Issue flagged by coverity. Add a safety check for the return value of dma_set_mask_and_coherent, go to a safe exit if it returns error.
--- drivers/net/ethernet/cadence/macb_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +5 -1
@@ -4571,7 +4571,11 @@ static int macb_probe(struct platform_device *pdev)#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT if (GEM_BFEXT (DAW64 ,gem_readl (bp,DCFG6 ))) { -dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (44 )); + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (44 )); +if (err) { +dev_err (&pdev->dev,"failed to set DMA mask\n" ); + goto err_out_free_netdev; + } bp->hw_dma_cap |=HW_DMA_CAP_64B ; }#endif
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 249/355 tipc: use kfree_sensitive() for aead cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
[ Upstream commit c8ef20fe7274c5766a317f9193b70bed717b6b3d ]
The tipc_aead_free() function currently uses kfree() to release the aead structure. However, this structure contains sensitive information, such as key's SALT value, which should be securely erased from memory to prevent potential leakage.
To enhance security, replace kfree() with kfree_sensitive() when freeing the aead structure. This change ensures that sensitive data is explicitly cleared before memory deallocation, aligning with the approach used in tipc_aead_init() and adhering to best practices for handling confidential information.
--- net/tipc/crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/crypto.c +1 -1
@@ -419,7 +419,7 @@ static void tipc_aead_free(struct rcu_head *rp) }free_percpu (aead->tfm_entry);kfree_sensitive (aead->key); -kfree (aead); +kfree_sensitive (aead); }static int tipc_aead_users (struct tipc_aead __rcu *aead)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 250/355 i2c: designware: Invoke runtime suspend on quick slave re-registration
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tan En De <[email protected]>
[ Upstream commit 2fe2b969d911a09abcd6a47401a3c66c38a310e6 ]
Replaced pm_runtime_put() with pm_runtime_put_sync_suspend() to ensure the runtime suspend is invoked immediately when unregistering a slave. This prevents a race condition where suspend was skipped when unregistering and registering slave in quick succession.
For example, consider the rapid sequence ofdelete_device -> new_device -> delete_device -> new_device. In this sequence, it is observed that the dw_i2c_plat_runtime_suspend() might not be invoked after delete_device operation.
This is because after delete_device operation, when the pm_runtime_put() is about to trigger suspend, the following new_device operation might race and cancel the suspend.
If that happens, during the new_device operation, dw_i2c_plat_runtime_resume() is skipped (since there was no suspend), which means i_dev->init(), i.e. i2c_dw_init_slave(), is skipped. Since i2c_dw_init_slave() is skipped, i2c_dw_configure_fifo_slave() is skipped too, which leaves DW_IC_INTR_MASK unconfigured. If we inspect the interrupt mask register using devmem, it will show as zero.
Example shell script to reproduce the issue:
``` #!/bin/sh SLAVE_LADDR=0x1010 SLAVE_BUS=13 NEW_DEVICE=/sys/bus/i2c/devices/i2c-$SLAVE_BUS/new_device DELETE_DEVICE=/sys/bus/i2c/devices/i2c-$SLAVE_BUS/delete_device # Create initial device echo slave-24c02 $SLAVE_LADDR > $NEW_DEVICE sleep 2 # Rapid sequence of # delete_device -> new_device -> delete_device -> new_device echo $SLAVE_LADDR > $DELETE_DEVICE echo slave-24c02 $SLAVE_LADDR > $NEW_DEVICE echo $SLAVE_LADDR > $DELETE_DEVICE echo slave-24c02 $SLAVE_LADDR > $NEW_DEVICE # Using devmem to inspect IC_INTR_MASK will show as zero ```
--- drivers/i2c/busses/i2c-designware-slave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-slave.c +1 -1
@@ -97,7 +97,7 @@ static int i2c_dw_unreg_slave(struct i2c_client *slave) dev->disable (dev);synchronize_irq (dev->irq); dev->slave =NULL ; -pm_runtime_put (dev->dev); +pm_runtime_put_sync_suspend (dev->dev);return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 251/355 emulex/benet: correct command version selection in be_cmd_get_stats()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit edb888d29748cee674006a52e544925dacc7728e ]
Logic here always sets hdr->version to 2 if it is not a BE3 or Lancer chip, even if it is BE2. Use 'else if' to prevent multiple assignments, setting version 0 for BE2, version 1 for BE3 and Lancer, and version 2 for others. Fixes potential incorrect version setting when BE2_chip and BE3_chip/lancer_chip checks could both be true.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +1 -1
@@ -1608,7 +1608,7 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)/* version 1 of the cmd is not supported only by BE2 */ if (BE2_chip (adapter)) hdr->version =0 ; -if (BE3_chip (adapter) ||lancer_chip (adapter)) +else if (BE3_chip (adapter) ||lancer_chip (adapter)) hdr->version =1 ;else hdr->version =2 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 252/355 wifi: mt76: mt76x2: Add support for LiteOn WN4516R,WN4519R
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henk Vergonet <[email protected]>
[ Upstream commit 3c0e4f606d8693795a2c965d6f4987b1bfc31097 ]
Adds support for:
- LiteOn WN4516R
- LiteOn WN4519R
Both use:
- A nonstandard USB connector
- Mediatek chipset MT7600U
- ASIC revision: 76320044
Disabled VHT support on ASIC revision 76320044:
This fixes the 5G connectibity issue on LiteOn WN4519R module see https://github.com/openwrt/mt76/issues/971
And may also fix the 5G issues on the XBox One Wireless Adapter see https://github.com/openwrt/mt76/issues/200
I have looked at the FCC info related to the MT7632U chip as mentioned in here:
https://github.com/openwrt/mt76/issues/459
These confirm the chipset does not support 'ac' mode and hence VHT should be turned of.
--- drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | 2 ++ .../net/wireless/mediatek/mt76/mt76x2/usb_init.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x2/usb.c +2 -0
@@ -17,6 +17,8 @@ static const struct usb_device_id mt76x2u_device_table[] = { { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */ { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */ { USB_DEVICE(0x0e8d, 0x7632) }, /* HC-M7662BU1 */ + { USB_DEVICE(0x0471, 0x2126) }, /* LiteOn WN4516R module, nonstandard USB connector */ + { USB_DEVICE(0x0471, 0x7600) }, /* LiteOn WN4519R module, nonstandard USB connector */ { USB_DEVICE(0x2c4e, 0x0103) }, /* Mercury UD13 */ { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */ { USB_DEVICE(0x045e, 0x02e6) }, /* XBox One Wireless Adapter */
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c +12 -1
@@ -191,6 +191,7 @@ int mt76x2u_register_device(struct mt76x02_dev *dev) {struct ieee80211_hw *hw =mt76_hw (dev);struct mt76_usb *usb = &dev->mt76.usb; +bool vht;int err;INIT_DELAYED_WORK (&dev->cal_work, mt76x2u_phy_calibrate);
@@ -215,7 +216,17 @@ int mt76x2u_register_device(struct mt76x02_dev *dev)/* check hw sg support in order to enable AMSDU */ hw->max_tx_fragments = dev->mt76.usb.sg_en ?MT_TX_SG_MAX_SIZE :1 ; - err =mt76_register_device (&dev->mt76, true, mt76x02_rates, +switch (dev->mt76.rev) { +case 0x76320044 : +/* these ASIC revisions do not support VHT */ + vht = false; +break ; +default : + vht = true; +break ; + } + + err =mt76_register_device (&dev->mt76, vht, mt76x02_rates,ARRAY_SIZE (mt76x02_rates));if (err) goto fail;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 253/355 sctp: Do not wake readers in __sctp_write_space()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Malat <[email protected]>
[ Upstream commit af295892a7abbf05a3c2ba7abc4d81bb448623d6 ]
Function __sctp_write_space() doesn't set poll key, which leads to ep_poll_callback() waking up all waiters, not only these waiting for the socket being writable. Set the key properly using wake_up_interruptible_poll(), which is preferred over the sync variant, as writers are not woken up before at least half of the queue is available. Also, TCP does the same.
--- net/sctp/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/socket.c +2 -1
@@ -8849,7 +8849,8 @@ static void __sctp_write_space(struct sctp_association *asoc) wq =rcu_dereference (sk->sk_wq);if (wq) {if (waitqueue_active (&wq->wait)) -wake_up_interruptible (&wq->wait); +wake_up_interruptible_poll (&wq->wait,EPOLLOUT | +EPOLLWRNORM |EPOLLWRBAND );/* Note that we try to include the Async I/O support * here by modeling from the current TCP/UDP code.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 254/355 i2c: npcm: Add clock toggle recovery
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tali Perry <[email protected]>
[ Upstream commit 38010591a0fc3203f1cee45b01ab358b72dd9ab2 ]
During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot).
--- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-npcm7xx.c +8 -4
@@ -1950,10 +1950,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode,/* check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA (&bus->adap) ==0 ) || (npcm_i2c_get_SCL (&bus->adap) ==0 )) { -dev_err (bus->dev,"I2C%d init fail: lines are low\n" , bus->num); -dev_err (bus->dev,"SDA=%d SCL=%d\n" ,npcm_i2c_get_SDA (&bus->adap), -npcm_i2c_get_SCL (&bus->adap)); -return -ENXIO ; +dev_warn (bus->dev," I2C%d SDA=%d SCL=%d, attempting to recover\n" , bus->num, +npcm_i2c_get_SDA (&bus->adap),npcm_i2c_get_SCL (&bus->adap)); +if (npcm_i2c_recovery_tgclk (&bus->adap)) { +dev_err (bus->dev,"I2C%d init fail: SDA=%d SCL=%d\n" , + bus->num,npcm_i2c_get_SDA (&bus->adap), +npcm_i2c_get_SCL (&bus->adap)); +return -ENXIO ; + } }npcm_i2c_int_enable (bus, true);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 255/355 net: dlink: add synchronization for stats update
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moon Yeounsu <[email protected]>
[ Upstream commit 12889ce926e9a9baf6b83d809ba316af539b89e2 ]
This patch synchronizes code that accesses from both user-space and IRQ contexts. The get_stats() function can be called from both context.
dev->stats.tx_errors and dev->stats.collisions are also updated in the tx_errors() function. Therefore, these fields must also be protected by synchronized.
There is no code that accessses dev->stats.tx_errors between the previous and updated lines, so the updating point can be moved.
--- drivers/net/ethernet/dlink/dl2k.c | 14 +++++++++++++- drivers/net/ethernet/dlink/dl2k.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/ethernet/dlink/dl2k.c +13 -1
@@ -146,6 +146,8 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) np->ioaddr = ioaddr; np->chip_id = chip_idx; np->pdev = pdev; + +spin_lock_init (&np->stats_lock);spin_lock_init (&np->tx_lock);spin_lock_init (&np->rx_lock);
@@ -869,7 +871,6 @@ tx_error (struct net_device *dev, int tx_status) frame_id = (tx_status &0xffff0000 );printk (KERN_ERR "%s: Transmit error, TxStatus %4.4x, FrameId %d.\n" , dev->name, tx_status, frame_id); - dev->stats.tx_errors++;/* Ttransmit Underrun */ if (tx_status &0x10 ) { dev->stats.tx_fifo_errors++;
@@ -906,9 +907,15 @@ tx_error (struct net_device *dev, int tx_status)rio_set_led_mode (dev);/* Let TxStartThresh stay default value */ } + +spin_lock (&np->stats_lock);/* Maximum Collisions */ if (tx_status &0x08 ) dev->stats.collisions++; + + dev->stats.tx_errors++; +spin_unlock (&np->stats_lock); +/* Restart the Tx */ dw32 (MACCtrl,dr16 (MACCtrl) | TxEnable); }
@@ -1077,7 +1084,9 @@ get_stats (struct net_device *dev)int i;#endif unsigned int stat_reg; +unsigned long flags; +spin_lock_irqsave (&np->stats_lock, flags);/* All statistics registers need to be acknowledged, else statistic overflow could cause problems */
@@ -1127,6 +1136,9 @@ get_stats (struct net_device *dev)dr16 (TCPCheckSumErrors);dr16 (UDPCheckSumErrors);dr16 (IPCheckSumErrors); + +spin_unlock_irqrestore (&np->stats_lock, flags); +return &dev->stats; }
drivers/net/ethernet/dlink/dl2k.h +2 -0
@@ -372,6 +372,8 @@ struct netdev_private {struct pci_dev *pdev;void __iomem *ioaddr;void __iomem *eeprom_addr; +// To ensure synchronization when stats are updated. +spinlock_t stats_lock;spinlock_t tx_lock;spinlock_t rx_lock;unsigned int rx_buf_sz;/* Based on MTU+slack. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 256/355 tcp: always seek for minimal rtt in tcp_rcv_rtt_update()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit b879dcb1aeeca278eacaac0b1e2425b1c7599f9f ]
tcp_rcv_rtt_update() goal is to maintain an estimation of the RTT in tp->rcv_rtt_est.rtt_us, used by tcp_rcv_space_adjust()
When TCP TS are enabled, tcp_rcv_rtt_update() is using EWMA to smooth the samples.
Change this to immediately latch the incoming value if it is lower than tp->rcv_rtt_est.rtt_us, so that tcp_rcv_space_adjust() does not overshoot tp->rcvq_space.space and sk->sk_rcvbuf.
--- net/ipv4/tcp_input.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
net/ipv4/tcp_input.c +8 -14
@@ -640,10 +640,12 @@ EXPORT_SYMBOL(tcp_initialize_rcv_mss);*/ static void tcp_rcv_rtt_update (struct tcp_sock *tp,u32 sample,int win_dep) { -u32 new_sample = tp->rcv_rtt_est.rtt_us; -long m = sample; +u32 new_sample, old_sample = tp->rcv_rtt_est.rtt_us; +long m = sample <<3 ; -if (new_sample !=0 ) { +if (old_sample ==0 || m < old_sample) { + new_sample = m; + }else {/* If we sample in larger samples in the non-timestamp * case, we could grossly overestimate the RTT especially * with chatty applications or bulk transfer apps which
@@ -654,17 +656,9 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)* else with timestamps disabled convergence takes too * long. */ -if (!win_dep) { - m -= (new_sample >>3 ); - new_sample += m; - }else { - m <<=3 ; -if (m < new_sample) - new_sample = m; - } - }else { -/* No previous measure. */ - new_sample = m <<3 ; +if (win_dep) +return ; + new_sample = old_sample - (old_sample >>3 ) + sample; } tp->rcv_rtt_est.rtt_us = new_sample;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 257/355 tcp: fix initial tp->rcvq_space.space value for passive TS enabled flows
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit cd171461b90a2d2cf230943df60d580174633718 ]
tcp_rcv_state_process() must tweak tp->advmss for TS enabled flows before the call to tcp_init_transfer() / tcp_init_buffer_space().
Otherwise tp->rcvq_space.space is off by 120 bytes (TCP_INIT_CWND * TCPOLEN_TSTAMP_ALIGNED).
--- net/ipv4/tcp_input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +3 -3
@@ -6512,6 +6512,9 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)if (!tp->srtt_us)tcp_synack_rtt_meas (sk, req); +if (tp->rx_opt.tstamp_ok) + tp->advmss -=TCPOLEN_TSTAMP_ALIGNED ; +if (req) {tcp_rcv_synrecv_state_fastopen (sk); }else {
@@ -6536,9 +6539,6 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) tp->snd_wnd =ntohs (th->window) << tp->rx_opt.snd_wscale;tcp_init_wl (tp,TCP_SKB_CB (skb)->seq); -if (tp->rx_opt.tstamp_ok) - tp->advmss -=TCPOLEN_TSTAMP_ALIGNED ; -if (!inet_csk (sk)->icsk_ca_ops->cong_control)tcp_update_pacing_rate (sk);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 258/355 ipv4/route: Use this_cpu_inc() for stats on PREEMPT_RT
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 1c0829788a6e6e165846b9bedd0b908ef16260b6 ]
The statistics are incremented with raw_cpu_inc() assuming it always happens with bottom half disabled. Without per-CPU locking in local_bh_disable() on PREEMPT_RT this is no longer true.
Use this_cpu_inc() on PREEMPT_RT for the increment to not worry about preemption.
--- net/ipv4/route.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv4/route.c +4 -0
@@ -197,7 +197,11 @@ const __u8 ip_tos2prio[16] = {EXPORT_SYMBOL (ip_tos2prio); static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat); +#ifndef CONFIG_PREEMPT_RT #define RT_CACHE_STAT_INC (field) raw_cpu_inc(rt_cache_stat.field) +#else +#define RT_CACHE_STAT_INC (field) this_cpu_inc(rt_cache_stat.field) +#endif #ifdef CONFIG_PROC_FS static void *rt_cache_seq_start (struct seq_file *seq,loff_t *pos)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 259/355 net: atlantic: generate software timestamp just before the doorbell
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Xing <[email protected]>
[ Upstream commit 285ad7477559b6b5ceed10ba7ecfed9d17c0e7c6 ]
Make sure the call of skb_tx_timestamp is as close as possible to the doorbell.
--- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 1 - drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_main.c +0 -1
@@ -117,7 +117,6 @@ static netdev_tx_t aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *nd }#endif -skb_tx_timestamp (skb);return aq_nic_xmit (aq_nic, skb); }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +2 -0
@@ -751,6 +751,8 @@ int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb) frags =aq_nic_map_skb (self, skb, ring); +skb_tx_timestamp (skb); +if (likely (frags)) { err = self->aq_hw_ops->hw_ring_tx_xmit (self->aq_hw, ring, frags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 260/355 pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit 4229c28323db141eda69cb99427be75d3edba071 ]
The regmap_update_bits() function can fail, so propagate its error up to the stack instead of silently ignoring that.
--- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +1 -3
@@ -354,9 +354,7 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev, val = grp->val[func]; -regmap_update_bits (info->regmap, reg, mask, val); - -return 0 ; +return regmap_update_bits (info->regmap, reg, mask, val); } static int armada_37xx_pmx_set(struct pinctrl_dev *pctldev,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 261/355 pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit 6481c0a83367b0672951ccc876fbae7ee37b594b ]
The regmap_read() function can fail, so propagate its error up to the stack instead of silently ignoring that.
--- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4 -1
@@ -396,10 +396,13 @@ static int armada_37xx_gpio_get_direction(struct gpio_chip *chip,struct armada_37xx_pinctrl *info =gpiochip_get_data (chip);unsigned int reg =OUTPUT_EN ;unsigned int val, mask; +int ret;armada_37xx_update_reg (®, &offset); mask =BIT (offset); -regmap_read (info->regmap, reg, &val); + ret =regmap_read (info->regmap, reg, &val); +if (ret) +return ret;if (val & mask)return GPIO_LINE_DIRECTION_OUT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 262/355 pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit bfa0ff804ffa8b1246ade8be08de98c9eb19d16f ]
The armada_37xx_gpio_direction_{in,out}put() functions can fail, so propagate their error values back to the stack instead of silently ignoring those.
--- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4 -3
@@ -468,16 +468,17 @@ static int armada_37xx_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, {struct armada_37xx_pinctrl *info =pinctrl_dev_get_drvdata (pctldev);struct gpio_chip *chip = range->gc; +int ret;dev_dbg (info->dev,"gpio_direction for pin %u as %s-%d to %s\n" , offset, range->name, offset, input ?"input" :"output" );if (input) -armada_37xx_gpio_direction_input (chip, offset); + ret =armada_37xx_gpio_direction_input (chip, offset);else -armada_37xx_gpio_direction_output (chip, offset,0 ); + ret =armada_37xx_gpio_direction_output (chip, offset,0 ); -return 0 ; +return ret; } static int armada_37xx_gpio_request_enable(struct pinctrl_dev *pctldev,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 263/355 pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit 57273ff8bb16f3842c2597b5bbcd49e7fa12edf7 ]
The regmap_read() function can fail, so propagate its error up to the stack instead of silently ignoring that.
--- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4 -1
@@ -439,11 +439,14 @@ static int armada_37xx_gpio_get(struct gpio_chip *chip, unsigned int offset)struct armada_37xx_pinctrl *info =gpiochip_get_data (chip);unsigned int reg =INPUT_VAL ;unsigned int val, mask; +int ret;armada_37xx_update_reg (®, &offset); mask =BIT (offset); -regmap_read (info->regmap, reg, &val); + ret =regmap_read (info->regmap, reg, &val); +if (ret) +return ret;return (val & mask) !=0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 264/355 net: mlx4: add SOF_TIMESTAMPING_TX_SOFTWARE flag when getting ts info
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Xing <[email protected]>
[ Upstream commit b86bcfee30576b752302c55693fff97242b35dfd ]
As mlx4 has implemented skb_tx_timestamp() in mlx4_en_xmit(), the SOFTWARE flag is surely needed when users are trying to get timestamp information.
--- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +1 -0
@@ -1905,6 +1905,7 @@ static int mlx4_en_get_ts_info(struct net_device *dev,if (mdev->dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_TS ) { info->so_timestamping |=SOF_TIMESTAMPING_TX_HARDWARE | +SOF_TIMESTAMPING_TX_SOFTWARE |SOF_TIMESTAMPING_RX_HARDWARE |SOF_TIMESTAMPING_RAW_HARDWARE ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 265/355 wifi: mac80211: do not offer a mesh path if forwarding is disabled
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Berg <[email protected]>
[ Upstream commit cf1b684a06170d253b47d6a5287821de976435bd ]
When processing a PREQ the code would always check whether we have a mesh path locally and reply accordingly. However, when forwarding is disabled then we should not reply with this information as we will not forward data packets down that path.
Move the check for dot11MeshForwarding up in the function and skip the mesh path lookup in that case. In the else block, set forward to false so that the rest of the function becomes a no-op and the dot11MeshForwarding check does not need to be duplicated.
This explains an effect observed in the Freifunk community where mesh forwarding is disabled. In that case a mesh with three STAs and only bad links in between them, individual STAs would occionally have indirect mpath entries. This should not have happened.
--- net/mac80211/mesh_hwmp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mac80211/mesh_hwmp.c +4 -2
@@ -620,7 +620,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,mesh_path_add_gate (mpath); }rcu_read_unlock (); - }else { + }else if (ifmsh->mshcfg.dot11MeshForwarding) {rcu_read_lock (); mpath =mesh_path_lookup (sdata, target_addr);if (mpath) {
@@ -638,6 +638,8 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, } }rcu_read_unlock (); + }else { + forward = false; }if (reply) {
@@ -655,7 +657,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, } } -if (forward && ifmsh->mshcfg.dot11MeshForwarding) { +if (forward) {u32 preq_id;u8 hopcount;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 266/355 clk: rockchip: rk3036: mark ddrphy as critical
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Stuebner <[email protected]>
[ Upstream commit 596a977b34a722c00245801a5774aa79cec4e81d ]
The ddrphy is supplied by the dpll, but due to the limited number of PLLs on the rk3036, the dpll also is used for other periperhals, like the GPU.
So it happened, when the Lima driver turned off the gpu clock, this in turn also disabled the dpll and thus the ram.
--- drivers/clk/rockchip/clk-rk3036.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk-rk3036.c +1 -0
@@ -429,6 +429,7 @@ static const char *const rk3036_critical_clocks[] __initconst = {"hclk_peri" ,"pclk_peri" ,"pclk_ddrupctl" , + "ddrphy", };static void __init rk3036_clk_init (struct device_node *np)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 267/355 scsi: lpfc: Fix lpfc_check_sli_ndlp() handling for GEN_REQUEST64 commands
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit 05ae6c9c7315d844fbc15afe393f5ba5e5771126 ]
In lpfc_check_sli_ndlp(), the get_job_els_rsp64_did remote_id assignment does not apply for GEN_REQUEST64 commands as it only has meaning for a ELS_REQUEST64 command. So, if (iocb->ndlp == ndlp) is false, we could erroneously return the wrong value. Fix by replacing the fallthrough statement with a break statement before the remote_id check.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +1 -1
@@ -4772,7 +4772,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba,case CMD_GEN_REQUEST64_CR :if (iocb->context_un.ndlp == ndlp)return 1 ; - fallthrough; +break ;case CMD_ELS_REQUEST64_CR :if (icmd->un.elsreq64.remoteID == ndlp->nlp_DID)return 1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 268/355 iommu/amd: Ensure GA log notifier callbacks finish running before module unload
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 94c721ea03c7078163f41dbaa101ac721ddac329 ]
Synchronize RCU when unregistering KVM's GA log notifier to ensure all in-flight interrupt handlers complete before KVM-the module is unloaded.
--- drivers/iommu/amd/iommu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iommu/amd/iommu.c +8 -0
@@ -750,6 +750,14 @@ int amd_iommu_register_ga_log_notifier(int (*notifier)(u32)) { iommu_ga_log_notifier = notifier; +/* +* Ensure all in-flight IRQ handlers run to completion before returning +* to the caller, e.g. to ensure module code isn't unloaded while it's +* being executed in the IRQ handler. +*/ +if (!notifier) +synchronize_rcu (); +return 0 ; }EXPORT_SYMBOL (amd_iommu_register_ga_log_notifier);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 269/355 vxlan: Do not treat dst cache initialization errors as fatal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 20c76dadc783759fd3819d289c72be590660cc8b ]
FDB entries are allocated in an atomic context as they can be added from the data path when learning is enabled.
After converting the FDB hash table to rhashtable, the insertion rate will be much higher (*) which will entail a much higher rate of per-CPU allocations via dst_cache_init().
When adding a large number of entries (e.g., 256k) in a batch, a small percentage (< 0.02%) of these per-CPU allocations will fail [1]. This does not happen with the current code since the insertion rate is low enough to give the per-CPU allocator a chance to asynchronously create new chunks of per-CPU memory.
Given that:
a. Only a small percentage of these per-CPU allocations fail.
b. The scenario where this happens might not be the most realistic one.
c. The driver can work correctly without dst caches. The dst_cache_*() APIs first check that the dst cache was properly initialized.
d. The dst caches are not always used (e.g., 'tos inherit').
It seems reasonable to not treat these allocation failures as fatal.
Therefore, do not bail when dst_cache_init() fails and suppress warnings by specifying '__GFP_NOWARN'.
[1] percpu: allocation failed, size=40 align=8 atomic=1, atomic alloc failed, no space left
(*) 97% reduction in average latency of vxlan_fdb_update() when adding 256k entries in a batch.
--- drivers/net/vxlan/vxlan_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/vxlan/vxlan_core.c +4 -4
@@ -712,10 +712,10 @@ static int vxlan_fdb_append(struct vxlan_fdb *f,if (rd ==NULL )return -ENOMEM ; -if (dst_cache_init (&rd->dst_cache,GFP_ATOMIC )) { -kfree (rd); -return -ENOMEM ; - } +/* The driver can work correctly without a dst cache, so do not treat +* dst cache initialization errors as fatal. +*/ +dst_cache_init (&rd->dst_cache,GFP_ATOMIC | __GFP_NOWARN); rd->remote_ip = *ip; rd->remote_port = port;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 270/355 software node: Correct a OOB check in software_node_get_reference_args()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 31e4e12e0e9609850cefd4b2e1adf782f56337d6 ]
software_node_get_reference_args() wants to get @index-th element, so the property value requires at least '(index + 1) * sizeof(*ref)' bytes but that can not be guaranteed by current OOB check, and may cause OOB for malformed property.
Fix by using as OOB check '((index + 1) * sizeof(*ref) > prop->length)'.
--- drivers/base/swnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/swnode.c +1 -1
@@ -508,7 +508,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,if (prop->is_inline)return -EINVAL ; -if (index *sizeof (*ref) >= prop->length) +if ((index +1 ) *sizeof (*ref) > prop->length)return -ENOENT ; ref_array = prop->pointer;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 271/355 scsi: lpfc: Use memcpy() for BIOS version
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit ae82eaf4aeea060bb736c3e20c0568b67c701d7d ]
The strlcat() with FORTIFY support is triggering a panic because it thinks the target buffer will overflow although the correct target buffer size is passed in.
Anyway, instead of memset() with 0 followed by a strlcat(), just use memcpy() and ensure that the resulting buffer is NULL terminated.
BIOSVersion is only used for the lpfc_printf_log() which expects a properly terminated string.
--- drivers/scsi/lpfc/lpfc_sli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_sli.c +2 -2
@@ -5530,9 +5530,9 @@ lpfc_sli4_get_ctl_attr(struct lpfc_hba *phba) phba->sli4_hba.lnk_info.lnk_no =bf_get (lpfc_cntl_attr_lnk_numb, cntl_attr); -memset (phba->BIOSVersion,0 ,sizeof (phba->BIOSVersion)); -strlcat (phba->BIOSVersion, (char *)cntl_attr->bios_ver_str, +memcpy (phba->BIOSVersion, cntl_attr->bios_ver_str,sizeof (phba->BIOSVersion)); + phba->BIOSVersion[sizeof (phba->BIOSVersion) -1 ] ='\0' ; lpfc_printf_log(phba, KERN_INFO, LOG_SLI, "3086 lnk_type:%d, lnk_numb:%d, bios_ver:%s\n",
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 272/355 sock: Correct error checking condition for (assign|release)_proto_idx()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit faeefc173be40512341b102cf1568aa0b6571acd ]
(assign|release)_proto_idx() wrongly check find_first_zero_bit() failure by condition '(prot->inuse_idx == PROTO_INUSE_NR - 1)' obviously.
Fix by correcting the condition to '(prot->inuse_idx == PROTO_INUSE_NR)'
--- net/core/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/sock.c +2 -2
@@ -3433,7 +3433,7 @@ static int assign_proto_idx(struct proto *prot) { prot->inuse_idx =find_first_zero_bit (proto_inuse_idx,PROTO_INUSE_NR ); -if (unlikely (prot->inuse_idx ==PROTO_INUSE_NR -1 )) { +if (unlikely (prot->inuse_idx ==PROTO_INUSE_NR )) {pr_err ("PROTO_INUSE_NR exhausted\n" );return -ENOSPC ; }
@@ -3444,7 +3444,7 @@ static int assign_proto_idx(struct proto *prot)static void release_proto_idx (struct proto *prot) { -if (prot->inuse_idx !=PROTO_INUSE_NR -1 ) +if (prot->inuse_idx !=PROTO_INUSE_NR )clear_bit (prot->inuse_idx, proto_inuse_idx); }#else
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 273/355 i40e: fix MMIO write access to an invalid page in i40e_clear_hw
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyungwook Boo <[email protected]>
[ Upstream commit 015bac5daca978448f2671478c553ce1f300c21e ]
When the device sends a specific input, an integer underflow can occur, leading to MMIO write access to an invalid page.
Prevent the integer underflow by changing the type of related variables.
--- drivers/net/ethernet/intel/i40e/i40e_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +4 -3
@@ -1320,10 +1320,11 @@ i40e_status i40e_pf_reset(struct i40e_hw *hw)void i40e_clear_hw (struct i40e_hw *hw) {u32 num_queues, base_queue; -u32 num_pf_int; -u32 num_vf_int; +s32 num_pf_int; +s32 num_vf_int;u32 num_vfs; -u32 i, j; +s32 i; +u32 j;u32 val;u32 eol =0x7ff ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 274/355 watchdog: da9052_wdt: respect TWDMIN
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcus Folkesson <[email protected]>
[ Upstream commit 325f510fcd9cda5a44bcb662b74ba4e3dabaca10 ]
We have to wait at least the minimium time for the watchdog window (TWDMIN) before writings to the wdt register after the watchdog is activated.
Otherwise the chip will assert TWD_ERROR and power down to reset mode.
--- drivers/watchdog/da9052_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/da9052_wdt.c +1 -0
@@ -164,6 +164,7 @@ static int da9052_wdt_probe(struct platform_device *pdev) da9052_wdt = &driver_data->wdt; da9052_wdt->timeout =DA9052_DEF_TIMEOUT ; + da9052_wdt->min_hw_heartbeat_ms =DA9052_TWDMIN ; da9052_wdt->info = &da9052_wdt_info; da9052_wdt->ops = &da9052_wdt_ops; da9052_wdt->parent = dev;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 275/355 bus: fsl-mc: increase MC_CMD_COMPLETION_TIMEOUT_MS value
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurentiu Tudor <[email protected]>
[ Upstream commit 23d060136841c58c2f9ee8c08ad945d1879ead4b ]
In case the MC firmware runs in debug mode with extensive prints pushed to the console, the current timeout of 500ms is not enough. Increase the timeout value so that we don't have any chance of wrongly assuming that the firmware is not responding when it's just taking more time.
--- drivers/bus/fsl-mc/mc-sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/fsl-mc/mc-sys.c +1 -1
@@ -19,7 +19,7 @@/** * Timeout in milliseconds to wait for the completion of an MC command */ -#define MC_CMD_COMPLETION_TIMEOUT_MS 500 +#define MC_CMD_COMPLETION_TIMEOUT_MS 15000/* * usleep_range() min and max values used to throttle down polling
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 276/355 ARM: OMAP2+: Fix l4ls clk domain handling in STANDBY
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sukrut Bellary <[email protected]>
[ Upstream commit 47fe74098f3dadba2f9cc1e507d813a4aa93f5f3 ]
Don't put the l4ls clk domain to sleep in case of standby. Since CM3 PM FW[1](ti-v4.1.y) doesn't wake-up/enable the l4ls clk domain upon wake-up, CM3 PM FW fails to wake-up the MPU.
[1] https://git.ti.com/cgit/processor-firmware/ti-amx3-cm3-pm-firmware/
--- arch/arm/mach-omap2/clockdomain.h | 1 + arch/arm/mach-omap2/clockdomains33xx_data.c | 2 +- arch/arm/mach-omap2/cm33xx.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/clockdomain.h +1 -0
@@ -48,6 +48,7 @@#define CLKDM_NO_AUTODEPS (1 << 4)#define CLKDM_ACTIVE_WITH_MPU (1 << 5)#define CLKDM_MISSING_IDLE_REPORTING (1 << 6) +#define CLKDM_STANDBY_FORCE_WAKEUP BIT(7)#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
arch/arm/mach-omap2/clockdomains33xx_data.c +1 -1
@@ -27,7 +27,7 @@ static struct clockdomain l4ls_am33xx_clkdm = { .pwrdm = { .name = "per_pwrdm" }, .cm_inst = AM33XX_CM_PER_MOD, .clkdm_offs = AM33XX_CM_PER_L4LS_CLKSTCTRL_OFFSET, - .flags = CLKDM_CAN_SWSUP, + .flags = CLKDM_CAN_SWSUP | CLKDM_STANDBY_FORCE_WAKEUP, };static struct clockdomain l3s_am33xx_clkdm = {
arch/arm/mach-omap2/cm33xx.c +13 -1
@@ -28,6 +28,9 @@#include "cm-regbits-34xx.h" #include "cm-regbits-33xx.h" #include "prm33xx.h" +#if IS_ENABLED (CONFIG_SUSPEND ) +#include <linux/suspend.h> +#endif /* * CLKCTRL_IDLEST_*: possible values for the CM_*_CLKCTRL.IDLEST bitfield:
@@ -336,8 +339,17 @@ static int am33xx_clkdm_clk_disable(struct clockdomain *clkdm) {bool hwsup = false; +#if IS_ENABLED (CONFIG_SUSPEND ) +/* +* In case of standby, Don't put the l4ls clk domain to sleep. +* Since CM3 PM FW doesn't wake-up/enable the l4ls clk domain +* upon wake-up, CM3 PM FW fails to wake-up th MPU. +*/ +if (pm_suspend_target_state ==PM_SUSPEND_STANDBY && + (clkdm->flags &CLKDM_STANDBY_FORCE_WAKEUP )) +return 0 ; +#endif hwsup =am33xx_cm_is_clkdm_in_hwsup (clkdm->cm_inst, clkdm->clkdm_offs); -if (!hwsup && (clkdm->flags &CLKDM_CAN_FORCE_SLEEP ))am33xx_clkdm_sleep (clkdm);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 277/355 tee: Prevent size calculation wraparound on 32-bit kernels
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
[ Upstream commit 39bb67edcc582b3b386a9ec983da67fa8a10ec03 ]
The current code around TEE_IOCTL_PARAM_SIZE() is a bit wrong on 32-bit kernels: Multiplying a user-provided 32-bit value with the size of a structure can wrap around on such platforms.
Fix it by using saturating arithmetic for the size calculation.
This has no security consequences because, in all users of TEE_IOCTL_PARAM_SIZE(), the subsequent kcalloc() implicitly checks for wrapping.
--- drivers/tee/tee_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/tee/tee_core.c +6 -5
@@ -10,6 +10,7 @@#include <linux/fs.h> #include <linux/idr.h> #include <linux/module.h> +#include <linux/overflow.h> #include <linux/slab.h> #include <linux/tee_drv.h> #include <linux/uaccess.h>
@@ -19,7 +20,7 @@#define TEE_NUM_DEVICES 32 -#define TEE_IOCTL_PARAM_SIZE (x) (sizeof(struct tee_param) * (x)) +#define TEE_IOCTL_PARAM_SIZE (x) (size_mul(sizeof(struct tee_param), (x)))#define TEE_UUID_NS_NAME_SIZE 128
@@ -492,7 +493,7 @@ static int tee_ioctl_open_session(struct tee_context *ctx,if (copy_from_user (&arg, uarg,sizeof (arg)))return -EFAULT ; -if (sizeof (arg) +TEE_IOCTL_PARAM_SIZE (arg.num_params) != buf.buf_len) +if (size_add (sizeof (arg),TEE_IOCTL_PARAM_SIZE (arg.num_params)) != buf.buf_len)return -EINVAL ;if (arg.num_params) {
@@ -570,7 +571,7 @@ static int tee_ioctl_invoke(struct tee_context *ctx,if (copy_from_user (&arg, uarg,sizeof (arg)))return -EFAULT ; -if (sizeof (arg) +TEE_IOCTL_PARAM_SIZE (arg.num_params) != buf.buf_len) +if (size_add (sizeof (arg),TEE_IOCTL_PARAM_SIZE (arg.num_params)) != buf.buf_len)return -EINVAL ;if (arg.num_params) {
@@ -704,7 +705,7 @@ static int tee_ioctl_supp_recv(struct tee_context *ctx,if (get_user (num_params, &uarg->num_params))return -EFAULT ; -if (sizeof (*uarg) +TEE_IOCTL_PARAM_SIZE (num_params) != buf.buf_len) +if (size_add (sizeof (*uarg),TEE_IOCTL_PARAM_SIZE (num_params)) != buf.buf_len)return -EINVAL ; params =kcalloc (num_params,sizeof (struct tee_param ),GFP_KERNEL );
@@ -803,7 +804,7 @@ static int tee_ioctl_supp_send(struct tee_context *ctx, get_user(num_params, &uarg->num_params))return -EFAULT ; -if (sizeof (*uarg) +TEE_IOCTL_PARAM_SIZE (num_params) > buf.buf_len) +if (size_add (sizeof (*uarg),TEE_IOCTL_PARAM_SIZE (num_params)) > buf.buf_len)return -EINVAL ; params =kcalloc (num_params,sizeof (struct tee_param ),GFP_KERNEL );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 278/355 Revert "bus: ti-sysc: Probe for l4_wkup and l4_cfg interconnect devices first"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit 36305857b1ead8f6ca033a913162ebc09bee0b43 ]
This reverts commit 4700a00755fb5a4bb5109128297d6fd2d1272ee6.
It breaks target-module@2b300050 ("ti,sysc-omap2") probe on AM62x in a case when minimally-configured system tries to network-boot:
[ 6.888776] probe of 2b300050.target-module returned 517 after 258 usecs [ 17.129637] probe of 2b300050.target-module returned 517 after 708 usecs [ 17.137397] platform 2b300050.target-module: deferred probe pending: (reason unknown) [ 26.878471] Waiting up to 100 more seconds for network.
There are minimal configurations possible when the deferred device is not being probed any more (because everything else has been successfully probed) and deferral lists are not processed any more.
Stable mmc enumeration can be achieved by filling /aliases node properly (4700a00755fb commit's rationale).
After revert:
[ 9.006816] IP-Config: Complete: [ 9.010058] device=lan0, ...
--- drivers/bus/ti-sysc.c | 49 ------------------------------------------- 1 file changed, 49 deletions(-)
drivers/bus/ti-sysc.c +0 -49
@@ -687,51 +687,6 @@ static int sysc_parse_and_check_child_range(struct sysc *ddata)return 0 ; } -/* Interconnect instances to probe before l4_per instances */ -static struct resource early_bus_ranges[] = { -/* am3/4 l4_wkup */ - { .start =0x44c00000 , .end =0x44c00000 +0x300000 , }, -/* omap4/5 and dra7 l4_cfg */ - { .start =0x4a000000 , .end =0x4a000000 +0x300000 , }, -/* omap4 l4_wkup */ - { .start =0x4a300000 , .end =0x4a300000 +0x30000 , }, -/* omap5 and dra7 l4_wkup without dra7 dcan segment */ - { .start =0x4ae00000 , .end =0x4ae00000 +0x30000 , }, -}; - -static atomic_t sysc_defer =ATOMIC_INIT (10 ); - -/** -* sysc_defer_non_critical - defer non_critical interconnect probing -* @ddata: device driver data -* -* We want to probe l4_cfg and l4_wkup interconnect instances before any -* l4_per instances as l4_per instances depend on resources on l4_cfg and -* l4_wkup interconnects. -*/ -static int sysc_defer_non_critical (struct sysc *ddata) -{ -struct resource *res; -int i; - -if (!atomic_read (&sysc_defer)) -return 0 ; - -for (i =0 ; i <ARRAY_SIZE (early_bus_ranges); i++) { - res = &early_bus_ranges[i]; -if (ddata->module_pa >= res->start && - ddata->module_pa <= res->end) { -atomic_set (&sysc_defer,0 ); - -return 0 ; - } - } - -atomic_dec_if_positive (&sysc_defer); - -return -EPROBE_DEFER ; -} -static struct device_node *stdout_path;static void sysc_init_stdout_path (struct sysc *ddata)
@@ -956,10 +911,6 @@ static int sysc_map_and_check_registers(struct sysc *ddata)if (error)return error; - error =sysc_defer_non_critical (ddata); -if (error) -return error; -sysc_check_children (ddata); error =sysc_parse_registers (ddata);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 279/355 platform: Add Surface platform directory
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maximilian Luz <[email protected]>
[ Upstream commit 1e3a2bc89de44ec34153ab1c1056346b51def250 ]
It may make sense to split the Microsoft Surface hardware platform drivers out to a separate subdirectory, since some of it may be shared between ARM and x86 in the future (regarding devices like the Surface Pro X).
Further, newer Surface devices will require additional platform drivers for fundamental support (mostly regarding their embedded controller), which may also warrant this split from a size perspective.
This commit introduces a new platform/surface subdirectory for the Surface device family, with subsequent commits moving existing Surface drivers over from platform/x86.
A new MAINTAINERS entry is added for this directory. Patches to files in this directory will be taken up by the platform-drivers-x86 team (i.e. Hans de Goede and Mark Gross) after they have been reviewed by Maximilian Luz.
Stable-dep-of: 61ce04601e0d ("platform/x86: dell_rbu: Fix list usage")
--- MAINTAINERS | 9 +++++++++ drivers/platform/Kconfig | 2 ++ drivers/platform/Makefile | 1 + drivers/platform/surface/Kconfig | 14 ++++++++++++++ drivers/platform/surface/Makefile | 5 +++++ 5 files changed, 31 insertions(+) create mode 100644 drivers/platform/surface/Kconfig create mode 100644 drivers/platform/surface/Makefile
MAINTAINERS +9 -0
@@ -11633,6 +11633,15 @@ F: drivers/scsi/smartpqi/smartpqi*.[ch] F: include/linux/cciss*.h F: include/uapi/linux/cciss*.h +MICROSOFT SURFACE HARDWARE PLATFORM SUPPORT +M: Hans de Goede <[email protected]> +M: Mark Gross <[email protected]> +M: Maximilian Luz <[email protected]> +L: [email protected] +S: Maintained +T: git git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git +F: drivers/platform/surface/ + MICROSOFT SURFACE PRO 3 BUTTON DRIVER M: Chen Yu <[email protected]> L: [email protected]
drivers/platform/Kconfig +2 -0
@@ -13,3 +13,5 @@ source "drivers/platform/chrome/Kconfig" source "drivers/platform/mellanox/Kconfig" source "drivers/platform/olpc/Kconfig" + +source "drivers/platform/surface/Kconfig"
drivers/platform/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_MIPS) += mips/ obj-$(CONFIG_OLPC_EC) += olpc/ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ +obj-$(CONFIG_SURFACE_PLATFORMS) += surface/
drivers/platform/surface/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Microsoft Surface Platform-Specific Drivers +# + +menuconfig SURFACE_PLATFORMS + bool "Microsoft Surface Platform-Specific Device Drivers" + default y + help + Say Y here to get to see options for platform-specific device drivers + for Microsoft Surface devices. This option alone does not add any + kernel code. + + If you say N, all options in this submenu will be skipped and disabled.
drivers/platform/surface/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for linux/drivers/platform/surface +# Microsoft Surface Platform-Specific Drivers +#
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 280/355 platform/x86: dell_rbu: Fix list usage
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stuart Hayes <[email protected]>
[ Upstream commit 61ce04601e0d8265ec6d2ffa6df5a7e1bce64854 ]
Pass the correct list head to list_for_each_entry*() when looping through the packet list.
Without this patch, reading the packet data via sysfs will show the data incorrectly (because it starts at the wrong packet), and clearing the packet list will result in a NULL pointer dereference.
--- drivers/platform/x86/dell_rbu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/dell_rbu.c +2 -2
@@ -292,7 +292,7 @@ static int packet_read_list(char *data, size_t * pread_length) remaining_bytes = *pread_length; bytes_read = rbu_data.packet_read_count; -list_for_each_entry (newpacket, (&packet_data_head.list)->next, list) { +list_for_each_entry (newpacket, &packet_data_head.list, list) { bytes_copied =do_packet_read (pdest, newpacket, remaining_bytes, bytes_read, &temp_count); remaining_bytes -= bytes_copied;
@@ -315,7 +315,7 @@ static void packet_empty_list(void) {struct packet_data *newpacket, *tmp; -list_for_each_entry_safe (newpacket, tmp, (&packet_data_head.list)->next, list) { +list_for_each_entry_safe (newpacket, tmp, &packet_data_head.list, list) {list_del (&newpacket->list);/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 281/355 platform/x86: dell_rbu: Stop overwriting data buffer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stuart Hayes <[email protected]>
[ Upstream commit f4b0fa38d5fefe9aed6ed831f3bd3538c168ee19 ]
The dell_rbu driver will use memset() to clear the data held by each packet when it is no longer needed (when the driver is unloaded, the packet size is changed, etc).
The amount of memory that is cleared (before this patch) is the normal packet size. However, the last packet in the list may be smaller.
Fix this to only clear the memory actually used by each packet, to prevent it from writing past the end of data buffer.
Because the packet data buffers are allocated with __get_free_pages() (in page-sized increments), this bug could only result in a buffer being overwritten when a packet size larger than one page is used. The only user of the dell_rbu module should be the Dell BIOS update program, which uses a packet size of 4096, so no issues should be seen without the patch, it just blocks the possiblity.
--- drivers/platform/x86/dell_rbu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/dell_rbu.c +1 -1
@@ -322,7 +322,7 @@ static void packet_empty_list(void)* zero out the RBU packet memory before freeing * to make sure there are no stale RBU packets left in memory */ -memset (newpacket->data,0 , rbu_data.packetsize); +memset (newpacket->data,0 , newpacket->length);set_memory_wb ((unsigned long )newpacket->data,1 << newpacket->ordernum); free_pages((unsigned long) newpacket->data,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 282/355 powerpc/eeh: Fix missing PE bridge reconfiguration during VFIO EEH recovery
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Narayana Murty N <[email protected]>
[ Upstream commit 33bc69cf6655cf60829a803a45275f11a74899e5 ]
VFIO EEH recovery for PCI passthrough devices fails on PowerNV and pseries platforms due to missing host-side PE bridge reconfiguration. In the current implementation, eeh_pe_configure() only performs RTAS or OPAL-based bridge reconfiguration for native host devices, but skips it entirely for PEs managed through VFIO in guest passthrough scenarios.
This leads to incomplete EEH recovery when a PCI error affects a passthrough device assigned to a QEMU/KVM guest. Although VFIO triggers the EEH recovery flow through VFIO_EEH_PE_ENABLE ioctl, the platform-specific bridge reconfiguration step is silently bypassed. As a result, the PE's config space is not fully restored, causing subsequent config space access failures or EEH freeze-on-access errors inside the guest.
This patch fixes the issue by ensuring that eeh_pe_configure() always invokes the platform's configure_bridge() callback (e.g., pseries_eeh_phb_configure_bridge) even for VFIO-managed PEs. This ensures that RTAS or OPAL calls to reconfigure the PE bridge are correctly issued on the host side, restoring the PE's configuration space after an EEH event.
This fix is essential for reliable EEH recovery in QEMU/KVM guests using VFIO PCI passthrough on PowerNV and pseries systems.
Tested with:
- QEMU/KVM guest using VFIO passthrough (IBM Power9,(lpar)Power11 host)
- Injected EEH errors with pseries EEH errinjct tool on host, recovery verified on qemu guest.
- Verified successful config space access and CAP_EXP DevCtl restoration after recovery
--- arch/powerpc/kernel/eeh.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/kernel/eeh.c +2 -0
@@ -1525,6 +1525,8 @@ int eeh_pe_configure(struct eeh_pe *pe)/* Invalid PE ? */ if (!pe)return -ENODEV ; +else + ret = eeh_ops->configure_bridge (pe);return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 283/355 Revert "x86/bugs: Make spectre user default depend on MITIGATION_SPECTRE_V2" on v6.6 and older
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
This reverts commit 0aa2553778b7531c70de77d729a38aea77626544 which is commit 98fdaeb296f51ef08e727a7cc72e5b5c864c4f4d upstream.
commit 7adb96687ce8 ("x86/bugs: Make spectre user default depend on MITIGATION_SPECTRE_V2") depends on commit 72c70f480a70 ("x86/bugs: Add a separate config for Spectre V2"), which introduced MITIGATION_SPECTRE_V2.
commit 72c70f480a70 ("x86/bugs: Add a separate config for Spectre V2") never landed in stable tree, thus, stable tree doesn't have MITIGATION_SPECTRE_V2, that said, commit 7adb96687ce8 ("x86/bugs: Make spectre user default depend on MITIGATION_SPECTRE_V2") has no value if the dependecy was not applied.
Revert commit 7adb96687ce8 ("x86/bugs: Make spectre user default depend on MITIGATION_SPECTRE_V2") in stable kernel which landed in in 5.4.294, 5.10.238, 5.15.185, 6.1.141 and 6.6.93 stable versions.
--- Documentation/admin-guide/kernel-parameters.txt | 2 -- arch/x86/kernel/cpu/bugs.c | 10 +++------- 2 files changed, 3 insertions(+), 9 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -2
@@ -5122,8 +5122,6 @@ Selecting 'on' will also enable the mitigation against user space to user space task attacks. - Selecting specific mitigation does not force enable - user mitigations. Selecting 'off' will disable both the kernel and the user space protections.
arch/x86/kernel/cpu/bugs.c +3 -7
@@ -1231,13 +1231,9 @@ static __ro_after_init enum spectre_v2_mstatic enum spectre_v2_user_cmd __init spectre_v2_parse_user_cmdline (void ) { -enum spectre_v2_user_cmd mode;char arg[20 ];int ret, i; - mode =IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V2 ) ? -SPECTRE_V2_USER_CMD_AUTO :SPECTRE_V2_USER_CMD_NONE ; -switch (spectre_v2_cmd) {case SPECTRE_V2_CMD_NONE :return SPECTRE_V2_USER_CMD_NONE ;
@@ -1250,7 +1246,7 @@ spectre_v2_parse_user_cmdline(void) ret =cmdline_find_option (boot_command_line,"spectre_v2_user" , arg,sizeof (arg));if (ret <0 ) -return mode; +return SPECTRE_V2_USER_CMD_AUTO ;for (i =0 ; i <ARRAY_SIZE (v2_user_options); i++) {if (match_option (arg, ret, v2_user_options[i].option)) {
@@ -1260,8 +1256,8 @@ spectre_v2_parse_user_cmdline(void) } } -pr_err ("Unknown user space protection option (%s). Switching to default\n" , arg); -return mode; +pr_err ("Unknown user space protection option (%s). Switching to AUTO select\n" , arg); +return SPECTRE_V2_USER_CMD_AUTO ; }static inline bool spectre_v2_in_eibrs_mode (enum spectre_v2_mitigation mode)
Greg Kroah-Hartman
maintainerPATCH 284/355 drivers/rapidio/rio_cm.c: prevent possible heap overwrite
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Morton <[email protected]>
commit 50695153d7ddde3b1696dbf0085be0033bf3ddb3 upstream.
In
riocm_cdev_ioctl(RIO_CM_CHAN_SEND)
-> cm_chan_msg_send()
-> riocm_ch_send()
cm_chan_msg_send() checks that userspace didn't send too much data but riocm_ch_send() failed to check that userspace sent sufficient data. The result is that riocm_ch_send() can write to fields in the rio_ch_chan_hdr which were outside the bounds of the space which cm_chan_msg_send() allocated.
Address this by teaching riocm_ch_send() to check that the entire rio_ch_chan_hdr was copied in from userspace.
--- drivers/rapidio/rio_cm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/rapidio/rio_cm.c +3 -0
@@ -787,6 +787,9 @@ static int riocm_ch_send(u16 ch_id, voidif (buf ==NULL || ch_id ==0 || len ==0 || len >RIO_MAX_MSG_SIZE )return -EINVAL ; +if (len <sizeof (struct rio_ch_chan_hdr )) +return -EINVAL ;/* insufficient data from user */ + ch =riocm_get_channel (ch_id);if (!ch) { riocm_error("%s(%d) ch_%d not found", current->comm,
Greg Kroah-Hartman
maintainerPATCH 285/355 jffs2: check that raw node were preallocated before writing summary
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Sadovnikov <[email protected]>
commit ec9e6f22bce433b260ea226de127ec68042849b0 upstream.
Syzkaller detected a kernel bug in jffs2_link_node_ref, caused by fault injection in jffs2_prealloc_raw_node_refs. jffs2_sum_write_sumnode doesn't check return value of jffs2_prealloc_raw_node_refs and simply lets any error propagate into jffs2_sum_write_data, which eventually calls jffs2_link_node_ref in order to link the summary to an expectedly allocated node.
kernel BUG at fs/jffs2/nodelist.c:592!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 1 PID: 31277 Comm: syz-executor.7 Not tainted 6.1.128-syzkaller-00139-ge10f83ca10a1 #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:jffs2_link_node_ref+0x570/0x690 fs/jffs2/nodelist.c:592 Call Trace: <TASK> jffs2_sum_write_data fs/jffs2/summary.c:841 [inline] jffs2_sum_write_sumnode+0xd1a/0x1da0 fs/jffs2/summary.c:874 jffs2_do_reserve_space+0xa18/0xd60 fs/jffs2/nodemgmt.c:388 jffs2_reserve_space+0x55f/0xaa0 fs/jffs2/nodemgmt.c:197 jffs2_write_inode_range+0x246/0xb50 fs/jffs2/write.c:362 jffs2_write_end+0x726/0x15d0 fs/jffs2/file.c:301 generic_perform_write+0x314/0x5d0 mm/filemap.c:3856 __generic_file_write_iter+0x2ae/0x4d0 mm/filemap.c:3973 generic_file_write_iter+0xe3/0x350 mm/filemap.c:4005 call_write_iter include/linux/fs.h:2265 [inline] do_iter_readv_writev+0x20f/0x3c0 fs/read_write.c:735 do_iter_write+0x186/0x710 fs/read_write.c:861 vfs_iter_write+0x70/0xa0 fs/read_write.c:902 iter_file_splice_write+0x73b/0xc90 fs/splice.c:685 do_splice_from fs/splice.c:763 [inline] direct_splice_actor+0x10c/0x170 fs/splice.c:950 splice_direct_to_actor+0x337/0xa10 fs/splice.c:896 do_splice_direct+0x1a9/0x280 fs/splice.c:1002 do_sendfile+0xb13/0x12c0 fs/read_write.c:1255 __do_sys_sendfile64 fs/read_write.c:1323 [inline] __se_sys_sendfile64 fs/read_write.c:1309 [inline] __x64_sys_sendfile64+0x1cf/0x210 fs/read_write.c:1309 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x35/0x80 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x6e/0xd8
Fix this issue by checking return value of jffs2_prealloc_raw_node_refs before calling jffs2_sum_write_data.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- fs/jffs2/summary.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/jffs2/summary.c +6 -1
@@ -858,7 +858,10 @@ int jffs2_sum_write_sumnode(struct jffs2spin_unlock (&c->erase_completion_lock); jeb = c->nextblock; -jffs2_prealloc_raw_node_refs (c, jeb,1 ); + ret =jffs2_prealloc_raw_node_refs (c, jeb,1 ); + +if (ret) + goto out;if (!c->summary->sum_num || !c->summary->sum_list_head) {JFFS2_WARNING ("Empty summary info!!!\n" );
@@ -872,6 +875,8 @@ int jffs2_sum_write_sumnode(struct jffs2 datasize += padsize; ret =jffs2_sum_write_data (c, jeb, infosize, datasize, padsize); + +out:spin_lock (&c->erase_completion_lock);return ret; }
Greg Kroah-Hartman
maintainerPATCH 286/355 jffs2: check jffs2_prealloc_raw_node_refs() result in few other places
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 2b6d96503255a3ed676cd70f8368870c6d6a25c6 upstream.
Fuzzing hit another invalid pointer dereference due to the lack of checking whether jffs2_prealloc_raw_node_refs() completed successfully. Subsequent logic implies that the node refs have been allocated.
Handle that. The code is ready for propagating the error upwards.
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 1 PID: 5835 Comm: syz-executor145 Not tainted 5.10.234-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:jffs2_link_node_ref+0xac/0x690 fs/jffs2/nodelist.c:600 Call Trace: jffs2_mark_erased_block fs/jffs2/erase.c:460 [inline] jffs2_erase_pending_blocks+0x688/0x1860 fs/jffs2/erase.c:118 jffs2_garbage_collect_pass+0x638/0x1a00 fs/jffs2/gc.c:253 jffs2_reserve_space+0x3f4/0xad0 fs/jffs2/nodemgmt.c:167 jffs2_write_inode_range+0x246/0xb50 fs/jffs2/write.c:362 jffs2_write_end+0x712/0x1110 fs/jffs2/file.c:302 generic_perform_write+0x2c2/0x500 mm/filemap.c:3347 __generic_file_write_iter+0x252/0x610 mm/filemap.c:3465 generic_file_write_iter+0xdb/0x230 mm/filemap.c:3497 call_write_iter include/linux/fs.h:2039 [inline] do_iter_readv_writev+0x46d/0x750 fs/read_write.c:740 do_iter_write+0x18c/0x710 fs/read_write.c:866 vfs_writev+0x1db/0x6a0 fs/read_write.c:939 do_pwritev fs/read_write.c:1036 [inline] __do_sys_pwritev fs/read_write.c:1083 [inline] __se_sys_pwritev fs/read_write.c:1078 [inline] __x64_sys_pwritev+0x235/0x310 fs/read_write.c:1078 do_syscall_64+0x30/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x67/0xd1
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- fs/jffs2/erase.c | 4 +++- fs/jffs2/scan.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
fs/jffs2/erase.c +3 -1
@@ -427,7 +427,9 @@ static void jffs2_mark_erased_block(stru .totlen = cpu_to_je32(c->cleanmarker_size) }; -jffs2_prealloc_raw_node_refs (c, jeb,1 ); + ret =jffs2_prealloc_raw_node_refs (c, jeb,1 ); +if (ret) + goto filebad; marker.hdr_crc =cpu_to_je32 (crc32 (0 , &marker,sizeof (struct jffs2_unknown_node )-4 ));
fs/jffs2/scan.c +3 -1
@@ -256,7 +256,9 @@ int jffs2_scan_medium(struct jffs2_sb_injffs2_dbg (1 ,"%s(): Skipping %d bytes in nextblock to ensure page alignment\n" , __func__, skip); -jffs2_prealloc_raw_node_refs (c, c->nextblock,1 ); + ret =jffs2_prealloc_raw_node_refs (c, c->nextblock,1 ); +if (ret) + goto out; jffs2_scan_dirty_space(c, c->nextblock, skip); }#endif
Greg Kroah-Hartman
maintainerPATCH 287/355 scsi: storvsc: Increase the timeouts to storvsc_timeout
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dexuan Cui <[email protected]>
commit b2f966568faaad326de97481096d0f3dc0971c43 upstream.
Currently storvsc_timeout is only used in storvsc_sdev_configure(), and 5s and 10s are used elsewhere. It turns out that rarely the 5s is not enough on Azure, so let's use storvsc_timeout everywhere.
In case a timeout happens and storvsc_channel_init() returns an error, close the VMBus channel so that any host-to-guest messages in the channel's ringbuffer, which might come late, can be safely ignored.
Add a "const" to storvsc_timeout.
--- drivers/scsi/storvsc_drv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/storvsc_drv.c +6 -4
@@ -400,7 +400,7 @@ MODULE_PARM_DESC(ring_avail_percent_lowa/* * Timeout in seconds for all devices managed by this driver. */ -static int storvsc_timeout =180 ; +static const int storvsc_timeout =180 ;#if IS_ENABLED (CONFIG_SCSI_FC_ATTRS )static struct scsi_transport_template *fc_transport_template;
@@ -779,7 +779,7 @@ static void handle_multichannel_storagereturn ; } - t =wait_for_completion_timeout (&request->wait_event,10 *HZ ); + t =wait_for_completion_timeout (&request->wait_event, storvsc_timeout *HZ );if (t ==0 ) {dev_err (dev,"Failed to create sub-channel: timed out\n" );return ;
@@ -840,7 +840,7 @@ static int storvsc_execute_vstor_op(struif (ret !=0 )return ret; - t =wait_for_completion_timeout (&request->wait_event,5 *HZ ); + t =wait_for_completion_timeout (&request->wait_event, storvsc_timeout *HZ );if (t ==0 )return -ETIMEDOUT ;
@@ -1301,6 +1301,8 @@ static int storvsc_connect_to_vsp(structreturn ret; ret =storvsc_channel_init (device, is_fc); +if (ret) +vmbus_close (device->channel);return ret; }
@@ -1623,7 +1625,7 @@ static int storvsc_host_reset_handler(stif (ret !=0 )return FAILED ; - t =wait_for_completion_timeout (&request->wait_event,5 *HZ ); + t =wait_for_completion_timeout (&request->wait_event, storvsc_timeout *HZ );if (t ==0 )return TIMEOUT_ERROR ;
Greg Kroah-Hartman
maintainerPATCH 288/355 scsi: s390: zfcp: Ensure synchronous unit_add
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Oberparleiter <[email protected]>
commit 9697ca0d53e3db357be26d2414276143c4a2cd49 upstream.
Improve the usability of the unit_add sysfs attribute by ensuring that the associated FCP LUN scan processing is completed synchronously. This enables configuration tooling to consistently determine the end of the scan process to allow for serialization of follow-on actions.
While the scan process associated with unit_add typically completes synchronously, it is deferred to an asynchronous background process if unit_add is used before initial remote port scanning has completed. This occurs when unit_add is used immediately after setting the associated FCP device online.
To ensure synchronous unit_add processing, wait for remote port scanning to complete before initiating the FCP LUN scan.
--- drivers/s390/scsi/zfcp_sysfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/scsi/zfcp_sysfs.c +2 -0
@@ -450,6 +450,8 @@ static ssize_t zfcp_sysfs_unit_add_storeif (kstrtoull (buf,0 , (unsigned long long *) &fcp_lun))return -EINVAL ; +flush_work (&port->rport_work); + retval =zfcp_unit_add (port, fcp_lun);if (retval)return retval;
Greg Kroah-Hartman
maintainerPATCH 289/355 udmabuf: use sgtable-based scatterlist wrappers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit afe382843717d44b24ef5014d57dcbaab75a4052 upstream.
Use common wrappers operating directly on the struct sg_table objects to fix incorrect use of scatterlists sync calls. dma_sync_sg_for_*() functions have to be called with the number of elements originally passed to dma_map_sg_*() function, not the one returned in sgtable's nents.
--- drivers/dma-buf/udmabuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma-buf/udmabuf.c +2 -3
@@ -127,8 +127,7 @@ static int begin_cpu_udmabuf(struct dma_ ubuf->sg =NULL ; } }else { -dma_sync_sg_for_cpu (dev, ubuf->sg->sgl, ubuf->sg->nents, - direction); +dma_sync_sgtable_for_cpu (dev, ubuf->sg, direction); }return ret;
@@ -143,7 +142,7 @@ static int end_cpu_udmabuf(struct dma_buif (!ubuf->sg)return -EINVAL ; -dma_sync_sg_for_device (dev, ubuf->sg->sgl, ubuf->sg->nents, direction); +dma_sync_sgtable_for_device (dev, ubuf->sg, direction);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 290/355 selinux: fix selinux_xfrm_alloc_user() to set correct ctx_len
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Smalley <[email protected]>
commit 86c8db86af43f52f682e53a0f2f0828683be1e52 upstream.
We should count the terminating NUL byte as part of the ctx_len. Otherwise, UBSAN logs a warning:
UBSAN: array-index-out-of-bounds in security/selinux/xfrm.c:99:14 index 60 is out of range for type 'char [*]'
The allocation itself is correct so there is no actual out of bounds indexing, just a warning.
--- security/selinux/xfrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/xfrm.c +1 -1
@@ -95,7 +95,7 @@ static int selinux_xfrm_alloc_user(struc ctx->ctx_doi =XFRM_SC_DOI_LSM ; ctx->ctx_alg =XFRM_SC_ALG_SELINUX ; - ctx->ctx_len = str_len; + ctx->ctx_len = str_len +1 ;memcpy (ctx->ctx_str, &uctx[1 ], str_len); ctx->ctx_str[str_len] ='\0' ; rc = security_context_to_sid(&selinux_state, ctx->ctx_str, str_len,
Greg Kroah-Hartman
maintainerPATCH 291/355 atm: Revert atm_account_tx() if copy_from_iter_full() fails.
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit 7851263998d4269125fd6cb3fdbfc7c6db853859 upstream.
In vcc_sendmsg(), we account skb->truesize to sk->sk_wmem_alloc by atm_account_tx().
It is expected to be reverted by atm_pop_raw() later called by vcc->dev->ops->send(vcc, skb).
However, vcc_sendmsg() misses the same revert when copy_from_iter_full() fails, and then we will leak a socket.
Let's factorise the revert part as atm_return_tx() and call it in the failure path.
Note that the corresponding sk_wmem_alloc operation can be found in alloc_tx() as of the blamed commit.
$ git blame -L:alloc_tx net/atm/common.c c55fa3cccbc2c~
--- include/linux/atmdev.h | 6 ++++++ net/atm/common.c | 1 + net/atm/raw.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-)
include/linux/atmdev.h +6 -0
@@ -248,6 +248,12 @@ static inline void atm_account_tx(structATM_SKB (skb)->atm_options = vcc->atm_options; } +static inline void atm_return_tx (struct atm_vcc *vcc,struct sk_buff *skb) +{ +WARN_ON_ONCE (refcount_sub_and_test (ATM_SKB (skb)->acct_truesize, + &sk_atm (vcc)->sk_wmem_alloc)); +} +static inline void atm_force_charge (struct atm_vcc *vcc,int truesize) {atomic_add (truesize, &sk_atm (vcc)->sk_rmem_alloc);
net/atm/common.c +1 -0
@@ -635,6 +635,7 @@ int vcc_sendmsg(struct socket *sock, str skb->dev =NULL ;/* for paths shared with net_device interfaces */ if (!copy_from_iter_full (skb_put (skb, size), size, &m->msg_iter)) { +atm_return_tx (vcc, skb);kfree_skb (skb); error = -EFAULT ; goto out;
net/atm/raw.c +1 -1
@@ -36,7 +36,7 @@ static void atm_pop_raw(struct atm_vcc *pr_debug ("(%d) %d -= %d\n" , vcc->vci,sk_wmem_alloc_get (sk),ATM_SKB (skb)->acct_truesize); -WARN_ON (refcount_sub_and_test (ATM_SKB (skb)->acct_truesize, &sk->sk_wmem_alloc)); +atm_return_tx (vcc, skb);dev_kfree_skb_any (skb); sk->sk_write_space (sk); }
Greg Kroah-Hartman
maintainerPATCH 292/355 HID: usbhid: Eliminate recurrent out-of-bounds bug in usbhid_parse()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Terry Junge <[email protected]>
commit fe7f7ac8e0c708446ff017453add769ffc15deed upstream.
Update struct hid_descriptor to better reflect the mandatory and optional parts of the HID Descriptor as per USB HID 1.11 specification.
Note: the kernel currently does not parse any optional HID class descriptors, only the mandatory report descriptor.
Update all references to member element desc[0] to rpt_desc.
Add test to verify bLength and bNumDescriptors values are valid.
Replace the for loop with direct access to the mandatory HID class descriptor member for the report descriptor. This eliminates the possibility of getting an out-of-bounds fault.
Add a warning message if the HID descriptor contains any unsupported optional HID class descriptors.
--- drivers/hid/hid-hyperv.c | 5 +++-- drivers/hid/usbhid/hid-core.c | 25 ++++++++++++++----------- drivers/usb/gadget/function/f_hid.c | 12 ++++++------ include/linux/hid.h | 3 ++- 4 files changed, 25 insertions(+), 20 deletions(-)
drivers/hid/hid-hyperv.c +3 -2
@@ -199,7 +199,8 @@ static void mousevsc_on_receive_device_iif (!input_device->hid_desc) goto cleanup; - input_device->report_desc_size = desc->desc[0 ].wDescriptorLength; + input_device->report_desc_size =le16_to_cpu ( + desc->rpt_desc.wDescriptorLength);if (input_device->report_desc_size ==0 ) { input_device->dev_info_status = -EINVAL ; goto cleanup;
@@ -217,7 +218,7 @@ static void mousevsc_on_receive_device_imemcpy (input_device->report_desc, ((unsigned char *)desc) + desc->bLength, - desc->desc[0 ].wDescriptorLength); +le16_to_cpu (desc->rpt_desc.wDescriptorLength));/* Send the ack */ memset (&ack,0 ,sizeof (struct mousevsc_prt_msg ));
drivers/hid/usbhid/hid-core.c +14 -11
@@ -984,12 +984,11 @@ static int usbhid_parse(struct hid_devicstruct usb_host_interface *interface = intf->cur_altsetting;struct usb_device *dev =interface_to_usbdev (intf);struct hid_descriptor *hdesc; +struct hid_class_descriptor *hcdesc;u32 quirks =0 ;unsigned int rsize =0 ;char *rdesc; -int ret, n; -int num_descriptors; -size_t offset = offsetof(struct hid_descriptor , desc); +int ret; quirks =hid_lookup_quirk (hid);
@@ -1011,20 +1010,19 @@ static int usbhid_parse(struct hid_devicreturn -ENODEV ; } -if (hdesc->bLength <sizeof (struct hid_descriptor )) { -dbg_hid ("hid descriptor is too short\n" ); +if (!hdesc->bNumDescriptors || + hdesc->bLength !=sizeof (*hdesc) + + (hdesc->bNumDescriptors -1 ) *sizeof (*hcdesc)) { +dbg_hid ("hid descriptor invalid, bLen=%hhu bNum=%hhu\n" , + hdesc->bLength, hdesc->bNumDescriptors);return -EINVAL ; } hid->version =le16_to_cpu (hdesc->bcdHID); hid->country = hdesc->bCountryCode; - num_descriptors =min_t (int, hdesc->bNumDescriptors, - (hdesc->bLength - offset) /sizeof (struct hid_class_descriptor )); - -for (n =0 ; n < num_descriptors; n++) -if (hdesc->desc[n].bDescriptorType ==HID_DT_REPORT ) - rsize =le16_to_cpu (hdesc->desc[n].wDescriptorLength); +if (hdesc->rpt_desc.bDescriptorType ==HID_DT_REPORT ) + rsize =le16_to_cpu (hdesc->rpt_desc.wDescriptorLength);if (!rsize || rsize >HID_MAX_DESCRIPTOR_SIZE ) {dbg_hid ("weird size of report descriptor (%u)\n" , rsize);
@@ -1052,6 +1050,11 @@ static int usbhid_parse(struct hid_devic goto err; } +if (hdesc->bNumDescriptors >1 ) +hid_warn (intf, +"%u unsupported optional hid class descriptors\n" , + (int )(hdesc->bNumDescriptors -1 )); + hid->quirks |= quirks;return 0 ;
drivers/usb/gadget/function/f_hid.c +6 -6
@@ -114,8 +114,8 @@ static struct hid_descriptor hidg_desc = .bcdHID = cpu_to_le16(0x0101), .bCountryCode = 0x00, .bNumDescriptors = 0x1, -/*.desc[0].bDescriptorType = DYNAMIC */ -/*.desc[0].wDescriptorLenght = DYNAMIC */ +/*.rpt_desc.bDescriptorType = DYNAMIC */ +/*.rpt_desc.wDescriptorLength = DYNAMIC */ };/* Super-Speed Support */
@@ -724,8 +724,8 @@ static int hidg_setup(struct usb_functiostruct hid_descriptor hidg_desc_copy = hidg_desc;VDBG (cdev,"USB_REQ_GET_DESCRIPTOR: HID\n" ); - hidg_desc_copy.desc[0 ].bDescriptorType =HID_DT_REPORT ; - hidg_desc_copy.desc[0 ].wDescriptorLength = + hidg_desc_copy.rpt_desc.bDescriptorType =HID_DT_REPORT ; + hidg_desc_copy.rpt_desc.wDescriptorLength =cpu_to_le16 (hidg->report_desc_length); length = min_t(unsigned short, length,
@@ -966,8 +966,8 @@ static int hidg_bind(struct usb_configur* We can use hidg_desc struct here but we should not relay * that its content won't change after returning from this function. */ - hidg_desc.desc[0 ].bDescriptorType =HID_DT_REPORT ; - hidg_desc.desc[0 ].wDescriptorLength = + hidg_desc.rpt_desc.bDescriptorType =HID_DT_REPORT ; + hidg_desc.rpt_desc.wDescriptorLength =cpu_to_le16 (hidg->report_desc_length); hidg_hs_in_ep_desc.bEndpointAddress =
include/linux/hid.h +2 -1
@@ -674,8 +674,9 @@ struct hid_descriptor {__le16 bcdHID;__u8 bCountryCode;__u8 bNumDescriptors; +struct hid_class_descriptor rpt_desc; -struct hid_class_descriptor desc[1 ]; +struct hid_class_descriptor opt_descs[]; } __attribute__ ((packed));#define HID_DEVICE (b, g, ven, prod) \
Greg Kroah-Hartman
maintainerPATCH 293/355 Input: sparcspkr - avoid unannotated fall-through
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 8b1d858cbd4e1800e9336404ba7892b5a721230d upstream.
Fix follow warnings with clang-21i (and reformat for clarity):
drivers/input/misc/sparcspkr.c:78:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
78 | case SND_TONE: break;
| ^
drivers/input/misc/sparcspkr.c:78:3: note: insert 'break;' to avoid fall-through
78 | case SND_TONE: break;
| ^
| break;
drivers/input/misc/sparcspkr.c:113:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
113 | case SND_TONE: break;
| ^
drivers/input/misc/sparcspkr.c:113:3: note: insert 'break;' to avoid fall-through
113 | case SND_TONE: break;
| ^
| break;2 warnings generated.
--- drivers/input/misc/sparcspkr.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/input/misc/sparcspkr.c +16 -6
@@ -74,9 +74,14 @@ static int bbc_spkr_event(struct input_dreturn -1 ;switch (code) { -case SND_BELL :if (value) value =1000 ; -case SND_TONE :break ; -default :return -1 ; +case SND_BELL : +if (value) + value =1000 ; +break ; +case SND_TONE : +break ; +default : +return -1 ; }if (value >20 && value <32767 )
@@ -112,9 +117,14 @@ static int grover_spkr_event(struct inpureturn -1 ;switch (code) { -case SND_BELL :if (value) value =1000 ; -case SND_TONE :break ; -default :return -1 ; +case SND_BELL : +if (value) + value =1000 ; +break ; +case SND_TONE : +break ; +default : +return -1 ; }if (value >20 && value <32767 )
Greg Kroah-Hartman
maintainerPATCH 294/355 ALSA: usb-audio: Rename ALSA kcontrol PCM and PCM1 for the KTMicro sound card
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
commit 93adf20ff4d6e865e0b974110d3cf2f07c057177 upstream.
PCM1 not in Pulseaudio's control list; standardize control to "Speaker" and "Headphone".
--- sound/usb/mixer_maps.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/usb/mixer_maps.c +12 -0
@@ -367,6 +367,13 @@ static const struct usbmix_name_map cors { 0 } }; +/* KTMicro USB */ +static struct usbmix_name_map s31b2_0022_map[] = { + {23 ,"Speaker Playback" }, + {18 ,"Headphone Playback" }, + {0 } +}; +/* ASUS ROG Zenith II with Realtek ALC1220-VB */ static const struct usbmix_name_map asus_zenith_ii_map[] = { {19 ,NULL ,12 },/* FU, Input Gain Pad - broken response, disabled */
@@ -649,6 +656,11 @@ static const struct usbmix_ctl_map usbmi .id = USB_ID(0x1395, 0x0025), .map = sennheiser_pc8_map, }, + { +/* KTMicro USB */ + .id = USB_ID(0X31b2, 0x0022), + .map = s31b2_0022_map, + }, { 0 } /* terminator */ };
Greg Kroah-Hartman
maintainerPATCH 295/355 ALSA: hda/intel: Add Thinkpad E15 to PM deny list
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c987a390f1b3b8bdac11031d7004e3410fe259bd upstream.
Lenovo Thinkpad E15 with Conexant CX8070 codec seems causing ugly noises after runtime-PM suspend. Disable the codec runtime PM as a workaround.
--- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/hda_intel.c +2 -0
@@ -2295,6 +2295,8 @@ static const struct snd_pci_quirk power_SND_PCI_QUIRK (0x1734 ,0x1232 ,"KONTRON SinglePC" ,0 ),/* Dell ALC3271 */ SND_PCI_QUIRK (0x1028 ,0x0962 ,"Dell ALC3271" ,0 ), +/* https://bugzilla.kernel.org/show_bug.cgi?id=220210 */ + SND_PCI_QUIRK(0x17aa, 0x5079, "Lenovo Thinkpad E15", 0), {} };#endif /* CONFIG_PM */
Greg Kroah-Hartman
maintainerPATCH 296/355 ALSA: hda/realtek: enable headset mic on Latitude 5420 Rugged
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Lane <[email protected]>
commit efa6bdf1bc75e26cafaa5f1d775e8bb7c5b0c431 upstream.
Like many Dell laptops, the 3.5mm port by default can not detect a combined headphones+mic headset or even a pure microphone. This change enables the port's functionality.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9151,6 +9151,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1028 ,0x0871 ,"Dell Precision 3630" ,ALC255_FIXUP_DELL_HEADSET_MIC ),SND_PCI_QUIRK (0x1028 ,0x0872 ,"Dell Precision 3630" ,ALC255_FIXUP_DELL_HEADSET_MIC ),SND_PCI_QUIRK (0x1028 ,0x0873 ,"Dell Precision 3930" ,ALC255_FIXUP_DUMMY_LINEOUT_VERB ), +SND_PCI_QUIRK (0x1028 ,0x0879 ,"Dell Latitude 5420 Rugged" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x08ad ,"Dell WYSE AIO" ,ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x08ae ,"Dell WYSE NB" ,ALC225_FIXUP_DELL1_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
Greg Kroah-Hartman
maintainerPATCH 297/355 hugetlb: unshare some PMDs when splitting VMAs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Houghton <[email protected]>
commit b30c14cd61025eeea2f2e8569606cd167ba9ad2d upstream.
PMD sharing can only be done in PUD_SIZE-aligned pieces of VMAs; however, it is possible that HugeTLB VMAs are split without unsharing the PMDs first.
Without this fix, it is possible to hit the uffd-wp-related WARN_ON_ONCE in hugetlb_change_protection [1]. The key there is that hugetlb_unshare_all_pmds will not attempt to unshare PMDs in non-PUD_SIZE-aligned sections of the VMA.
It might seem ideal to unshare in hugetlb_vm_op_open, but we need to unshare in both the new and old VMAs, so unsharing in hugetlb_vm_op_split seems natural.
[1]: https://lore.kernel.org/linux-mm/CADrL8HVeOkj0QH5VZZbRzybNE8CG-tEGFshnA+bG9nMgcWtBSg@mail.gmail.com/
[backport notes: I believe the "Fixes" tag is somewhat wrong - kernels before that commit already had an adjust_range_if_pmd_sharing_possible() that assumes that shared PMDs can't straddle page table boundaries. huge_pmd_unshare() takes different parameter type]
--- mm/hugetlb.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
mm/hugetlb.c +65 -0
@@ -96,6 +96,8 @@ static inline void ClearPageHugeFreed(st/* Forward declaration */ static int hugetlb_acct_memory (struct hstate *h,long delta); +static void hugetlb_unshare_pmds (struct vm_area_struct *vma, +unsigned long start,unsigned long end);static inline void unlock_or_release_subpool (struct hugepage_subpool *spool) {
@@ -3697,6 +3699,25 @@ static int hugetlb_vm_op_split(struct vm {if (addr & ~(huge_page_mask (hstate_vma (vma))))return -EINVAL ; + +/* +* PMD sharing is only possible for PUD_SIZE-aligned address ranges +* in HugeTLB VMAs. If we will lose PUD_SIZE alignment due to this +* split, unshare PMDs in the PUD_SIZE interval surrounding addr now. +*/ +if (addr & ~PUD_MASK ) { +/* +* hugetlb_vm_op_split is called right before we attempt to +* split the VMA. We will need to unshare PMDs in the old and +* new VMAs, so let's unshare before we split. +*/ +unsigned long floor = addr &PUD_MASK ; +unsigned long ceil = floor +PUD_SIZE ; + +if (floor >= vma->vm_start && ceil <= vma->vm_end) +hugetlb_unshare_pmds (vma, floor, ceil); + } +return 0 ; }
@@ -5706,6 +5727,50 @@ void move_hugetlb_state(struct page *old } } +static void hugetlb_unshare_pmds (struct vm_area_struct *vma, +unsigned long start, +unsigned long end) +{ +struct hstate *h =hstate_vma (vma); +unsigned long sz =huge_page_size (h); +struct mm_struct *mm = vma->vm_mm; +struct mmu_notifier_range range; +unsigned long address; +spinlock_t *ptl; +pte_t *ptep; + +if (!(vma->vm_flags &VM_MAYSHARE )) +return ; + +if (start >= end) +return ; + +flush_cache_range (vma, start, end); +/* +* No need to call adjust_range_if_pmd_sharing_possible(), because +* we have already done the PUD_SIZE alignment. +*/ +mmu_notifier_range_init (&range,MMU_NOTIFY_CLEAR ,0 , vma, mm, + start, end); +mmu_notifier_invalidate_range_start (&range); +i_mmap_lock_write (vma->vm_file->f_mapping); +for (address = start; address < end; address +=PUD_SIZE ) { + ptep =huge_pte_offset (mm, address, sz); +if (!ptep) +continue ; + ptl =huge_pte_lock (h, mm, ptep); +huge_pmd_unshare (mm, vma, &address, ptep); +spin_unlock (ptl); + } +flush_hugetlb_tlb_range (vma, start, end); +i_mmap_unlock_write (vma->vm_file->f_mapping); +/* +* No need to call mmu_notifier_invalidate_range(), see +* Documentation/mm/mmu_notifier.rst. +*/ +mmu_notifier_invalidate_range_end (&range); +} +#ifdef CONFIG_CMA static bool cma_reserve_called__initdata ;
Greg Kroah-Hartman
maintainerPATCH 298/355 mm/hugetlb: unshare page tables during VMA split, not before
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 081056dc00a27bccb55ccc3c6f230a3d5fd3f7e0 upstream.
Currently, __split_vma() triggers hugetlb page table unsharing through vm_ops->may_split(). This happens before the VMA lock and rmap locks are taken - which is too early, it allows racing VMA-locked page faults in our process and racing rmap walks from other processes to cause page tables to be shared again before we actually perform the split.
Fix it by explicitly calling into the hugetlb unshare logic from __split_vma() in the same place where THP splitting also happens. At that point, both the VMA and the rmap(s) are write-locked.
An annoying detail is that we can now call into the helper hugetlb_unshare_pmds() from two different locking contexts:
1. from hugetlb_split(), holding:
- mmap lock (exclusively)
- VMA lock
- file rmap lock (exclusively)
2. hugetlb_unshare_all_pmds(), which I think is designed to be able to call us with only the mmap lock held (in shared mode), but currently only runs while holding mmap lock (exclusively) and VMA lock
Backporting note:
This commit fixes a racy protection that was introduced in commit b30c14cd6102 ("hugetlb: unshare some PMDs when splitting VMAs"); that commit claimed to fix an issue introduced in 5.13, but it should actually also go all the way back.
[stable backport: code got moved around, VMA splitting is in __vma_adjust, hugetlb lock wasn't used back then]
--- include/linux/hugetlb.h | 6 +++++ mm/hugetlb.c | 53 ++++++++++++++++++++++++++++++++++++------------ mm/mmap.c | 8 +++++++ 3 files changed, 54 insertions(+), 13 deletions(-)
include/linux/hugetlb.h +6 -0
@@ -188,6 +188,8 @@ unsigned long hugetlb_change_protection( unsigned long address, unsigned long end, pgprot_t newprot);bool is_hugetlb_entry_migration (pte_t pte); +void hugetlb_unshare_all_pmds (struct vm_area_struct *vma); +void hugetlb_split (struct vm_area_struct *vma,unsigned long addr);#else /* !CONFIG_HUGETLB_PAGE */
@@ -369,6 +371,10 @@ static inline vm_fault_t hugetlb_fault(s return 0; } +static inline void hugetlb_unshare_all_pmds (struct vm_area_struct *vma) { } + +static inline void hugetlb_split (struct vm_area_struct *vma,unsigned long addr) {} +#endif /* !CONFIG_HUGETLB_PAGE */ /* * hugepages at page global directory. If arch support
mm/hugetlb.c +40 -13
96 lines not on this page · raw message
mm/mmap.c +8 -0
@@ -832,7 +832,15 @@ int __vma_adjust(struct vm_area_struct * } } again: +/* +* Get rid of huge pages and shared page tables straddling the split +* boundary. +*/ vma_adjust_trans_huge (orig_vma, start, end, adjust_next); +if (is_vm_hugetlb_page (orig_vma)) { +hugetlb_split (orig_vma, start); +hugetlb_split (orig_vma, end); + }if (file) { mapping = file->f_mapping;
Greg Kroah-Hartman
maintainerPATCH 299/355 mm: hugetlb: independent PMD page table shared count
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Shixin <[email protected]>
commit 59d9094df3d79443937add8700b2ef1a866b1081 upstream.
The folio refcount may be increased unexpectly through try_get_folio() by caller such as split_huge_pages. In huge_pmd_unshare(), we use refcount to check whether a pmd page table is shared. The check is incorrect if the refcount is increased by the above caller, and this can cause the page table leaked:
BUG: Bad page state in process sh pfn:109324 page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x66 pfn:0x109324 flags: 0x17ffff800000000(node=0|zone=2|lastcpupid=0xfffff) page_type: f2(table) raw: 017ffff800000000 0000000000000000 0000000000000000 0000000000000000 raw: 0000000000000066 0000000000000000 00000000f2000000 0000000000000000 page dumped because: nonzero mapcount ... CPU: 31 UID: 0 PID: 7515 Comm: sh Kdump: loaded Tainted: G B 6.13.0-rc2master+ #7 Tainted: [B]=BAD_PAGE Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 Call trace: show_stack+0x20/0x38 (C) dump_stack_lvl+0x80/0xf8 dump_stack+0x18/0x28 bad_page+0x8c/0x130 free_page_is_bad_report+0xa4/0xb0 free_unref_page+0x3cc/0x620 __folio_put+0xf4/0x158 split_huge_pages_all+0x1e0/0x3e8 split_huge_pages_write+0x25c/0x2d8 full_proxy_write+0x64/0xd8 vfs_write+0xcc/0x280 ksys_write+0x70/0x110 __arm64_sys_write+0x24/0x38 invoke_syscall+0x50/0x120 el0_svc_common.constprop.0+0xc8/0xf0 do_el0_svc+0x24/0x38 el0_svc+0x34/0x128 el0t_64_sync_handler+0xc8/0xd0 el0t_64_sync+0x190/0x198
The issue may be triggered by damon, offline_page, page_idle, etc, which will increase the refcount of page table.
1. The page table itself will be discarded after reporting the "nonzero mapcount".
2. The HugeTLB page mapped by the page table miss freeing since we treat the page table as shared and a shared page table will not be unmapped.
Fix it by introducing independent PMD page table shared count. As described by comment, pt_index/pt_mm/pt_frag_refcount are used for s390 gmap, x86 pgds and powerpc, pt_share_count is used for x86/arm64/riscv pmds, so we can reuse the field as pt_share_count.
[backport note: struct ptdesc did not exist yet, stuff it equivalently into struct page instead]
--- include/linux/mm.h | 3 +++ include/linux/mm_types.h | 3 +++ mm/hugetlb.c | 18 ++++++++---------- 3 files changed, 14 insertions(+), 10 deletions(-)
include/linux/mm.h +3 -0
@@ -2318,6 +2318,9 @@ static inline bool pgtable_pmd_page_ctorif (!pmd_ptlock_init (page))return false;__SetPageTable (page); +#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE +atomic_set (&page->pt_share_count,0 ); +#endif inc_zone_page_state (page,NR_PAGETABLE );return true; }
include/linux/mm_types.h +3 -0
@@ -151,6 +151,9 @@ struct page {union {struct mm_struct *pt_mm;/* x86 pgds only */ atomic_t pt_frag_refcount;/* powerpc */ +#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE +atomic_t pt_share_count; +#endif };#if ALLOC_SPLIT_PTLOCKS spinlock_t *ptl;
mm/hugetlb.c +8 -10
@@ -5442,7 +5442,7 @@ pte_t *huge_pmd_share(struct mm_struct * spte =huge_pte_offset (svma->vm_mm, saddr,vma_mmu_pagesize (svma));if (spte) { -get_page (virt_to_page (spte)); +atomic_inc (&virt_to_page (spte)->pt_share_count);break ; } }
@@ -5457,7 +5457,7 @@ pte_t *huge_pmd_share(struct mm_struct * (pmd_t *)((unsigned long)spte & PAGE_MASK));mm_inc_nr_pmds (mm); }else { -put_page (virt_to_page (spte)); +atomic_dec (&virt_to_page (spte)->pt_share_count); }spin_unlock (ptl); out:
@@ -5468,11 +5468,7 @@ out:/* * unmap huge page backed by shared pte. * -* Hugetlb pte page is ref counted at the time of mapping. If pte is shared -* indicated by page_count > 1, unmap is achieved by clearing pud and -* decrementing the ref count. If count == 1, the pte page is not shared. -* -* Called with page table lock held and i_mmap_rwsem held in write mode. +* Called with page table lock held. * * returns: 1 successfully unmapped a shared pte page * 0 the underlying pte page is not shared, or it is the last user
@@ -5480,17 +5476,19 @@ out:int huge_pmd_unshare (struct mm_struct *mm,struct vm_area_struct *vma,unsigned long *addr,pte_t *ptep) { +unsigned long sz =huge_page_size (hstate_vma (vma));pgd_t *pgd =pgd_offset (mm, *addr);p4d_t *p4d =p4d_offset (pgd, *addr);pud_t *pud =pud_offset (p4d, *addr);i_mmap_assert_write_locked (vma->vm_file->f_mapping); -BUG_ON (page_count (virt_to_page (ptep)) ==0 ); -if (page_count (virt_to_page (ptep)) ==1 ) +if (sz !=PMD_SIZE ) +return 0 ; +if (!atomic_read (&virt_to_page (ptep)->pt_share_count))return 0 ;pud_clear (pud); -put_page (virt_to_page (ptep)); +atomic_dec (&virt_to_page (ptep)->pt_share_count);mm_dec_nr_pmds (mm);/* * This update of passed address optimizes loops sequentially
Greg Kroah-Hartman
maintainerPATCH 300/355 mm/hugetlb: fix huge_pmd_unshare() vs GUP-fast race
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 1013af4f585fccc4d3e5c5824d174de2257f7d6d upstream.
huge_pmd_unshare() drops a reference on a page table that may have previously been shared across processes, potentially turning it into a normal page table used in another process in which unrelated VMAs can afterwards be installed.
If this happens in the middle of a concurrent gup_fast(), gup_fast() could end up walking the page tables of another process. While I don't see any way in which that immediately leads to kernel memory corruption, it is really weird and unexpected.
Fix it with an explicit broadcast IPI through tlb_remove_table_sync_one(), just like we do in khugepaged when removing page tables for a THP collapse.
--- mm/hugetlb.c | 7 +++++++ 1 file changed, 7 insertions(+)
mm/hugetlb.c +7 -0
@@ -5488,6 +5488,13 @@ int huge_pmd_unshare(struct mm_struct *mreturn 0 ;pud_clear (pud); +/* +* Once our caller drops the rmap lock, some other process might be +* using this page table as a normal, non-hugetlb page table. +* Wait for pending gup_fast() in other threads to finish before letting +* that happen. +*/ +tlb_remove_table_sync_one ();atomic_dec (&virt_to_page (ptep)->pt_share_count);mm_dec_nr_pmds (mm);/*
Greg Kroah-Hartman
maintainerPATCH 301/355 erofs: remove unused trace event erofs_destroy_inode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Xiang <[email protected]>
commit 30b58444807c93bffeaba7d776110f2a909d2f9a upstream.
The trace event erofs_destroy_inode was added but remains unused. This unused event contributes approximately 5KB to the kernel module size.
--- include/trace/events/erofs.h | 18 ------------------ 1 file changed, 18 deletions(-)
include/trace/events/erofs.h +0 -18
@@ -235,24 +235,6 @@ DEFINE_EVENT(erofs__map_blocks_exit, z_eTP_ARGS (inode, map, flags, ret) ); -TRACE_EVENT (erofs_destroy_inode, - TP_PROTO(struct inode *inode), - -TP_ARGS (inode), - -TP_STRUCT__entry ( - __field( dev_t, dev ) -__field ( erofs_nid_t, nid ) - ), - -TP_fast_assign ( - __entry->dev = inode->i_sb->s_dev; - __entry->nid = EROFS_I(inode)->nid; - ), - -TP_printk ("dev = (%d,%d), nid = %llu" ,show_dev_nid (__entry)) -); -#endif /* _TRACE_EROFS_H */ /* This part must be outside protection */
Greg Kroah-Hartman
maintainerPATCH 302/355 drm/nouveau/bl: increase buffer size to avoid truncate warning
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Keller <[email protected]>
[ Upstream commit 61b2b3737499f1fb361a54a16828db24a8345e85 ]
The nouveau_get_backlight_name() function generates a unique name for the backlight interface, appending an id from 1 to 99 for all backlight devices after the first.
GCC 15 (and likely other compilers) produce the following -Wformat-truncation warning:
nouveau_backlight.c: In function ‘nouveau_backlight_init’:
nouveau_backlight.c:56:69: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 3 [-Werror=format-truncation=]
56 | snprintf(backlight_name, BL_NAME_SIZE, "nv_backlight%d", nb);
| ^~
In function ‘nouveau_get_backlight_name’,
inlined from ‘nouveau_backlight_init’ at nouveau_backlight.c:351:7:
nouveau_backlight.c:56:56: note: directive argument in the range [1, 2147483647]
56 | snprintf(backlight_name, BL_NAME_SIZE, "nv_backlight%d", nb);
| ^~~~~~~~~~~~~~~~
nouveau_backlight.c:56:17: note: ‘snprintf’ output between 14 and 23 bytes into a destination of size 15
56 | snprintf(backlight_name, BL_NAME_SIZE, "nv_backlight%d", nb);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The warning started appearing after commit ab244be47a8f ("drm/nouveau:
Fix a potential theorical leak in nouveau_get_backlight_name()") This fix for the ida usage removed the explicit value check for ids larger than 99. The compiler is unable to intuit that the ida_alloc_max() limits the returned value range between 0 and 99.
Because the compiler can no longer infer that the number ranges from 0 to 99, it thinks that it could use as many as 11 digits (10 + the potential - sign for negative numbers).
The warning has gone unfixed for some time, with at least one kernel test robot report. The code breaks W=1 builds, which is especially frustrating with the introduction of CONFIG_WERROR.
The string is stored temporarily on the stack and then copied into the device name. Its not a big deal to use 11 more bytes of stack rounding out to an even 24 bytes. Increase BL_NAME_SIZE to 24 to avoid the truncation warning. This fixes the W=1 builds that include this driver.
Compile tested only.
--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -1
@@ -40,7 +40,7 @@#include "nouveau_connector.h" static struct ida bl_ida; -#define BL_NAME_SIZE 15 // 12 for name + 2 for digits + 1 for '\0' +#define BL_NAME_SIZE 24 // 12 for name + 11 for digits + 1 for '\0'struct nouveau_backlight {struct backlight_device *dev;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 303/355 hwmon: (occ) Add new temperature sensor type
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eddie James <[email protected]>
[ Upstream commit db4919ec86ff405273a767e1a9b51e2760e73ce5 ]
The latest version of the On-Chip Controller (OCC) has a different format for the temperature sensor data. Add a new temperature sensor version to handle this data.
Stable-dep-of: 744c2fe950e9 ("hwmon: (occ) Rework attribute registration for stack usage")
--- drivers/hwmon/occ/common.c | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
drivers/hwmon/occ/common.c +75 -0
@@ -41,6 +41,14 @@ struct temp_sensor_2 {u8 value; } __packed; +struct temp_sensor_10 { +u32 sensor_id; +u8 fru_type; +u8 value; +u8 throttle; +u8 reserved; +} __packed; +struct freq_sensor_1 {u16 sensor_id;u16 value;
@@ -307,6 +315,60 @@ static ssize_t occ_show_temp_2(struct device *dev,return snprintf (buf,PAGE_SIZE -1 ,"%u\n" , val); } +static ssize_t occ_show_temp_10 (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int rc; +u32 val =0 ; +struct temp_sensor_10 *temp; +struct occ *occ =dev_get_drvdata (dev); +struct occ_sensors *sensors = &occ->sensors; +struct sensor_device_attribute_2 *sattr =to_sensor_dev_attr_2 (attr); + + rc =occ_update_response (occ); +if (rc) +return rc; + + temp = ((struct temp_sensor_10 *)sensors->temp.data) + sattr->index; + +switch (sattr->nr) { +case 0 : + val =get_unaligned_be32 (&temp->sensor_id); +break ; +case 1 : + val = temp->value; +if (val ==OCC_TEMP_SENSOR_FAULT ) +return -EREMOTEIO ; + +/* +* VRM doesn't return temperature, only alarm bit. This +* attribute maps to tempX_alarm instead of tempX_input for +* VRM +*/ +if (temp->fru_type !=OCC_FRU_TYPE_VRM ) { +/* sensor not ready */ +if (val ==0 ) +return -EAGAIN ; + + val *=1000 ; + } +break ; +case 2 : + val = temp->fru_type; +break ; +case 3 : + val = temp->value ==OCC_TEMP_SENSOR_FAULT ; +break ; +case 4 : + val = temp->throttle *1000 ; +break ; +default : +return -EINVAL ; + } + +return snprintf (buf,PAGE_SIZE -1 ,"%u\n" , val); +} +static ssize_t occ_show_freq_1 (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -745,6 +807,10 @@ static int occ_setup_sensor_attrs(struct occ *occ) num_attrs += (sensors->temp.num_sensors *4 ); show_temp = occ_show_temp_2;break ; +case 0x10 : + num_attrs += (sensors->temp.num_sensors *5 ); + show_temp = occ_show_temp_10; +break ;default : sensors->temp.num_sensors =0 ; }
@@ -844,6 +910,15 @@ static int occ_setup_sensor_attrs(struct occ *occ) attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_temp,NULL ,3 , i); attr++; + +if (sensors->temp.version ==0x10 ) { +snprintf (attr->name,sizeof (attr->name), +"temp%d_max" , s); + attr->sensor =OCC_INIT_ATTR (attr->name,0444 , + show_temp,NULL , +4 , i); + attr++; + } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 304/355 hwmon: (occ) Add soft minimum power cap attribute
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eddie James <[email protected]>
[ Upstream commit 84dc9e8a7eec2cdff00728baedf0fb35fc7c11e8 ]
Export the power caps data for the soft minimum power cap through hwmon.
Stable-dep-of: 744c2fe950e9 ("hwmon: (occ) Rework attribute registration for stack usage")
--- drivers/hwmon/occ/common.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/hwmon/occ/common.c +16 -3
@@ -685,6 +685,9 @@ static ssize_t occ_show_caps_3(struct device *dev,case 7 : val = caps->user_source;break ; +case 8 : + val =get_unaligned_be16 (&caps->soft_min) *1000000ULL ; +break ;default :return -EINVAL ; }
@@ -845,12 +848,13 @@ static int occ_setup_sensor_attrs(struct occ *occ)case 1 : num_attrs += (sensors->caps.num_sensors *7 );break ; -case 3 : - show_caps = occ_show_caps_3; - fallthrough;case 2 : num_attrs += (sensors->caps.num_sensors *8 );break ; +case 3 : + show_caps = occ_show_caps_3; + num_attrs += (sensors->caps.num_sensors *9 ); +break ;default : sensors->caps.num_sensors =0 ; }
@@ -1057,6 +1061,15 @@ static int occ_setup_sensor_attrs(struct occ *occ) attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL ,7 ,0 ); attr++; + +if (sensors->caps.version >2 ) { +snprintf (attr->name,sizeof (attr->name), +"power%d_cap_min_soft" , s); + attr->sensor =OCC_INIT_ATTR (attr->name,0444 , + show_caps,NULL , +8 ,0 ); + attr++; + } } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 305/355 hwmon: (occ) Rework attribute registration for stack usage
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 744c2fe950e936c4d62430de899d6253424200ed ]
clang produces an output with excessive stack usage when building the occ_setup_sensor_attrs() function, apparently the result of having a lot of struct literals and building with the -fno-strict-overflow option that leads clang to skip some optimization in case the 'attr' pointer overruns:
drivers/hwmon/occ/common.c:775:12: error: stack frame size (1392) exceeds limit (1280) in 'occ_setup_sensor_attrs' [-Werror,-Wframe-larger-than]
Replace the custom macros for initializing the attributes with a simpler function call that does not run into this corner case.
--- drivers/hwmon/occ/common.c | 212 +++++++++++++++---------------------- 1 file changed, 85 insertions(+), 127 deletions(-)
drivers/hwmon/occ/common.c +85 -127
@@ -759,29 +759,30 @@ static ssize_t occ_show_extended(struct device *dev, }/* -* Some helper macros to make it easier to define an occ_attribute. Since these -* are dynamically allocated, we shouldn't use the existing kernel macros which +* A helper to make it easier to define an occ_attribute. Since these +* are dynamically allocated, we cannot use the existing kernel macros which * stringify the name argument. */ -#define ATTR_OCC (_name, _mode, _show, _store) { \ - .attr = { \ - .name = _name, \ - .mode = VERIFY_OCTAL_PERMISSIONS(_mode), \ - }, \ - .show = _show, \ - .store = _store, \ -} - -#define SENSOR_ATTR_OCC (_name, _mode, _show, _store, _nr, _index) { \ - .dev_attr = ATTR_OCC(_name, _mode, _show, _store), \ - .index = _index, \ - .nr = _nr, \ +static void occ_init_attribute (struct occ_attribute *attr,int mode, +ssize_t (*show)(struct device *dev,struct device_attribute *attr,char *buf), +ssize_t (*store)(struct device *dev,struct device_attribute *attr, +const char *buf,size_t count), +int nr,int index,const char *fmt, ...) +{ +va_list args; + +va_start (args, fmt); +vsnprintf (attr->name,sizeof (attr->name), fmt, args); +va_end (args); + + attr->sensor.dev_attr.attr.name = attr->name; + attr->sensor.dev_attr.attr.mode = mode; + attr->sensor.dev_attr.show = show; + attr->sensor.dev_attr.store = store; + attr->sensor.index = index; + attr->sensor.nr = nr; } -#define OCC_INIT_ATTR (_name, _mode, _show, _store, _nr, _index) \ - ((struct sensor_device_attribute_2) \ - SENSOR_ATTR_OCC(_name, _mode, _show, _store, _nr, _index)) -/* * Allocate and instatiate sensor_device_attribute_2s. It's most efficient to * use our own instead of the built-in hwmon attribute types.
@@ -867,14 +868,15 @@ static int occ_setup_sensor_attrs(struct occ *occ) sensors->extended.num_sensors =0 ; } - occ->attrs =devm_kzalloc (dev,sizeof (*occ->attrs) * num_attrs, + occ->attrs =devm_kcalloc (dev, num_attrs,sizeof (*occ->attrs),GFP_KERNEL );if (!occ->attrs)return -ENOMEM ;/* null-terminated list */ - occ->group.attrs =devm_kzalloc (dev,sizeof (*occ->group.attrs) * - num_attrs +1 ,GFP_KERNEL ); + occ->group.attrs =devm_kcalloc (dev, num_attrs +1 , +sizeof (*occ->group.attrs), +GFP_KERNEL );if (!occ->group.attrs)return -ENOMEM ;
@@ -884,43 +886,33 @@ static int occ_setup_sensor_attrs(struct occ *occ) s = i +1 ; temp = ((struct temp_sensor_2 *)sensors->temp.data) + i; -snprintf (attr->name,sizeof (attr->name),"temp%d_label" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_temp,NULL , -0 , i); +occ_init_attribute (attr,0444 , show_temp,NULL , +0 , i,"temp%d_label" , s); attr++;if (sensors->temp.version >1 && temp->fru_type ==OCC_FRU_TYPE_VRM ) { -snprintf (attr->name,sizeof (attr->name), -"temp%d_alarm" , s); +occ_init_attribute (attr,0444 , show_temp,NULL , +1 , i,"temp%d_alarm" , s); }else { -snprintf (attr->name,sizeof (attr->name), -"temp%d_input" , s); +occ_init_attribute (attr,0444 , show_temp,NULL , +1 , i,"temp%d_input" , s); } - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_temp,NULL , -1 , i); attr++;if (sensors->temp.version >1 ) { -snprintf (attr->name,sizeof (attr->name), -"temp%d_fru_type" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_temp,NULL ,2 , i); +occ_init_attribute (attr,0444 , show_temp,NULL , +2 , i,"temp%d_fru_type" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"temp%d_fault" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_temp,NULL ,3 , i); +occ_init_attribute (attr,0444 , show_temp,NULL , +3 , i,"temp%d_fault" , s); attr++;if (sensors->temp.version ==0x10 ) { -snprintf (attr->name,sizeof (attr->name), -"temp%d_max" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_temp,NULL , -4 , i); +occ_init_attribute (attr,0444 , show_temp,NULL , +4 , i,"temp%d_max" , s); attr++; } }
@@ -929,14 +921,12 @@ static int occ_setup_sensor_attrs(struct occ *occ)for (i =0 ; i < sensors->freq.num_sensors; ++i) { s = i +1 ; -snprintf (attr->name,sizeof (attr->name),"freq%d_label" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_freq,NULL , -0 , i); +occ_init_attribute (attr,0444 , show_freq,NULL , +0 , i,"freq%d_label" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"freq%d_input" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_freq,NULL , -1 , i); +occ_init_attribute (attr,0444 , show_freq,NULL , +1 , i,"freq%d_input" , s); attr++; }
@@ -952,32 +942,24 @@ static int occ_setup_sensor_attrs(struct occ *occ) s = (i *4 ) +1 ;for (j =0 ; j <4 ; ++j) { -snprintf (attr->name,sizeof (attr->name), -"power%d_label" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL , - nr++, i); +occ_init_attribute (attr,0444 , show_power, +NULL , nr++, i, +"power%d_label" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_average" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL , - nr++, i); +occ_init_attribute (attr,0444 , show_power, +NULL , nr++, i, +"power%d_average" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_average_interval" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL , - nr++, i); +occ_init_attribute (attr,0444 , show_power, +NULL , nr++, i, +"power%d_average_interval" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_input" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL , - nr++, i); +occ_init_attribute (attr,0444 , show_power, +NULL , nr++, i, +"power%d_input" , s); attr++; s++;
@@ -989,28 +971,20 @@ static int occ_setup_sensor_attrs(struct occ *occ)for (i =0 ; i < sensors->power.num_sensors; ++i) { s = i +1 ; -snprintf (attr->name,sizeof (attr->name), -"power%d_label" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL ,0 , i); +occ_init_attribute (attr,0444 , show_power,NULL , +0 , i,"power%d_label" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_average" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL ,1 , i); +occ_init_attribute (attr,0444 , show_power,NULL , +1 , i,"power%d_average" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_average_interval" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL ,2 , i); +occ_init_attribute (attr,0444 , show_power,NULL , +2 , i,"power%d_average_interval" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_input" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_power,NULL ,3 , i); +occ_init_attribute (attr,0444 , show_power,NULL , +3 , i,"power%d_input" , s); attr++; }
@@ -1018,56 +992,43 @@ static int occ_setup_sensor_attrs(struct occ *occ) }if (sensors->caps.num_sensors >=1 ) { -snprintf (attr->name,sizeof (attr->name),"power%d_label" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL , -0 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +0 ,0 ,"power%d_label" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"power%d_cap" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL , -1 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +1 ,0 ,"power%d_cap" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"power%d_input" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL , -2 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +2 ,0 ,"power%d_input" , s); attr++; -snprintf (attr->name,sizeof (attr->name), -"power%d_cap_not_redundant" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL , -3 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +3 ,0 ,"power%d_cap_not_redundant" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"power%d_cap_max" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL , -4 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +4 ,0 ,"power%d_cap_max" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"power%d_cap_min" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , show_caps,NULL , -5 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +5 ,0 ,"power%d_cap_min" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"power%d_cap_user" , - s); - attr->sensor =OCC_INIT_ATTR (attr->name,0644 , show_caps, - occ_store_caps_user,6 ,0 ); +occ_init_attribute (attr,0644 , show_caps, occ_store_caps_user, +6 ,0 ,"power%d_cap_user" , s); attr++;if (sensors->caps.version >1 ) { -snprintf (attr->name,sizeof (attr->name), -"power%d_cap_user_source" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_caps,NULL ,7 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +7 ,0 ,"power%d_cap_user_source" , s); attr++;if (sensors->caps.version >2 ) { -snprintf (attr->name,sizeof (attr->name), -"power%d_cap_min_soft" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - show_caps,NULL , -8 ,0 ); +occ_init_attribute (attr,0444 , show_caps,NULL , +8 ,0 , +"power%d_cap_min_soft" , s); attr++; } }
@@ -1076,19 +1037,16 @@ static int occ_setup_sensor_attrs(struct occ *occ)for (i =0 ; i < sensors->extended.num_sensors; ++i) { s = i +1 ; -snprintf (attr->name,sizeof (attr->name),"extn%d_label" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - occ_show_extended,NULL ,0 , i); +occ_init_attribute (attr,0444 , occ_show_extended,NULL , +0 , i,"extn%d_label" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"extn%d_flags" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - occ_show_extended,NULL ,1 , i); +occ_init_attribute (attr,0444 , occ_show_extended,NULL , +1 , i,"extn%d_flags" , s); attr++; -snprintf (attr->name,sizeof (attr->name),"extn%d_input" , s); - attr->sensor =OCC_INIT_ATTR (attr->name,0444 , - occ_show_extended,NULL ,2 , i); +occ_init_attribute (attr,0444 , occ_show_extended,NULL , +2 , i,"extn%d_input" , s); attr++; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 306/355 hwmon: (occ) fix unaligned accesses
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 2c021b45c154958566aad0cae9f74ab26a2d5732 ]
Passing a pointer to an unaligned integer as a function argument is undefined behavior:
drivers/hwmon/occ/common.c:492:27: warning: taking address of packed member 'accumulator' of class or structure 'power_sensor_2' may result in an unaligned pointer value [-Waddress-of-packed-member]
492 | val = occ_get_powr_avg(&power->accumulator,
| ^~~~~~~~~~~~~~~~~~
drivers/hwmon/occ/common.c:493:13: warning: taking address of packed member 'update_tag' of class or structure 'power_sensor_2' may result in an unaligned pointer value [-Waddress-of-packed-member]
493 | &power->update_tag);
| ^~~~~~~~~~~~~~~~~Move the get_unaligned() calls out of the function and pass these through argument registers instead.
--- drivers/hwmon/occ/common.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/hwmon/occ/common.c +13 -15
@@ -468,12 +468,10 @@ static ssize_t occ_show_power_1(struct device *dev,return snprintf (buf,PAGE_SIZE -1 ,"%llu\n" , val); } -static u64 occ_get_powr_avg (u64 *accum,u32 *samples) +static u64 occ_get_powr_avg (u64 accum,u32 samples) { -u64 divisor =get_unaligned_be32 (samples); - -return (divisor ==0 ) ?0 : -div64_u64 (get_unaligned_be64 (accum) *1000000ULL , divisor); +return (samples ==0 ) ?0 : +mul_u64_u32_div (accum,1000000UL , samples); } static ssize_t occ_show_power_2(struct device *dev,
@@ -498,8 +496,8 @@ static ssize_t occ_show_power_2(struct device *dev,get_unaligned_be32 (&power->sensor_id), power->function_id, power->apss_channel);case 1 : - val =occ_get_powr_avg (&power->accumulator, - &power->update_tag); + val =occ_get_powr_avg (get_unaligned_be64 (&power->accumulator), +get_unaligned_be32 (&power->update_tag));break ;case 2 : val = (u64)get_unaligned_be32(&power->update_tag) *
@@ -536,8 +534,8 @@ static ssize_t occ_show_power_a0(struct device *dev,return snprintf (buf,PAGE_SIZE -1 ,"%u_system\n" ,get_unaligned_be32 (&power->sensor_id));case 1 : - val =occ_get_powr_avg (&power->system.accumulator, - &power->system.update_tag); + val =occ_get_powr_avg (get_unaligned_be64 (&power->system.accumulator), +get_unaligned_be32 (&power->system.update_tag));break ;case 2 : val = (u64)get_unaligned_be32(&power->system.update_tag) *
@@ -550,8 +548,8 @@ static ssize_t occ_show_power_a0(struct device *dev,return snprintf (buf,PAGE_SIZE -1 ,"%u_proc\n" ,get_unaligned_be32 (&power->sensor_id));case 5 : - val =occ_get_powr_avg (&power->proc.accumulator, - &power->proc.update_tag); + val =occ_get_powr_avg (get_unaligned_be64 (&power->proc.accumulator), +get_unaligned_be32 (&power->proc.update_tag));break ;case 6 : val = (u64)get_unaligned_be32(&power->proc.update_tag) *
@@ -564,8 +562,8 @@ static ssize_t occ_show_power_a0(struct device *dev,return snprintf (buf,PAGE_SIZE -1 ,"%u_vdd\n" ,get_unaligned_be32 (&power->sensor_id));case 9 : - val =occ_get_powr_avg (&power->vdd.accumulator, - &power->vdd.update_tag); + val =occ_get_powr_avg (get_unaligned_be64 (&power->vdd.accumulator), +get_unaligned_be32 (&power->vdd.update_tag));break ;case 10 : val = (u64)get_unaligned_be32(&power->vdd.update_tag) *
@@ -578,8 +576,8 @@ static ssize_t occ_show_power_a0(struct device *dev,return snprintf (buf,PAGE_SIZE -1 ,"%u_vdn\n" ,get_unaligned_be32 (&power->sensor_id));case 13 : - val =occ_get_powr_avg (&power->vdn.accumulator, - &power->vdn.update_tag); + val =occ_get_powr_avg (get_unaligned_be64 (&power->vdn.accumulator), +get_unaligned_be32 (&power->vdn.update_tag));break ;case 14 : val = (u64)get_unaligned_be32(&power->vdn.update_tag) *
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 307/355 pldmfw: Select CRC32 when PLDMFW is selected
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit 1224b218a4b9203656ecc932152f4c81a97b4fcc ]
pldmfw calls crc32 code and depends on it being enabled, else there is a link error as follows. So PLDMFW should select CRC32.
lib/pldmfw/pldmfw.o: In function `pldmfw_flash_image':
pldmfw.c:(.text+0x70f): undefined reference to `crc32_le_base'
This problem was introduced by commit b8265621f488 ("Add pldmfw library for PLDM firmware update").
It manifests as of commit d69ea414c9b4 ("ice: implement device flash update via devlink").
And is more likely to occur as of commit 9ad19171b6d6 ("lib/crc: remove unnecessary prompt for CONFIG_CRC32 and drop 'default y'").
Found by chance while exercising builds based on tinyconfig.
--- lib/Kconfig | 1 + 1 file changed, 1 insertion(+)
lib/Kconfig +1 -0
@@ -692,4 +692,5 @@ config GENERIC_LIB_UCMPDI2 config PLDMFW bool + select CRC32 default n
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 308/355 aoe: clean device rq_list in aoedev_downdev()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Sanders <[email protected]>
[ Upstream commit 7f90d45e57cb2ef1f0adcaf925ddffdfc5e680ca ]
An aoe device's rq_list contains accepted block requests that are waiting to be transmitted to the aoe target. This queue was added as part of the conversion to blk_mq. However, the queue was not cleaned out when an aoe device is downed which caused blk_mq_freeze_queue() to sleep indefinitely waiting for those requests to complete, causing a hang. This fix cleans out the queue before calling blk_mq_freeze_queue().
--- drivers/block/aoe/aoedev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/block/aoe/aoedev.c +8 -0
@@ -198,6 +198,7 @@ aoedev_downdev(struct aoedev *d) {struct aoetgt *t, **tt, **te;struct list_head *head, *pos, *nx; +struct request *rq, *rqnext;int i; d->flags &= ~DEVFL_UP ;
@@ -223,6 +224,13 @@ aoedev_downdev(struct aoedev *d)/* clean out the in-process request (if any) */ aoe_failip (d); +/* clean out any queued block requests */ +list_for_each_entry_safe (rq, rqnext, &d->rq_list, queuelist) { +list_del_init (&rq->queuelist); +blk_mq_start_request (rq); +blk_mq_end_request (rq,BLK_STS_IOERR ); + } +/* fast fail all pending I/O */ if (d->blkq) {/* UP is cleared, freeze+quiesce to insure all are errored */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 309/355 net: ice: Perform accurate aRFS flow match
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Kumar <[email protected]>
[ Upstream commit 5d3bc9e5e725aa36cca9b794e340057feb6880b4 ]
This patch fixes an issue seen in a large-scale deployment under heavy incoming pkts where the aRFS flow wrongly matches a flow and reprograms the NIC with wrong settings. That mis-steering causes RX-path latency spikes and noisy neighbor effects when many connections collide on the same hash (some of our production servers have 20-30K connections).
set_rps_cpu() calls ndo_rx_flow_steer() with flow_id that is calculated by hashing the skb sized by the per rx-queue table size. This results in multiple connections (even across different rx-queues) getting the same hash value. The driver steer function modifies the wrong flow to use this rx-queue, e.g.: Flow#1 is first added:
Flow#1: <ip1, port1, ip2, port2>, Hash 'h', q#10
Later when a new flow needs to be added:
Flow#2: <ip3, port3, ip4, port4>, Hash 'h', q#20
The driver finds the hash 'h' from Flow#1 and updates it to use q#20. This results in both flows getting un-optimized - packets for Flow#1 goes to q#20, and then reprogrammed back to q#10 later and so on; and Flow #2 programming is never done as Flow#1 is matched first for all misses. Many flows may wrongly share the same hash and reprogram rules of the original flow each with their own q#.
Tested on two 144-core servers with 16K netperf sessions for 180s. Netperf clients are pinned to cores 0-71 sequentially (so that wrong packets on q#s 72-143 can be measured). IRQs are set 1:1 for queues -> CPUs, enable XPS, enable aRFS (global value is 144 * rps_flow_cnt).
Test notes about results from ice_rx_flow_steer():
---------------------------------------------------
1. "Skip:" counter increments here:
if (fltr_info->q_index == rxq_idx ||
arfs_entry->fltr_state != ICE_ARFS_ACTIVE)
goto out;
2. "Add:" counter increments here:
ret = arfs_entry->fltr_info.fltr_id;
INIT_HLIST_NODE(&arfs_entry->list_entry);
3. "Update:" counter increments here:
/* update the queue to forward to on an already existing flow */Runtime comparison: original code vs with the patch for different rps_flow_cnt values.
+-------------------------------+--------------+--------------+ | rps_flow_cnt | 512 | 2048 | +-------------------------------+--------------+--------------+ | Ratio of Pkts on Good:Bad q's | 214 vs 822K | 1.1M vs 980K | | Avoid wrong aRFS programming | 0 vs 310K | 0 vs 30K | | CPU User | 216 vs 183 | 216 vs 206 | | CPU System | 1441 vs 1171 | 1447 vs 1320 | | CPU Softirq | 1245 vs 920 | 1238 vs 961 | | CPU Total | 29 vs 22.7 | 29 vs 24.9 | | aRFS Update | 533K vs 59 | 521K vs 32 | | aRFS Skip | 82M vs 77M | 7.2M vs 4.5M | +-------------------------------+--------------+--------------+
A separate TCP_STREAM and TCP_RR with 1,4,8,16,64,128,256,512 connections showed no performance degradation.
Some points on the patch/aRFS behavior:
1. Enabling full tuple matching ensures flows are always correctly matched, even with smaller hash sizes.
2. 5-6% drop in CPU utilization as the packets arrive at the correct CPUs and fewer calls to driver for programming on misses.
3. Larger hash tables reduces mis-steering due to more unique flow hashes, but still has clashes. However, with larger per-device rps_flow_cnt, old flows take more time to expire and new aRFS flows cannot be added if h/w limits are reached (rps_may_expire_flow() succeeds when 10*rps_flow_cnt pkts have been processed by this cpu that are not part of the flow).
--- drivers/net/ethernet/intel/ice/ice_arfs.c | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+)
drivers/net/ethernet/intel/ice/ice_arfs.c +48 -0
@@ -376,6 +376,50 @@ ice_arfs_is_perfect_flow_set(struct ice_hw *hw, __be16 l3_proto, u8 l4_proto)return false; } +/** +* ice_arfs_cmp - Check if aRFS filter matches this flow. +* @fltr_info: filter info of the saved ARFS entry. +* @fk: flow dissector keys. +* @n_proto: One of htons(ETH_P_IP) or htons(ETH_P_IPV6). +* @ip_proto: One of IPPROTO_TCP or IPPROTO_UDP. +* +* Since this function assumes limited values for n_proto and ip_proto, it +* is meant to be called only from ice_rx_flow_steer(). +* +* Return: +* * true - fltr_info refers to the same flow as fk. +* * false - fltr_info and fk refer to different flows. +*/ +static bool +ice_arfs_cmp (const struct ice_fdir_fltr *fltr_info,const struct flow_keys *fk, +__be16 n_proto,u8 ip_proto) +{ +/* Determine if the filter is for IPv4 or IPv6 based on flow_type, +* which is one of ICE_FLTR_PTYPE_NONF_IPV{4,6}_{TCP,UDP}. +*/ +bool is_v4 = fltr_info->flow_type ==ICE_FLTR_PTYPE_NONF_IPV4_TCP || + fltr_info->flow_type ==ICE_FLTR_PTYPE_NONF_IPV4_UDP ; + +/* Following checks are arranged in the quickest and most discriminative +* fields first for early failure. +*/ +if (is_v4) +return n_proto ==htons (ETH_P_IP ) && + fltr_info->ip.v4.src_port == fk->ports.src && + fltr_info->ip.v4.dst_port == fk->ports.dst && + fltr_info->ip.v4.src_ip == fk->addrs.v4addrs.src && + fltr_info->ip.v4.dst_ip == fk->addrs.v4addrs.dst && + fltr_info->ip.v4.proto == ip_proto; + +return fltr_info->ip.v6.src_port == fk->ports.src && + fltr_info->ip.v6.dst_port == fk->ports.dst && + fltr_info->ip.v6.proto == ip_proto && + !memcmp (&fltr_info->ip.v6.src_ip, &fk->addrs.v6addrs.src, +sizeof (struct in6_addr )) && + !memcmp (&fltr_info->ip.v6.dst_ip, &fk->addrs.v6addrs.dst, +sizeof (struct in6_addr )); +} +/** * ice_rx_flow_steer - steer the Rx flow to where application is being run * @netdev: ptr to the netdev being adjusted
@@ -447,6 +491,10 @@ ice_rx_flow_steer(struct net_device *netdev, const struct sk_buff *skb,continue ; fltr_info = &arfs_entry->fltr_info; + +if (!ice_arfs_cmp (fltr_info, &fk, n_proto, ip_proto)) +continue ; + ret = fltr_info->fltr_id; if (fltr_info->q_index == rxq_idx ||
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 310/355 wifi: carl9170: do not ping device which has failed to load firmware
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Antipov <[email protected]>
[ Upstream commit 15d25307692312cec4b57052da73387f91a2e870 ]
Syzkaller reports [1, 2] crashes caused by an attempts to ping the device which has failed to load firmware. Since such a device doesn't pass 'ieee80211_register_hw()', an internal workqueue managed by 'ieee80211_queue_work()' is not yet created and an attempt to queue work on it causes null-ptr-deref.
[1] https://syzkaller.appspot.com/bug?extid=9a4aec827829942045ff
[2] https://syzkaller.appspot.com/bug?extid=0d8afba53e8fb2633217
--- drivers/net/wireless/ath/carl9170/usb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/carl9170/usb.c +13 -6
@@ -438,14 +438,21 @@ static void carl9170_usb_rx_complete(struct urb *urb)if (atomic_read (&ar->rx_anch_urbs) ==0 ) {/* -* The system is too slow to cope with -* the enormous workload. We have simply -* run out of active rx urbs and this -* unfortunately leads to an unpredictable -* device. +* At this point, either the system is too slow to +* cope with the enormous workload (so we have simply +* run out of active rx urbs and this unfortunately +* leads to an unpredictable device), or the device +* is not fully functional after an unsuccessful +* firmware loading attempts (so it doesn't pass +* ieee80211_register_hw() and there is no internal +* workqueue at all). */ -ieee80211_queue_work (ar->hw, &ar->ping_work); +if (ar->registered) +ieee80211_queue_work (ar->hw, &ar->ping_work); +else +pr_warn_once ("device %s is not registered\n" , +dev_name (&ar->udev->dev)); } }else {/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 311/355 mpls: Use rcu_dereference_rtnl() in mpls_route_input_rcu().
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 6dbb0d97c5096072c78a6abffe393584e57ae945 ]
As syzbot reported [0], mpls_route_input_rcu() can be called from mpls_getroute(), where is under RTNL.
net->mpls.platform_label is only updated under RTNL.
Let's use rcu_dereference_rtnl() in mpls_route_input_rcu() to silence the splat.
[0]:
WARNING: suspicious RCU usage 6.15.0-rc7-syzkaller-00082-g5cdb2c77c4c3 #0 Not tainted
----------------------------net/mpls/af_mpls.c:84 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz.2.4451/17730:
#0: ffffffff9012a3e8 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_lock net/core/rtnetlink.c:80 [inline] #0: ffffffff9012a3e8 (rtnl_mutex){+.+.}-{4:4}, at: rtnetlink_rcv_msg+0x371/0xe90 net/core/rtnetlink.c:6961
stack backtrace: CPU: 1 UID: 0 PID: 17730 Comm: syz.2.4451 Not tainted 6.15.0-rc7-syzkaller-00082-g5cdb2c77c4c3 #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x16c/0x1f0 lib/dump_stack.c:120 lockdep_rcu_suspicious+0x166/0x260 kernel/locking/lockdep.c:6865 mpls_route_input_rcu+0x1d4/0x200 net/mpls/af_mpls.c:84 mpls_getroute+0x621/0x1ea0 net/mpls/af_mpls.c:2381 rtnetlink_rcv_msg+0x3c9/0xe90 net/core/rtnetlink.c:6964 netlink_rcv_skb+0x16d/0x440 net/netlink/af_netlink.c:2534 netlink_unicast_kernel net/netlink/af_netlink.c:1313 [inline] netlink_unicast+0x53a/0x7f0 net/netlink/af_netlink.c:1339 netlink_sendmsg+0x8d1/0xdd0 net/netlink/af_netlink.c:1883 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg net/socket.c:727 [inline] ____sys_sendmsg+0xa98/0xc70 net/socket.c:2566 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2620 __sys_sendmmsg+0x200/0x420 net/socket.c:2709 __do_sys_sendmmsg net/socket.c:2736 [inline] __se_sys_sendmmsg net/socket.c:2733 [inline] __x64_sys_sendmmsg+0x9c/0x100 net/socket.c:2733 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x230 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f0a2818e969 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f0a28f52038 EFLAGS: 00000246 ORIG_RAX: 0000000000000133 RAX: ffffffffffffffda RBX: 00007f0a283b5fa0 RCX: 00007f0a2818e969 RDX: 0000000000000003 RSI: 0000200000000080 RDI: 0000000000000003 RBP: 00007f0a28210ab1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f0a283b5fa0 R15: 00007ffce5e9f268 </TASK>
--- net/mpls/af_mpls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mpls/af_mpls.c +2 -2
@@ -80,8 +80,8 @@ static struct mpls_route *mpls_route_input_rcu(struct net *net, unsigned index)if (index < net->mpls.platform_labels) {struct mpls_route __rcu **platform_label = -rcu_dereference (net->mpls.platform_label); - rt =rcu_dereference (platform_label[index]); +rcu_dereference_rtnl (net->mpls.platform_label); + rt =rcu_dereference_rtnl (platform_label[index]); }return rt; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 312/355 atm: atmtcp: Free invalid length skb in atmtcp_c_send().
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 2f370ae1fb6317985f3497b1bb80d457508ca2f7 ]
syzbot reported the splat below. [0]
vcc_sendmsg() copies data passed from userspace to skb and passes it to vcc->dev->ops->send().
atmtcp_c_send() accesses skb->data as struct atmtcp_hdr after checking if skb->len is 0, but it's not enough.
Also, when skb->len == 0, skb and sk (vcc) were leaked because dev_kfree_skb() is not called and sk_wmem_alloc adjustment is missing to revert atm_account_tx() in vcc_sendmsg(), which is expected to be done in atm_pop_raw().
Let's properly free skb with an invalid length in atmtcp_c_send().
[0]:
BUG: KMSAN: uninit-value in atmtcp_c_send+0x255/0xed0 drivers/atm/atmtcp.c:294 atmtcp_c_send+0x255/0xed0 drivers/atm/atmtcp.c:294 vcc_sendmsg+0xd7c/0xff0 net/atm/common.c:644 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg+0x330/0x3d0 net/socket.c:727 ____sys_sendmsg+0x7e0/0xd80 net/socket.c:2566 ___sys_sendmsg+0x271/0x3b0 net/socket.c:2620 __sys_sendmsg net/socket.c:2652 [inline] __do_sys_sendmsg net/socket.c:2657 [inline] __se_sys_sendmsg net/socket.c:2655 [inline] __x64_sys_sendmsg+0x211/0x3e0 net/socket.c:2655 x64_sys_call+0x32fb/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was created at:
slab_post_alloc_hook mm/slub.c:4154 [inline] slab_alloc_node mm/slub.c:4197 [inline] kmem_cache_alloc_node_noprof+0x818/0xf00 mm/slub.c:4249 kmalloc_reserve+0x13c/0x4b0 net/core/skbuff.c:579 __alloc_skb+0x347/0x7d0 net/core/skbuff.c:670 alloc_skb include/linux/skbuff.h:1336 [inline] vcc_sendmsg+0xb40/0xff0 net/atm/common.c:628 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg+0x330/0x3d0 net/socket.c:727 ____sys_sendmsg+0x7e0/0xd80 net/socket.c:2566 ___sys_sendmsg+0x271/0x3b0 net/socket.c:2620 __sys_sendmsg net/socket.c:2652 [inline] __do_sys_sendmsg net/socket.c:2657 [inline] __se_sys_sendmsg net/socket.c:2655 [inline] __x64_sys_sendmsg+0x211/0x3e0 net/socket.c:2655 x64_sys_call+0x32fb/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f CPU: 1 UID: 0 PID: 5798 Comm: syz-executor192 Not tainted 6.16.0-rc1-syzkaller-00010-g2c4a1f3fe03e #0 PREEMPT(undef) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
--- drivers/atm/atmtcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/atm/atmtcp.c +3 -1
@@ -288,7 +288,9 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)struct sk_buff *new_skb;int result =0 ; -if (!skb->len)return 0 ; +if (skb->len <sizeof (struct atmtcp_hdr )) + goto done; + dev = vcc->dev_data; hdr = (struct atmtcp_hdr *) skb->data;if (hdr->length ==ATMTCP_HDR_MAGIC ) {
Signature · 1 line
2.39.5