Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error linking kernel/futex.o #325

Closed
nathanchance opened this issue Jan 23, 2019 · 18 comments
Closed

Error linking kernel/futex.o #325

nathanchance opened this issue Jan 23, 2019 · 18 comments
Assignees
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] linux A bug that should be fixed in the mainline kernel. [CONFIG] allyesconfig Issue affects allyesconfig on certain architectures [FIXED][LINUX] 5.15 This bug was fixed in Linux 5.15

Comments

@nathanchance
Copy link
Member

I was going to resend the patch that fixes #287 but as I was trying to come up with some testing steps for people, I ran into this error with an arm allyesconfig build (little endian):

arm-linux-gnueabi-ld: kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
make[2]: *** [/linux-next/Makefile:1021: vmlinux] Error 1
make[1]: *** [/linux-next/Makefile:296: __build_one_by_one] Error 2

I need the following patches to avoid other link/build errors:

It doesn't appear to be a kernel regression because it goes all the way back to v4.19 which I know I had building with ld.bfd but I switched to ld.lld a few weeks ago and have had no issues with linking since then.

Unfortunately, I don't have time today to try and see if LLVM or binutils is the issue (even with the new server I am renting with a Ryzen 7, it takes 15-20 minutes a build clean), hence opening this issue. I've been reproducing in our Docker container (to eliminate any environment related issues) with the following commands:

git clone -b arm-link-fail-v5.0 git://github.com/nathanchance/linux

cd linux

docker run --interactive --mount type=bind,source="${PWD}",target=/"$(basename "${PWD}")",readonly --rm --tty --workdir /"$(basename "${PWD}")" clangbuiltlinux/ubuntu

cat <<EOF > /build.sh
rm -rf /out && mkdir -p /out

echo "CONFIG_CPU_BIG_ENDIAN=n" >> /out/le.config

time make -j"$(nproc --all)" ARCH=arm CC="ccache clang-9" HOSTCC="ccache clang-9" CROSS_COMPILE=arm-linux-gnueabi- KCONFIG_ALLCONFIG=/out/le.config O=/out allyesconfig vmlinux
EOF

bash /build.sh

binutils has never been upgraded in our Docker container so it seems unlikely that it is the cause of the regression, making it look like Clang is probably the issue. Will keep the issue updated with my findings.

@nathanchance nathanchance added [BUG] Untriaged Something isn't working [ARCH] arm32 This bug impacts ARCH=arm labels Jan 23, 2019
@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jan 23, 2019 via email

@nickdesaulniers
Copy link
Member

It doesn't appear to be a kernel regression because it goes all the way back to v4.19 which I know I had building with ld.bfd but I switched to ld.lld a few weeks ago and have had no issues with linking since then.

Were those allyesconfig's though? Maybe a new config got added that broke this?

@smithp35
Copy link

I can't see a smoking gun with either clang or gcc right now.

That particular error message is coming from a bit of inline assembly in futex.h
#define __futex_atomic_ex_table(err_reg)
"3:\n"
" .pushsection __ex_table,"a"\n"
" .align 3\n"
" .long 1b, 4f, 2b, 4f\n"
" .popsection\n"
" .pushsection .text.fixup,"ax"\n"
" .align 2\n"
"4: mov %0, " err_reg "\n"
" b 3b\n"
" .popsection"

clang (integrated-as) will define a .Ltmp0 symbol for 3: and hence the B 3b is represented as an R_ARM_JUMP24 to .Ltmp0. This seems fine to me and shouldn't be a problem for a linker to extend the range with a stub if .text.fixup is placed a long way away from .Ltmp0.

clang (-fno-integrated-as) and gcc (I'm using 5.4) encode 3: differently. They use the section symbol for .Ltmp0 + addend (where addend is encoded in the immediate field of the branch). This looks like it is handled correctly by the ld.bfd stub generation code. To be honest I don't think that LLD will handle this in all cases as a branch to a section symbol + offset is extremely rare, particularly in Arm as it does not support ARM/Thumb interworking.

From bitter experience a lot of stub generating bugs can be latent for years, it only takes the contents of a few sections to move a bit and something can go from being clearly out of range to only just out of range to trigger a subtle bug.

@smithp35
Copy link

smithp35 commented Jan 24, 2019

I've raised https://llvm.org/pr40438 to cover LLD not including the addend when measuring range to branch + symbol + addend. The probability of a relocation out of range error is small as we would need source of relocation < (symbol + addend), and (symbol - source) < addend.

@nathanchance
Copy link
Member Author

Were those allyesconfig's though?

Yes.

I realized that I have never actually tested mainline continuously (I only test -next) so I went back to next-20181210 because that's when I first started building arm allyesconfig (commit) and applied the patches listed in the first comment (plus a few others needed to fix errors along the way, all of which ended up in mainline) and sure enough, it builds and links successfully. I went ahead and started walking forward and was able to build successfully on next-20181224 but not on next-20190102 (the following next version since Stephen took the next week off). next-20181224 was based on v4.20-rc7 so I went ahead and started bisecting. As it turns out...

git bisect start '--term-new=fixed' '--term-old=unfixed'
# fixed: [6a1d293238c1774cef23c25b5188b0c134c29a34] Add linux-next specific files for 20181224
git bisect fixed 6a1d293238c1774cef23c25b5188b0c134c29a34
# unfixed: [7566ec393f4161572ba6f11ad5171fd5d59b0fbd] Linux 4.20-rc7
git bisect unfixed 7566ec393f4161572ba6f11ad5171fd5d59b0fbd
# fixed: [c8487f62082d0acc3faae807339650e9a5dd7ecf] Merge remote-tracking branch 'mtd/mtd/next'
git bisect fixed c8487f62082d0acc3faae807339650e9a5dd7ecf
# fixed: [2c04e516a0eab28f3027308c4e0576c6b0fe6196] Merge remote-tracking branch 'pstore/for-next/pstore'
git bisect fixed 2c04e516a0eab28f3027308c4e0576c6b0fe6196
# fixed: [cb604541bd60b80ab514d0de99d08b6f1f5a3218] Merge remote-tracking branch 'arm-soc/for-next'
git bisect fixed cb604541bd60b80ab514d0de99d08b6f1f5a3218
# unfixed: [e2e2dcf6f40b0777185c20ca84e6388923a55df8] ARM: Document merges
git bisect unfixed e2e2dcf6f40b0777185c20ca84e6388923a55df8
# unfixed: [48a8e49987d9a119dadd620b89da099a12624e3d] Merge remote-tracking branch 'hyperv-fixes/hyperv-fixes'
git bisect unfixed 48a8e49987d9a119dadd620b89da099a12624e3d
# fixed: [a902309d44036699130ba2b9a603db68cc0808a3] Merge remote-tracking branch 'arm/for-next'
git bisect fixed a902309d44036699130ba2b9a603db68cc0808a3
# fixed: [9cc5b4676d0c2ae34c15edba8e9060b8b08028ac] Merge remote-tracking branch 'leaks/leaks-next'
git bisect fixed 9cc5b4676d0c2ae34c15edba8e9060b8b08028ac
# unfixed: [11fda148040bb987949f9b957aceb483407e32cb] kbuild: remove $(obj)/ prefixes in ./Kbuild
git bisect unfixed 11fda148040bb987949f9b957aceb483407e32cb
# unfixed: [2f8967f21a18a8e520a9d17bde204e3b4f164724] kconfig: split the lexer out of zconf.y
git bisect unfixed 2f8967f21a18a8e520a9d17bde204e3b4f164724
# unfixed: [9f84a0f7f1a613335a9aaf0abd5858906752bf93] leaking_addresses: check if file name contains address
git bisect unfixed 9f84a0f7f1a613335a9aaf0abd5858906752bf93
# unfixed: [5cfc879caee810828d90aec808d85560f34f02af] pcmcia: remove per-arch PCMCIA config entry
git bisect unfixed 5cfc879caee810828d90aec808d85560f34f02af
# fixed: [5cd6239506cb97fb00c5992c1adaf6f9f788c5f2] kernel hacking: support building kernel with -Og optimization level
git bisect fixed 5cd6239506cb97fb00c5992c1adaf6f9f788c5f2
# unfixed: [892a5210d8977d1b805aaaceb548c0ff72329494] openrisc: make function cache_loop() inline
git bisect unfixed 892a5210d8977d1b805aaaceb548c0ff72329494
# fixed: [eb14ab6c93199e7cc0186482dba0769c01c06e35] ARM: mm: fix build error in fix_to_virt with -Og optimization level
git bisect fixed eb14ab6c93199e7cc0186482dba0769c01c06e35
# fixed: [13d2598cc964173bb063cffda9de778a89cdcfcd] kernel hacking: add a config option to disable compiler auto-inlining
git bisect fixed 13d2598cc964173bb063cffda9de778a89cdcfcd
# first fixed commit: [13d2598cc964173bb063cffda9de778a89cdcfcd] kernel hacking: add a config option to disable compiler auto-inlining

CONFIG_NO_AUTO_INLINE was "fixing" it and I never noticed because it was always there when building allyesconfig. However, it didn't make it into 5.0-rc1 then Masahiro dropped it from his tree.

If I mark futex_atomic_cmpxchg_inatomic as noinline like so, the kernel successfully links with ld.bfd:

diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
index 0a46676b4245..1d723584addc 100644
--- a/arch/arm/include/asm/futex.h
+++ b/arch/arm/include/asm/futex.h
@@ -42,7 +42,7 @@
        uaccess_restore(__ua_flags);                            \
 })

-static inline int
+static noinline int
 futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
                              u32 oldval, u32 newval)
 {

Note: ld.lld works just fine, even without that diff.

nathanchance pushed a commit that referenced this issue Oct 13, 2019
…s locked down")

Running the latest kernel through my "make instances" stress tests, I
triggered the following bug (with KASAN and kmemleak enabled):

mkdir invoked oom-killer:
gfp_mask=0x40cd0(GFP_KERNEL|__GFP_COMP|__GFP_RECLAIMABLE), order=0,
oom_score_adj=0
CPU: 1 PID: 2229 Comm: mkdir Not tainted 5.4.0-rc2-test #325
Hardware name: MSI MS-7823/CSM-H87M-G43 (MS-7823), BIOS V1.6 02/22/2014
Call Trace:
 dump_stack+0x64/0x8c
 dump_header+0x43/0x3b7
 ? trace_hardirqs_on+0x48/0x4a
 oom_kill_process+0x68/0x2d5
 out_of_memory+0x2aa/0x2d0
 __alloc_pages_nodemask+0x96d/0xb67
 __alloc_pages_node+0x19/0x1e
 alloc_slab_page+0x17/0x45
 new_slab+0xd0/0x234
 ___slab_alloc.constprop.86+0x18f/0x336
 ? alloc_inode+0x2c/0x74
 ? irq_trace+0x12/0x1e
 ? tracer_hardirqs_off+0x1d/0xd7
 ? __slab_alloc.constprop.85+0x21/0x53
 __slab_alloc.constprop.85+0x31/0x53
 ? __slab_alloc.constprop.85+0x31/0x53
 ? alloc_inode+0x2c/0x74
 kmem_cache_alloc+0x50/0x179
 ? alloc_inode+0x2c/0x74
 alloc_inode+0x2c/0x74
 new_inode_pseudo+0xf/0x48
 new_inode+0x15/0x25
 tracefs_get_inode+0x23/0x7c
 ? lookup_one_len+0x54/0x6c
 tracefs_create_file+0x53/0x11d
 trace_create_file+0x15/0x33
 event_create_dir+0x2a3/0x34b
 __trace_add_new_event+0x1c/0x26
 event_trace_add_tracer+0x56/0x86
 trace_array_create+0x13e/0x1e1
 instance_mkdir+0x8/0x17
 tracefs_syscall_mkdir+0x39/0x50
 ? get_dname+0x31/0x31
 vfs_mkdir+0x78/0xa3
 do_mkdirat+0x71/0xb0
 sys_mkdir+0x19/0x1b
 do_fast_syscall_32+0xb0/0xed

I bisected this down to the addition of the proxy_ops into tracefs for
lockdown. It appears that the allocation of the proxy_ops and then freeing
it in the destroy_inode callback, is causing havoc with the memory system.
Reading the documentation about destroy_inode and talking with Linus about
this, this is buggy and wrong. When defining the destroy_inode() method, it
is expected that the destroy_inode() will also free the inode, and not just
the extra allocations done in the creation of the inode. The faulty commit
causes a memory leak of the inode data structure when they are deleted.

Instead of allocating the proxy_ops (and then having to free it) the checks
should be done by the open functions themselves, and not hack into the
tracefs directory. First revert the tracefs updates for locked_down and then
later we can add the locked_down checks in the kernel/trace files.

Link: http://lkml.kernel.org/r/20191011135458.7399da44@gandalf.local.home

Fixes: ccbd54f ("tracefs: Restrict tracefs when the kernel is locked down")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
@nickdesaulniers
Copy link
Member

MTK reports hitting this as well. I can repro, but it seems even with a pared down config, MTK hits it as well (seems I can repro with AOSP clang r353983c, but not newer builds of clang with that config).
config.arm.thumb2kernel.txt

@nickdesaulniers
Copy link
Member

arm-linux-gnueabi-ld: kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'

When I build with Clang, I see:

$ llvm-objdump -Dr kernel/futex.o
...
Disassembly of section .text.fixup:
...
      58: 02 c0 a0 e1                   mov     r12, r2
      5c: 5f 00 00 ea                   b       #380 <$a+0x1e0>
                        0000005c:  R_ARM_JUMP24 .init.text
...

Which is the relocation that bfd is complaining about.

I suspect that the sections in between .init.text and .text.fixup are larger when built w/ Clang than w/ GCC (observed when linking .tmp_vmlinux1, ie. before arch/arm/boot/compressed/vmlinux.lds.S munges .text.fixup into .text). I'll bet moving a function that generated that relocation out of the init section allows for the relocation to fit, but it seems that kernel/futex.c is arch independent, so I'm not sure that's a viable solution.

clang (-fno-integrated-as) and gcc (I'm using 5.4) encode 3: differently.

Right, the R_ARM_JUMP24 becomes problematic when the sections are placed too far apart.

https://gcc.gnu.org/ml/gcc/2011-10/msg00224.html I think discusses a similar error, with the response being "sorry, I can't do that").

In arch/arm/kernel/vmlinux.lds.S, RO_DATA(PAGE_SIZE) is what defines all of the sections between .text and .ARM.unwind_idx, ie.

.rodata
.modinfo
.pci_fixup
__ksymtab
__ksymtab_gpl
__ksymtab_strings
__param
__modver
__ex_table

(.rodata is pretty big, it's the second largest section after .text).

So if we could move those (and maybe ARM_UNWIND_SECTIONS, NOTES, and ARM_VECTORS, then .text.fixup wouldn't be so far away from .init.text.

I'm thinking:

diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 23150c0f0f4d..619cb62dd715 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -68,8 +68,6 @@ SECTIONS
 #endif
 	_etext = .;			/* End of text section */
 
-	RO_DATA(PAGE_SIZE)
-
 	. = ALIGN(4);
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
@@ -77,12 +75,6 @@ SECTIONS
 		__stop___ex_table = .;
 	}
 
-#ifdef CONFIG_ARM_UNWIND
-	ARM_UNWIND_SECTIONS
-#endif
-
-	NOTES
-
 #ifdef CONFIG_STRICT_KERNEL_RWX
 	. = ALIGN(1<<SECTION_SHIFT);
 #else
@@ -142,6 +134,14 @@ SECTIONS
 #endif
 	__init_end = .;
 
+	RO_DATA(PAGE_SIZE)
+
+#ifdef CONFIG_ARM_UNWIND
+	ARM_UNWIND_SECTIONS
+#endif
+
+	NOTES
+
 	_sdata = .;
 	RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
 	_edata = .;

Strictly speaking, just the move of RO_DATA might be enough. We might also want to look at other arch's too see if they place .rodata here or somewhere else. Without knowing what kind of data is encoded in all of these sections, moving any of them may trigger other failures. Untested.

@nickdesaulniers
Copy link
Member

(doesn't work) 💩

@nickdesaulniers
Copy link
Member

@nickdesaulniers
Copy link
Member

The workaround for now is to just use LLD, but would be nice to fix. Maybe bfd doesn't do range extension for relocations referring to notype symbols (from inline asm) @smithp35 will check bfd source.

@nickdesaulniers nickdesaulniers added the [WORKAROUND] Applied This bug has an applied workaround label Feb 8, 2020
@smithp35
Copy link

smithp35 commented Feb 8, 2020

I've been able to write a failing test case that might indicate the problem in bfd

        .syntax unified
        .text
_start:
        .type _start, %function
        b destination
        b .destination
        .section .destination, "ax", %progbits
        .global destination
destination:
        bx lr

WIth linker script:

SECTIONS {
    .text 0x8000 : { *(.text) }
    .destination 0x10000000 : { *(.destination) }
}

lvm-mc --triple=armv7a-linux-gnueabihf -filetype=obj stub.s -o stub.o
arm-linux-gnueabihf-ld.bfd stub.o --script stub.lds -o stub.axf
(.text+0x4): relocation truncated to fit: R_ARM_JUMP24 against `.destination'

Looking at the bfd code it looks like branches to section symbols (type STT_SECTION) are untouched by all the of the stub handling code. These get mapped to a branch type of ST_BRANCH_LONG, with only one other occurrence in the file.

static bfd_boolean
elf32_arm_swap_symbol_in (bfd * abfd,
			  const void *psrc,
			  const void *pshn,
			  Elf_Internal_Sym *dst)
...
  else if (ELF_ST_TYPE (dst->st_info) == STT_SECTION)
    ARM_SET_SYM_BRANCH_TYPE (dst->st_target_internal, ST_BRANCH_LONG);

And

static enum elf32_arm_stub_type
arm_type_of_stub (struct bfd_link_info *info,
		  asection *input_sec,
		  const Elf_Internal_Rela *rel,
		  unsigned char st_type,
		  enum arm_st_branch_type *actual_branch_type,
		  struct elf32_arm_link_hash_entry *hash,
		  bfd_vma destination,
		  asection *sym_sec,
		  bfd *input_bfd,
		  const char *name)
...
  if (branch_type == ST_BRANCH_LONG)
    return stub_type;

So it looks like branches to .section symbols are the trigger of the problem. As I understand it the clang-integrated-as won't use branch to section symbols, but the gnu assembler will.

@nickdesaulniers
Copy link
Member

Thanks for the expertise to understand the failure, and concise reproducer! Let's let the binutils developers know.

@ardbiesheuvel
Copy link

I don't remember the exact details, but this is probably also the reason why i had to move the .fixup section closer to .text, as it contains cross section branches to asm labels as well.

@nickdesaulniers
Copy link
Member

Closing for now; if this is easily reproducible we should try to get a bug report to the BFD devs.

@nathanchance
Copy link
Member Author

nathanchance commented Jul 22, 2021

Reopening because this crash with multi_v7_defconfig + CONFIG_THUMB2_KERNEL=y is resolved with @arndb 's patch. Thomas Gleixner actually suggested one in that thread that should be acceptable and resolves this issue but I never saw it go anywhere. I have pinged the thread.

@nathanchance nathanchance reopened this Jul 22, 2021
@nickdesaulniers
Copy link
Member

SonicBSV pushed a commit to SonicBSV/android_kernel_asus_sdm660 that referenced this issue Aug 23, 2022
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
developerjuan729 pushed a commit to developerjuan729/android_kernel_msm-5.4_oneplus_sm6375 that referenced this issue Nov 2, 2022
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
iqba78 pushed a commit to iqba78/android_kernel_xiaomi_sdm660_southwest that referenced this issue Dec 17, 2022
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Blackmanx pushed a commit to Blackmanx/bigshot_kernel_realme_sm8250 that referenced this issue Dec 21, 2022
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
much-doge pushed a commit to much-doge/Quantum_Quackery that referenced this issue Dec 30, 2022
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rohail33 pushed a commit to Rohail33/Realking_xiaomi_xaga that referenced this issue Dec 31, 2022
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Wrdn28 pushed a commit to Wrdn28/X01AD_Kernel that referenced this issue Mar 11, 2023
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rem01Gaming pushed a commit to Rem01Gaming/liquid_kernel_realme_even that referenced this issue May 21, 2023
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
JoysKo pushed a commit to JoysKo/HYBRID_CAF_kernel that referenced this issue Jul 30, 2023
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
intersectRaven pushed a commit to intersectRaven/rk356x-kernel that referenced this issue Sep 16, 2023
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
warudooooo added a commit to warudooooo/android_kernel_sm6225_spes that referenced this issue Sep 20, 2023
Merge: 9e5a216016f0 a027d43cf3f2
Author: warudo <waldoreyes2301@gmail.com>
Date:   Wed Sep 20 16:00:07 2023 +0800

    Merge tag 'v4.19.215' of https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable

    This is the 4.19.215 stable release

commit a027d43cf3f2fdaabf467b4bcb92d0fe748c2eaf
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Nov 2 18:26:46 2021 +0100

    Linux 4.19.215

    Link: https://lore.kernel.org/r/20211101082451.430720900@linuxfoundation.org
    Link: https://lore.kernel.org/r/20211101114224.924071362@linuxfoundation.org
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Hulk Robot <hulkrobot@huawei.com>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1ff3c379248ea579aa122d4ca245028e4bc9af23
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:47 2021 -0400

    sctp: add vtag check in sctp_sf_ootb

    [ Upstream commit 9d02831e517aa36ee6bdb453a0eb47bd49923fe3 ]

    sctp_sf_ootb() is called when processing DATA chunk in closed state,
    and many other places are also using it.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    When fails to verify the vtag from the chunk, this patch sets asoc
    to NULL, so that the abort will be made with the vtag from the
    received chunk later.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d9a4f990aab48dd5c134a9e76c7b651d404b05d3
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:46 2021 -0400

    sctp: add vtag check in sctp_sf_do_8_5_1_E_sa

    [ Upstream commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998 ]

    sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk
    in cookie_wait and cookie_echoed state.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    Note that when fails to verify the vtag from SHUTDOWN-ACK chunk,
    SHUTDOWN COMPLETE message will still be sent back to peer, but
    with the vtag from SHUTDOWN-ACK chunk, as said in 5) of
    rfc4960#section-8.4.

    While at it, also remove the unnecessary chunk length check from
    sctp_sf_shut_8_4_5(), as it's already done in both places where
    it calls sctp_sf_shut_8_4_5().

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7bf2f6a30d1851c530ad5e4ee7e5c45fb6be0128
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:45 2021 -0400

    sctp: add vtag check in sctp_sf_violation

    [ Upstream commit aa0f697e45286a6b5f0ceca9418acf54b9099d99 ]

    sctp_sf_violation() is called when processing HEARTBEAT_ACK chunk
    in cookie_wait state, and some other places are also using it.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 86044244fc6f9eaec0070cb668e0d500de22dbba
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:44 2021 -0400

    sctp: fix the processing for COOKIE_ECHO chunk

    [ Upstream commit a64b341b8695e1c744dd972b39868371b4f68f83 ]

    1. In closed state: in sctp_sf_do_5_1D_ce():

      When asoc is NULL, making packet for abort will use chunk's vtag
      in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk
      should be verified before using peer.i.init_tag to make packet
      for abort in sctp_ootb_pkt_new(), and just discard it if vtag is
      not correct.

    2. In the other states: in sctp_sf_do_5_2_4_dupcook():

      asoc always exists, but duplicate cookie_echo's vtag will be
      handled by sctp_tietags_compare() and then take actions, so before
      that we only verify the vtag for the abort sent for invalid chunk
      length.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1f52dfacca7bb315d89f5ece5660b0337809798e
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:41 2021 -0400

    sctp: use init_tag from inithdr for ABORT chunk

    [ Upstream commit 4f7019c7eb33967eb87766e0e4602b5576873680 ]

    Currently Linux SCTP uses the verification tag of the existing SCTP
    asoc when failing to process and sending the packet with the ABORT
    chunk. This will result in the peer accepting the ABORT chunk and
    removing the SCTP asoc. One could exploit this to terminate a SCTP
    asoc.

    This patch is to fix it by always using the initiate tag of the
    received INIT chunk for the ABORT chunk to be sent.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b75fa48e42d022d6757b7de29178d531df8cf43b
Author: Trevor Woerner <twoerner@gmail.com>
Date:   Sun Oct 24 13:50:02 2021 -0400

    net: nxp: lpc_eth.c: avoid hang when bringing interface down

    commit ace19b992436a257d9a793672e57abc28fe83e2e upstream.

    A hard hang is observed whenever the ethernet interface is brought
    down. If the PHY is stopped before the LPC core block is reset,
    the SoC will hang. Comparing lpc_eth_close() and lpc_eth_open() I
    re-arranged the ordering of the functions calls in lpc_eth_close() to
    reset the hardware before stopping the PHY.
    Fixes: b7370112f519 ("lpc32xx: Added ethernet driver")
    Signed-off-by: Trevor Woerner <twoerner@gmail.com>
    Acked-by: Vladimir Zapolskiy <vz@mleia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 84a9eb9a2f179ea5e6398fe270560a8aaa16f996
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Fri Oct 22 11:53:43 2021 -0400

    net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent

    commit 95a359c9553342d36d408d35331ff0bfce75272f upstream.

    The dma failure was reported in the raspberry pi github (issue #4117).
    https://github.com/raspberrypi/linux/issues/4117
    The use of dma_set_mask_and_coherent fixes the issue.
    Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430.

    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fcda74cc95aa450a6d17780ccb1a8853cac7d0cd
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Fri Oct 22 11:13:53 2021 -0400

    net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails

    commit d6423d2ec39cce2bfca418c81ef51792891576bc upstream.

    The driver needs to clean up and return when the initialization fails on resume.

    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 25d852a8adf017a478246d19c8b282e975521e8a
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Wed Oct 20 12:11:16 2021 -0700

    nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST

    commit 4a089e95b4d6bb625044d47aed0c442a8f7bd093 upstream.

    nios2:allmodconfig builds fail with

    make[1]: *** No rule to make target 'arch/nios2/boot/dts/""',
    	needed by 'arch/nios2/boot/dts/built-in.a'.  Stop.
    make: [Makefile:1868: arch/nios2/boot/dts] Error 2 (ignored)

    This is seen with compile tests since those enable NIOS2_DTB_SOURCE_BOOL,
    which in turn enables NIOS2_DTB_SOURCE. This causes the build error
    because the default value for NIOS2_DTB_SOURCE is an empty string.
    Disable NIOS2_DTB_SOURCE_BOOL for compile tests to avoid the error.

    Fixes: 2fc8483fdcde ("nios2: Build infrastructure")
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02302cbd52264337630a32848ac03648648e9685
Author: Michael Chan <michael.chan@broadcom.com>
Date:   Mon Oct 25 05:05:28 2021 -0400

    net: Prevent infinite while loop in skb_tx_hash()

    commit 0c57eeecc559ca6bc18b8c4e2808bc78dbe769b0 upstream.

    Drivers call netdev_set_num_tc() and then netdev_set_tc_queue()
    to set the queue count and offset for each TC.  So the queue count
    and offset for the TCs may be zero for a short period after dev->num_tc
    has been set.  If a TX packet is being transmitted at this time in the
    code path netdev_pick_tx() -> skb_tx_hash(), skb_tx_hash() may see
    nonzero dev->num_tc but zero qcount for the TC.  The while loop that
    keeps looping while hash >= qcount will not end.

    Fix it by checking the TC's qcount to be nonzero before using it.

    Fixes: eadec877ce9c ("net: Add support for subordinate traffic classes to netdev_pick_tx")
    Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
    Signed-off-by: Michael Chan <michael.chan@broadcom.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbf150b16a3635634b7dfb7f229d8fcd643c6c51
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Sun Oct 24 16:13:56 2021 +0300

    net: batman-adv: fix error handling

    commit 6f68cd634856f8ca93bafd623ba5357e0f648c68 upstream.

    Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
    in wrong error handling in batadv_mesh_init().

    Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
    of any batadv_*_init() calls failure. This approach may work well, when
    there is some kind of indicator, which can tell which parts of batadv are
    initialized; but there isn't any.

    All written above lead to cleaning up uninitialized fields. Even if we hide
    ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
    GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]

    To fix these bugs we can unwind batadv_*_init() calls one by one.
    It is good approach for 2 reasons: 1) It fixes bugs on error handling
    path 2) It improves the performance, since we won't call unneeded
    batadv_*_free() functions.

    So, this patch makes all batadv_*_init() clean up all allocated memory
    before returning with an error to no call correspoing batadv_*_free()
    and open-codes batadv_mesh_free() with proper order to avoid touching
    uninitialized fields.

    Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/ [1]
    Reported-and-tested-by: syzbot+28b0702ada0bf7381f58@syzkaller.appspotmail.com
    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Acked-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3dae1a4eced3ee733d7222e69b8a55caf2d61091
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Oct 12 10:37:35 2021 +0800

    regmap: Fix possible double-free in regcache_rbtree_exit()

    commit 55e6d8037805b3400096d621091dfbf713f97e83 upstream.

    In regcache_rbtree_insert_to_block(), when 'present' realloc failed,
    the 'blk' which is supposed to assign to 'rbnode->block' will be freed,
    so 'rbnode->block' points a freed memory, in the error handling path of
    regcache_rbtree_init(), 'rbnode->block' will be freed again in
    regcache_rbtree_exit(), KASAN will report double-free as follows:

    BUG: KASAN: double-free or invalid-free in kfree+0xce/0x390
    Call Trace:
     slab_free_freelist_hook+0x10d/0x240
     kfree+0xce/0x390
     regcache_rbtree_exit+0x15d/0x1a0
     regcache_rbtree_init+0x224/0x2c0
     regcache_init+0x88d/0x1310
     __regmap_init+0x3151/0x4a80
     __devm_regmap_init+0x7d/0x100
     madera_spi_probe+0x10f/0x333 [madera_spi]
     spi_probe+0x183/0x210
     really_probe+0x285/0xc30

    To fix this, moving up the assignment of rbnode->block to immediately after
    the reallocation has succeeded so that the data structure stays valid even
    if the second reallocation fails.

    Reported-by: Hulk Robot <hulkci@huawei.com>
    Fixes: 3f4ff561bc88b ("regmap: rbtree: Make cache_present bitmap per node")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20211012023735.1632786-1-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cdaf7a469244b5e65ae5eda062ff5ea90172de62
Author: Clément Bœsch <u@pkh.me>
Date:   Sun Sep 5 02:20:27 2021 +0200

    arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node

    commit 0764e365dacd0b8f75c1736f9236be280649bd18 upstream.

    RX and TX delay are provided by ethernet PHY. Reflect that in ethernet
    node.

    Fixes: 44a94c7ef989 ("arm64: dts: allwinner: H5: Restore EMAC changes")
    Signed-off-by: Clément Bœsch <u@pkh.me>
    Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Link: https://lore.kernel.org/r/20210905002027.171984-1-u@pkh.me
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2864b6d54244b82a8c7d4628a43055c57bfba80c
Author: Patrisious Haddad <phaddad@nvidia.com>
Date:   Wed Oct 6 12:31:53 2021 +0300

    RDMA/mlx5: Set user priority for DCT

    commit 1ab52ac1e9bc9391f592c9fa8340a6e3e9c36286 upstream.

    Currently, the driver doesn't set the PCP-based priority for DCT, hence
    DCT response packets are transmitted without user priority.

    Fix it by setting user provided priority in the eth_prio field in the DCT
    context, which in turn sets the value in the transmitted packet.

    Fixes: 776a3906b692 ("IB/mlx5: Add support for DC target QP")
    Link: https://lore.kernel.org/r/5fd2d94a13f5742d8803c218927322257d53205c.1633512672.git.leonro@nvidia.com
    Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 326da4f6ffdbd8671e86f69ded7a714dcc12fecf
Author: Johan Hovold <johan@kernel.org>
Date:   Tue Oct 26 12:36:17 2021 +0200

    net: lan78xx: fix division by zero in send path

    commit db6c3c064f5d55fa9969f33eafca3cdbefbb3541 upstream.

    Add the missing endpoint max-packet sanity check to probe() to avoid
    division by zero in lan78xx_tx_bh() in case a malicious device has
    broken descriptors (or when doing descriptor fuzz testing).

    Note that USB core will reject URBs submitted for endpoints with zero
    wMaxPacketSize but that drivers doing packet-size calculations still
    need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip
    endpoint descriptors with maxpacket=0")).

    Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
    Cc: stable@vger.kernel.org      # 4.3
    Cc: Woojung.Huh@microchip.com <Woojung.Huh@microchip.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2ff5289793fd61c56ac8774408f27350e5da865f
Author: Haibo Chen <haibo.chen@nxp.com>
Date:   Fri Oct 15 10:00:36 2021 +0800

    mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit

    commit 9af372dc70e9fdcbb70939dac75365e7b88580b4 upstream.

    To reset standard tuning circuit completely, after clear ESDHC_MIX_CTRL_EXE_TUNE,
    also need to clear bit buffer_read_ready, this operation will finally clear the
    USDHC IP internal logic flag execute_tuning_with_clr_buf, make sure the following
    normal data transfer will not be impacted by standard tuning logic used before.

    Find this issue when do quick SD card insert/remove stress test. During standard
    tuning prodedure, if remove SD card, USDHC standard tuning logic can't clear the
    internal flag execute_tuning_with_clr_buf. Next time when insert SD card, all
    data related commands can't get any data related interrupts, include data transfer
    complete interrupt, data timeout interrupt, data CRC interrupt, data end bit interrupt.
    Always trigger software timeout issue. Even reset the USDHC through bits in register
    SYS_CTRL (0x2C, bit28 reset tuning, bit26 reset data, bit 25 reset command, bit 24
    reset all) can't recover this. From the user's point of view, USDHC stuck, SD can't
    be recognized any more.

    Fixes: d9370424c948 ("mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card")
    Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1634263236-6111-1-git-send-email-haibo.chen@nxp.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7824414c2903e2cfe56ea610387a22c0c88fb468
Author: Shawn Guo <shawn.guo@linaro.org>
Date:   Mon Oct 4 10:49:35 2021 +0800

    mmc: sdhci: Map more voltage level to SDHCI_POWER_330

    commit 4217d07b9fb328751f877d3bd9550122014860a2 upstream.

    On Thundercomm TurboX CM2290, the eMMC OCR reports vdd = 23 (3.5 ~ 3.6 V),
    which is being treated as an invalid value by sdhci_set_power_noreg().
    And thus eMMC is totally broken on the platform.

    [    1.436599] ------------[ cut here ]------------
    [    1.436606] mmc0: Invalid vdd 0x17
    [    1.436640] WARNING: CPU: 2 PID: 69 at drivers/mmc/host/sdhci.c:2048 sdhci_set_power_noreg+0x168/0x2b4
    [    1.436655] Modules linked in:
    [    1.436662] CPU: 2 PID: 69 Comm: kworker/u8:1 Tainted: G        W         5.15.0-rc1+ #137
    [    1.436669] Hardware name: Thundercomm TurboX CM2290 (DT)
    [    1.436674] Workqueue: events_unbound async_run_entry_fn
    [    1.436685] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [    1.436692] pc : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436698] lr : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436703] sp : ffff800010803a60
    [    1.436705] x29: ffff800010803a60 x28: ffff6a9102465f00 x27: ffff6a9101720a70
    [    1.436715] x26: ffff6a91014de1c0 x25: ffff6a91014de010 x24: ffff6a91016af280
    [    1.436724] x23: ffffaf7b1b276640 x22: 0000000000000000 x21: ffff6a9101720000
    [    1.436733] x20: ffff6a9101720370 x19: ffff6a9101720580 x18: 0000000000000020
    [    1.436743] x17: 0000000000000000 x16: 0000000000000004 x15: ffffffffffffffff
    [    1.436751] x14: 0000000000000000 x13: 00000000fffffffd x12: ffffaf7b1b84b0bc
    [    1.436760] x11: ffffaf7b1b720d10 x10: 000000000000000a x9 : ffff800010803a60
    [    1.436769] x8 : 000000000000000a x7 : 000000000000000f x6 : 00000000fffff159
    [    1.436778] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
    [    1.436787] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff6a9101718d80
    [    1.436797] Call trace:
    [    1.436800]  sdhci_set_power_noreg+0x168/0x2b4
    [    1.436805]  sdhci_set_ios+0xa0/0x7fc
    [    1.436811]  mmc_power_up.part.0+0xc4/0x164
    [    1.436818]  mmc_start_host+0xa0/0xb0
    [    1.436824]  mmc_add_host+0x60/0x90
    [    1.436830]  __sdhci_add_host+0x174/0x330
    [    1.436836]  sdhci_msm_probe+0x7c0/0x920
    [    1.436842]  platform_probe+0x68/0xe0
    [    1.436850]  really_probe.part.0+0x9c/0x31c
    [    1.436857]  __driver_probe_device+0x98/0x144
    [    1.436863]  driver_probe_device+0xc8/0x15c
    [    1.436869]  __device_attach_driver+0xb4/0x120
    [    1.436875]  bus_for_each_drv+0x78/0xd0
    [    1.436881]  __device_attach_async_helper+0xac/0xd0
    [    1.436888]  async_run_entry_fn+0x34/0x110
    [    1.436895]  process_one_work+0x1d0/0x354
    [    1.436903]  worker_thread+0x13c/0x470
    [    1.436910]  kthread+0x150/0x160
    [    1.436915]  ret_from_fork+0x10/0x20
    [    1.436923] ---[ end trace fcfac44cb045c3a8 ]---

    Fix the issue by mapping MMC_VDD_35_36 (and MMC_VDD_34_35) to
    SDHCI_POWER_330 as well.

    Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20211004024935.15326-1-shawn.guo@linaro.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29d56f3790e684e630d56f500b59e834fa382209
Author: Jaehoon Chung <jh80.chung@samsung.com>
Date:   Fri Oct 22 17:21:06 2021 +0900

    mmc: dw_mmc: exynos: fix the finding clock sample value

    commit 697542bceae51f7620af333b065dd09d213629fb upstream.

    Even though there are candiates value if can't find best value, it's
    returned -EIO. It's not proper behavior.
    If there is not best value, use a first candiate value to work eMMC.

    Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
    Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Tested-by: Christian Hewitt <christianshewitt@gmail.com>
    Cc: stable@vger.kernel.org
    Fixes: c537a1c5ff63 ("mmc: dw_mmc: exynos: add variable delay tuning sequence")
    Link: https://lore.kernel.org/r/20211022082106.1557-1-jh80.chung@samsung.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 24f8658690477e8983f88cbfe21fb7f4062ad837
Author: Wenbin Mei <wenbin.mei@mediatek.com>
Date:   Tue Oct 26 15:08:12 2021 +0800

    mmc: cqhci: clear HALT state after CQE enable

    commit 92b18252b91de567cd875f2e84722b10ab34ee28 upstream.

    While mmc0 enter suspend state, we need halt CQE to send legacy cmd(flush
    cache) and disable cqe, for resume back, we enable CQE and not clear HALT
    state.
    In this case MediaTek mmc host controller will keep the value for HALT
    state after CQE disable/enable flow, so the next CQE transfer after resume
    will be timeout due to CQE is in HALT state, the log as below:
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: timeout for tag 2
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Caps:      0x100020b6 | Version:  0x00000510
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Config:    0x00001103 | Control:  0x00000001
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int stat:  0x00000000 | Int enab: 0x00000006
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int sig:   0x00000006 | Int Coal: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: TDL base:  0xfd05f000 | TDL up32: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Doorbell:  0x8000203c | TCN:      0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Task clr:  0x00000000 | SSC1:     0x00001000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: SSC2:      0x00000001 | DCMD rsp: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: RED mask:  0xfdf9a080 | TERRI:    0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Resp idx:  0x00000000 | Resp arg: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQP:     0x00000000 | CRNQDUN:  0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQIS:    0x00000000 | CRNQIE:   0x00000000

    This change check HALT state after CQE enable, if CQE is in HALT state, we
    will clear it.

    Signed-off-by: Wenbin Mei <wenbin.mei@mediatek.com>
    Cc: stable@vger.kernel.org
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
    Link: https://lore.kernel.org/r/20211026070812.9359-1-wenbin.mei@mediatek.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99641238575c26c2e47fa593f562dae476709d68
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 13:56:08 2021 +0200

    mmc: vub300: fix control-message timeouts

    commit 8c8171929116cc23f74743d99251eedadf62341a upstream.

    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.

    Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
    Cc: stable@vger.kernel.org      # 3.0
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211025115608.5287-1-johan@kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6d0d68d6da68159948cad3d808d61bb291a0283
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Aug 29 15:16:14 2021 -0700

    ipv6: make exception cache less predictible

    commit a00df2caffed3883c341d5685f830434312e4a43 upstream.

    Even after commit 4785305c05b2 ("ipv6: use siphash in rt6_exception_hash()"),
    an attacker can still use brute force to learn some secrets from a victim
    linux host.

    One way to defeat these attacks is to make the max depth of the hash
    table bucket a random value.

    Before this patch, each bucket of the hash table used to store exceptions
    could contain 6 items under attack.

    After the patch, each bucket would contains a random number of items,
    between 6 and 10. The attacker can no longer infer secrets.

    This is slightly increasing memory size used by the hash table,
    we do not expect this to be a problem.

    Following patch is dealing with the same issue in IPv4.

    Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Wei Wang <weiwan@google.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad829847ad59af8e26a1f1c345716099abbc7a58
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Oct 29 10:50:26 2021 +0300

    ipv6: use siphash in rt6_exception_hash()

    commit 4785305c05b25a242e5314cc821f54ade4c18810 upstream.

    A group of security researchers brought to our attention
    the weakness of hash function used in rt6_exception_hash()

    Lets use siphash instead of Jenkins Hash, to considerably
    reduce security risks.

    Following patch deals with IPv4.

    Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Wei Wang <weiwan@google.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Acked-by: Wei Wang <weiwan@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e2856767eb1a9cfcfcd82136928037f04920e97
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Oct 29 10:50:25 2021 +0300

    ipv4: use siphash instead of Jenkins in fnhe_hashfun()

    commit 6457378fe796815c973f631a1904e147d6ee33b1 upstream.

    A group of security researchers brought to our attention
    the weakness of hash function used in fnhe_hashfun().

    Lets use siphash instead of Jenkins Hash, to considerably
    reduce security risks.

    Also remove the inline keyword, this really is distracting.

    Fixes: d546c621542d ("ipv4: harden fnhe_hashfun()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Willy Tarreau <w@1wt.eu>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8121d0d4fd108280f5cd7b7fe8c6592adaa37be9
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Thu Sep 30 20:49:42 2021 +0300

    Revert "net: mdiobus: Fix memory leak in __mdiobus_register"

    commit 10eff1f5788b6ffac212c254e2f3666219576889 upstream.

    This reverts commit ab609f25d19858513919369ff3d9a63c02cd9e2e.

    This patch is correct in the sense that we _should_ call device_put() in
    case of device_register() failure, but the problem in this code is more
    vast.

    We need to set bus->state to UNMDIOBUS_REGISTERED before calling
    device_register() to correctly release the device in mdiobus_free().
    This patch prevents us from doing it, since in case of device_register()
    failure put_device() will be called 2 times and it will cause UAF or
    something else.

    Also, Reported-by: tag in revered commit was wrong, since syzbot
    reported different leak in same function.

    Link: https://lore.kernel.org/netdev/20210928092657.GI2048@kadam/
    Acked-by: Yanfei Xu <yanfei.xu@windriver.com>
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Link: https://lore.kernel.org/r/f12fb1faa4eccf0f355788225335eb4309ff2599.1633024062.git.paskripkin@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4a9043ba1b0e9bea1da0fe34366222974f2c0f92
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date:   Mon Oct 25 16:49:36 2021 +0200

    nfc: port100: fix using -ERRNO as command type mask

    commit 2195f2062e4cc93870da8e71c318ef98a1c51cef upstream.

    During probing, the driver tries to get a list (mask) of supported
    command types in port100_get_command_type_mask() function.  The value
    is u64 and 0 is treated as invalid mask (no commands supported).  The
    function however returns also -ERRNO as u64 which will be interpret as
    valid command mask.

    Return 0 on every error case of port100_get_command_type_mask(), so the
    probing will stop.

    Cc: <stable@vger.kernel.org>
    Fixes: 0347a6ab300a ("NFC: port100: Commands mechanism implementation")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a36119f9b3fb069437383a8eff4e65181b6e7e2f
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Fri Oct 22 09:12:26 2021 +0000

    ata: sata_mv: Fix the error handling of mv_chip_id()

    commit a0023bb9dd9bc439d44604eeec62426a990054cd upstream.

    mv_init_host() propagates the value returned by mv_chip_id() which in turn
    gets propagated by mv_pci_init_one() and hits local_pci_probe().

    During the process of driver probing, the probe function should return < 0
    for failure, otherwise, the kernel will treat value > 0 as success.

    Since this is a bug rather than a recoverable runtime error we should
    use dev_alert() instead of dev_err().

    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 78c2dc1cdf0bdfc83e473d78f23da4d2aeb98142
Author: Wang Hai <wanghai38@huawei.com>
Date:   Tue Oct 26 20:40:15 2021 +0800

    usbnet: fix error return code in usbnet_probe()

    commit 6f7c88691191e6c52ef2543d6f1da8d360b27a24 upstream.

    Return error code if usb_maxpacket() returns 0 in usbnet_probe()

    Fixes: 397430b50a36 ("usbnet: sanity check for maxpacket")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    Reviewed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211026124015.3025136-1-wanghai38@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 002d82227c0abe29118cf80f7e2f396b22d448ed
Author: Oliver Neukum <oneukum@suse.com>
Date:   Thu Oct 21 14:29:44 2021 +0200

    usbnet: sanity check for maxpacket

    commit 397430b50a363d8b7bdda00522123f82df6adc5e upstream.

    maxpacket of 0 makes no sense and oopses as we need to divide
    by it. Give up.

    V2: fixed typo in log and stylistic issues

    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Reported-by: syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com
    Reviewed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211021122944.21816-1-oneukum@suse.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d725978abb0bac6e0c427548dfd6db86709a2a1e
Author: Nathan Chancellor <natechancellor@gmail.com>
Date:   Sat Jan 5 19:35:25 2019 +0100

    ARM: 8819/1: Remove '-p' from LDFLAGS

    commit 091bb549f7722723b284f63ac665e2aedcf9dec9 upstream.

    This option is not supported by lld:

        ld.lld: error: unknown argument: -p

    This has been a no-op in binutils since 2004 (see commit dea514f51da1 in
    that tree). Given that the lowest officially supported of binutils for
    the kernel is 2.20, which was released in 2009, nobody needs this flag
    around so just remove it. Commit 1a381d4a0a9a ("arm64: remove no-op -p
    linker flag") did the same for arm64.

    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
    Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Acked-by: Nicolas Pitre <nico@linaro.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Stefan Agner <stefan@agner.ch>
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aaf4e1b05cab800b36b40c1aa09f7c13ef30de56
Author: Robin Murphy <robin.murphy@arm.com>
Date:   Mon Jul 12 15:27:46 2021 +0100

    arm64: Avoid premature usercopy failure

    commit 295cf156231ca3f9e3a66bde7fab5e09c41835e0 upstream.

    Al reminds us that the usercopy API must only return complete failure
    if absolutely nothing could be copied. Currently, if userspace does
    something silly like giving us an unaligned pointer to Device memory,
    or a size which overruns MTE tag bounds, we may fail to honour that
    requirement when faulting on a multi-byte access even though a smaller
    access could have succeeded.

    Add a mitigation to the fixup routines to fall back to a single-byte
    copy if we faulted on a larger access before anything has been written
    to the destination, to guarantee making *some* forward progress. We
    needn't be too concerned about the overall performance since this should
    only occur when callers are doing something a bit dodgy in the first
    place. Particularly broken userspace might still be able to trick
    generic_perform_write() into an infinite loop by targeting write() at
    an mmap() of some read-only device register where the fault-in load
    succeeds but any store synchronously aborts such that copy_to_user() is
    genuinely unable to make progress, but, well, don't do that...

    CC: stable@vger.kernel.org
    Reported-by: Chen Huang <chenhuang5@huawei.com>
    Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Robin Murphy <robin.murphy@arm.com>
    Link: https://lore.kernel.org/r/dc03d5c675731a1f24a62417dba5429ad744234e.1626098433.git.robin.murphy@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Chen Huang <chenhuang5@huawei.com>

commit 5909b851b5e11d04f299e5f0a8937e9dcc807248
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Date:   Wed Oct 6 01:55:22 2021 +0530

    powerpc/bpf: Fix BPF_MOD when imm == 1

    commit 8bbc9d822421d9ac8ff9ed26a3713c9afc69d6c8 upstream.

    Only ignore the operation if dividing by 1.

    Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
    Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Tested-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Acked-by: Song Liu <songliubraving@fb.com>
    Acked-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/c674ca18c3046885602caebb326213731c675d06.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
    [cascardo: use PPC_LI instead of EMIT(PPC_RAW_LI)]
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 901741a53d7cf45be861e881c0e3cba5b4bd1f94
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:37 2021 +0100

    ARM: 9141/1: only warn about XIP address when not compile testing

    commit 48ccc8edf5b90622cdc4f8878e0042ab5883e2ca upstream.

    In randconfig builds, we sometimes come across this warning:

    arm-linux-gnueabi-ld: XIP start address may cause MPU programming issues

    While this is helpful for actual systems to figure out why it
    fails, the warning does not provide any benefit for build testing,
    so guard it in a check for CONFIG_COMPILE_TEST, which is usually
    set on randconfig builds.

    Fixes: 216218308cfb ("ARM: 8713/1: NOMMU: Support MPU in XIP configuration")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee4b38ce37ed31beca29d3ebec7db3d5e87fe39e
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:09 2021 +0100

    ARM: 9139/1: kprobes: fix arch_init_kprobes() prototype

    commit 1f323127cab086e4fd618981b1e5edc396eaf0f4 upstream.

    With extra warnings enabled, gcc complains about this function
    definition:

    arch/arm/probes/kprobes/core.c: In function 'arch_init_kprobes':
    arch/arm/probes/kprobes/core.c:465:12: warning: old-style function definition [-Wold-style-definition]
      465 | int __init arch_init_kprobes()

    Link: https://lore.kernel.org/all/20201027093057.c685a14b386acacb3c449e3d@kernel.org/

    Fixes: 24ba613c9d6c ("ARM kprobes: core code")
    Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c0b4f1db7feef31d401814121760b45aff7885c1
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:04 2021 +0100

    ARM: 9134/1: remove duplicate memcpy() definition

    commit eaf6cc7165c9c5aa3c2f9faa03a98598123d0afb upstream.

    Both the decompressor code and the kasan logic try to override
    the memcpy() and memmove()  definitions, which leading to a clash
    in a KASAN-enabled kernel with XZ decompression:

    arch/arm/boot/compressed/decompress.c:50:9: error: 'memmove' macro redefined [-Werror,-Wmacro-redefined]
     #define memmove memmove
            ^
    arch/arm/include/asm/string.h:59:9: note: previous definition is here
     #define memmove(dst, src, len) __memmove(dst, src, len)
            ^
    arch/arm/boot/compressed/decompress.c:51:9: error: 'memcpy' macro redefined [-Werror,-Wmacro-redefined]
     #define memcpy memcpy
            ^
    arch/arm/include/asm/string.h:58:9: note: previous definition is here
     #define memcpy(dst, src, len) __memcpy(dst, src, len)
            ^

    Here we want the set of functions from the decompressor, so undefine
    the other macros before the override.

    Link: https://lore.kernel.org/linux-arm-kernel/CACRpkdZYJogU_SN3H9oeVq=zJkRgRT1gDz3xp59gdqWXxw-B=w@mail.gmail.com/
    Link: https://lore.kernel.org/lkml/202105091112.F5rmd4By-lkp@intel.com/

    Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
    Fixes: a7f464f3db93 ("ARM: 7001/2: Wire up support for the XZ decompressor")
    Reported-by: kernel test robot <lkp@intel.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 00dcbb2d2cd3594faa2f977f2f7175cf23d4e326
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Mon Oct 4 18:03:28 2021 +0100

    ARM: 9133/1: mm: proc-macros: ensure *_tlb_fns are 4B aligned

    commit e6a0c958bdf9b2e1b57501fc9433a461f0a6aadd upstream.

    A kernel built with CONFIG_THUMB2_KERNEL=y and using clang as the
    assembler could generate non-naturally-aligned v7wbi_tlb_fns which
    results in a boot failure. The original commit adding the macro missed
    the .align directive on this data.

    Link: https://github.com/ClangBuiltLinux/linux/issues/1447
    Link: https://lore.kernel.org/all/0699da7b-354f-aecc-a62f-e25693209af4@linaro.org/
    Debugged-by: Ard Biesheuvel <ardb@kernel.org>
    Debugged-by: Nathan Chancellor <nathan@kernel.org>
    Debugged-by: Richard Henderson <richard.henderson@linaro.org>

    Fixes: 66a625a88174 ("ARM: mm: proc-macros: Add generic proc/cache/tlb struct definition macros")
    Suggested-by: Ard Biesheuvel <ardb@kernel.org>
    Acked-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 38ec06730e44b2166e87fecca9e36380080801ac
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Oct 27 09:53:15 2021 +0200

    Linux 4.19.214

    Link: https://lore.kernel.org/r/20211025190926.680827862@linuxfoundation.org
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0b7d55ca605e611aceeadf7c29c75808faae951a
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Wed Sep 8 19:25:59 2021 +0100

    ARM: 9122/1: select HAVE_FUTEX_CMPXCHG

    commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

    tglx notes:
      This function [futex_detect_cmpxchg] is only needed when an
      architecture has to runtime discover whether the CPU supports it or
      not.  ARM has unconditional support for this, so the obvious thing to
      do is the below.

    Fixes linkage failure from Clang randconfigs:
    kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
    and boot failures for CONFIG_THUMB2_KERNEL.

    Link: https://github.com/ClangBuiltLinux/linux/issues/325

    Comments from Nick Desaulniers:

     See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
     futex_atomic_cmpxchg_inatomic() test")

    Reported-by: Arnd Bergmann <arnd@arndb.de>
    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Suggested-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Cc: stable@vger.kernel.org # v3.14+
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3de1ed125fc4c35bf7abb08260646100a6dcb04e
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Mon Oct 18 15:44:12 2021 -0400

    tracing: Have all levels of checks prevent recursion

    commit ed65df63a39a3f6ed04f7258de8b6789e5021c18 upstream.

    While writing an email explaining the "bit = 0" logic for a discussion on
    making ftrace_test_recursion_trylock() disable preemption, I discovered a
    path that makes the "not do the logic if bit is zero" unsafe.

    The recursion logic is done in hot paths like the function tracer. Thus,
    any code executed causes noticeable overhead. Thus, tricks are done to try
    to limit the amount of code executed. This included the recursion testing
    logic.

    Having recursion testing is important, as there are many paths that can
    end up in an infinite recursion cycle when tracing every function in the
    kernel. Thus protection is needed to prevent that from happening.

    Because it is OK to recurse due to different running context levels (e.g.
    an interrupt preempts a trace, and then a trace occurs in the interrupt
    handler), a set of bits are used to know which context one is in (normal,
    softirq, irq and NMI). If a recursion occurs in the same level, it is
    prevented*.

    Then there are infrastructure levels of recursion as well. When more than
    one callback is attached to the same function to trace, it calls a loop
    function to iterate over all the callbacks. Both the callbacks and the
    loop function have recursion protection. The callbacks use the
    "ftrace_test_recursion_trylock()" which has a "function" set of context
    bits to test, and the loop function calls the internal
    trace_test_and_set_recursion() directly, with an "internal" set of bits.

    If an architecture does not implement all the features supported by ftrace
    then the callbacks are never called directly, and the loop function is
    called instead, which will implement the features of ftrace.

    Since both the loop function and the callbacks do recursion protection, it
    was seemed unnecessary to do it in both locations. Thus, a trick was made
    to have the internal set of recursion bits at a more significant bit
    location than the function bits. Then, if any of the higher bits were set,
    the logic of the function bits could be skipped, as any new recursion
    would first have to go through the loop function.

    This is true for architectures that do not support all the ftrace
    features, because all functions being traced must first go through the
    loop function before going to the callbacks. But this is not true for
    architectures that support all the ftrace features. That's because the
    loop function could be called due to two callbacks attached to the same
    function, but then a recursion function inside the callback could be
    called that does not share any other callback, and it will be called
    directly.

    i.e.

     traced_function_1: [ more than one callback tracing it ]
       call loop_func

     loop_func:
       trace_recursion set internal bit
       call callback

     callback:
       trace_recursion [ skipped because internal bit is set, return 0 ]
       call traced_function_2

     traced_function_2: [ only traced by above callback ]
       call callback

     callback:
       trace_recursion [ skipped because internal bit is set, return 0 ]
       call traced_function_2

     [ wash, rinse, repeat, BOOM! out of shampoo! ]

    Thus, the "bit == 0 skip" trick is not safe, unless the loop function is
    call for all functions.

    Since we want to encourage architectures to implement all ftrace features,
    having them slow down due to this extra logic may encourage the
    maintainers to update to the latest ftrace features. And because this
    logic is only safe for them, remove it completely.

     [*] There is on layer of recursion that is allowed, and that is to allow
         for the transition between interrupt context (normal -> softirq ->
         irq -> NMI), because a trace may occur before the context update is
         visible to the trace recursion logic.

    Link: https://lore.kernel.org/all/609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com/
    Link: https://lkml.kernel.org/r/20211018154412.09fcad3c@gandalf.local.home

    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
    Cc: Helge Deller <deller@gmx.de>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Cc: Palmer Dabbelt <palmer@dabbelt.com>
    Cc: Albert Ou <aou@eecs.berkeley.edu>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Miroslav Benes <mbenes@suse.cz>
    Cc: Joe Lawrence <joe.lawrence@redhat.com>
    Cc: Colin Ian King <colin.king@canonical.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Jisheng Zhang <jszhang@kernel.org>
    Cc: =?utf-8?b?546L6LSH?= <yun.wang@linux.alibaba.com>
    Cc: Guo Ren <guoren@kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: edc15cafcbfa3 ("tracing: Avoid unnecessary multiple recursion checks")
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a9831afa2dc8a18205403907c41aa4e0950ac611
Author: Yanfei Xu <yanfei.xu@windriver.com>
Date:   Sun Sep 26 12:53:13 2021 +0800

    net: mdiobus: Fix memory leak in __mdiobus_register

    commit ab609f25d19858513919369ff3d9a63c02cd9e2e upstream.

    Once device_register() failed, we should call put_device() to
    decrement reference count for cleanup. Or it will cause memory
    leak.

    BUG: memory leak
    unreferenced object 0xffff888114032e00 (size 256):
      comm "kworker/1:3", pid 2960, jiffies 4294943572 (age 15.920s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 08 2e 03 14 81 88 ff ff  ................
        08 2e 03 14 81 88 ff ff 90 76 65 82 ff ff ff ff  .........ve.....
      backtrace:
        [<ffffffff8265cfab>] kmalloc include/linux/slab.h:591 [inline]
        [<ffffffff8265cfab>] kzalloc include/linux/slab.h:721 [inline]
        [<ffffffff8265cfab>] device_private_init drivers/base/core.c:3203 [inline]
        [<ffffffff8265cfab>] device_add+0x89b/0xdf0 drivers/base/core.c:3253
        [<ffffffff828dd643>] __mdiobus_register+0xc3/0x450 drivers/net/phy/mdio_bus.c:537
        [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
        [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
        [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
        [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
        [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
        [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
        [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
        [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
        [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
        [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
        [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
        [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
        [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
        [<ffffffff82660916>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
        [<ffffffff8265cd0b>] device_add+0x5fb/0xdf0 drivers/base/core.c:3359
        [<ffffffff82c343b9>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2170
        [<ffffffff82c4473c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238

    BUG: memory leak
    unreferenced object 0xffff888116f06900 (size 32):
      comm "kworker/0:2", pid 2670, jiffies 4294944448 (age 7.160s)
      hex dump (first 32 bytes):
        75 73 62 2d 30 30 31 3a 30 30 33 00 00 00 00 00  usb-001:003.....
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<ffffffff81484516>] kstrdup+0x36/0x70 mm/util.c:60
        [<ffffffff814845a3>] kstrdup_const+0x53/0x80 mm/util.c:83
        [<ffffffff82296ba2>] kvasprintf_const+0xc2/0x110 lib/kasprintf.c:48
        [<ffffffff82358d4b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
        [<ffffffff826575f3>] dev_set_name+0x63/0x90 drivers/base/core.c:3147
        [<ffffffff828dd63b>] __mdiobus_register+0xbb/0x450 drivers/net/phy/mdio_bus.c:535
        [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
        [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
        [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
        [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
        [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
        [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
        [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
        [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
        [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
        [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
        [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
        [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
        [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969

    Reported-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
    Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 629e870ca473bbf3ec2429d441efb0406869783d
Author: Dexuan Cui <decui@microsoft.com>
Date:   Thu Oct 7 21:35:46 2021 -0700

    scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma()

    commit 50b6cb3516365cb69753b006be2b61c966b70588 upstream.

    After commit ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at
    can_queue"), a 416-CPU VM running on Hyper-V hangs during boot because the
    hv_storvsc driver sets scsi_driver.can_queue to an integer value that
    exceeds SHRT_MAX, and hence scsi_add_host_with_dma() sets
    shost->cmd_per_lun to a negative "short" value.

    Use min_t(int, ...) to work around the issue.

    Link: https://lore.kernel.org/r/20211008043546.6006-1-decui@microsoft.com
    Fixes: ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at can_queue")
    Cc: stable@vger.kernel.org
    Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
    Reviewed-by: Ming Lei <ming.lei@redhat.com>
    Reviewed-by: John Garry <john.garry@huawei.com>
    Signed-off-by: Dexuan Cui <decui@microsoft.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1360f9cde7eaaea4e6b48ab4ec544c706dbc6a8a
Author: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Date:   Tue Oct 12 17:29:35 2021 +0300

    ALSA: hda: avoid write to STATESTS if controller is in reset

    [ Upstream commit b37a15188eae9d4c49c5bb035e0c8d4058e4d9b3 ]

    The snd_hdac_bus_reset_link() contains logic to clear STATESTS register
    before performing controller reset. This code dates back to an old
    bugfix in commit e8a7f136f5ed ("[ALSA] hda-intel - Improve HD-audio
    codec probing robustness"). Originally the code was added to
    azx_reset().

    The code was moved around in commit a41d122449be ("ALSA: hda - Embed bus
    into controller object") and ended up to snd_hdac_bus_reset_link() and
    called primarily via snd_hdac_bus_init_chip().

    The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is
    called when controller is not in reset. In this case, STATESTS can be
    cleared. This can be useful e.g. when forcing a controller reset to retry
    codec probe. A normal non-power-on reset will not clear the bits.

    However, this old logic is problematic when controller is already in
    reset. The HDA specification states that controller must be taken out of
    reset before writing to registers other than GCTL.CRST (1.0a spec,
    3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost
    if the controller is already in reset per the HDA specification mentioned.

    This has been harmless on older hardware. On newer generation of Intel
    PCIe based HDA controllers, if configured to report issues, this write
    will emit an unsupported request error. If ACPI Platform Error Interface
    (APEI) is enabled in kernel, this will end up to kernel log.

    Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if
    the function is called when controller is not in reset. Otherwise
    clearing the bits is not possible and should be skipped.

    Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
    Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f7db1bc1cdb809fdd65d50485fb67bd418eadbd5
Author: Prashant Malani <pmalani@chromium.org>
Date:   Tue Sep 28 03:19:34 2021 -0700

    platform/x86: intel_scu_ipc: Update timeout value in comment

    [ Upstream commit a0c5814b9933f25ecb6de169483c5b88cf632bca ]

    The comment decribing the IPC timeout hadn't been updated when the
    actual timeout was changed from 3 to 5 seconds in
    commit a7d53dbbc70a ("platform/x86: intel_scu_ipc: Increase virtual
    timeout from 3 to 5 seconds") .

    Since the value is anyway updated to 10s now, take this opportunity to
    update the value in the comment too.

    Signed-off-by: Prashant Malani <pmalani@chromium.org>
    Cc: Benson Leung <bleung@chromium.org>
    Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Link: https://lore.kernel.org/r/20210928101932.2543937-4-pmalani@chromium.org
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a5b34409d3fc52114c828be4adbc30744fa3258b
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sat Oct 9 11:33:49 2021 +0000

    isdn: mISDN: Fix sleeping function called from invalid context

    [ Upstream commit 6510e80a0b81b5d814e3aea6297ba42f5e76f73c ]

    The driver can call card->isac.release() function from an atomic
    context.

    Fix this by calling this function after releasing the lock.

    The following log reveals it:

    [   44.168226 ] BUG: sleeping function called from invalid context at kernel/workqueue.c:3018
    [   44.168941 ] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5475, name: modprobe
    [   44.169574 ] INFO: lockdep is turned off.
    [   44.169899 ] irq event stamp: 0
    [   44.170160 ] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
    [   44.170627 ] hardirqs last disabled at (0): [<ffffffff814209ed>] copy_process+0x132d/0x3e00
    [   44.171240 ] softirqs last  enabled at (0): [<ffffffff81420a1a>] copy_process+0x135a/0x3e00
    [   44.171852 ] softirqs last disabled at (0): [<0000000000000000>] 0x0
    [   44.172318 ] Preemption disabled at:
    [   44.172320 ] [<ffffffffa009b0a9>] nj_release+0x69/0x500 [netjet]
    [   44.174441 ] Call Trace:
    [   44.174630 ]  dump_stack_lvl+0xa8/0xd1
    [   44.174912 ]  dump_stack+0x15/0x17
    [   44.175166 ]  ___might_sleep+0x3a2/0x510
    [   44.175459 ]  ? nj_release+0x69/0x500 [netjet]
    [   44.175791 ]  __might_sleep+0x82/0xe0
    [   44.176063 ]  ? start_flush_work+0x20/0x7b0
    [   44.176375 ]  start_flush_work+0x33/0x7b0
    [   44.176672 ]  ? trace_irq_enable_rcuidle+0x85/0x170
    [   44.177034 ]  ? kasan_quarantine_put+0xaa/0x1f0
    [   44.177372 ]  ? kasan_quarantine_put+0xaa/0x1f0
    [   44.177711 ]  __flush_work+0x11a/0x1a0
    [   44.177991 ]  ? flush_work+0x20/0x20
    [   44.178257 ]  ? lock_release+0x13c/0x8f0
    [   44.178550 ]  ? __kasan_check_write+0x14/0x20
    [   44.178872 ]  ? do_raw_spin_lock+0x148/0x360
    [   44.179187 ]  ? read_lock_is_recursive+0x20/0x20
    [   44.179530 ]  ? __kasan_check_read+0x11/0x20
    [   44.179846 ]  ? do_raw_spin_unlock+0x55/0x900
    [   44.180168 ]  ? ____kasan_slab_free+0x116/0x140
    [   44.180505 ]  ? _raw_spin_unlock_irqrestore+0x41/0x60
    [   44.180878 ]  ? skb_queue_purge+0x1a3/0x1c0
    [   44.181189 ]  ? kfree+0x13e/0x290
    [   44.181438 ]  flush_work+0x17/0x20
    [   44.181695 ]  mISDN_freedchannel+0xe8/0x100
    [   44.182006 ]  isac_release+0x210/0x260 [mISDNipac]
    [   44.182366 ]  nj_release+0xf6/0x500 [netjet]
    [   44.182685 ]  nj_remove+0x48/0x70 [netjet]
    [   44.182989 ]  pci_device_remove+0xa9/0x250

    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 207f6c3a82e19626aedad6e2f9aa0bb348495447
Author: Herve Codina <herve.codina@bootlin.com>
Date:   Fri Oct 8 12:34:40 2021 +0200

    ARM: dts: spear3xx: Fix gmac node

    [ Upstream commit 6636fec29cdf6665bd219564609e8651f6ddc142 ]

    On SPEAr3xx, ethernet driver is not compatible with the SPEAr600
    one.
    Indeed, SPEAr3xx uses an earlier version of this IP (v3.40) and
    needs some driver tuning compare to SPEAr600.

    The v3.40 IP support was added to stmmac driver and this patch
    fixes this issue and use the correct compatible string for
    SPEAr3xx

    Signed-off-by: Herve Codina <herve.codina@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit cfe8c4a4d6eb21af53504c6b85393de2f8345685
Author: Herve Codina <herve.codina@bootlin.com>
Date:   Fri Oct 8 12:34:39 2021 +0200

    net: stmmac: add support for dwmac 3.40a

    [ Upstream commit 9cb1d19f47fafad7dcf7c8564e633440c946cfd7 ]

    dwmac 3.40a is an old ip version that can be found on SPEAr3xx soc.

    Signed-off-by: Herve Codina <herve.codina@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f03a8a85e91580f7881b24c24ab2e4e37d8080b1
Author: Filipe Manana <fdmanana@suse.com>
Date:   Fri Oct 1 13:52:30 2021 +0100

    btrfs: deal with errors when checking if a dir entry exists during log replay

    [ Upstream commit 77a5b9e3d14cbce49ceed2766b2003c034c066dc ]

    Currently inode_in_dir() ignores errors returned from
    btrfs_lookup_dir_index_item() and from btrfs_lookup_dir_item(), treating
    any errors as if the directory entry does not exists in the fs/subvolume
    tree, which is obviously not correct, as we can get errors such as -EIO
    when reading extent buffers while searching the fs/subvolume's tree.

    Fix that by making inode_in_dir() return the errors and making its only
    caller, add_inode_ref(), deal with returned errors a…
warudooooo added a commit to warudooooo/android_kernel_sm6225_spes that referenced this issue Sep 20, 2023
…x/kernel/git/stable/linux-stable

commit 00a95330f3b295d4a581c36a5f2949c731386e37
Merge: 9e5a216016f0 a027d43cf3f2
Author: warudo <waldoreyes2301@gmail.com>
Date:   Wed Sep 20 16:00:07 2023 +0800

    Merge tag 'v4.19.215'

    This is the 4.19.215 stable release

commit a027d43cf3f2fdaabf467b4bcb92d0fe748c2eaf
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Nov 2 18:26:46 2021 +0100

    Linux 4.19.215

    Link: https://lore.kernel.org/r/20211101082451.430720900@linuxfoundation.org
    Link: https://lore.kernel.org/r/20211101114224.924071362@linuxfoundation.org
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Hulk Robot <hulkrobot@huawei.com>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1ff3c379248ea579aa122d4ca245028e4bc9af23
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:47 2021 -0400

    sctp: add vtag check in sctp_sf_ootb

    [ Upstream commit 9d02831e517aa36ee6bdb453a0eb47bd49923fe3 ]

    sctp_sf_ootb() is called when processing DATA chunk in closed state,
    and many other places are also using it.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    When fails to verify the vtag from the chunk, this patch sets asoc
    to NULL, so that the abort will be made with the vtag from the
    received chunk later.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d9a4f990aab48dd5c134a9e76c7b651d404b05d3
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:46 2021 -0400

    sctp: add vtag check in sctp_sf_do_8_5_1_E_sa

    [ Upstream commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998 ]

    sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk
    in cookie_wait and cookie_echoed state.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    Note that when fails to verify the vtag from SHUTDOWN-ACK chunk,
    SHUTDOWN COMPLETE message will still be sent back to peer, but
    with the vtag from SHUTDOWN-ACK chunk, as said in 5) of
    rfc4960#section-8.4.

    While at it, also remove the unnecessary chunk length check from
    sctp_sf_shut_8_4_5(), as it's already done in both places where
    it calls sctp_sf_shut_8_4_5().

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7bf2f6a30d1851c530ad5e4ee7e5c45fb6be0128
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:45 2021 -0400

    sctp: add vtag check in sctp_sf_violation

    [ Upstream commit aa0f697e45286a6b5f0ceca9418acf54b9099d99 ]

    sctp_sf_violation() is called when processing HEARTBEAT_ACK chunk
    in cookie_wait state, and some other places are also using it.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 86044244fc6f9eaec0070cb668e0d500de22dbba
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:44 2021 -0400

    sctp: fix the processing for COOKIE_ECHO chunk

    [ Upstream commit a64b341b8695e1c744dd972b39868371b4f68f83 ]

    1. In closed state: in sctp_sf_do_5_1D_ce():

      When asoc is NULL, making packet for abort will use chunk's vtag
      in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk
      should be verified before using peer.i.init_tag to make packet
      for abort in sctp_ootb_pkt_new(), and just discard it if vtag is
      not correct.

    2. In the other states: in sctp_sf_do_5_2_4_dupcook():

      asoc always exists, but duplicate cookie_echo's vtag will be
      handled by sctp_tietags_compare() and then take actions, so before
      that we only verify the vtag for the abort sent for invalid chunk
      length.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1f52dfacca7bb315d89f5ece5660b0337809798e
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:41 2021 -0400

    sctp: use init_tag from inithdr for ABORT chunk

    [ Upstream commit 4f7019c7eb33967eb87766e0e4602b5576873680 ]

    Currently Linux SCTP uses the verification tag of the existing SCTP
    asoc when failing to process and sending the packet with the ABORT
    chunk. This will result in the peer accepting the ABORT chunk and
    removing the SCTP asoc. One could exploit this to terminate a SCTP
    asoc.

    This patch is to fix it by always using the initiate tag of the
    received INIT chunk for the ABORT chunk to be sent.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b75fa48e42d022d6757b7de29178d531df8cf43b
Author: Trevor Woerner <twoerner@gmail.com>
Date:   Sun Oct 24 13:50:02 2021 -0400

    net: nxp: lpc_eth.c: avoid hang when bringing interface down

    commit ace19b992436a257d9a793672e57abc28fe83e2e upstream.

    A hard hang is observed whenever the ethernet interface is brought
    down. If the PHY is stopped before the LPC core block is reset,
    the SoC will hang. Comparing lpc_eth_close() and lpc_eth_open() I
    re-arranged the ordering of the functions calls in lpc_eth_close() to
    reset the hardware before stopping the PHY.
    Fixes: b7370112f519 ("lpc32xx: Added ethernet driver")
    Signed-off-by: Trevor Woerner <twoerner@gmail.com>
    Acked-by: Vladimir Zapolskiy <vz@mleia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 84a9eb9a2f179ea5e6398fe270560a8aaa16f996
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Fri Oct 22 11:53:43 2021 -0400

    net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent

    commit 95a359c9553342d36d408d35331ff0bfce75272f upstream.

    The dma failure was reported in the raspberry pi github (issue #4117).
    https://github.com/raspberrypi/linux/issues/4117
    The use of dma_set_mask_and_coherent fixes the issue.
    Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430.

    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fcda74cc95aa450a6d17780ccb1a8853cac7d0cd
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Fri Oct 22 11:13:53 2021 -0400

    net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails

    commit d6423d2ec39cce2bfca418c81ef51792891576bc upstream.

    The driver needs to clean up and return when the initialization fails on resume.

    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 25d852a8adf017a478246d19c8b282e975521e8a
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Wed Oct 20 12:11:16 2021 -0700

    nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST

    commit 4a089e95b4d6bb625044d47aed0c442a8f7bd093 upstream.

    nios2:allmodconfig builds fail with

    make[1]: *** No rule to make target 'arch/nios2/boot/dts/""',
    	needed by 'arch/nios2/boot/dts/built-in.a'.  Stop.
    make: [Makefile:1868: arch/nios2/boot/dts] Error 2 (ignored)

    This is seen with compile tests since those enable NIOS2_DTB_SOURCE_BOOL,
    which in turn enables NIOS2_DTB_SOURCE. This causes the build error
    because the default value for NIOS2_DTB_SOURCE is an empty string.
    Disable NIOS2_DTB_SOURCE_BOOL for compile tests to avoid the error.

    Fixes: 2fc8483fdcde ("nios2: Build infrastructure")
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02302cbd52264337630a32848ac03648648e9685
Author: Michael Chan <michael.chan@broadcom.com>
Date:   Mon Oct 25 05:05:28 2021 -0400

    net: Prevent infinite while loop in skb_tx_hash()

    commit 0c57eeecc559ca6bc18b8c4e2808bc78dbe769b0 upstream.

    Drivers call netdev_set_num_tc() and then netdev_set_tc_queue()
    to set the queue count and offset for each TC.  So the queue count
    and offset for the TCs may be zero for a short period after dev->num_tc
    has been set.  If a TX packet is being transmitted at this time in the
    code path netdev_pick_tx() -> skb_tx_hash(), skb_tx_hash() may see
    nonzero dev->num_tc but zero qcount for the TC.  The while loop that
    keeps looping while hash >= qcount will not end.

    Fix it by checking the TC's qcount to be nonzero before using it.

    Fixes: eadec877ce9c ("net: Add support for subordinate traffic classes to netdev_pick_tx")
    Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
    Signed-off-by: Michael Chan <michael.chan@broadcom.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbf150b16a3635634b7dfb7f229d8fcd643c6c51
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Sun Oct 24 16:13:56 2021 +0300

    net: batman-adv: fix error handling

    commit 6f68cd634856f8ca93bafd623ba5357e0f648c68 upstream.

    Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
    in wrong error handling in batadv_mesh_init().

    Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
    of any batadv_*_init() calls failure. This approach may work well, when
    there is some kind of indicator, which can tell which parts of batadv are
    initialized; but there isn't any.

    All written above lead to cleaning up uninitialized fields. Even if we hide
    ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
    GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]

    To fix these bugs we can unwind batadv_*_init() calls one by one.
    It is good approach for 2 reasons: 1) It fixes bugs on error handling
    path 2) It improves the performance, since we won't call unneeded
    batadv_*_free() functions.

    So, this patch makes all batadv_*_init() clean up all allocated memory
    before returning with an error to no call correspoing batadv_*_free()
    and open-codes batadv_mesh_free() with proper order to avoid touching
    uninitialized fields.

    Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/ [1]
    Reported-and-tested-by: syzbot+28b0702ada0bf7381f58@syzkaller.appspotmail.com
    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Acked-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3dae1a4eced3ee733d7222e69b8a55caf2d61091
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Oct 12 10:37:35 2021 +0800

    regmap: Fix possible double-free in regcache_rbtree_exit()

    commit 55e6d8037805b3400096d621091dfbf713f97e83 upstream.

    In regcache_rbtree_insert_to_block(), when 'present' realloc failed,
    the 'blk' which is supposed to assign to 'rbnode->block' will be freed,
    so 'rbnode->block' points a freed memory, in the error handling path of
    regcache_rbtree_init(), 'rbnode->block' will be freed again in
    regcache_rbtree_exit(), KASAN will report double-free as follows:

    BUG: KASAN: double-free or invalid-free in kfree+0xce/0x390
    Call Trace:
     slab_free_freelist_hook+0x10d/0x240
     kfree+0xce/0x390
     regcache_rbtree_exit+0x15d/0x1a0
     regcache_rbtree_init+0x224/0x2c0
     regcache_init+0x88d/0x1310
     __regmap_init+0x3151/0x4a80
     __devm_regmap_init+0x7d/0x100
     madera_spi_probe+0x10f/0x333 [madera_spi]
     spi_probe+0x183/0x210
     really_probe+0x285/0xc30

    To fix this, moving up the assignment of rbnode->block to immediately after
    the reallocation has succeeded so that the data structure stays valid even
    if the second reallocation fails.

    Reported-by: Hulk Robot <hulkci@huawei.com>
    Fixes: 3f4ff561bc88b ("regmap: rbtree: Make cache_present bitmap per node")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20211012023735.1632786-1-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cdaf7a469244b5e65ae5eda062ff5ea90172de62
Author: Clément Bœsch <u@pkh.me>
Date:   Sun Sep 5 02:20:27 2021 +0200

    arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node

    commit 0764e365dacd0b8f75c1736f9236be280649bd18 upstream.

    RX and TX delay are provided by ethernet PHY. Reflect that in ethernet
    node.

    Fixes: 44a94c7ef989 ("arm64: dts: allwinner: H5: Restore EMAC changes")
    Signed-off-by: Clément Bœsch <u@pkh.me>
    Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Link: https://lore.kernel.org/r/20210905002027.171984-1-u@pkh.me
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2864b6d54244b82a8c7d4628a43055c57bfba80c
Author: Patrisious Haddad <phaddad@nvidia.com>
Date:   Wed Oct 6 12:31:53 2021 +0300

    RDMA/mlx5: Set user priority for DCT

    commit 1ab52ac1e9bc9391f592c9fa8340a6e3e9c36286 upstream.

    Currently, the driver doesn't set the PCP-based priority for DCT, hence
    DCT response packets are transmitted without user priority.

    Fix it by setting user provided priority in the eth_prio field in the DCT
    context, which in turn sets the value in the transmitted packet.

    Fixes: 776a3906b692 ("IB/mlx5: Add support for DC target QP")
    Link: https://lore.kernel.org/r/5fd2d94a13f5742d8803c218927322257d53205c.1633512672.git.leonro@nvidia.com
    Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 326da4f6ffdbd8671e86f69ded7a714dcc12fecf
Author: Johan Hovold <johan@kernel.org>
Date:   Tue Oct 26 12:36:17 2021 +0200

    net: lan78xx: fix division by zero in send path

    commit db6c3c064f5d55fa9969f33eafca3cdbefbb3541 upstream.

    Add the missing endpoint max-packet sanity check to probe() to avoid
    division by zero in lan78xx_tx_bh() in case a malicious device has
    broken descriptors (or when doing descriptor fuzz testing).

    Note that USB core will reject URBs submitted for endpoints with zero
    wMaxPacketSize but that drivers doing packet-size calculations still
    need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip
    endpoint descriptors with maxpacket=0")).

    Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
    Cc: stable@vger.kernel.org      # 4.3
    Cc: Woojung.Huh@microchip.com <Woojung.Huh@microchip.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2ff5289793fd61c56ac8774408f27350e5da865f
Author: Haibo Chen <haibo.chen@nxp.com>
Date:   Fri Oct 15 10:00:36 2021 +0800

    mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit

    commit 9af372dc70e9fdcbb70939dac75365e7b88580b4 upstream.

    To reset standard tuning circuit completely, after clear ESDHC_MIX_CTRL_EXE_TUNE,
    also need to clear bit buffer_read_ready, this operation will finally clear the
    USDHC IP internal logic flag execute_tuning_with_clr_buf, make sure the following
    normal data transfer will not be impacted by standard tuning logic used before.

    Find this issue when do quick SD card insert/remove stress test. During standard
    tuning prodedure, if remove SD card, USDHC standard tuning logic can't clear the
    internal flag execute_tuning_with_clr_buf. Next time when insert SD card, all
    data related commands can't get any data related interrupts, include data transfer
    complete interrupt, data timeout interrupt, data CRC interrupt, data end bit interrupt.
    Always trigger software timeout issue. Even reset the USDHC through bits in register
    SYS_CTRL (0x2C, bit28 reset tuning, bit26 reset data, bit 25 reset command, bit 24
    reset all) can't recover this. From the user's point of view, USDHC stuck, SD can't
    be recognized any more.

    Fixes: d9370424c948 ("mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card")
    Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1634263236-6111-1-git-send-email-haibo.chen@nxp.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7824414c2903e2cfe56ea610387a22c0c88fb468
Author: Shawn Guo <shawn.guo@linaro.org>
Date:   Mon Oct 4 10:49:35 2021 +0800

    mmc: sdhci: Map more voltage level to SDHCI_POWER_330

    commit 4217d07b9fb328751f877d3bd9550122014860a2 upstream.

    On Thundercomm TurboX CM2290, the eMMC OCR reports vdd = 23 (3.5 ~ 3.6 V),
    which is being treated as an invalid value by sdhci_set_power_noreg().
    And thus eMMC is totally broken on the platform.

    [    1.436599] ------------[ cut here ]------------
    [    1.436606] mmc0: Invalid vdd 0x17
    [    1.436640] WARNING: CPU: 2 PID: 69 at drivers/mmc/host/sdhci.c:2048 sdhci_set_power_noreg+0x168/0x2b4
    [    1.436655] Modules linked in:
    [    1.436662] CPU: 2 PID: 69 Comm: kworker/u8:1 Tainted: G        W         5.15.0-rc1+ #137
    [    1.436669] Hardware name: Thundercomm TurboX CM2290 (DT)
    [    1.436674] Workqueue: events_unbound async_run_entry_fn
    [    1.436685] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [    1.436692] pc : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436698] lr : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436703] sp : ffff800010803a60
    [    1.436705] x29: ffff800010803a60 x28: ffff6a9102465f00 x27: ffff6a9101720a70
    [    1.436715] x26: ffff6a91014de1c0 x25: ffff6a91014de010 x24: ffff6a91016af280
    [    1.436724] x23: ffffaf7b1b276640 x22: 0000000000000000 x21: ffff6a9101720000
    [    1.436733] x20: ffff6a9101720370 x19: ffff6a9101720580 x18: 0000000000000020
    [    1.436743] x17: 0000000000000000 x16: 0000000000000004 x15: ffffffffffffffff
    [    1.436751] x14: 0000000000000000 x13: 00000000fffffffd x12: ffffaf7b1b84b0bc
    [    1.436760] x11: ffffaf7b1b720d10 x10: 000000000000000a x9 : ffff800010803a60
    [    1.436769] x8 : 000000000000000a x7 : 000000000000000f x6 : 00000000fffff159
    [    1.436778] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
    [    1.436787] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff6a9101718d80
    [    1.436797] Call trace:
    [    1.436800]  sdhci_set_power_noreg+0x168/0x2b4
    [    1.436805]  sdhci_set_ios+0xa0/0x7fc
    [    1.436811]  mmc_power_up.part.0+0xc4/0x164
    [    1.436818]  mmc_start_host+0xa0/0xb0
    [    1.436824]  mmc_add_host+0x60/0x90
    [    1.436830]  __sdhci_add_host+0x174/0x330
    [    1.436836]  sdhci_msm_probe+0x7c0/0x920
    [    1.436842]  platform_probe+0x68/0xe0
    [    1.436850]  really_probe.part.0+0x9c/0x31c
    [    1.436857]  __driver_probe_device+0x98/0x144
    [    1.436863]  driver_probe_device+0xc8/0x15c
    [    1.436869]  __device_attach_driver+0xb4/0x120
    [    1.436875]  bus_for_each_drv+0x78/0xd0
    [    1.436881]  __device_attach_async_helper+0xac/0xd0
    [    1.436888]  async_run_entry_fn+0x34/0x110
    [    1.436895]  process_one_work+0x1d0/0x354
    [    1.436903]  worker_thread+0x13c/0x470
    [    1.436910]  kthread+0x150/0x160
    [    1.436915]  ret_from_fork+0x10/0x20
    [    1.436923] ---[ end trace fcfac44cb045c3a8 ]---

    Fix the issue by mapping MMC_VDD_35_36 (and MMC_VDD_34_35) to
    SDHCI_POWER_330 as well.

    Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20211004024935.15326-1-shawn.guo@linaro.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29d56f3790e684e630d56f500b59e834fa382209
Author: Jaehoon Chung <jh80.chung@samsung.com>
Date:   Fri Oct 22 17:21:06 2021 +0900

    mmc: dw_mmc: exynos: fix the finding clock sample value

    commit 697542bceae51f7620af333b065dd09d213629fb upstream.

    Even though there are candiates value if can't find best value, it's
    returned -EIO. It's not proper behavior.
    If there is not best value, use a first candiate value to work eMMC.

    Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
    Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Tested-by: Christian Hewitt <christianshewitt@gmail.com>
    Cc: stable@vger.kernel.org
    Fixes: c537a1c5ff63 ("mmc: dw_mmc: exynos: add variable delay tuning sequence")
    Link: https://lore.kernel.org/r/20211022082106.1557-1-jh80.chung@samsung.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 24f8658690477e8983f88cbfe21fb7f4062ad837
Author: Wenbin Mei <wenbin.mei@mediatek.com>
Date:   Tue Oct 26 15:08:12 2021 +0800

    mmc: cqhci: clear HALT state after CQE enable

    commit 92b18252b91de567cd875f2e84722b10ab34ee28 upstream.

    While mmc0 enter suspend state, we need halt CQE to send legacy cmd(flush
    cache) and disable cqe, for resume back, we enable CQE and not clear HALT
    state.
    In this case MediaTek mmc host controller will keep the value for HALT
    state after CQE disable/enable flow, so the next CQE transfer after resume
    will be timeout due to CQE is in HALT state, the log as below:
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: timeout for tag 2
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Caps:      0x100020b6 | Version:  0x00000510
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Config:    0x00001103 | Control:  0x00000001
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int stat:  0x00000000 | Int enab: 0x00000006
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int sig:   0x00000006 | Int Coal: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: TDL base:  0xfd05f000 | TDL up32: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Doorbell:  0x8000203c | TCN:      0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Task clr:  0x00000000 | SSC1:     0x00001000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: SSC2:      0x00000001 | DCMD rsp: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: RED mask:  0xfdf9a080 | TERRI:    0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Resp idx:  0x00000000 | Resp arg: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQP:     0x00000000 | CRNQDUN:  0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQIS:    0x00000000 | CRNQIE:   0x00000000

    This change check HALT state after CQE enable, if CQE is in HALT state, we
    will clear it.

    Signed-off-by: Wenbin Mei <wenbin.mei@mediatek.com>
    Cc: stable@vger.kernel.org
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
    Link: https://lore.kernel.org/r/20211026070812.9359-1-wenbin.mei@mediatek.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99641238575c26c2e47fa593f562dae476709d68
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 13:56:08 2021 +0200

    mmc: vub300: fix control-message timeouts

    commit 8c8171929116cc23f74743d99251eedadf62341a upstream.

    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.

    Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
    Cc: stable@vger.kernel.org      # 3.0
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211025115608.5287-1-johan@kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6d0d68d6da68159948cad3d808d61bb291a0283
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Aug 29 15:16:14 2021 -0700

    ipv6: make exception cache less predictible

    commit a00df2caffed3883c341d5685f830434312e4a43 upstream.

    Even after commit 4785305c05b2 ("ipv6: use siphash in rt6_exception_hash()"),
    an attacker can still use brute force to learn some secrets from a victim
    linux host.

    One way to defeat these attacks is to make the max depth of the hash
    table bucket a random value.

    Before this patch, each bucket of the hash table used to store exceptions
    could contain 6 items under attack.

    After the patch, each bucket would contains a random number of items,
    between 6 and 10. The attacker can no longer infer secrets.

    This is slightly increasing memory size used by the hash table,
    we do not expect this to be a problem.

    Following patch is dealing with the same issue in IPv4.

    Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Wei Wang <weiwan@google.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad829847ad59af8e26a1f1c345716099abbc7a58
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Oct 29 10:50:26 2021 +0300

    ipv6: use siphash in rt6_exception_hash()

    commit 4785305c05b25a242e5314cc821f54ade4c18810 upstream.

    A group of security researchers brought to our attention
    the weakness of hash function used in rt6_exception_hash()

    Lets use siphash instead of Jenkins Hash, to considerably
    reduce security risks.

    Following patch deals with IPv4.

    Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Wei Wang <weiwan@google.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Acked-by: Wei Wang <weiwan@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e2856767eb1a9cfcfcd82136928037f04920e97
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Oct 29 10:50:25 2021 +0300

    ipv4: use siphash instead of Jenkins in fnhe_hashfun()

    commit 6457378fe796815c973f631a1904e147d6ee33b1 upstream.

    A group of security researchers brought to our attention
    the weakness of hash function used in fnhe_hashfun().

    Lets use siphash instead of Jenkins Hash, to considerably
    reduce security risks.

    Also remove the inline keyword, this really is distracting.

    Fixes: d546c621542d ("ipv4: harden fnhe_hashfun()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Willy Tarreau <w@1wt.eu>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8121d0d4fd108280f5cd7b7fe8c6592adaa37be9
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Thu Sep 30 20:49:42 2021 +0300

    Revert "net: mdiobus: Fix memory leak in __mdiobus_register"

    commit 10eff1f5788b6ffac212c254e2f3666219576889 upstream.

    This reverts commit ab609f25d19858513919369ff3d9a63c02cd9e2e.

    This patch is correct in the sense that we _should_ call device_put() in
    case of device_register() failure, but the problem in this code is more
    vast.

    We need to set bus->state to UNMDIOBUS_REGISTERED before calling
    device_register() to correctly release the device in mdiobus_free().
    This patch prevents us from doing it, since in case of device_register()
    failure put_device() will be called 2 times and it will cause UAF or
    something else.

    Also, Reported-by: tag in revered commit was wrong, since syzbot
    reported different leak in same function.

    Link: https://lore.kernel.org/netdev/20210928092657.GI2048@kadam/
    Acked-by: Yanfei Xu <yanfei.xu@windriver.com>
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Link: https://lore.kernel.org/r/f12fb1faa4eccf0f355788225335eb4309ff2599.1633024062.git.paskripkin@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4a9043ba1b0e9bea1da0fe34366222974f2c0f92
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date:   Mon Oct 25 16:49:36 2021 +0200

    nfc: port100: fix using -ERRNO as command type mask

    commit 2195f2062e4cc93870da8e71c318ef98a1c51cef upstream.

    During probing, the driver tries to get a list (mask) of supported
    command types in port100_get_command_type_mask() function.  The value
    is u64 and 0 is treated as invalid mask (no commands supported).  The
    function however returns also -ERRNO as u64 which will be interpret as
    valid command mask.

    Return 0 on every error case of port100_get_command_type_mask(), so the
    probing will stop.

    Cc: <stable@vger.kernel.org>
    Fixes: 0347a6ab300a ("NFC: port100: Commands mechanism implementation")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a36119f9b3fb069437383a8eff4e65181b6e7e2f
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Fri Oct 22 09:12:26 2021 +0000

    ata: sata_mv: Fix the error handling of mv_chip_id()

    commit a0023bb9dd9bc439d44604eeec62426a990054cd upstream.

    mv_init_host() propagates the value returned by mv_chip_id() which in turn
    gets propagated by mv_pci_init_one() and hits local_pci_probe().

    During the process of driver probing, the probe function should return < 0
    for failure, otherwise, the kernel will treat value > 0 as success.

    Since this is a bug rather than a recoverable runtime error we should
    use dev_alert() instead of dev_err().

    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 78c2dc1cdf0bdfc83e473d78f23da4d2aeb98142
Author: Wang Hai <wanghai38@huawei.com>
Date:   Tue Oct 26 20:40:15 2021 +0800

    usbnet: fix error return code in usbnet_probe()

    commit 6f7c88691191e6c52ef2543d6f1da8d360b27a24 upstream.

    Return error code if usb_maxpacket() returns 0 in usbnet_probe()

    Fixes: 397430b50a36 ("usbnet: sanity check for maxpacket")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    Reviewed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211026124015.3025136-1-wanghai38@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 002d82227c0abe29118cf80f7e2f396b22d448ed
Author: Oliver Neukum <oneukum@suse.com>
Date:   Thu Oct 21 14:29:44 2021 +0200

    usbnet: sanity check for maxpacket

    commit 397430b50a363d8b7bdda00522123f82df6adc5e upstream.

    maxpacket of 0 makes no sense and oopses as we need to divide
    by it. Give up.

    V2: fixed typo in log and stylistic issues

    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Reported-by: syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com
    Reviewed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211021122944.21816-1-oneukum@suse.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d725978abb0bac6e0c427548dfd6db86709a2a1e
Author: Nathan Chancellor <natechancellor@gmail.com>
Date:   Sat Jan 5 19:35:25 2019 +0100

    ARM: 8819/1: Remove '-p' from LDFLAGS

    commit 091bb549f7722723b284f63ac665e2aedcf9dec9 upstream.

    This option is not supported by lld:

        ld.lld: error: unknown argument: -p

    This has been a no-op in binutils since 2004 (see commit dea514f51da1 in
    that tree). Given that the lowest officially supported of binutils for
    the kernel is 2.20, which was released in 2009, nobody needs this flag
    around so just remove it. Commit 1a381d4a0a9a ("arm64: remove no-op -p
    linker flag") did the same for arm64.

    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
    Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Acked-by: Nicolas Pitre <nico@linaro.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Stefan Agner <stefan@agner.ch>
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aaf4e1b05cab800b36b40c1aa09f7c13ef30de56
Author: Robin Murphy <robin.murphy@arm.com>
Date:   Mon Jul 12 15:27:46 2021 +0100

    arm64: Avoid premature usercopy failure

    commit 295cf156231ca3f9e3a66bde7fab5e09c41835e0 upstream.

    Al reminds us that the usercopy API must only return complete failure
    if absolutely nothing could be copied. Currently, if userspace does
    something silly like giving us an unaligned pointer to Device memory,
    or a size which overruns MTE tag bounds, we may fail to honour that
    requirement when faulting on a multi-byte access even though a smaller
    access could have succeeded.

    Add a mitigation to the fixup routines to fall back to a single-byte
    copy if we faulted on a larger access before anything has been written
    to the destination, to guarantee making *some* forward progress. We
    needn't be too concerned about the overall performance since this should
    only occur when callers are doing something a bit dodgy in the first
    place. Particularly broken userspace might still be able to trick
    generic_perform_write() into an infinite loop by targeting write() at
    an mmap() of some read-only device register where the fault-in load
    succeeds but any store synchronously aborts such that copy_to_user() is
    genuinely unable to make progress, but, well, don't do that...

    CC: stable@vger.kernel.org
    Reported-by: Chen Huang <chenhuang5@huawei.com>
    Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Robin Murphy <robin.murphy@arm.com>
    Link: https://lore.kernel.org/r/dc03d5c675731a1f24a62417dba5429ad744234e.1626098433.git.robin.murphy@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Chen Huang <chenhuang5@huawei.com>

commit 5909b851b5e11d04f299e5f0a8937e9dcc807248
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Date:   Wed Oct 6 01:55:22 2021 +0530

    powerpc/bpf: Fix BPF_MOD when imm == 1

    commit 8bbc9d822421d9ac8ff9ed26a3713c9afc69d6c8 upstream.

    Only ignore the operation if dividing by 1.

    Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
    Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Tested-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Acked-by: Song Liu <songliubraving@fb.com>
    Acked-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/c674ca18c3046885602caebb326213731c675d06.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
    [cascardo: use PPC_LI instead of EMIT(PPC_RAW_LI)]
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 901741a53d7cf45be861e881c0e3cba5b4bd1f94
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:37 2021 +0100

    ARM: 9141/1: only warn about XIP address when not compile testing

    commit 48ccc8edf5b90622cdc4f8878e0042ab5883e2ca upstream.

    In randconfig builds, we sometimes come across this warning:

    arm-linux-gnueabi-ld: XIP start address may cause MPU programming issues

    While this is helpful for actual systems to figure out why it
    fails, the warning does not provide any benefit for build testing,
    so guard it in a check for CONFIG_COMPILE_TEST, which is usually
    set on randconfig builds.

    Fixes: 216218308cfb ("ARM: 8713/1: NOMMU: Support MPU in XIP configuration")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee4b38ce37ed31beca29d3ebec7db3d5e87fe39e
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:09 2021 +0100

    ARM: 9139/1: kprobes: fix arch_init_kprobes() prototype

    commit 1f323127cab086e4fd618981b1e5edc396eaf0f4 upstream.

    With extra warnings enabled, gcc complains about this function
    definition:

    arch/arm/probes/kprobes/core.c: In function 'arch_init_kprobes':
    arch/arm/probes/kprobes/core.c:465:12: warning: old-style function definition [-Wold-style-definition]
      465 | int __init arch_init_kprobes()

    Link: https://lore.kernel.org/all/20201027093057.c685a14b386acacb3c449e3d@kernel.org/

    Fixes: 24ba613c9d6c ("ARM kprobes: core code")
    Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c0b4f1db7feef31d401814121760b45aff7885c1
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:04 2021 +0100

    ARM: 9134/1: remove duplicate memcpy() definition

    commit eaf6cc7165c9c5aa3c2f9faa03a98598123d0afb upstream.

    Both the decompressor code and the kasan logic try to override
    the memcpy() and memmove()  definitions, which leading to a clash
    in a KASAN-enabled kernel with XZ decompression:

    arch/arm/boot/compressed/decompress.c:50:9: error: 'memmove' macro redefined [-Werror,-Wmacro-redefined]
     #define memmove memmove
            ^
    arch/arm/include/asm/string.h:59:9: note: previous definition is here
     #define memmove(dst, src, len) __memmove(dst, src, len)
            ^
    arch/arm/boot/compressed/decompress.c:51:9: error: 'memcpy' macro redefined [-Werror,-Wmacro-redefined]
     #define memcpy memcpy
            ^
    arch/arm/include/asm/string.h:58:9: note: previous definition is here
     #define memcpy(dst, src, len) __memcpy(dst, src, len)
            ^

    Here we want the set of functions from the decompressor, so undefine
    the other macros before the override.

    Link: https://lore.kernel.org/linux-arm-kernel/CACRpkdZYJogU_SN3H9oeVq=zJkRgRT1gDz3xp59gdqWXxw-B=w@mail.gmail.com/
    Link: https://lore.kernel.org/lkml/202105091112.F5rmd4By-lkp@intel.com/

    Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
    Fixes: a7f464f3db93 ("ARM: 7001/2: Wire up support for the XZ decompressor")
    Reported-by: kernel test robot <lkp@intel.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 00dcbb2d2cd3594faa2f977f2f7175cf23d4e326
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Mon Oct 4 18:03:28 2021 +0100

    ARM: 9133/1: mm: proc-macros: ensure *_tlb_fns are 4B aligned

    commit e6a0c958bdf9b2e1b57501fc9433a461f0a6aadd upstream.

    A kernel built with CONFIG_THUMB2_KERNEL=y and using clang as the
    assembler could generate non-naturally-aligned v7wbi_tlb_fns which
    results in a boot failure. The original commit adding the macro missed
    the .align directive on this data.

    Link: https://github.com/ClangBuiltLinux/linux/issues/1447
    Link: https://lore.kernel.org/all/0699da7b-354f-aecc-a62f-e25693209af4@linaro.org/
    Debugged-by: Ard Biesheuvel <ardb@kernel.org>
    Debugged-by: Nathan Chancellor <nathan@kernel.org>
    Debugged-by: Richard Henderson <richard.henderson@linaro.org>

    Fixes: 66a625a88174 ("ARM: mm: proc-macros: Add generic proc/cache/tlb struct definition macros")
    Suggested-by: Ard Biesheuvel <ardb@kernel.org>
    Acked-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 38ec06730e44b2166e87fecca9e36380080801ac
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Oct 27 09:53:15 2021 +0200

    Linux 4.19.214

    Link: https://lore.kernel.org/r/20211025190926.680827862@linuxfoundation.org
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0b7d55ca605e611aceeadf7c29c75808faae951a
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Wed Sep 8 19:25:59 2021 +0100

    ARM: 9122/1: select HAVE_FUTEX_CMPXCHG

    commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

    tglx notes:
      This function [futex_detect_cmpxchg] is only needed when an
      architecture has to runtime discover whether the CPU supports it or
      not.  ARM has unconditional support for this, so the obvious thing to
      do is the below.

    Fixes linkage failure from Clang randconfigs:
    kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
    and boot failures for CONFIG_THUMB2_KERNEL.

    Link: https://github.com/ClangBuiltLinux/linux/issues/325

    Comments from Nick Desaulniers:

     See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
     futex_atomic_cmpxchg_inatomic() test")

    Reported-by: Arnd Bergmann <arnd@arndb.de>
    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Suggested-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Cc: stable@vger.kernel.org # v3.14+
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3de1ed125fc4c35bf7abb08260646100a6dcb04e
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Mon Oct 18 15:44:12 2021 -0400

    tracing: Have all levels of checks prevent recursion

    commit ed65df63a39a3f6ed04f7258de8b6789e5021c18 upstream.

    While writing an email explaining the "bit = 0" logic for a discussion on
    making ftrace_test_recursion_trylock() disable preemption, I discovered a
    path that makes the "not do the logic if bit is zero" unsafe.

    The recursion logic is done in hot paths like the function tracer. Thus,
    any code executed causes noticeable overhead. Thus, tricks are done to try
    to limit the amount of code executed. This included the recursion testing
    logic.

    Having recursion testing is important, as there are many paths that can
    end up in an infinite recursion cycle when tracing every function in the
    kernel. Thus protection is needed to prevent that from happening.

    Because it is OK to recurse due to different running context levels (e.g.
    an interrupt preempts a trace, and then a trace occurs in the interrupt
    handler), a set of bits are used to know which context one is in (normal,
    softirq, irq and NMI). If a recursion occurs in the same level, it is
    prevented*.

    Then there are infrastructure levels of recursion as well. When more than
    one callback is attached to the same function to trace, it calls a loop
    function to iterate over all the callbacks. Both the callbacks and the
    loop function have recursion protection. The callbacks use the
    "ftrace_test_recursion_trylock()" which has a "function" set of context
    bits to test, and the loop function calls the internal
    trace_test_and_set_recursion() directly, with an "internal" set of bits.

    If an architecture does not implement all the features supported by ftrace
    then the callbacks are never called directly, and the loop function is
    called instead, which will implement the features of ftrace.

    Since both the loop function and the callbacks do recursion protection, it
    was seemed unnecessary to do it in both locations. Thus, a trick was made
    to have the internal set of recursion bits at a more significant bit
    location than the function bits. Then, if any of the higher bits were set,
    the logic of the function bits could be skipped, as any new recursion
    would first have to go through the loop function.

    This is true for architectures that do not support all the ftrace
    features, because all functions being traced must first go through the
    loop function before going to the callbacks. But this is not true for
    architectures that support all the ftrace features. That's because the
    loop function could be called due to two callbacks attached to the same
    function, but then a recursion function inside the callback could be
    called that does not share any other callback, and it will be called
    directly.

    i.e.

     traced_function_1: [ more than one callback tracing it ]
       call loop_func

     loop_func:
       trace_recursion set internal bit
       call callback

     callback:
       trace_recursion [ skipped because internal bit is set, return 0 ]
       call traced_function_2

     traced_function_2: [ only traced by above callback ]
       call callback

     callback:
       trace_recursion [ skipped because internal bit is set, return 0 ]
       call traced_function_2

     [ wash, rinse, repeat, BOOM! out of shampoo! ]

    Thus, the "bit == 0 skip" trick is not safe, unless the loop function is
    call for all functions.

    Since we want to encourage architectures to implement all ftrace features,
    having them slow down due to this extra logic may encourage the
    maintainers to update to the latest ftrace features. And because this
    logic is only safe for them, remove it completely.

     [*] There is on layer of recursion that is allowed, and that is to allow
         for the transition between interrupt context (normal -> softirq ->
         irq -> NMI), because a trace may occur before the context update is
         visible to the trace recursion logic.

    Link: https://lore.kernel.org/all/609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com/
    Link: https://lkml.kernel.org/r/20211018154412.09fcad3c@gandalf.local.home

    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
    Cc: Helge Deller <deller@gmx.de>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Cc: Palmer Dabbelt <palmer@dabbelt.com>
    Cc: Albert Ou <aou@eecs.berkeley.edu>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Miroslav Benes <mbenes@suse.cz>
    Cc: Joe Lawrence <joe.lawrence@redhat.com>
    Cc: Colin Ian King <colin.king@canonical.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Jisheng Zhang <jszhang@kernel.org>
    Cc: =?utf-8?b?546L6LSH?= <yun.wang@linux.alibaba.com>
    Cc: Guo Ren <guoren@kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: edc15cafcbfa3 ("tracing: Avoid unnecessary multiple recursion checks")
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a9831afa2dc8a18205403907c41aa4e0950ac611
Author: Yanfei Xu <yanfei.xu@windriver.com>
Date:   Sun Sep 26 12:53:13 2021 +0800

    net: mdiobus: Fix memory leak in __mdiobus_register

    commit ab609f25d19858513919369ff3d9a63c02cd9e2e upstream.

    Once device_register() failed, we should call put_device() to
    decrement reference count for cleanup. Or it will cause memory
    leak.

    BUG: memory leak
    unreferenced object 0xffff888114032e00 (size 256):
      comm "kworker/1:3", pid 2960, jiffies 4294943572 (age 15.920s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 08 2e 03 14 81 88 ff ff  ................
        08 2e 03 14 81 88 ff ff 90 76 65 82 ff ff ff ff  .........ve.....
      backtrace:
        [<ffffffff8265cfab>] kmalloc include/linux/slab.h:591 [inline]
        [<ffffffff8265cfab>] kzalloc include/linux/slab.h:721 [inline]
        [<ffffffff8265cfab>] device_private_init drivers/base/core.c:3203 [inline]
        [<ffffffff8265cfab>] device_add+0x89b/0xdf0 drivers/base/core.c:3253
        [<ffffffff828dd643>] __mdiobus_register+0xc3/0x450 drivers/net/phy/mdio_bus.c:537
        [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
        [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
        [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
        [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
        [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
        [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
        [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
        [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
        [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
        [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
        [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
        [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
        [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
        [<ffffffff82660916>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
        [<ffffffff8265cd0b>] device_add+0x5fb/0xdf0 drivers/base/core.c:3359
        [<ffffffff82c343b9>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2170
        [<ffffffff82c4473c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238

    BUG: memory leak
    unreferenced object 0xffff888116f06900 (size 32):
      comm "kworker/0:2", pid 2670, jiffies 4294944448 (age 7.160s)
      hex dump (first 32 bytes):
        75 73 62 2d 30 30 31 3a 30 30 33 00 00 00 00 00  usb-001:003.....
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<ffffffff81484516>] kstrdup+0x36/0x70 mm/util.c:60
        [<ffffffff814845a3>] kstrdup_const+0x53/0x80 mm/util.c:83
        [<ffffffff82296ba2>] kvasprintf_const+0xc2/0x110 lib/kasprintf.c:48
        [<ffffffff82358d4b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
        [<ffffffff826575f3>] dev_set_name+0x63/0x90 drivers/base/core.c:3147
        [<ffffffff828dd63b>] __mdiobus_register+0xbb/0x450 drivers/net/phy/mdio_bus.c:535
        [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
        [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
        [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
        [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
        [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
        [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
        [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
        [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
        [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
        [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
        [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
        [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
        [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969

    Reported-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
    Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 629e870ca473bbf3ec2429d441efb0406869783d
Author: Dexuan Cui <decui@microsoft.com>
Date:   Thu Oct 7 21:35:46 2021 -0700

    scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma()

    commit 50b6cb3516365cb69753b006be2b61c966b70588 upstream.

    After commit ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at
    can_queue"), a 416-CPU VM running on Hyper-V hangs during boot because the
    hv_storvsc driver sets scsi_driver.can_queue to an integer value that
    exceeds SHRT_MAX, and hence scsi_add_host_with_dma() sets
    shost->cmd_per_lun to a negative "short" value.

    Use min_t(int, ...) to work around the issue.

    Link: https://lore.kernel.org/r/20211008043546.6006-1-decui@microsoft.com
    Fixes: ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at can_queue")
    Cc: stable@vger.kernel.org
    Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
    Reviewed-by: Ming Lei <ming.lei@redhat.com>
    Reviewed-by: John Garry <john.garry@huawei.com>
    Signed-off-by: Dexuan Cui <decui@microsoft.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1360f9cde7eaaea4e6b48ab4ec544c706dbc6a8a
Author: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Date:   Tue Oct 12 17:29:35 2021 +0300

    ALSA: hda: avoid write to STATESTS if controller is in reset

    [ Upstream commit b37a15188eae9d4c49c5bb035e0c8d4058e4d9b3 ]

    The snd_hdac_bus_reset_link() contains logic to clear STATESTS register
    before performing controller reset. This code dates back to an old
    bugfix in commit e8a7f136f5ed ("[ALSA] hda-intel - Improve HD-audio
    codec probing robustness"). Originally the code was added to
    azx_reset().

    The code was moved around in commit a41d122449be ("ALSA: hda - Embed bus
    into controller object") and ended up to snd_hdac_bus_reset_link() and
    called primarily via snd_hdac_bus_init_chip().

    The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is
    called when controller is not in reset. In this case, STATESTS can be
    cleared. This can be useful e.g. when forcing a controller reset to retry
    codec probe. A normal non-power-on reset will not clear the bits.

    However, this old logic is problematic when controller is already in
    reset. The HDA specification states that controller must be taken out of
    reset before writing to registers other than GCTL.CRST (1.0a spec,
    3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost
    if the controller is already in reset per the HDA specification mentioned.

    This has been harmless on older hardware. On newer generation of Intel
    PCIe based HDA controllers, if configured to report issues, this write
    will emit an unsupported request error. If ACPI Platform Error Interface
    (APEI) is enabled in kernel, this will end up to kernel log.

    Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if
    the function is called when controller is not in reset. Otherwise
    clearing the bits is not possible and should be skipped.

    Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
    Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f7db1bc1cdb809fdd65d50485fb67bd418eadbd5
Author: Prashant Malani <pmalani@chromium.org>
Date:   Tue Sep 28 03:19:34 2021 -0700

    platform/x86: intel_scu_ipc: Update timeout value in comment

    [ Upstream commit a0c5814b9933f25ecb6de169483c5b88cf632bca ]

    The comment decribing the IPC timeout hadn't been updated when the
    actual timeout was changed from 3 to 5 seconds in
    commit a7d53dbbc70a ("platform/x86: intel_scu_ipc: Increase virtual
    timeout from 3 to 5 seconds") .

    Since the value is anyway updated to 10s now, take this opportunity to
    update the value in the comment too.

    Signed-off-by: Prashant Malani <pmalani@chromium.org>
    Cc: Benson Leung <bleung@chromium.org>
    Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Link: https://lore.kernel.org/r/20210928101932.2543937-4-pmalani@chromium.org
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a5b34409d3fc52114c828be4adbc30744fa3258b
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sat Oct 9 11:33:49 2021 +0000

    isdn: mISDN: Fix sleeping function called from invalid context

    [ Upstream commit 6510e80a0b81b5d814e3aea6297ba42f5e76f73c ]

    The driver can call card->isac.release() function from an atomic
    context.

    Fix this by calling this function after releasing the lock.

    The following log reveals it:

    [   44.168226 ] BUG: sleeping function called from invalid context at kernel/workqueue.c:3018
    [   44.168941 ] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5475, name: modprobe
    [   44.169574 ] INFO: lockdep is turned off.
    [   44.169899 ] irq event stamp: 0
    [   44.170160 ] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
    [   44.170627 ] hardirqs last disabled at (0): [<ffffffff814209ed>] copy_process+0x132d/0x3e00
    [   44.171240 ] softirqs last  enabled at (0): [<ffffffff81420a1a>] copy_process+0x135a/0x3e00
    [   44.171852 ] softirqs last disabled at (0): [<0000000000000000>] 0x0
    [   44.172318 ] Preemption disabled at:
    [   44.172320 ] [<ffffffffa009b0a9>] nj_release+0x69/0x500 [netjet]
    [   44.174441 ] Call Trace:
    [   44.174630 ]  dump_stack_lvl+0xa8/0xd1
    [   44.174912 ]  dump_stack+0x15/0x17
    [   44.175166 ]  ___might_sleep+0x3a2/0x510
    [   44.175459 ]  ? nj_release+0x69/0x500 [netjet]
    [   44.175791 ]  __might_sleep+0x82/0xe0
    [   44.176063 ]  ? start_flush_work+0x20/0x7b0
    [   44.176375 ]  start_flush_work+0x33/0x7b0
    [   44.176672 ]  ? trace_irq_enable_rcuidle+0x85/0x170
    [   44.177034 ]  ? kasan_quarantine_put+0xaa/0x1f0
    [   44.177372 ]  ? kasan_quarantine_put+0xaa/0x1f0
    [   44.177711 ]  __flush_work+0x11a/0x1a0
    [   44.177991 ]  ? flush_work+0x20/0x20
    [   44.178257 ]  ? lock_release+0x13c/0x8f0
    [   44.178550 ]  ? __kasan_check_write+0x14/0x20
    [   44.178872 ]  ? do_raw_spin_lock+0x148/0x360
    [   44.179187 ]  ? read_lock_is_recursive+0x20/0x20
    [   44.179530 ]  ? __kasan_check_read+0x11/0x20
    [   44.179846 ]  ? do_raw_spin_unlock+0x55/0x900
    [   44.180168 ]  ? ____kasan_slab_free+0x116/0x140
    [   44.180505 ]  ? _raw_spin_unlock_irqrestore+0x41/0x60
    [   44.180878 ]  ? skb_queue_purge+0x1a3/0x1c0
    [   44.181189 ]  ? kfree+0x13e/0x290
    [   44.181438 ]  flush_work+0x17/0x20
    [   44.181695 ]  mISDN_freedchannel+0xe8/0x100
    [   44.182006 ]  isac_release+0x210/0x260 [mISDNipac]
    [   44.182366 ]  nj_release+0xf6/0x500 [netjet]
    [   44.182685 ]  nj_remove+0x48/0x70 [netjet]
    [   44.182989 ]  pci_device_remove+0xa9/0x250

    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 207f6c3a82e19626aedad6e2f9aa0bb348495447
Author: Herve Codina <herve.codina@bootlin.com>
Date:   Fri Oct 8 12:34:40 2021 +0200

    ARM: dts: spear3xx: Fix gmac node

    [ Upstream commit 6636fec29cdf6665bd219564609e8651f6ddc142 ]

    On SPEAr3xx, ethernet driver is not compatible with the SPEAr600
    one.
    Indeed, SPEAr3xx uses an earlier version of this IP (v3.40) and
    needs some driver tuning compare to SPEAr600.

    The v3.40 IP support was added to stmmac driver and this patch
    fixes this issue and use the correct compatible string for
    SPEAr3xx

    Signed-off-by: Herve Codina <herve.codina@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit cfe8c4a4d6eb21af53504c6b85393de2f8345685
Author: Herve Codina <herve.codina@bootlin.com>
Date:   Fri Oct 8 12:34:39 2021 +0200

    net: stmmac: add support for dwmac 3.40a

    [ Upstream commit 9cb1d19f47fafad7dcf7c8564e633440c946cfd7 ]

    dwmac 3.40a is an old ip version that can be found on SPEAr3xx soc.

    Signed-off-by: Herve Codina <herve.codina@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f03a8a85e91580f7881b24c24ab2e4e37d8080b1
Author: Filipe Manana <fdmanana@suse.com>
Date:   Fri Oct 1 13:52:30 2021 +0100

    btrfs: deal with errors when checking if a dir entry exists during log replay

    [ Upstream commit 77a5b9e3d14cbce49ceed2766b2003c034c066dc ]

    Currently inode_in_dir() ignores errors returned from
    btrfs_lookup_dir_index_item() and from btrfs_lookup_dir_item(), treating
    any errors as if the directory entry does not exists in the fs/subvolume
    tree, which is obviously not correct, as we can get errors such as -EIO
    when reading extent buffers while searching the fs/subvolume's tree.

    Fix that by making inode_in_dir() return the errors and making its only
    caller, add_inode_ref(), deal…
warudooooo added a commit to warudooooo/android_kernel_sm6225_spes that referenced this issue Sep 20, 2023
…x/kernel/git/stable/linux-stable

commit 00a95330f3b295d4a581c36a5f2949c731386e37
Merge: 9e5a216016f0 a027d43cf3f2
Author: warudo <waldoreyes2301@gmail.com>
Date:   Wed Sep 20 16:00:07 2023 +0800

    Merge tag 'v4.19.215'

    This is the 4.19.215 stable release

commit a027d43cf3f2fdaabf467b4bcb92d0fe748c2eaf
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Nov 2 18:26:46 2021 +0100

    Linux 4.19.215

    Link: https://lore.kernel.org/r/20211101082451.430720900@linuxfoundation.org
    Link: https://lore.kernel.org/r/20211101114224.924071362@linuxfoundation.org
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Hulk Robot <hulkrobot@huawei.com>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1ff3c379248ea579aa122d4ca245028e4bc9af23
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:47 2021 -0400

    sctp: add vtag check in sctp_sf_ootb

    [ Upstream commit 9d02831e517aa36ee6bdb453a0eb47bd49923fe3 ]

    sctp_sf_ootb() is called when processing DATA chunk in closed state,
    and many other places are also using it.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    When fails to verify the vtag from the chunk, this patch sets asoc
    to NULL, so that the abort will be made with the vtag from the
    received chunk later.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d9a4f990aab48dd5c134a9e76c7b651d404b05d3
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:46 2021 -0400

    sctp: add vtag check in sctp_sf_do_8_5_1_E_sa

    [ Upstream commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998 ]

    sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk
    in cookie_wait and cookie_echoed state.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    Note that when fails to verify the vtag from SHUTDOWN-ACK chunk,
    SHUTDOWN COMPLETE message will still be sent back to peer, but
    with the vtag from SHUTDOWN-ACK chunk, as said in 5) of
    rfc4960#section-8.4.

    While at it, also remove the unnecessary chunk length check from
    sctp_sf_shut_8_4_5(), as it's already done in both places where
    it calls sctp_sf_shut_8_4_5().

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7bf2f6a30d1851c530ad5e4ee7e5c45fb6be0128
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:45 2021 -0400

    sctp: add vtag check in sctp_sf_violation

    [ Upstream commit aa0f697e45286a6b5f0ceca9418acf54b9099d99 ]

    sctp_sf_violation() is called when processing HEARTBEAT_ACK chunk
    in cookie_wait state, and some other places are also using it.

    The vtag in the chunk's sctphdr should be verified, otherwise, as
    later in chunk length check, it may send abort with the existent
    asoc's vtag, which can be exploited by one to cook a malicious
    chunk to terminate a SCTP asoc.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 86044244fc6f9eaec0070cb668e0d500de22dbba
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:44 2021 -0400

    sctp: fix the processing for COOKIE_ECHO chunk

    [ Upstream commit a64b341b8695e1c744dd972b39868371b4f68f83 ]

    1. In closed state: in sctp_sf_do_5_1D_ce():

      When asoc is NULL, making packet for abort will use chunk's vtag
      in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk
      should be verified before using peer.i.init_tag to make packet
      for abort in sctp_ootb_pkt_new(), and just discard it if vtag is
      not correct.

    2. In the other states: in sctp_sf_do_5_2_4_dupcook():

      asoc always exists, but duplicate cookie_echo's vtag will be
      handled by sctp_tietags_compare() and then take actions, so before
      that we only verify the vtag for the abort sent for invalid chunk
      length.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1f52dfacca7bb315d89f5ece5660b0337809798e
Author: Xin Long <lucien.xin@gmail.com>
Date:   Wed Oct 20 07:42:41 2021 -0400

    sctp: use init_tag from inithdr for ABORT chunk

    [ Upstream commit 4f7019c7eb33967eb87766e0e4602b5576873680 ]

    Currently Linux SCTP uses the verification tag of the existing SCTP
    asoc when failing to process and sending the packet with the ABORT
    chunk. This will result in the peer accepting the ABORT chunk and
    removing the SCTP asoc. One could exploit this to terminate a SCTP
    asoc.

    This patch is to fix it by always using the initiate tag of the
    received INIT chunk for the ABORT chunk to be sent.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b75fa48e42d022d6757b7de29178d531df8cf43b
Author: Trevor Woerner <twoerner@gmail.com>
Date:   Sun Oct 24 13:50:02 2021 -0400

    net: nxp: lpc_eth.c: avoid hang when bringing interface down

    commit ace19b992436a257d9a793672e57abc28fe83e2e upstream.

    A hard hang is observed whenever the ethernet interface is brought
    down. If the PHY is stopped before the LPC core block is reset,
    the SoC will hang. Comparing lpc_eth_close() and lpc_eth_open() I
    re-arranged the ordering of the functions calls in lpc_eth_close() to
    reset the hardware before stopping the PHY.
    Fixes: b7370112f519 ("lpc32xx: Added ethernet driver")
    Signed-off-by: Trevor Woerner <twoerner@gmail.com>
    Acked-by: Vladimir Zapolskiy <vz@mleia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 84a9eb9a2f179ea5e6398fe270560a8aaa16f996
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Fri Oct 22 11:53:43 2021 -0400

    net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent

    commit 95a359c9553342d36d408d35331ff0bfce75272f upstream.

    The dma failure was reported in the raspberry pi github (issue #4117).
    https://github.com/raspberrypi/linux/issues/4117
    The use of dma_set_mask_and_coherent fixes the issue.
    Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430.

    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fcda74cc95aa450a6d17780ccb1a8853cac7d0cd
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Fri Oct 22 11:13:53 2021 -0400

    net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails

    commit d6423d2ec39cce2bfca418c81ef51792891576bc upstream.

    The driver needs to clean up and return when the initialization fails on resume.

    Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 25d852a8adf017a478246d19c8b282e975521e8a
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Wed Oct 20 12:11:16 2021 -0700

    nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST

    commit 4a089e95b4d6bb625044d47aed0c442a8f7bd093 upstream.

    nios2:allmodconfig builds fail with

    make[1]: *** No rule to make target 'arch/nios2/boot/dts/""',
    	needed by 'arch/nios2/boot/dts/built-in.a'.  Stop.
    make: [Makefile:1868: arch/nios2/boot/dts] Error 2 (ignored)

    This is seen with compile tests since those enable NIOS2_DTB_SOURCE_BOOL,
    which in turn enables NIOS2_DTB_SOURCE. This causes the build error
    because the default value for NIOS2_DTB_SOURCE is an empty string.
    Disable NIOS2_DTB_SOURCE_BOOL for compile tests to avoid the error.

    Fixes: 2fc8483fdcde ("nios2: Build infrastructure")
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02302cbd52264337630a32848ac03648648e9685
Author: Michael Chan <michael.chan@broadcom.com>
Date:   Mon Oct 25 05:05:28 2021 -0400

    net: Prevent infinite while loop in skb_tx_hash()

    commit 0c57eeecc559ca6bc18b8c4e2808bc78dbe769b0 upstream.

    Drivers call netdev_set_num_tc() and then netdev_set_tc_queue()
    to set the queue count and offset for each TC.  So the queue count
    and offset for the TCs may be zero for a short period after dev->num_tc
    has been set.  If a TX packet is being transmitted at this time in the
    code path netdev_pick_tx() -> skb_tx_hash(), skb_tx_hash() may see
    nonzero dev->num_tc but zero qcount for the TC.  The while loop that
    keeps looping while hash >= qcount will not end.

    Fix it by checking the TC's qcount to be nonzero before using it.

    Fixes: eadec877ce9c ("net: Add support for subordinate traffic classes to netdev_pick_tx")
    Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
    Signed-off-by: Michael Chan <michael.chan@broadcom.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbf150b16a3635634b7dfb7f229d8fcd643c6c51
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Sun Oct 24 16:13:56 2021 +0300

    net: batman-adv: fix error handling

    commit 6f68cd634856f8ca93bafd623ba5357e0f648c68 upstream.

    Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
    in wrong error handling in batadv_mesh_init().

    Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
    of any batadv_*_init() calls failure. This approach may work well, when
    there is some kind of indicator, which can tell which parts of batadv are
    initialized; but there isn't any.

    All written above lead to cleaning up uninitialized fields. Even if we hide
    ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
    GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]

    To fix these bugs we can unwind batadv_*_init() calls one by one.
    It is good approach for 2 reasons: 1) It fixes bugs on error handling
    path 2) It improves the performance, since we won't call unneeded
    batadv_*_free() functions.

    So, this patch makes all batadv_*_init() clean up all allocated memory
    before returning with an error to no call correspoing batadv_*_free()
    and open-codes batadv_mesh_free() with proper order to avoid touching
    uninitialized fields.

    Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/ [1]
    Reported-and-tested-by: syzbot+28b0702ada0bf7381f58@syzkaller.appspotmail.com
    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Acked-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3dae1a4eced3ee733d7222e69b8a55caf2d61091
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Oct 12 10:37:35 2021 +0800

    regmap: Fix possible double-free in regcache_rbtree_exit()

    commit 55e6d8037805b3400096d621091dfbf713f97e83 upstream.

    In regcache_rbtree_insert_to_block(), when 'present' realloc failed,
    the 'blk' which is supposed to assign to 'rbnode->block' will be freed,
    so 'rbnode->block' points a freed memory, in the error handling path of
    regcache_rbtree_init(), 'rbnode->block' will be freed again in
    regcache_rbtree_exit(), KASAN will report double-free as follows:

    BUG: KASAN: double-free or invalid-free in kfree+0xce/0x390
    Call Trace:
     slab_free_freelist_hook+0x10d/0x240
     kfree+0xce/0x390
     regcache_rbtree_exit+0x15d/0x1a0
     regcache_rbtree_init+0x224/0x2c0
     regcache_init+0x88d/0x1310
     __regmap_init+0x3151/0x4a80
     __devm_regmap_init+0x7d/0x100
     madera_spi_probe+0x10f/0x333 [madera_spi]
     spi_probe+0x183/0x210
     really_probe+0x285/0xc30

    To fix this, moving up the assignment of rbnode->block to immediately after
    the reallocation has succeeded so that the data structure stays valid even
    if the second reallocation fails.

    Reported-by: Hulk Robot <hulkci@huawei.com>
    Fixes: 3f4ff561bc88b ("regmap: rbtree: Make cache_present bitmap per node")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20211012023735.1632786-1-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cdaf7a469244b5e65ae5eda062ff5ea90172de62
Author: Clément Bœsch <u@pkh.me>
Date:   Sun Sep 5 02:20:27 2021 +0200

    arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node

    commit 0764e365dacd0b8f75c1736f9236be280649bd18 upstream.

    RX and TX delay are provided by ethernet PHY. Reflect that in ethernet
    node.

    Fixes: 44a94c7ef989 ("arm64: dts: allwinner: H5: Restore EMAC changes")
    Signed-off-by: Clément Bœsch <u@pkh.me>
    Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Link: https://lore.kernel.org/r/20210905002027.171984-1-u@pkh.me
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2864b6d54244b82a8c7d4628a43055c57bfba80c
Author: Patrisious Haddad <phaddad@nvidia.com>
Date:   Wed Oct 6 12:31:53 2021 +0300

    RDMA/mlx5: Set user priority for DCT

    commit 1ab52ac1e9bc9391f592c9fa8340a6e3e9c36286 upstream.

    Currently, the driver doesn't set the PCP-based priority for DCT, hence
    DCT response packets are transmitted without user priority.

    Fix it by setting user provided priority in the eth_prio field in the DCT
    context, which in turn sets the value in the transmitted packet.

    Fixes: 776a3906b692 ("IB/mlx5: Add support for DC target QP")
    Link: https://lore.kernel.org/r/5fd2d94a13f5742d8803c218927322257d53205c.1633512672.git.leonro@nvidia.com
    Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 326da4f6ffdbd8671e86f69ded7a714dcc12fecf
Author: Johan Hovold <johan@kernel.org>
Date:   Tue Oct 26 12:36:17 2021 +0200

    net: lan78xx: fix division by zero in send path

    commit db6c3c064f5d55fa9969f33eafca3cdbefbb3541 upstream.

    Add the missing endpoint max-packet sanity check to probe() to avoid
    division by zero in lan78xx_tx_bh() in case a malicious device has
    broken descriptors (or when doing descriptor fuzz testing).

    Note that USB core will reject URBs submitted for endpoints with zero
    wMaxPacketSize but that drivers doing packet-size calculations still
    need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip
    endpoint descriptors with maxpacket=0")).

    Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
    Cc: stable@vger.kernel.org      # 4.3
    Cc: Woojung.Huh@microchip.com <Woojung.Huh@microchip.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2ff5289793fd61c56ac8774408f27350e5da865f
Author: Haibo Chen <haibo.chen@nxp.com>
Date:   Fri Oct 15 10:00:36 2021 +0800

    mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit

    commit 9af372dc70e9fdcbb70939dac75365e7b88580b4 upstream.

    To reset standard tuning circuit completely, after clear ESDHC_MIX_CTRL_EXE_TUNE,
    also need to clear bit buffer_read_ready, this operation will finally clear the
    USDHC IP internal logic flag execute_tuning_with_clr_buf, make sure the following
    normal data transfer will not be impacted by standard tuning logic used before.

    Find this issue when do quick SD card insert/remove stress test. During standard
    tuning prodedure, if remove SD card, USDHC standard tuning logic can't clear the
    internal flag execute_tuning_with_clr_buf. Next time when insert SD card, all
    data related commands can't get any data related interrupts, include data transfer
    complete interrupt, data timeout interrupt, data CRC interrupt, data end bit interrupt.
    Always trigger software timeout issue. Even reset the USDHC through bits in register
    SYS_CTRL (0x2C, bit28 reset tuning, bit26 reset data, bit 25 reset command, bit 24
    reset all) can't recover this. From the user's point of view, USDHC stuck, SD can't
    be recognized any more.

    Fixes: d9370424c948 ("mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card")
    Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1634263236-6111-1-git-send-email-haibo.chen@nxp.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7824414c2903e2cfe56ea610387a22c0c88fb468
Author: Shawn Guo <shawn.guo@linaro.org>
Date:   Mon Oct 4 10:49:35 2021 +0800

    mmc: sdhci: Map more voltage level to SDHCI_POWER_330

    commit 4217d07b9fb328751f877d3bd9550122014860a2 upstream.

    On Thundercomm TurboX CM2290, the eMMC OCR reports vdd = 23 (3.5 ~ 3.6 V),
    which is being treated as an invalid value by sdhci_set_power_noreg().
    And thus eMMC is totally broken on the platform.

    [    1.436599] ------------[ cut here ]------------
    [    1.436606] mmc0: Invalid vdd 0x17
    [    1.436640] WARNING: CPU: 2 PID: 69 at drivers/mmc/host/sdhci.c:2048 sdhci_set_power_noreg+0x168/0x2b4
    [    1.436655] Modules linked in:
    [    1.436662] CPU: 2 PID: 69 Comm: kworker/u8:1 Tainted: G        W         5.15.0-rc1+ #137
    [    1.436669] Hardware name: Thundercomm TurboX CM2290 (DT)
    [    1.436674] Workqueue: events_unbound async_run_entry_fn
    [    1.436685] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [    1.436692] pc : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436698] lr : sdhci_set_power_noreg+0x168/0x2b4
    [    1.436703] sp : ffff800010803a60
    [    1.436705] x29: ffff800010803a60 x28: ffff6a9102465f00 x27: ffff6a9101720a70
    [    1.436715] x26: ffff6a91014de1c0 x25: ffff6a91014de010 x24: ffff6a91016af280
    [    1.436724] x23: ffffaf7b1b276640 x22: 0000000000000000 x21: ffff6a9101720000
    [    1.436733] x20: ffff6a9101720370 x19: ffff6a9101720580 x18: 0000000000000020
    [    1.436743] x17: 0000000000000000 x16: 0000000000000004 x15: ffffffffffffffff
    [    1.436751] x14: 0000000000000000 x13: 00000000fffffffd x12: ffffaf7b1b84b0bc
    [    1.436760] x11: ffffaf7b1b720d10 x10: 000000000000000a x9 : ffff800010803a60
    [    1.436769] x8 : 000000000000000a x7 : 000000000000000f x6 : 00000000fffff159
    [    1.436778] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
    [    1.436787] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff6a9101718d80
    [    1.436797] Call trace:
    [    1.436800]  sdhci_set_power_noreg+0x168/0x2b4
    [    1.436805]  sdhci_set_ios+0xa0/0x7fc
    [    1.436811]  mmc_power_up.part.0+0xc4/0x164
    [    1.436818]  mmc_start_host+0xa0/0xb0
    [    1.436824]  mmc_add_host+0x60/0x90
    [    1.436830]  __sdhci_add_host+0x174/0x330
    [    1.436836]  sdhci_msm_probe+0x7c0/0x920
    [    1.436842]  platform_probe+0x68/0xe0
    [    1.436850]  really_probe.part.0+0x9c/0x31c
    [    1.436857]  __driver_probe_device+0x98/0x144
    [    1.436863]  driver_probe_device+0xc8/0x15c
    [    1.436869]  __device_attach_driver+0xb4/0x120
    [    1.436875]  bus_for_each_drv+0x78/0xd0
    [    1.436881]  __device_attach_async_helper+0xac/0xd0
    [    1.436888]  async_run_entry_fn+0x34/0x110
    [    1.436895]  process_one_work+0x1d0/0x354
    [    1.436903]  worker_thread+0x13c/0x470
    [    1.436910]  kthread+0x150/0x160
    [    1.436915]  ret_from_fork+0x10/0x20
    [    1.436923] ---[ end trace fcfac44cb045c3a8 ]---

    Fix the issue by mapping MMC_VDD_35_36 (and MMC_VDD_34_35) to
    SDHCI_POWER_330 as well.

    Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20211004024935.15326-1-shawn.guo@linaro.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29d56f3790e684e630d56f500b59e834fa382209
Author: Jaehoon Chung <jh80.chung@samsung.com>
Date:   Fri Oct 22 17:21:06 2021 +0900

    mmc: dw_mmc: exynos: fix the finding clock sample value

    commit 697542bceae51f7620af333b065dd09d213629fb upstream.

    Even though there are candiates value if can't find best value, it's
    returned -EIO. It's not proper behavior.
    If there is not best value, use a first candiate value to work eMMC.

    Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
    Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Tested-by: Christian Hewitt <christianshewitt@gmail.com>
    Cc: stable@vger.kernel.org
    Fixes: c537a1c5ff63 ("mmc: dw_mmc: exynos: add variable delay tuning sequence")
    Link: https://lore.kernel.org/r/20211022082106.1557-1-jh80.chung@samsung.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 24f8658690477e8983f88cbfe21fb7f4062ad837
Author: Wenbin Mei <wenbin.mei@mediatek.com>
Date:   Tue Oct 26 15:08:12 2021 +0800

    mmc: cqhci: clear HALT state after CQE enable

    commit 92b18252b91de567cd875f2e84722b10ab34ee28 upstream.

    While mmc0 enter suspend state, we need halt CQE to send legacy cmd(flush
    cache) and disable cqe, for resume back, we enable CQE and not clear HALT
    state.
    In this case MediaTek mmc host controller will keep the value for HALT
    state after CQE disable/enable flow, so the next CQE transfer after resume
    will be timeout due to CQE is in HALT state, the log as below:
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: timeout for tag 2
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Caps:      0x100020b6 | Version:  0x00000510
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Config:    0x00001103 | Control:  0x00000001
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int stat:  0x00000000 | Int enab: 0x00000006
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int sig:   0x00000006 | Int Coal: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: TDL base:  0xfd05f000 | TDL up32: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Doorbell:  0x8000203c | TCN:      0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Task clr:  0x00000000 | SSC1:     0x00001000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: SSC2:      0x00000001 | DCMD rsp: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: RED mask:  0xfdf9a080 | TERRI:    0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Resp idx:  0x00000000 | Resp arg: 0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQP:     0x00000000 | CRNQDUN:  0x00000000
    <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQIS:    0x00000000 | CRNQIE:   0x00000000

    This change check HALT state after CQE enable, if CQE is in HALT state, we
    will clear it.

    Signed-off-by: Wenbin Mei <wenbin.mei@mediatek.com>
    Cc: stable@vger.kernel.org
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
    Link: https://lore.kernel.org/r/20211026070812.9359-1-wenbin.mei@mediatek.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99641238575c26c2e47fa593f562dae476709d68
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Oct 25 13:56:08 2021 +0200

    mmc: vub300: fix control-message timeouts

    commit 8c8171929116cc23f74743d99251eedadf62341a upstream.

    USB control-message timeouts are specified in milliseconds and should
    specifically not vary with CONFIG_HZ.

    Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
    Cc: stable@vger.kernel.org      # 3.0
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211025115608.5287-1-johan@kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6d0d68d6da68159948cad3d808d61bb291a0283
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Aug 29 15:16:14 2021 -0700

    ipv6: make exception cache less predictible

    commit a00df2caffed3883c341d5685f830434312e4a43 upstream.

    Even after commit 4785305c05b2 ("ipv6: use siphash in rt6_exception_hash()"),
    an attacker can still use brute force to learn some secrets from a victim
    linux host.

    One way to defeat these attacks is to make the max depth of the hash
    table bucket a random value.

    Before this patch, each bucket of the hash table used to store exceptions
    could contain 6 items under attack.

    After the patch, each bucket would contains a random number of items,
    between 6 and 10. The attacker can no longer infer secrets.

    This is slightly increasing memory size used by the hash table,
    we do not expect this to be a problem.

    Following patch is dealing with the same issue in IPv4.

    Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Wei Wang <weiwan@google.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad829847ad59af8e26a1f1c345716099abbc7a58
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Oct 29 10:50:26 2021 +0300

    ipv6: use siphash in rt6_exception_hash()

    commit 4785305c05b25a242e5314cc821f54ade4c18810 upstream.

    A group of security researchers brought to our attention
    the weakness of hash function used in rt6_exception_hash()

    Lets use siphash instead of Jenkins Hash, to considerably
    reduce security risks.

    Following patch deals with IPv4.

    Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Wei Wang <weiwan@google.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Acked-by: Wei Wang <weiwan@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e2856767eb1a9cfcfcd82136928037f04920e97
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Oct 29 10:50:25 2021 +0300

    ipv4: use siphash instead of Jenkins in fnhe_hashfun()

    commit 6457378fe796815c973f631a1904e147d6ee33b1 upstream.

    A group of security researchers brought to our attention
    the weakness of hash function used in fnhe_hashfun().

    Lets use siphash instead of Jenkins Hash, to considerably
    reduce security risks.

    Also remove the inline keyword, this really is distracting.

    Fixes: d546c621542d ("ipv4: harden fnhe_hashfun()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Keyu Man <kman001@ucr.edu>
    Cc: Willy Tarreau <w@1wt.eu>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [OP: adjusted context for 4.19 stable]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8121d0d4fd108280f5cd7b7fe8c6592adaa37be9
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Thu Sep 30 20:49:42 2021 +0300

    Revert "net: mdiobus: Fix memory leak in __mdiobus_register"

    commit 10eff1f5788b6ffac212c254e2f3666219576889 upstream.

    This reverts commit ab609f25d19858513919369ff3d9a63c02cd9e2e.

    This patch is correct in the sense that we _should_ call device_put() in
    case of device_register() failure, but the problem in this code is more
    vast.

    We need to set bus->state to UNMDIOBUS_REGISTERED before calling
    device_register() to correctly release the device in mdiobus_free().
    This patch prevents us from doing it, since in case of device_register()
    failure put_device() will be called 2 times and it will cause UAF or
    something else.

    Also, Reported-by: tag in revered commit was wrong, since syzbot
    reported different leak in same function.

    Link: https://lore.kernel.org/netdev/20210928092657.GI2048@kadam/
    Acked-by: Yanfei Xu <yanfei.xu@windriver.com>
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Link: https://lore.kernel.org/r/f12fb1faa4eccf0f355788225335eb4309ff2599.1633024062.git.paskripkin@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4a9043ba1b0e9bea1da0fe34366222974f2c0f92
Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Date:   Mon Oct 25 16:49:36 2021 +0200

    nfc: port100: fix using -ERRNO as command type mask

    commit 2195f2062e4cc93870da8e71c318ef98a1c51cef upstream.

    During probing, the driver tries to get a list (mask) of supported
    command types in port100_get_command_type_mask() function.  The value
    is u64 and 0 is treated as invalid mask (no commands supported).  The
    function however returns also -ERRNO as u64 which will be interpret as
    valid command mask.

    Return 0 on every error case of port100_get_command_type_mask(), so the
    probing will stop.

    Cc: <stable@vger.kernel.org>
    Fixes: 0347a6ab300a ("NFC: port100: Commands mechanism implementation")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a36119f9b3fb069437383a8eff4e65181b6e7e2f
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Fri Oct 22 09:12:26 2021 +0000

    ata: sata_mv: Fix the error handling of mv_chip_id()

    commit a0023bb9dd9bc439d44604eeec62426a990054cd upstream.

    mv_init_host() propagates the value returned by mv_chip_id() which in turn
    gets propagated by mv_pci_init_one() and hits local_pci_probe().

    During the process of driver probing, the probe function should return < 0
    for failure, otherwise, the kernel will treat value > 0 as success.

    Since this is a bug rather than a recoverable runtime error we should
    use dev_alert() instead of dev_err().

    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 78c2dc1cdf0bdfc83e473d78f23da4d2aeb98142
Author: Wang Hai <wanghai38@huawei.com>
Date:   Tue Oct 26 20:40:15 2021 +0800

    usbnet: fix error return code in usbnet_probe()

    commit 6f7c88691191e6c52ef2543d6f1da8d360b27a24 upstream.

    Return error code if usb_maxpacket() returns 0 in usbnet_probe()

    Fixes: 397430b50a36 ("usbnet: sanity check for maxpacket")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    Reviewed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211026124015.3025136-1-wanghai38@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 002d82227c0abe29118cf80f7e2f396b22d448ed
Author: Oliver Neukum <oneukum@suse.com>
Date:   Thu Oct 21 14:29:44 2021 +0200

    usbnet: sanity check for maxpacket

    commit 397430b50a363d8b7bdda00522123f82df6adc5e upstream.

    maxpacket of 0 makes no sense and oopses as we need to divide
    by it. Give up.

    V2: fixed typo in log and stylistic issues

    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Reported-by: syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com
    Reviewed-by: Johan Hovold <johan@kernel.org>
    Link: https://lore.kernel.org/r/20211021122944.21816-1-oneukum@suse.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d725978abb0bac6e0c427548dfd6db86709a2a1e
Author: Nathan Chancellor <natechancellor@gmail.com>
Date:   Sat Jan 5 19:35:25 2019 +0100

    ARM: 8819/1: Remove '-p' from LDFLAGS

    commit 091bb549f7722723b284f63ac665e2aedcf9dec9 upstream.

    This option is not supported by lld:

        ld.lld: error: unknown argument: -p

    This has been a no-op in binutils since 2004 (see commit dea514f51da1 in
    that tree). Given that the lowest officially supported of binutils for
    the kernel is 2.20, which was released in 2009, nobody needs this flag
    around so just remove it. Commit 1a381d4a0a9a ("arm64: remove no-op -p
    linker flag") did the same for arm64.

    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
    Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Acked-by: Nicolas Pitre <nico@linaro.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Stefan Agner <stefan@agner.ch>
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aaf4e1b05cab800b36b40c1aa09f7c13ef30de56
Author: Robin Murphy <robin.murphy@arm.com>
Date:   Mon Jul 12 15:27:46 2021 +0100

    arm64: Avoid premature usercopy failure

    commit 295cf156231ca3f9e3a66bde7fab5e09c41835e0 upstream.

    Al reminds us that the usercopy API must only return complete failure
    if absolutely nothing could be copied. Currently, if userspace does
    something silly like giving us an unaligned pointer to Device memory,
    or a size which overruns MTE tag bounds, we may fail to honour that
    requirement when faulting on a multi-byte access even though a smaller
    access could have succeeded.

    Add a mitigation to the fixup routines to fall back to a single-byte
    copy if we faulted on a larger access before anything has been written
    to the destination, to guarantee making *some* forward progress. We
    needn't be too concerned about the overall performance since this should
    only occur when callers are doing something a bit dodgy in the first
    place. Particularly broken userspace might still be able to trick
    generic_perform_write() into an infinite loop by targeting write() at
    an mmap() of some read-only device register where the fault-in load
    succeeds but any store synchronously aborts such that copy_to_user() is
    genuinely unable to make progress, but, well, don't do that...

    CC: stable@vger.kernel.org
    Reported-by: Chen Huang <chenhuang5@huawei.com>
    Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Robin Murphy <robin.murphy@arm.com>
    Link: https://lore.kernel.org/r/dc03d5c675731a1f24a62417dba5429ad744234e.1626098433.git.robin.murphy@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Chen Huang <chenhuang5@huawei.com>

commit 5909b851b5e11d04f299e5f0a8937e9dcc807248
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Date:   Wed Oct 6 01:55:22 2021 +0530

    powerpc/bpf: Fix BPF_MOD when imm == 1

    commit 8bbc9d822421d9ac8ff9ed26a3713c9afc69d6c8 upstream.

    Only ignore the operation if dividing by 1.

    Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
    Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Tested-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Acked-by: Song Liu <songliubraving@fb.com>
    Acked-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/c674ca18c3046885602caebb326213731c675d06.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
    [cascardo: use PPC_LI instead of EMIT(PPC_RAW_LI)]
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 901741a53d7cf45be861e881c0e3cba5b4bd1f94
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:37 2021 +0100

    ARM: 9141/1: only warn about XIP address when not compile testing

    commit 48ccc8edf5b90622cdc4f8878e0042ab5883e2ca upstream.

    In randconfig builds, we sometimes come across this warning:

    arm-linux-gnueabi-ld: XIP start address may cause MPU programming issues

    While this is helpful for actual systems to figure out why it
    fails, the warning does not provide any benefit for build testing,
    so guard it in a check for CONFIG_COMPILE_TEST, which is usually
    set on randconfig builds.

    Fixes: 216218308cfb ("ARM: 8713/1: NOMMU: Support MPU in XIP configuration")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee4b38ce37ed31beca29d3ebec7db3d5e87fe39e
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:09 2021 +0100

    ARM: 9139/1: kprobes: fix arch_init_kprobes() prototype

    commit 1f323127cab086e4fd618981b1e5edc396eaf0f4 upstream.

    With extra warnings enabled, gcc complains about this function
    definition:

    arch/arm/probes/kprobes/core.c: In function 'arch_init_kprobes':
    arch/arm/probes/kprobes/core.c:465:12: warning: old-style function definition [-Wold-style-definition]
      465 | int __init arch_init_kprobes()

    Link: https://lore.kernel.org/all/20201027093057.c685a14b386acacb3c449e3d@kernel.org/

    Fixes: 24ba613c9d6c ("ARM kprobes: core code")
    Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c0b4f1db7feef31d401814121760b45aff7885c1
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Oct 18 15:30:04 2021 +0100

    ARM: 9134/1: remove duplicate memcpy() definition

    commit eaf6cc7165c9c5aa3c2f9faa03a98598123d0afb upstream.

    Both the decompressor code and the kasan logic try to override
    the memcpy() and memmove()  definitions, which leading to a clash
    in a KASAN-enabled kernel with XZ decompression:

    arch/arm/boot/compressed/decompress.c:50:9: error: 'memmove' macro redefined [-Werror,-Wmacro-redefined]
     #define memmove memmove
            ^
    arch/arm/include/asm/string.h:59:9: note: previous definition is here
     #define memmove(dst, src, len) __memmove(dst, src, len)
            ^
    arch/arm/boot/compressed/decompress.c:51:9: error: 'memcpy' macro redefined [-Werror,-Wmacro-redefined]
     #define memcpy memcpy
            ^
    arch/arm/include/asm/string.h:58:9: note: previous definition is here
     #define memcpy(dst, src, len) __memcpy(dst, src, len)
            ^

    Here we want the set of functions from the decompressor, so undefine
    the other macros before the override.

    Link: https://lore.kernel.org/linux-arm-kernel/CACRpkdZYJogU_SN3H9oeVq=zJkRgRT1gDz3xp59gdqWXxw-B=w@mail.gmail.com/
    Link: https://lore.kernel.org/lkml/202105091112.F5rmd4By-lkp@intel.com/

    Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
    Fixes: a7f464f3db93 ("ARM: 7001/2: Wire up support for the XZ decompressor")
    Reported-by: kernel test robot <lkp@intel.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 00dcbb2d2cd3594faa2f977f2f7175cf23d4e326
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Mon Oct 4 18:03:28 2021 +0100

    ARM: 9133/1: mm: proc-macros: ensure *_tlb_fns are 4B aligned

    commit e6a0c958bdf9b2e1b57501fc9433a461f0a6aadd upstream.

    A kernel built with CONFIG_THUMB2_KERNEL=y and using clang as the
    assembler could generate non-naturally-aligned v7wbi_tlb_fns which
    results in a boot failure. The original commit adding the macro missed
    the .align directive on this data.

    Link: https://github.com/ClangBuiltLinux/linux/issues/1447
    Link: https://lore.kernel.org/all/0699da7b-354f-aecc-a62f-e25693209af4@linaro.org/
    Debugged-by: Ard Biesheuvel <ardb@kernel.org>
    Debugged-by: Nathan Chancellor <nathan@kernel.org>
    Debugged-by: Richard Henderson <richard.henderson@linaro.org>

    Fixes: 66a625a88174 ("ARM: mm: proc-macros: Add generic proc/cache/tlb struct definition macros")
    Suggested-by: Ard Biesheuvel <ardb@kernel.org>
    Acked-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 38ec06730e44b2166e87fecca9e36380080801ac
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Oct 27 09:53:15 2021 +0200

    Linux 4.19.214

    Link: https://lore.kernel.org/r/20211025190926.680827862@linuxfoundation.org
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0b7d55ca605e611aceeadf7c29c75808faae951a
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Wed Sep 8 19:25:59 2021 +0100

    ARM: 9122/1: select HAVE_FUTEX_CMPXCHG

    commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

    tglx notes:
      This function [futex_detect_cmpxchg] is only needed when an
      architecture has to runtime discover whether the CPU supports it or
      not.  ARM has unconditional support for this, so the obvious thing to
      do is the below.

    Fixes linkage failure from Clang randconfigs:
    kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
    and boot failures for CONFIG_THUMB2_KERNEL.

    Link: https://github.com/ClangBuiltLinux/linux/issues/325

    Comments from Nick Desaulniers:

     See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
     futex_atomic_cmpxchg_inatomic() test")

    Reported-by: Arnd Bergmann <arnd@arndb.de>
    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Suggested-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Cc: stable@vger.kernel.org # v3.14+
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3de1ed125fc4c35bf7abb08260646100a6dcb04e
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Mon Oct 18 15:44:12 2021 -0400

    tracing: Have all levels of checks prevent recursion

    commit ed65df63a39a3f6ed04f7258de8b6789e5021c18 upstream.

    While writing an email explaining the "bit = 0" logic for a discussion on
    making ftrace_test_recursion_trylock() disable preemption, I discovered a
    path that makes the "not do the logic if bit is zero" unsafe.

    The recursion logic is done in hot paths like the function tracer. Thus,
    any code executed causes noticeable overhead. Thus, tricks are done to try
    to limit the amount of code executed. This included the recursion testing
    logic.

    Having recursion testing is important, as there are many paths that can
    end up in an infinite recursion cycle when tracing every function in the
    kernel. Thus protection is needed to prevent that from happening.

    Because it is OK to recurse due to different running context levels (e.g.
    an interrupt preempts a trace, and then a trace occurs in the interrupt
    handler), a set of bits are used to know which context one is in (normal,
    softirq, irq and NMI). If a recursion occurs in the same level, it is
    prevented*.

    Then there are infrastructure levels of recursion as well. When more than
    one callback is attached to the same function to trace, it calls a loop
    function to iterate over all the callbacks. Both the callbacks and the
    loop function have recursion protection. The callbacks use the
    "ftrace_test_recursion_trylock()" which has a "function" set of context
    bits to test, and the loop function calls the internal
    trace_test_and_set_recursion() directly, with an "internal" set of bits.

    If an architecture does not implement all the features supported by ftrace
    then the callbacks are never called directly, and the loop function is
    called instead, which will implement the features of ftrace.

    Since both the loop function and the callbacks do recursion protection, it
    was seemed unnecessary to do it in both locations. Thus, a trick was made
    to have the internal set of recursion bits at a more significant bit
    location than the function bits. Then, if any of the higher bits were set,
    the logic of the function bits could be skipped, as any new recursion
    would first have to go through the loop function.

    This is true for architectures that do not support all the ftrace
    features, because all functions being traced must first go through the
    loop function before going to the callbacks. But this is not true for
    architectures that support all the ftrace features. That's because the
    loop function could be called due to two callbacks attached to the same
    function, but then a recursion function inside the callback could be
    called that does not share any other callback, and it will be called
    directly.

    i.e.

     traced_function_1: [ more than one callback tracing it ]
       call loop_func

     loop_func:
       trace_recursion set internal bit
       call callback

     callback:
       trace_recursion [ skipped because internal bit is set, return 0 ]
       call traced_function_2

     traced_function_2: [ only traced by above callback ]
       call callback

     callback:
       trace_recursion [ skipped because internal bit is set, return 0 ]
       call traced_function_2

     [ wash, rinse, repeat, BOOM! out of shampoo! ]

    Thus, the "bit == 0 skip" trick is not safe, unless the loop function is
    call for all functions.

    Since we want to encourage architectures to implement all ftrace features,
    having them slow down due to this extra logic may encourage the
    maintainers to update to the latest ftrace features. And because this
    logic is only safe for them, remove it completely.

     [*] There is on layer of recursion that is allowed, and that is to allow
         for the transition between interrupt context (normal -> softirq ->
         irq -> NMI), because a trace may occur before the context update is
         visible to the trace recursion logic.

    Link: https://lore.kernel.org/all/609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com/
    Link: https://lkml.kernel.org/r/20211018154412.09fcad3c@gandalf.local.home

    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
    Cc: Helge Deller <deller@gmx.de>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Cc: Palmer Dabbelt <palmer@dabbelt.com>
    Cc: Albert Ou <aou@eecs.berkeley.edu>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Miroslav Benes <mbenes@suse.cz>
    Cc: Joe Lawrence <joe.lawrence@redhat.com>
    Cc: Colin Ian King <colin.king@canonical.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Jisheng Zhang <jszhang@kernel.org>
    Cc: =?utf-8?b?546L6LSH?= <yun.wang@linux.alibaba.com>
    Cc: Guo Ren <guoren@kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: edc15cafcbfa3 ("tracing: Avoid unnecessary multiple recursion checks")
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a9831afa2dc8a18205403907c41aa4e0950ac611
Author: Yanfei Xu <yanfei.xu@windriver.com>
Date:   Sun Sep 26 12:53:13 2021 +0800

    net: mdiobus: Fix memory leak in __mdiobus_register

    commit ab609f25d19858513919369ff3d9a63c02cd9e2e upstream.

    Once device_register() failed, we should call put_device() to
    decrement reference count for cleanup. Or it will cause memory
    leak.

    BUG: memory leak
    unreferenced object 0xffff888114032e00 (size 256):
      comm "kworker/1:3", pid 2960, jiffies 4294943572 (age 15.920s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 08 2e 03 14 81 88 ff ff  ................
        08 2e 03 14 81 88 ff ff 90 76 65 82 ff ff ff ff  .........ve.....
      backtrace:
        [<ffffffff8265cfab>] kmalloc include/linux/slab.h:591 [inline]
        [<ffffffff8265cfab>] kzalloc include/linux/slab.h:721 [inline]
        [<ffffffff8265cfab>] device_private_init drivers/base/core.c:3203 [inline]
        [<ffffffff8265cfab>] device_add+0x89b/0xdf0 drivers/base/core.c:3253
        [<ffffffff828dd643>] __mdiobus_register+0xc3/0x450 drivers/net/phy/mdio_bus.c:537
        [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
        [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
        [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
        [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
        [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
        [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
        [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
        [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
        [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
        [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
        [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
        [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
        [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
        [<ffffffff82660916>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
        [<ffffffff8265cd0b>] device_add+0x5fb/0xdf0 drivers/base/core.c:3359
        [<ffffffff82c343b9>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2170
        [<ffffffff82c4473c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238

    BUG: memory leak
    unreferenced object 0xffff888116f06900 (size 32):
      comm "kworker/0:2", pid 2670, jiffies 4294944448 (age 7.160s)
      hex dump (first 32 bytes):
        75 73 62 2d 30 30 31 3a 30 30 33 00 00 00 00 00  usb-001:003.....
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<ffffffff81484516>] kstrdup+0x36/0x70 mm/util.c:60
        [<ffffffff814845a3>] kstrdup_const+0x53/0x80 mm/util.c:83
        [<ffffffff82296ba2>] kvasprintf_const+0xc2/0x110 lib/kasprintf.c:48
        [<ffffffff82358d4b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
        [<ffffffff826575f3>] dev_set_name+0x63/0x90 drivers/base/core.c:3147
        [<ffffffff828dd63b>] __mdiobus_register+0xbb/0x450 drivers/net/phy/mdio_bus.c:535
        [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
        [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
        [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
        [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
        [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
        [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
        [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
        [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
        [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
        [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
        [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
        [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
        [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969

    Reported-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
    Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 629e870ca473bbf3ec2429d441efb0406869783d
Author: Dexuan Cui <decui@microsoft.com>
Date:   Thu Oct 7 21:35:46 2021 -0700

    scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma()

    commit 50b6cb3516365cb69753b006be2b61c966b70588 upstream.

    After commit ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at
    can_queue"), a 416-CPU VM running on Hyper-V hangs during boot because the
    hv_storvsc driver sets scsi_driver.can_queue to an integer value that
    exceeds SHRT_MAX, and hence scsi_add_host_with_dma() sets
    shost->cmd_per_lun to a negative "short" value.

    Use min_t(int, ...) to work around the issue.

    Link: https://lore.kernel.org/r/20211008043546.6006-1-decui@microsoft.com
    Fixes: ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at can_queue")
    Cc: stable@vger.kernel.org
    Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
    Reviewed-by: Ming Lei <ming.lei@redhat.com>
    Reviewed-by: John Garry <john.garry@huawei.com>
    Signed-off-by: Dexuan Cui <decui@microsoft.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1360f9cde7eaaea4e6b48ab4ec544c706dbc6a8a
Author: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Date:   Tue Oct 12 17:29:35 2021 +0300

    ALSA: hda: avoid write to STATESTS if controller is in reset

    [ Upstream commit b37a15188eae9d4c49c5bb035e0c8d4058e4d9b3 ]

    The snd_hdac_bus_reset_link() contains logic to clear STATESTS register
    before performing controller reset. This code dates back to an old
    bugfix in commit e8a7f136f5ed ("[ALSA] hda-intel - Improve HD-audio
    codec probing robustness"). Originally the code was added to
    azx_reset().

    The code was moved around in commit a41d122449be ("ALSA: hda - Embed bus
    into controller object") and ended up to snd_hdac_bus_reset_link() and
    called primarily via snd_hdac_bus_init_chip().

    The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is
    called when controller is not in reset. In this case, STATESTS can be
    cleared. This can be useful e.g. when forcing a controller reset to retry
    codec probe. A normal non-power-on reset will not clear the bits.

    However, this old logic is problematic when controller is already in
    reset. The HDA specification states that controller must be taken out of
    reset before writing to registers other than GCTL.CRST (1.0a spec,
    3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost
    if the controller is already in reset per the HDA specification mentioned.

    This has been harmless on older hardware. On newer generation of Intel
    PCIe based HDA controllers, if configured to report issues, this write
    will emit an unsupported request error. If ACPI Platform Error Interface
    (APEI) is enabled in kernel, this will end up to kernel log.

    Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if
    the function is called when controller is not in reset. Otherwise
    clearing the bits is not possible and should be skipped.

    Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
    Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f7db1bc1cdb809fdd65d50485fb67bd418eadbd5
Author: Prashant Malani <pmalani@chromium.org>
Date:   Tue Sep 28 03:19:34 2021 -0700

    platform/x86: intel_scu_ipc: Update timeout value in comment

    [ Upstream commit a0c5814b9933f25ecb6de169483c5b88cf632bca ]

    The comment decribing the IPC timeout hadn't been updated when the
    actual timeout was changed from 3 to 5 seconds in
    commit a7d53dbbc70a ("platform/x86: intel_scu_ipc: Increase virtual
    timeout from 3 to 5 seconds") .

    Since the value is anyway updated to 10s now, take this opportunity to
    update the value in the comment too.

    Signed-off-by: Prashant Malani <pmalani@chromium.org>
    Cc: Benson Leung <bleung@chromium.org>
    Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Link: https://lore.kernel.org/r/20210928101932.2543937-4-pmalani@chromium.org
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a5b34409d3fc52114c828be4adbc30744fa3258b
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sat Oct 9 11:33:49 2021 +0000

    isdn: mISDN: Fix sleeping function called from invalid context

    [ Upstream commit 6510e80a0b81b5d814e3aea6297ba42f5e76f73c ]

    The driver can call card->isac.release() function from an atomic
    context.

    Fix this by calling this function after releasing the lock.

    The following log reveals it:

    [   44.168226 ] BUG: sleeping function called from invalid context at kernel/workqueue.c:3018
    [   44.168941 ] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5475, name: modprobe
    [   44.169574 ] INFO: lockdep is turned off.
    [   44.169899 ] irq event stamp: 0
    [   44.170160 ] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
    [   44.170627 ] hardirqs last disabled at (0): [<ffffffff814209ed>] copy_process+0x132d/0x3e00
    [   44.171240 ] softirqs last  enabled at (0): [<ffffffff81420a1a>] copy_process+0x135a/0x3e00
    [   44.171852 ] softirqs last disabled at (0): [<0000000000000000>] 0x0
    [   44.172318 ] Preemption disabled at:
    [   44.172320 ] [<ffffffffa009b0a9>] nj_release+0x69/0x500 [netjet]
    [   44.174441 ] Call Trace:
    [   44.174630 ]  dump_stack_lvl+0xa8/0xd1
    [   44.174912 ]  dump_stack+0x15/0x17
    [   44.175166 ]  ___might_sleep+0x3a2/0x510
    [   44.175459 ]  ? nj_release+0x69/0x500 [netjet]
    [   44.175791 ]  __might_sleep+0x82/0xe0
    [   44.176063 ]  ? start_flush_work+0x20/0x7b0
    [   44.176375 ]  start_flush_work+0x33/0x7b0
    [   44.176672 ]  ? trace_irq_enable_rcuidle+0x85/0x170
    [   44.177034 ]  ? kasan_quarantine_put+0xaa/0x1f0
    [   44.177372 ]  ? kasan_quarantine_put+0xaa/0x1f0
    [   44.177711 ]  __flush_work+0x11a/0x1a0
    [   44.177991 ]  ? flush_work+0x20/0x20
    [   44.178257 ]  ? lock_release+0x13c/0x8f0
    [   44.178550 ]  ? __kasan_check_write+0x14/0x20
    [   44.178872 ]  ? do_raw_spin_lock+0x148/0x360
    [   44.179187 ]  ? read_lock_is_recursive+0x20/0x20
    [   44.179530 ]  ? __kasan_check_read+0x11/0x20
    [   44.179846 ]  ? do_raw_spin_unlock+0x55/0x900
    [   44.180168 ]  ? ____kasan_slab_free+0x116/0x140
    [   44.180505 ]  ? _raw_spin_unlock_irqrestore+0x41/0x60
    [   44.180878 ]  ? skb_queue_purge+0x1a3/0x1c0
    [   44.181189 ]  ? kfree+0x13e/0x290
    [   44.181438 ]  flush_work+0x17/0x20
    [   44.181695 ]  mISDN_freedchannel+0xe8/0x100
    [   44.182006 ]  isac_release+0x210/0x260 [mISDNipac]
    [   44.182366 ]  nj_release+0xf6/0x500 [netjet]
    [   44.182685 ]  nj_remove+0x48/0x70 [netjet]
    [   44.182989 ]  pci_device_remove+0xa9/0x250

    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 207f6c3a82e19626aedad6e2f9aa0bb348495447
Author: Herve Codina <herve.codina@bootlin.com>
Date:   Fri Oct 8 12:34:40 2021 +0200

    ARM: dts: spear3xx: Fix gmac node

    [ Upstream commit 6636fec29cdf6665bd219564609e8651f6ddc142 ]

    On SPEAr3xx, ethernet driver is not compatible with the SPEAr600
    one.
    Indeed, SPEAr3xx uses an earlier version of this IP (v3.40) and
    needs some driver tuning compare to SPEAr600.

    The v3.40 IP support was added to stmmac driver and this patch
    fixes this issue and use the correct compatible string for
    SPEAr3xx

    Signed-off-by: Herve Codina <herve.codina@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit cfe8c4a4d6eb21af53504c6b85393de2f8345685
Author: Herve Codina <herve.codina@bootlin.com>
Date:   Fri Oct 8 12:34:39 2021 +0200

    net: stmmac: add support for dwmac 3.40a

    [ Upstream commit 9cb1d19f47fafad7dcf7c8564e633440c946cfd7 ]

    dwmac 3.40a is an old ip version that can be found on SPEAr3xx soc.

    Signed-off-by: Herve Codina <herve.codina@bootlin.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f03a8a85e91580f7881b24c24ab2e4e37d8080b1
Author: Filipe Manana <fdmanana@suse.com>
Date:   Fri Oct 1 13:52:30 2021 +0100

    btrfs: deal with errors when checking if a dir entry exists during log replay

    [ Upstream commit 77a5b9e3d14cbce49ceed2766b2003c034c066dc ]

    Currently inode_in_dir() ignores errors returned from
    btrfs_lookup_dir_index_item() and from btrfs_lookup_dir_item(), treating
    any errors as if the directory entry does not exists in the fs/subvolume
    tree, which is obviously not correct, as we can get errors such as -EIO
    when reading extent buffers while searching the fs/subvolume's tree.

    Fix that by making inode_in_dir() return the errors and making its only
    caller, add_inode_ref(), deal…
warudooooo added a commit to warudooooo/android_kernel_sm6225_spes that referenced this issue Sep 20, 2023
…x/kernel/git/stable/linux-stable

    commit 00a95330f3b295d4a581c36a5f2949c731386e37
    Merge: 9e5a216016f0 a027d43cf3f2
    Author: warudo <waldoreyes2301@gmail.com>
    Date:   Wed Sep 20 16:00:07 2023 +0800

        Merge tag 'v4.19.215'

        This is the 4.19.215 stable release

    commit a027d43cf3f2fdaabf467b4bcb92d0fe748c2eaf
    Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Date:   Tue Nov 2 18:26:46 2021 +0100

        Linux 4.19.215

        Link: https://lore.kernel.org/r/20211101082451.430720900@linuxfoundation.org
        Link: https://lore.kernel.org/r/20211101114224.924071362@linuxfoundation.org
        Tested-by: Jon Hunter <jonathanh@nvidia.com>
        Tested-by: Shuah Khan <skhan@linuxfoundation.org>
        Tested-by: Guenter Roeck <linux@roeck-us.net>
        Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
        Tested-by: Hulk Robot <hulkrobot@huawei.com>
        Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
        Tested-by: Pavel Machek (CIP) <pavel@denx.de>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 1ff3c379248ea579aa122d4ca245028e4bc9af23
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Wed Oct 20 07:42:47 2021 -0400

        sctp: add vtag check in sctp_sf_ootb

        [ Upstream commit 9d02831e517aa36ee6bdb453a0eb47bd49923fe3 ]

        sctp_sf_ootb() is called when processing DATA chunk in closed state,
        and many other places are also using it.

        The vtag in the chunk's sctphdr should be verified, otherwise, as
        later in chunk length check, it may send abort with the existent
        asoc's vtag, which can be exploited by one to cook a malicious
        chunk to terminate a SCTP asoc.

        When fails to verify the vtag from the chunk, this patch sets asoc
        to NULL, so that the abort will be made with the vtag from the
        received chunk later.

        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
        Signed-off-by: Xin Long <lucien.xin@gmail.com>
        Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit d9a4f990aab48dd5c134a9e76c7b651d404b05d3
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Wed Oct 20 07:42:46 2021 -0400

        sctp: add vtag check in sctp_sf_do_8_5_1_E_sa

        [ Upstream commit ef16b1734f0a176277b7bb9c71a6d977a6ef3998 ]

        sctp_sf_do_8_5_1_E_sa() is called when processing SHUTDOWN_ACK chunk
        in cookie_wait and cookie_echoed state.

        The vtag in the chunk's sctphdr should be verified, otherwise, as
        later in chunk length check, it may send abort with the existent
        asoc's vtag, which can be exploited by one to cook a malicious
        chunk to terminate a SCTP asoc.

        Note that when fails to verify the vtag from SHUTDOWN-ACK chunk,
        SHUTDOWN COMPLETE message will still be sent back to peer, but
        with the vtag from SHUTDOWN-ACK chunk, as said in 5) of
        rfc4960#section-8.4.

        While at it, also remove the unnecessary chunk length check from
        sctp_sf_shut_8_4_5(), as it's already done in both places where
        it calls sctp_sf_shut_8_4_5().

        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
        Signed-off-by: Xin Long <lucien.xin@gmail.com>
        Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit 7bf2f6a30d1851c530ad5e4ee7e5c45fb6be0128
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Wed Oct 20 07:42:45 2021 -0400

        sctp: add vtag check in sctp_sf_violation

        [ Upstream commit aa0f697e45286a6b5f0ceca9418acf54b9099d99 ]

        sctp_sf_violation() is called when processing HEARTBEAT_ACK chunk
        in cookie_wait state, and some other places are also using it.

        The vtag in the chunk's sctphdr should be verified, otherwise, as
        later in chunk length check, it may send abort with the existent
        asoc's vtag, which can be exploited by one to cook a malicious
        chunk to terminate a SCTP asoc.

        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
        Signed-off-by: Xin Long <lucien.xin@gmail.com>
        Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit 86044244fc6f9eaec0070cb668e0d500de22dbba
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Wed Oct 20 07:42:44 2021 -0400

        sctp: fix the processing for COOKIE_ECHO chunk

        [ Upstream commit a64b341b8695e1c744dd972b39868371b4f68f83 ]

        1. In closed state: in sctp_sf_do_5_1D_ce():

          When asoc is NULL, making packet for abort will use chunk's vtag
          in sctp_ootb_pkt_new(). But when asoc exists, vtag from the chunk
          should be verified before using peer.i.init_tag to make packet
          for abort in sctp_ootb_pkt_new(), and just discard it if vtag is
          not correct.

        2. In the other states: in sctp_sf_do_5_2_4_dupcook():

          asoc always exists, but duplicate cookie_echo's vtag will be
          handled by sctp_tietags_compare() and then take actions, so before
          that we only verify the vtag for the abort sent for invalid chunk
          length.

        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
        Signed-off-by: Xin Long <lucien.xin@gmail.com>
        Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit 1f52dfacca7bb315d89f5ece5660b0337809798e
    Author: Xin Long <lucien.xin@gmail.com>
    Date:   Wed Oct 20 07:42:41 2021 -0400

        sctp: use init_tag from inithdr for ABORT chunk

        [ Upstream commit 4f7019c7eb33967eb87766e0e4602b5576873680 ]

        Currently Linux SCTP uses the verification tag of the existing SCTP
        asoc when failing to process and sending the packet with the ABORT
        chunk. This will result in the peer accepting the ABORT chunk and
        removing the SCTP asoc. One could exploit this to terminate a SCTP
        asoc.

        This patch is to fix it by always using the initiate tag of the
        received INIT chunk for the ABORT chunk to be sent.

        Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
        Signed-off-by: Xin Long <lucien.xin@gmail.com>
        Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit b75fa48e42d022d6757b7de29178d531df8cf43b
    Author: Trevor Woerner <twoerner@gmail.com>
    Date:   Sun Oct 24 13:50:02 2021 -0400

        net: nxp: lpc_eth.c: avoid hang when bringing interface down

        commit ace19b992436a257d9a793672e57abc28fe83e2e upstream.

        A hard hang is observed whenever the ethernet interface is brought
        down. If the PHY is stopped before the LPC core block is reset,
        the SoC will hang. Comparing lpc_eth_close() and lpc_eth_open() I
        re-arranged the ordering of the functions calls in lpc_eth_close() to
        reset the hardware before stopping the PHY.
        Fixes: b7370112f519 ("lpc32xx: Added ethernet driver")
        Signed-off-by: Trevor Woerner <twoerner@gmail.com>
        Acked-by: Vladimir Zapolskiy <vz@mleia.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 84a9eb9a2f179ea5e6398fe270560a8aaa16f996
    Author: Yuiko Oshino <yuiko.oshino@microchip.com>
    Date:   Fri Oct 22 11:53:43 2021 -0400

        net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent

        commit 95a359c9553342d36d408d35331ff0bfce75272f upstream.

        The dma failure was reported in the raspberry pi github (issue #4117).
        https://github.com/raspberrypi/linux/issues/4117
        The use of dma_set_mask_and_coherent fixes the issue.
        Tested on 32/64-bit raspberry pi CM4 and 64-bit ubuntu x86 PC with EVB-LAN7430.

        Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
        Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit fcda74cc95aa450a6d17780ccb1a8853cac7d0cd
    Author: Yuiko Oshino <yuiko.oshino@microchip.com>
    Date:   Fri Oct 22 11:13:53 2021 -0400

        net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails

        commit d6423d2ec39cce2bfca418c81ef51792891576bc upstream.

        The driver needs to clean up and return when the initialization fails on resume.

        Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
        Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 25d852a8adf017a478246d19c8b282e975521e8a
    Author: Guenter Roeck <linux@roeck-us.net>
    Date:   Wed Oct 20 12:11:16 2021 -0700

        nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST

        commit 4a089e95b4d6bb625044d47aed0c442a8f7bd093 upstream.

        nios2:allmodconfig builds fail with

        make[1]: *** No rule to make target 'arch/nios2/boot/dts/""',
        	needed by 'arch/nios2/boot/dts/built-in.a'.  Stop.
        make: [Makefile:1868: arch/nios2/boot/dts] Error 2 (ignored)

        This is seen with compile tests since those enable NIOS2_DTB_SOURCE_BOOL,
        which in turn enables NIOS2_DTB_SOURCE. This causes the build error
        because the default value for NIOS2_DTB_SOURCE is an empty string.
        Disable NIOS2_DTB_SOURCE_BOOL for compile tests to avoid the error.

        Fixes: 2fc8483fdcde ("nios2: Build infrastructure")
        Signed-off-by: Guenter Roeck <linux@roeck-us.net>
        Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
        Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 02302cbd52264337630a32848ac03648648e9685
    Author: Michael Chan <michael.chan@broadcom.com>
    Date:   Mon Oct 25 05:05:28 2021 -0400

        net: Prevent infinite while loop in skb_tx_hash()

        commit 0c57eeecc559ca6bc18b8c4e2808bc78dbe769b0 upstream.

        Drivers call netdev_set_num_tc() and then netdev_set_tc_queue()
        to set the queue count and offset for each TC.  So the queue count
        and offset for the TCs may be zero for a short period after dev->num_tc
        has been set.  If a TX packet is being transmitted at this time in the
        code path netdev_pick_tx() -> skb_tx_hash(), skb_tx_hash() may see
        nonzero dev->num_tc but zero qcount for the TC.  The while loop that
        keeps looping while hash >= qcount will not end.

        Fix it by checking the TC's qcount to be nonzero before using it.

        Fixes: eadec877ce9c ("net: Add support for subordinate traffic classes to netdev_pick_tx")
        Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
        Signed-off-by: Michael Chan <michael.chan@broadcom.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit fbf150b16a3635634b7dfb7f229d8fcd643c6c51
    Author: Pavel Skripkin <paskripkin@gmail.com>
    Date:   Sun Oct 24 16:13:56 2021 +0300

        net: batman-adv: fix error handling

        commit 6f68cd634856f8ca93bafd623ba5357e0f648c68 upstream.

        Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
        in wrong error handling in batadv_mesh_init().

        Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
        of any batadv_*_init() calls failure. This approach may work well, when
        there is some kind of indicator, which can tell which parts of batadv are
        initialized; but there isn't any.

        All written above lead to cleaning up uninitialized fields. Even if we hide
        ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
        GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]

        To fix these bugs we can unwind batadv_*_init() calls one by one.
        It is good approach for 2 reasons: 1) It fixes bugs on error handling
        path 2) It improves the performance, since we won't call unneeded
        batadv_*_free() functions.

        So, this patch makes all batadv_*_init() clean up all allocated memory
        before returning with an error to no call correspoing batadv_*_free()
        and open-codes batadv_mesh_free() with proper order to avoid touching
        uninitialized fields.

        Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/ [1]
        Reported-and-tested-by: syzbot+28b0702ada0bf7381f58@syzkaller.appspotmail.com
        Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
        Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
        Acked-by: Sven Eckelmann <sven@narfation.org>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 3dae1a4eced3ee733d7222e69b8a55caf2d61091
    Author: Yang Yingliang <yangyingliang@huawei.com>
    Date:   Tue Oct 12 10:37:35 2021 +0800

        regmap: Fix possible double-free in regcache_rbtree_exit()

        commit 55e6d8037805b3400096d621091dfbf713f97e83 upstream.

        In regcache_rbtree_insert_to_block(), when 'present' realloc failed,
        the 'blk' which is supposed to assign to 'rbnode->block' will be freed,
        so 'rbnode->block' points a freed memory, in the error handling path of
        regcache_rbtree_init(), 'rbnode->block' will be freed again in
        regcache_rbtree_exit(), KASAN will report double-free as follows:

        BUG: KASAN: double-free or invalid-free in kfree+0xce/0x390
        Call Trace:
         slab_free_freelist_hook+0x10d/0x240
         kfree+0xce/0x390
         regcache_rbtree_exit+0x15d/0x1a0
         regcache_rbtree_init+0x224/0x2c0
         regcache_init+0x88d/0x1310
         __regmap_init+0x3151/0x4a80
         __devm_regmap_init+0x7d/0x100
         madera_spi_probe+0x10f/0x333 [madera_spi]
         spi_probe+0x183/0x210
         really_probe+0x285/0xc30

        To fix this, moving up the assignment of rbnode->block to immediately after
        the reallocation has succeeded so that the data structure stays valid even
        if the second reallocation fails.

        Reported-by: Hulk Robot <hulkci@huawei.com>
        Fixes: 3f4ff561bc88b ("regmap: rbtree: Make cache_present bitmap per node")
        Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
        Link: https://lore.kernel.org/r/20211012023735.1632786-1-yangyingliang@huawei.com
        Signed-off-by: Mark Brown <broonie@kernel.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit cdaf7a469244b5e65ae5eda062ff5ea90172de62
    Author: Clément Bœsch <u@pkh.me>
    Date:   Sun Sep 5 02:20:27 2021 +0200

        arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node

        commit 0764e365dacd0b8f75c1736f9236be280649bd18 upstream.

        RX and TX delay are provided by ethernet PHY. Reflect that in ethernet
        node.

        Fixes: 44a94c7ef989 ("arm64: dts: allwinner: H5: Restore EMAC changes")
        Signed-off-by: Clément Bœsch <u@pkh.me>
        Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
        Reviewed-by: Andrew Lunn <andrew@lunn.ch>
        Signed-off-by: Maxime Ripard <maxime@cerno.tech>
        Link: https://lore.kernel.org/r/20210905002027.171984-1-u@pkh.me
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 2864b6d54244b82a8c7d4628a43055c57bfba80c
    Author: Patrisious Haddad <phaddad@nvidia.com>
    Date:   Wed Oct 6 12:31:53 2021 +0300

        RDMA/mlx5: Set user priority for DCT

        commit 1ab52ac1e9bc9391f592c9fa8340a6e3e9c36286 upstream.

        Currently, the driver doesn't set the PCP-based priority for DCT, hence
        DCT response packets are transmitted without user priority.

        Fix it by setting user provided priority in the eth_prio field in the DCT
        context, which in turn sets the value in the transmitted packet.

        Fixes: 776a3906b692 ("IB/mlx5: Add support for DC target QP")
        Link: https://lore.kernel.org/r/5fd2d94a13f5742d8803c218927322257d53205c.1633512672.git.leonro@nvidia.com
        Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
        Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
        Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
        Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 326da4f6ffdbd8671e86f69ded7a714dcc12fecf
    Author: Johan Hovold <johan@kernel.org>
    Date:   Tue Oct 26 12:36:17 2021 +0200

        net: lan78xx: fix division by zero in send path

        commit db6c3c064f5d55fa9969f33eafca3cdbefbb3541 upstream.

        Add the missing endpoint max-packet sanity check to probe() to avoid
        division by zero in lan78xx_tx_bh() in case a malicious device has
        broken descriptors (or when doing descriptor fuzz testing).

        Note that USB core will reject URBs submitted for endpoints with zero
        wMaxPacketSize but that drivers doing packet-size calculations still
        need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip
        endpoint descriptors with maxpacket=0")).

        Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
        Cc: stable@vger.kernel.org      # 4.3
        Cc: Woojung.Huh@microchip.com <Woojung.Huh@microchip.com>
        Signed-off-by: Johan Hovold <johan@kernel.org>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 2ff5289793fd61c56ac8774408f27350e5da865f
    Author: Haibo Chen <haibo.chen@nxp.com>
    Date:   Fri Oct 15 10:00:36 2021 +0800

        mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit

        commit 9af372dc70e9fdcbb70939dac75365e7b88580b4 upstream.

        To reset standard tuning circuit completely, after clear ESDHC_MIX_CTRL_EXE_TUNE,
        also need to clear bit buffer_read_ready, this operation will finally clear the
        USDHC IP internal logic flag execute_tuning_with_clr_buf, make sure the following
        normal data transfer will not be impacted by standard tuning logic used before.

        Find this issue when do quick SD card insert/remove stress test. During standard
        tuning prodedure, if remove SD card, USDHC standard tuning logic can't clear the
        internal flag execute_tuning_with_clr_buf. Next time when insert SD card, all
        data related commands can't get any data related interrupts, include data transfer
        complete interrupt, data timeout interrupt, data CRC interrupt, data end bit interrupt.
        Always trigger software timeout issue. Even reset the USDHC through bits in register
        SYS_CTRL (0x2C, bit28 reset tuning, bit26 reset data, bit 25 reset command, bit 24
        reset all) can't recover this. From the user's point of view, USDHC stuck, SD can't
        be recognized any more.

        Fixes: d9370424c948 ("mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card")
        Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
        Acked-by: Adrian Hunter <adrian.hunter@intel.com>
        Cc: stable@vger.kernel.org
        Link: https://lore.kernel.org/r/1634263236-6111-1-git-send-email-haibo.chen@nxp.com
        Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 7824414c2903e2cfe56ea610387a22c0c88fb468
    Author: Shawn Guo <shawn.guo@linaro.org>
    Date:   Mon Oct 4 10:49:35 2021 +0800

        mmc: sdhci: Map more voltage level to SDHCI_POWER_330

        commit 4217d07b9fb328751f877d3bd9550122014860a2 upstream.

        On Thundercomm TurboX CM2290, the eMMC OCR reports vdd = 23 (3.5 ~ 3.6 V),
        which is being treated as an invalid value by sdhci_set_power_noreg().
        And thus eMMC is totally broken on the platform.

        [    1.436599] ------------[ cut here ]------------
        [    1.436606] mmc0: Invalid vdd 0x17
        [    1.436640] WARNING: CPU: 2 PID: 69 at drivers/mmc/host/sdhci.c:2048 sdhci_set_power_noreg+0x168/0x2b4
        [    1.436655] Modules linked in:
        [    1.436662] CPU: 2 PID: 69 Comm: kworker/u8:1 Tainted: G        W         5.15.0-rc1+ #137
        [    1.436669] Hardware name: Thundercomm TurboX CM2290 (DT)
        [    1.436674] Workqueue: events_unbound async_run_entry_fn
        [    1.436685] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
        [    1.436692] pc : sdhci_set_power_noreg+0x168/0x2b4
        [    1.436698] lr : sdhci_set_power_noreg+0x168/0x2b4
        [    1.436703] sp : ffff800010803a60
        [    1.436705] x29: ffff800010803a60 x28: ffff6a9102465f00 x27: ffff6a9101720a70
        [    1.436715] x26: ffff6a91014de1c0 x25: ffff6a91014de010 x24: ffff6a91016af280
        [    1.436724] x23: ffffaf7b1b276640 x22: 0000000000000000 x21: ffff6a9101720000
        [    1.436733] x20: ffff6a9101720370 x19: ffff6a9101720580 x18: 0000000000000020
        [    1.436743] x17: 0000000000000000 x16: 0000000000000004 x15: ffffffffffffffff
        [    1.436751] x14: 0000000000000000 x13: 00000000fffffffd x12: ffffaf7b1b84b0bc
        [    1.436760] x11: ffffaf7b1b720d10 x10: 000000000000000a x9 : ffff800010803a60
        [    1.436769] x8 : 000000000000000a x7 : 000000000000000f x6 : 00000000fffff159
        [    1.436778] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
        [    1.436787] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff6a9101718d80
        [    1.436797] Call trace:
        [    1.436800]  sdhci_set_power_noreg+0x168/0x2b4
        [    1.436805]  sdhci_set_ios+0xa0/0x7fc
        [    1.436811]  mmc_power_up.part.0+0xc4/0x164
        [    1.436818]  mmc_start_host+0xa0/0xb0
        [    1.436824]  mmc_add_host+0x60/0x90
        [    1.436830]  __sdhci_add_host+0x174/0x330
        [    1.436836]  sdhci_msm_probe+0x7c0/0x920
        [    1.436842]  platform_probe+0x68/0xe0
        [    1.436850]  really_probe.part.0+0x9c/0x31c
        [    1.436857]  __driver_probe_device+0x98/0x144
        [    1.436863]  driver_probe_device+0xc8/0x15c
        [    1.436869]  __device_attach_driver+0xb4/0x120
        [    1.436875]  bus_for_each_drv+0x78/0xd0
        [    1.436881]  __device_attach_async_helper+0xac/0xd0
        [    1.436888]  async_run_entry_fn+0x34/0x110
        [    1.436895]  process_one_work+0x1d0/0x354
        [    1.436903]  worker_thread+0x13c/0x470
        [    1.436910]  kthread+0x150/0x160
        [    1.436915]  ret_from_fork+0x10/0x20
        [    1.436923] ---[ end trace fcfac44cb045c3a8 ]---

        Fix the issue by mapping MMC_VDD_35_36 (and MMC_VDD_34_35) to
        SDHCI_POWER_330 as well.

        Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
        Acked-by: Adrian Hunter <adrian.hunter@intel.com>
        Cc: stable@vger.kernel.org
        Link: https://lore.kernel.org/r/20211004024935.15326-1-shawn.guo@linaro.org
        Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 29d56f3790e684e630d56f500b59e834fa382209
    Author: Jaehoon Chung <jh80.chung@samsung.com>
    Date:   Fri Oct 22 17:21:06 2021 +0900

        mmc: dw_mmc: exynos: fix the finding clock sample value

        commit 697542bceae51f7620af333b065dd09d213629fb upstream.

        Even though there are candiates value if can't find best value, it's
        returned -EIO. It's not proper behavior.
        If there is not best value, use a first candiate value to work eMMC.

        Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
        Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
        Tested-by: Christian Hewitt <christianshewitt@gmail.com>
        Cc: stable@vger.kernel.org
        Fixes: c537a1c5ff63 ("mmc: dw_mmc: exynos: add variable delay tuning sequence")
        Link: https://lore.kernel.org/r/20211022082106.1557-1-jh80.chung@samsung.com
        Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 24f8658690477e8983f88cbfe21fb7f4062ad837
    Author: Wenbin Mei <wenbin.mei@mediatek.com>
    Date:   Tue Oct 26 15:08:12 2021 +0800

        mmc: cqhci: clear HALT state after CQE enable

        commit 92b18252b91de567cd875f2e84722b10ab34ee28 upstream.

        While mmc0 enter suspend state, we need halt CQE to send legacy cmd(flush
        cache) and disable cqe, for resume back, we enable CQE and not clear HALT
        state.
        In this case MediaTek mmc host controller will keep the value for HALT
        state after CQE disable/enable flow, so the next CQE transfer after resume
        will be timeout due to CQE is in HALT state, the log as below:
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: timeout for tag 2
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Caps:      0x100020b6 | Version:  0x00000510
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Config:    0x00001103 | Control:  0x00000001
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int stat:  0x00000000 | Int enab: 0x00000006
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Int sig:   0x00000006 | Int Coal: 0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: TDL base:  0xfd05f000 | TDL up32: 0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Doorbell:  0x8000203c | TCN:      0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Task clr:  0x00000000 | SSC1:     0x00001000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: SSC2:      0x00000001 | DCMD rsp: 0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: RED mask:  0xfdf9a080 | TERRI:    0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: Resp idx:  0x00000000 | Resp arg: 0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQP:     0x00000000 | CRNQDUN:  0x00000000
        <4>.(4)[318:kworker/4:1H]mmc0: cqhci: CRNQIS:    0x00000000 | CRNQIE:   0x00000000

        This change check HALT state after CQE enable, if CQE is in HALT state, we
        will clear it.

        Signed-off-by: Wenbin Mei <wenbin.mei@mediatek.com>
        Cc: stable@vger.kernel.org
        Acked-by: Adrian Hunter <adrian.hunter@intel.com>
        Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
        Link: https://lore.kernel.org/r/20211026070812.9359-1-wenbin.mei@mediatek.com
        Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 99641238575c26c2e47fa593f562dae476709d68
    Author: Johan Hovold <johan@kernel.org>
    Date:   Mon Oct 25 13:56:08 2021 +0200

        mmc: vub300: fix control-message timeouts

        commit 8c8171929116cc23f74743d99251eedadf62341a upstream.

        USB control-message timeouts are specified in milliseconds and should
        specifically not vary with CONFIG_HZ.

        Fixes: 88095e7b473a ("mmc: Add new VUB300 USB-to-SD/SDIO/MMC driver")
        Cc: stable@vger.kernel.org      # 3.0
        Signed-off-by: Johan Hovold <johan@kernel.org>
        Link: https://lore.kernel.org/r/20211025115608.5287-1-johan@kernel.org
        Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit c6d0d68d6da68159948cad3d808d61bb291a0283
    Author: Eric Dumazet <edumazet@google.com>
    Date:   Sun Aug 29 15:16:14 2021 -0700

        ipv6: make exception cache less predictible

        commit a00df2caffed3883c341d5685f830434312e4a43 upstream.

        Even after commit 4785305c05b2 ("ipv6: use siphash in rt6_exception_hash()"),
        an attacker can still use brute force to learn some secrets from a victim
        linux host.

        One way to defeat these attacks is to make the max depth of the hash
        table bucket a random value.

        Before this patch, each bucket of the hash table used to store exceptions
        could contain 6 items under attack.

        After the patch, each bucket would contains a random number of items,
        between 6 and 10. The attacker can no longer infer secrets.

        This is slightly increasing memory size used by the hash table,
        we do not expect this to be a problem.

        Following patch is dealing with the same issue in IPv4.

        Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
        Signed-off-by: Eric Dumazet <edumazet@google.com>
        Reported-by: Keyu Man <kman001@ucr.edu>
        Cc: Wei Wang <weiwan@google.com>
        Cc: Martin KaFai Lau <kafai@fb.com>
        Reviewed-by: David Ahern <dsahern@kernel.org>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        [OP: adjusted context for 4.19 stable]
        Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit ad829847ad59af8e26a1f1c345716099abbc7a58
    Author: Eric Dumazet <edumazet@google.com>
    Date:   Fri Oct 29 10:50:26 2021 +0300

        ipv6: use siphash in rt6_exception_hash()

        commit 4785305c05b25a242e5314cc821f54ade4c18810 upstream.

        A group of security researchers brought to our attention
        the weakness of hash function used in rt6_exception_hash()

        Lets use siphash instead of Jenkins Hash, to considerably
        reduce security risks.

        Following patch deals with IPv4.

        Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
        Signed-off-by: Eric Dumazet <edumazet@google.com>
        Reported-by: Keyu Man <kman001@ucr.edu>
        Cc: Wei Wang <weiwan@google.com>
        Cc: Martin KaFai Lau <kafai@fb.com>
        Acked-by: Wei Wang <weiwan@google.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        [OP: adjusted context for 4.19 stable]
        Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 6e2856767eb1a9cfcfcd82136928037f04920e97
    Author: Eric Dumazet <edumazet@google.com>
    Date:   Fri Oct 29 10:50:25 2021 +0300

        ipv4: use siphash instead of Jenkins in fnhe_hashfun()

        commit 6457378fe796815c973f631a1904e147d6ee33b1 upstream.

        A group of security researchers brought to our attention
        the weakness of hash function used in fnhe_hashfun().

        Lets use siphash instead of Jenkins Hash, to considerably
        reduce security risks.

        Also remove the inline keyword, this really is distracting.

        Fixes: d546c621542d ("ipv4: harden fnhe_hashfun()")
        Signed-off-by: Eric Dumazet <edumazet@google.com>
        Reported-by: Keyu Man <kman001@ucr.edu>
        Cc: Willy Tarreau <w@1wt.eu>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        [OP: adjusted context for 4.19 stable]
        Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 8121d0d4fd108280f5cd7b7fe8c6592adaa37be9
    Author: Pavel Skripkin <paskripkin@gmail.com>
    Date:   Thu Sep 30 20:49:42 2021 +0300

        Revert "net: mdiobus: Fix memory leak in __mdiobus_register"

        commit 10eff1f5788b6ffac212c254e2f3666219576889 upstream.

        This reverts commit ab609f25d19858513919369ff3d9a63c02cd9e2e.

        This patch is correct in the sense that we _should_ call device_put() in
        case of device_register() failure, but the problem in this code is more
        vast.

        We need to set bus->state to UNMDIOBUS_REGISTERED before calling
        device_register() to correctly release the device in mdiobus_free().
        This patch prevents us from doing it, since in case of device_register()
        failure put_device() will be called 2 times and it will cause UAF or
        something else.

        Also, Reported-by: tag in revered commit was wrong, since syzbot
        reported different leak in same function.

        Link: https://lore.kernel.org/netdev/20210928092657.GI2048@kadam/
        Acked-by: Yanfei Xu <yanfei.xu@windriver.com>
        Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
        Link: https://lore.kernel.org/r/f12fb1faa4eccf0f355788225335eb4309ff2599.1633024062.git.paskripkin@gmail.com
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 4a9043ba1b0e9bea1da0fe34366222974f2c0f92
    Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Date:   Mon Oct 25 16:49:36 2021 +0200

        nfc: port100: fix using -ERRNO as command type mask

        commit 2195f2062e4cc93870da8e71c318ef98a1c51cef upstream.

        During probing, the driver tries to get a list (mask) of supported
        command types in port100_get_command_type_mask() function.  The value
        is u64 and 0 is treated as invalid mask (no commands supported).  The
        function however returns also -ERRNO as u64 which will be interpret as
        valid command mask.

        Return 0 on every error case of port100_get_command_type_mask(), so the
        probing will stop.

        Cc: <stable@vger.kernel.org>
        Fixes: 0347a6ab300a ("NFC: port100: Commands mechanism implementation")
        Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit a36119f9b3fb069437383a8eff4e65181b6e7e2f
    Author: Zheyu Ma <zheyuma97@gmail.com>
    Date:   Fri Oct 22 09:12:26 2021 +0000

        ata: sata_mv: Fix the error handling of mv_chip_id()

        commit a0023bb9dd9bc439d44604eeec62426a990054cd upstream.

        mv_init_host() propagates the value returned by mv_chip_id() which in turn
        gets propagated by mv_pci_init_one() and hits local_pci_probe().

        During the process of driver probing, the probe function should return < 0
        for failure, otherwise, the kernel will treat value > 0 as success.

        Since this is a bug rather than a recoverable runtime error we should
        use dev_alert() instead of dev_err().

        Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
        Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 78c2dc1cdf0bdfc83e473d78f23da4d2aeb98142
    Author: Wang Hai <wanghai38@huawei.com>
    Date:   Tue Oct 26 20:40:15 2021 +0800

        usbnet: fix error return code in usbnet_probe()

        commit 6f7c88691191e6c52ef2543d6f1da8d360b27a24 upstream.

        Return error code if usb_maxpacket() returns 0 in usbnet_probe()

        Fixes: 397430b50a36 ("usbnet: sanity check for maxpacket")
        Reported-by: Hulk Robot <hulkci@huawei.com>
        Signed-off-by: Wang Hai <wanghai38@huawei.com>
        Reviewed-by: Johan Hovold <johan@kernel.org>
        Link: https://lore.kernel.org/r/20211026124015.3025136-1-wanghai38@huawei.com
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 002d82227c0abe29118cf80f7e2f396b22d448ed
    Author: Oliver Neukum <oneukum@suse.com>
    Date:   Thu Oct 21 14:29:44 2021 +0200

        usbnet: sanity check for maxpacket

        commit 397430b50a363d8b7bdda00522123f82df6adc5e upstream.

        maxpacket of 0 makes no sense and oopses as we need to divide
        by it. Give up.

        V2: fixed typo in log and stylistic issues

        Signed-off-by: Oliver Neukum <oneukum@suse.com>
        Reported-by: syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com
        Reviewed-by: Johan Hovold <johan@kernel.org>
        Link: https://lore.kernel.org/r/20211021122944.21816-1-oneukum@suse.com
        Signed-off-by: Jakub Kicinski <kuba@kernel.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit d725978abb0bac6e0c427548dfd6db86709a2a1e
    Author: Nathan Chancellor <natechancellor@gmail.com>
    Date:   Sat Jan 5 19:35:25 2019 +0100

        ARM: 8819/1: Remove '-p' from LDFLAGS

        commit 091bb549f7722723b284f63ac665e2aedcf9dec9 upstream.

        This option is not supported by lld:

            ld.lld: error: unknown argument: -p

        This has been a no-op in binutils since 2004 (see commit dea514f51da1 in
        that tree). Given that the lowest officially supported of binutils for
        the kernel is 2.20, which was released in 2009, nobody needs this flag
        around so just remove it. Commit 1a381d4a0a9a ("arm64: remove no-op -p
        linker flag") did the same for arm64.

        Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
        Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
        Acked-by: Nicolas Pitre <nico@linaro.org>
        Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
        Reviewed-by: Stefan Agner <stefan@agner.ch>
        Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit aaf4e1b05cab800b36b40c1aa09f7c13ef30de56
    Author: Robin Murphy <robin.murphy@arm.com>
    Date:   Mon Jul 12 15:27:46 2021 +0100

        arm64: Avoid premature usercopy failure

        commit 295cf156231ca3f9e3a66bde7fab5e09c41835e0 upstream.

        Al reminds us that the usercopy API must only return complete failure
        if absolutely nothing could be copied. Currently, if userspace does
        something silly like giving us an unaligned pointer to Device memory,
        or a size which overruns MTE tag bounds, we may fail to honour that
        requirement when faulting on a multi-byte access even though a smaller
        access could have succeeded.

        Add a mitigation to the fixup routines to fall back to a single-byte
        copy if we faulted on a larger access before anything has been written
        to the destination, to guarantee making *some* forward progress. We
        needn't be too concerned about the overall performance since this should
        only occur when callers are doing something a bit dodgy in the first
        place. Particularly broken userspace might still be able to trick
        generic_perform_write() into an infinite loop by targeting write() at
        an mmap() of some read-only device register where the fault-in load
        succeeds but any store synchronously aborts such that copy_to_user() is
        genuinely unable to make progress, but, well, don't do that...

        CC: stable@vger.kernel.org
        Reported-by: Chen Huang <chenhuang5@huawei.com>
        Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
        Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
        Signed-off-by: Robin Murphy <robin.murphy@arm.com>
        Link: https://lore.kernel.org/r/dc03d5c675731a1f24a62417dba5429ad744234e.1626098433.git.robin.murphy@arm.com
        Signed-off-by: Will Deacon <will@kernel.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
        Signed-off-by: Chen Huang <chenhuang5@huawei.com>

    commit 5909b851b5e11d04f299e5f0a8937e9dcc807248
    Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Date:   Wed Oct 6 01:55:22 2021 +0530

        powerpc/bpf: Fix BPF_MOD when imm == 1

        commit 8bbc9d822421d9ac8ff9ed26a3713c9afc69d6c8 upstream.

        Only ignore the operation if dividing by 1.

        Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
        Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
        Tested-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
        Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
        Acked-by: Song Liu <songliubraving@fb.com>
        Acked-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
        Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
        Link: https://lore.kernel.org/r/c674ca18c3046885602caebb326213731c675d06.1633464148.git.naveen.n.rao@linux.vnet.ibm.com
        [cascardo: use PPC_LI instead of EMIT(PPC_RAW_LI)]
        Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 901741a53d7cf45be861e881c0e3cba5b4bd1f94
    Author: Arnd Bergmann <arnd@arndb.de>
    Date:   Mon Oct 18 15:30:37 2021 +0100

        ARM: 9141/1: only warn about XIP address when not compile testing

        commit 48ccc8edf5b90622cdc4f8878e0042ab5883e2ca upstream.

        In randconfig builds, we sometimes come across this warning:

        arm-linux-gnueabi-ld: XIP start address may cause MPU programming issues

        While this is helpful for actual systems to figure out why it
        fails, the warning does not provide any benefit for build testing,
        so guard it in a check for CONFIG_COMPILE_TEST, which is usually
        set on randconfig builds.

        Fixes: 216218308cfb ("ARM: 8713/1: NOMMU: Support MPU in XIP configuration")
        Signed-off-by: Arnd Bergmann <arnd@arndb.de>
        Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit ee4b38ce37ed31beca29d3ebec7db3d5e87fe39e
    Author: Arnd Bergmann <arnd@arndb.de>
    Date:   Mon Oct 18 15:30:09 2021 +0100

        ARM: 9139/1: kprobes: fix arch_init_kprobes() prototype

        commit 1f323127cab086e4fd618981b1e5edc396eaf0f4 upstream.

        With extra warnings enabled, gcc complains about this function
        definition:

        arch/arm/probes/kprobes/core.c: In function 'arch_init_kprobes':
        arch/arm/probes/kprobes/core.c:465:12: warning: old-style function definition [-Wold-style-definition]
          465 | int __init arch_init_kprobes()

        Link: https://lore.kernel.org/all/20201027093057.c685a14b386acacb3c449e3d@kernel.org/

        Fixes: 24ba613c9d6c ("ARM kprobes: core code")
        Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
        Signed-off-by: Arnd Bergmann <arnd@arndb.de>
        Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit c0b4f1db7feef31d401814121760b45aff7885c1
    Author: Arnd Bergmann <arnd@arndb.de>
    Date:   Mon Oct 18 15:30:04 2021 +0100

        ARM: 9134/1: remove duplicate memcpy() definition

        commit eaf6cc7165c9c5aa3c2f9faa03a98598123d0afb upstream.

        Both the decompressor code and the kasan logic try to override
        the memcpy() and memmove()  definitions, which leading to a clash
        in a KASAN-enabled kernel with XZ decompression:

        arch/arm/boot/compressed/decompress.c:50:9: error: 'memmove' macro redefined [-Werror,-Wmacro-redefined]
         #define memmove memmove
                ^
        arch/arm/include/asm/string.h:59:9: note: previous definition is here
         #define memmove(dst, src, len) __memmove(dst, src, len)
                ^
        arch/arm/boot/compressed/decompress.c:51:9: error: 'memcpy' macro redefined [-Werror,-Wmacro-redefined]
         #define memcpy memcpy
                ^
        arch/arm/include/asm/string.h:58:9: note: previous definition is here
         #define memcpy(dst, src, len) __memcpy(dst, src, len)
                ^

        Here we want the set of functions from the decompressor, so undefine
        the other macros before the override.

        Link: https://lore.kernel.org/linux-arm-kernel/CACRpkdZYJogU_SN3H9oeVq=zJkRgRT1gDz3xp59gdqWXxw-B=w@mail.gmail.com/
        Link: https://lore.kernel.org/lkml/202105091112.F5rmd4By-lkp@intel.com/

        Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
        Fixes: a7f464f3db93 ("ARM: 7001/2: Wire up support for the XZ decompressor")
        Reported-by: kernel test robot <lkp@intel.com>
        Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
        Signed-off-by: Arnd Bergmann <arnd@arndb.de>
        Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 00dcbb2d2cd3594faa2f977f2f7175cf23d4e326
    Author: Nick Desaulniers <ndesaulniers@google.com>
    Date:   Mon Oct 4 18:03:28 2021 +0100

        ARM: 9133/1: mm: proc-macros: ensure *_tlb_fns are 4B aligned

        commit e6a0c958bdf9b2e1b57501fc9433a461f0a6aadd upstream.

        A kernel built with CONFIG_THUMB2_KERNEL=y and using clang as the
        assembler could generate non-naturally-aligned v7wbi_tlb_fns which
        results in a boot failure. The original commit adding the macro missed
        the .align directive on this data.

        Link: https://github.com/ClangBuiltLinux/linux/issues/1447
        Link: https://lore.kernel.org/all/0699da7b-354f-aecc-a62f-e25693209af4@linaro.org/
        Debugged-by: Ard Biesheuvel <ardb@kernel.org>
        Debugged-by: Nathan Chancellor <nathan@kernel.org>
        Debugged-by: Richard Henderson <richard.henderson@linaro.org>

        Fixes: 66a625a88174 ("ARM: mm: proc-macros: Add generic proc/cache/tlb struct definition macros")
        Suggested-by: Ard Biesheuvel <ardb@kernel.org>
        Acked-by: Ard Biesheuvel <ardb@kernel.org>
        Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
        Tested-by: Nathan Chancellor <nathan@kernel.org>
        Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 38ec06730e44b2166e87fecca9e36380080801ac
    Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Date:   Wed Oct 27 09:53:15 2021 +0200

        Linux 4.19.214

        Link: https://lore.kernel.org/r/20211025190926.680827862@linuxfoundation.org
        Tested-by: Pavel Machek (CIP) <pavel@denx.de>
        Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
        Tested-by: Shuah Khan <skhan@linuxfoundation.org>
        Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
        Tested-by: Guenter Roeck <linux@roeck-us.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 0b7d55ca605e611aceeadf7c29c75808faae951a
    Author: Nick Desaulniers <ndesaulniers@google.com>
    Date:   Wed Sep 8 19:25:59 2021 +0100

        ARM: 9122/1: select HAVE_FUTEX_CMPXCHG

        commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

        tglx notes:
          This function [futex_detect_cmpxchg] is only needed when an
          architecture has to runtime discover whether the CPU supports it or
          not.  ARM has unconditional support for this, so the obvious thing to
          do is the below.

        Fixes linkage failure from Clang randconfigs:
        kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
        and boot failures for CONFIG_THUMB2_KERNEL.

        Link: https://github.com/ClangBuiltLinux/linux/issues/325

        Comments from Nick Desaulniers:

         See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
         futex_atomic_cmpxchg_inatomic() test")

        Reported-by: Arnd Bergmann <arnd@arndb.de>
        Reported-by: Nathan Chancellor <nathan@kernel.org>
        Suggested-by: Thomas Gleixner <tglx@linutronix.de>
        Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
        Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
        Tested-by: Nathan Chancellor <nathan@kernel.org>
        Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
        Cc: stable@vger.kernel.org # v3.14+
        Reviewed-by: Arnd Bergmann <arnd@arndb.de>
        Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 3de1ed125fc4c35bf7abb08260646100a6dcb04e
    Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Date:   Mon Oct 18 15:44:12 2021 -0400

        tracing: Have all levels of checks prevent recursion

        commit ed65df63a39a3f6ed04f7258de8b6789e5021c18 upstream.

        While writing an email explaining the "bit = 0" logic for a discussion on
        making ftrace_test_recursion_trylock() disable preemption, I discovered a
        path that makes the "not do the logic if bit is zero" unsafe.

        The recursion logic is done in hot paths like the function tracer. Thus,
        any code executed causes noticeable overhead. Thus, tricks are done to try
        to limit the amount of code executed. This included the recursion testing
        logic.

        Having recursion testing is important, as there are many paths that can
        end up in an infinite recursion cycle when tracing every function in the
        kernel. Thus protection is needed to prevent that from happening.

        Because it is OK to recurse due to different running context levels (e.g.
        an interrupt preempts a trace, and then a trace occurs in the interrupt
        handler), a set of bits are used to know which context one is in (normal,
        softirq, irq and NMI). If a recursion occurs in the same level, it is
        prevented*.

        Then there are infrastructure levels of recursion as well. When more than
        one callback is attached to the same function to trace, it calls a loop
        function to iterate over all the callbacks. Both the callbacks and the
        loop function have recursion protection. The callbacks use the
        "ftrace_test_recursion_trylock()" which has a "function" set of context
        bits to test, and the loop function calls the internal
        trace_test_and_set_recursion() directly, with an "internal" set of bits.

        If an architecture does not implement all the features supported by ftrace
        then the callbacks are never called directly, and the loop function is
        called instead, which will implement the features of ftrace.

        Since both the loop function and the callbacks do recursion protection, it
        was seemed unnecessary to do it in both locations. Thus, a trick was made
        to have the internal set of recursion bits at a more significant bit
        location than the function bits. Then, if any of the higher bits were set,
        the logic of the function bits could be skipped, as any new recursion
        would first have to go through the loop function.

        This is true for architectures that do not support all the ftrace
        features, because all functions being traced must first go through the
        loop function before going to the callbacks. But this is not true for
        architectures that support all the ftrace features. That's because the
        loop function could be called due to two callbacks attached to the same
        function, but then a recursion function inside the callback could be
        called that does not share any other callback, and it will be called
        directly.

        i.e.

         traced_function_1: [ more than one callback tracing it ]
           call loop_func

         loop_func:
           trace_recursion set internal bit
           call callback

         callback:
           trace_recursion [ skipped because internal bit is set, return 0 ]
           call traced_function_2

         traced_function_2: [ only traced by above callback ]
           call callback

         callback:
           trace_recursion [ skipped because internal bit is set, return 0 ]
           call traced_function_2

         [ wash, rinse, repeat, BOOM! out of shampoo! ]

        Thus, the "bit == 0 skip" trick is not safe, unless the loop function is
        call for all functions.

        Since we want to encourage architectures to implement all ftrace features,
        having them slow down due to this extra logic may encourage the
        maintainers to update to the latest ftrace features. And because this
        logic is only safe for them, remove it completely.

         [*] There is on layer of recursion that is allowed, and that is to allow
             for the transition between interrupt context (normal -> softirq ->
             irq -> NMI), because a trace may occur before the context update is
             visible to the trace recursion logic.

        Link: https://lore.kernel.org/all/609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com/
        Link: https://lkml.kernel.org/r/20211018154412.09fcad3c@gandalf.local.home

        Cc: Linus Torvalds <torvalds@linux-foundation.org>
        Cc: Petr Mladek <pmladek@suse.com>
        Cc: Ingo Molnar <mingo@redhat.com>
        Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
        Cc: Helge Deller <deller@gmx.de>
        Cc: Michael Ellerman <mpe@ellerman.id.au>
        Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
        Cc: Paul Mackerras <paulus@samba.org>
        Cc: Paul Walmsley <paul.walmsley@sifive.com>
        Cc: Palmer Dabbelt <palmer@dabbelt.com>
        Cc: Albert Ou <aou@eecs.berkeley.edu>
        Cc: Thomas Gleixner <tglx@linutronix.de>
        Cc: Borislav Petkov <bp@alien8.de>
        Cc: "H. Peter Anvin" <hpa@zytor.com>
        Cc: Josh Poimboeuf <jpoimboe@redhat.com>
        Cc: Jiri Kosina <jikos@kernel.org>
        Cc: Miroslav Benes <mbenes@suse.cz>
        Cc: Joe Lawrence <joe.lawrence@redhat.com>
        Cc: Colin Ian King <colin.king@canonical.com>
        Cc: Masami Hiramatsu <mhiramat@kernel.org>
        Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
        Cc: Nicholas Piggin <npiggin@gmail.com>
        Cc: Jisheng Zhang <jszhang@kernel.org>
        Cc: =?utf-8?b?546L6LSH?= <yun.wang@linux.alibaba.com>
        Cc: Guo Ren <guoren@kernel.org>
        Cc: stable@vger.kernel.org
        Fixes: edc15cafcbfa3 ("tracing: Avoid unnecessary multiple recursion checks")
        Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit a9831afa2dc8a18205403907c41aa4e0950ac611
    Author: Yanfei Xu <yanfei.xu@windriver.com>
    Date:   Sun Sep 26 12:53:13 2021 +0800

        net: mdiobus: Fix memory leak in __mdiobus_register

        commit ab609f25d19858513919369ff3d9a63c02cd9e2e upstream.

        Once device_register() failed, we should call put_device() to
        decrement reference count for cleanup. Or it will cause memory
        leak.

        BUG: memory leak
        unreferenced object 0xffff888114032e00 (size 256):
          comm "kworker/1:3", pid 2960, jiffies 4294943572 (age 15.920s)
          hex dump (first 32 bytes):
            00 00 00 00 00 00 00 00 08 2e 03 14 81 88 ff ff  ................
            08 2e 03 14 81 88 ff ff 90 76 65 82 ff ff ff ff  .........ve.....
          backtrace:
            [<ffffffff8265cfab>] kmalloc include/linux/slab.h:591 [inline]
            [<ffffffff8265cfab>] kzalloc include/linux/slab.h:721 [inline]
            [<ffffffff8265cfab>] device_private_init drivers/base/core.c:3203 [inline]
            [<ffffffff8265cfab>] device_add+0x89b/0xdf0 drivers/base/core.c:3253
            [<ffffffff828dd643>] __mdiobus_register+0xc3/0x450 drivers/net/phy/mdio_bus.c:537
            [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
            [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
            [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
            [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
            [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
            [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
            [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
            [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
            [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
            [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
            [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
            [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
            [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969
            [<ffffffff82660916>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:487
            [<ffffffff8265cd0b>] device_add+0x5fb/0xdf0 drivers/base/core.c:3359
            [<ffffffff82c343b9>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2170
            [<ffffffff82c4473c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238

        BUG: memory leak
        unreferenced object 0xffff888116f06900 (size 32):
          comm "kworker/0:2", pid 2670, jiffies 4294944448 (age 7.160s)
          hex dump (first 32 bytes):
            75 73 62 2d 30 30 31 3a 30 30 33 00 00 00 00 00  usb-001:003.....
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          backtrace:
            [<ffffffff81484516>] kstrdup+0x36/0x70 mm/util.c:60
            [<ffffffff814845a3>] kstrdup_const+0x53/0x80 mm/util.c:83
            [<ffffffff82296ba2>] kvasprintf_const+0xc2/0x110 lib/kasprintf.c:48
            [<ffffffff82358d4b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
            [<ffffffff826575f3>] dev_set_name+0x63/0x90 drivers/base/core.c:3147
            [<ffffffff828dd63b>] __mdiobus_register+0xbb/0x450 drivers/net/phy/mdio_bus.c:535
            [<ffffffff828cb835>] __devm_mdiobus_register+0x75/0xf0 drivers/net/phy/mdio_devres.c:87
            [<ffffffff82b92a00>] ax88772_init_mdio drivers/net/usb/asix_devices.c:676 [inline]
            [<ffffffff82b92a00>] ax88772_bind+0x330/0x480 drivers/net/usb/asix_devices.c:786
            [<ffffffff82baa33f>] usbnet_probe+0x3ff/0xdf0 drivers/net/usb/usbnet.c:1745
            [<ffffffff82c36e17>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
            [<ffffffff82661d17>] call_driver_probe drivers/base/dd.c:517 [inline]
            [<ffffffff82661d17>] really_probe.part.0+0xe7/0x380 drivers/base/dd.c:596
            [<ffffffff826620bc>] really_probe drivers/base/dd.c:558 [inline]
            [<ffffffff826620bc>] __driver_probe_device+0x10c/0x1e0 drivers/base/dd.c:751
            [<ffffffff826621ba>] driver_probe_device+0x2a/0x120 drivers/base/dd.c:781
            [<ffffffff82662a26>] __device_attach_driver+0xf6/0x140 drivers/base/dd.c:898
            [<ffffffff8265eca7>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:427
            [<ffffffff826625a2>] __device_attach+0x122/0x260 drivers/base/dd.c:969

        Reported-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
        Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
        Reviewed-by: Andrew Lunn <andrew@lunn.ch>
        Signed-off-by: David S. Miller <davem@davemloft.net>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 629e870ca473bbf3ec2429d441efb0406869783d
    Author: Dexuan Cui <decui@microsoft.com>
    Date:   Thu Oct 7 21:35:46 2021 -0700

        scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma()

        commit 50b6cb3516365cb69753b006be2b61c966b70588 upstream.

        After commit ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at
        can_queue"), a 416-CPU VM running on Hyper-V hangs during boot because the
        hv_storvsc driver sets scsi_driver.can_queue to an integer value that
        exceeds SHRT_MAX, and hence scsi_add_host_with_dma() sets
        shost->cmd_per_lun to a negative "short" value.

        Use min_t(int, ...) to work around the issue.

        Link: https://lore.kernel.org/r/20211008043546.6006-1-decui@microsoft.com
        Fixes: ea2f0f77538c ("scsi: core: Cap scsi_host cmd_per_lun at can_queue")
        Cc: stable@vger.kernel.org
        Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
        Reviewed-by: Ming Lei <ming.lei@redhat.com>
        Reviewed-by: John Garry <john.garry@huawei.com>
        Signed-off-by: Dexuan Cui <decui@microsoft.com>
        Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
        Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    commit 1360f9cde7eaaea4e6b48ab4ec544c706dbc6a8a
    Author: Kai Vehmanen <kai.vehmanen@linux.intel.com>
    Date:   Tue Oct 12 17:29:35 2021 +0300

        ALSA: hda: avoid write to STATESTS if controller is in reset

        [ Upstream commit b37a15188eae9d4c49c5bb035e0c8d4058e4d9b3 ]

        The snd_hdac_bus_reset_link() contains logic to clear STATESTS register
        before performing controller reset. This code dates back to an old
        bugfix in commit e8a7f136f5ed ("[ALSA] hda-intel - Improve HD-audio
        codec probing robustness"). Originally the code was added to
        azx_reset().

        The code was moved around in commit a41d122449be ("ALSA: hda - Embed bus
        into controller object") and ended up to snd_hdac_bus_reset_link() and
        called primarily via snd_hdac_bus_init_chip().

        The logic to clear STATESTS is correct when snd_hdac_bus_init_chip() is
        called when controller is not in reset. In this case, STATESTS can be
        cleared. This can be useful e.g. when forcing a controller reset to retry
        codec probe. A normal non-power-on reset will not clear the bits.

        However, this old logic is problematic when controller is already in
        reset. The HDA specification states that controller must be taken out of
        reset before writing to registers other than GCTL.CRST (1.0a spec,
        3.3.7). The write to STATESTS in snd_hdac_bus_reset_link() will be lost
        if the controller is already in reset per the HDA specification mentioned.

        This has been harmless on older hardware. On newer generation of Intel
        PCIe based HDA controllers, if configured to report issues, this write
        will emit an unsupported request error. If ACPI Platform Error Interface
        (APEI) is enabled in kernel, this will end up to kernel log.

        Fix the code in snd_hdac_bus_reset_link() to only clear the STATESTS if
        the function is called when controller is not in reset. Otherwise
        clearing the bits is not possible and should be skipped.

        Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
        Link: https://lore.kernel.org/r/20211012142935.3731820-1-kai.vehmanen@linux.intel.com
        Signed-off-by: Takashi Iwai <tiwai@suse.de>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit f7db1bc1cdb809fdd65d50485fb67bd418eadbd5
    Author: Prashant Malani <pmalani@chromium.org>
    Date:   Tue Sep 28 03:19:34 2021 -0700

        platform/x86: intel_scu_ipc: Update timeout value in comment

        [ Upstream commit a0c5814b9933f25ecb6de169483c5b88cf632bca ]

        The comment decribing the IPC timeout hadn't been updated when the
        actual timeout was changed from 3 to 5 seconds in
        commit a7d53dbbc70a ("platform/x86: intel_scu_ipc: Increase virtual
        timeout from 3 to 5 seconds") .

        Since the value is anyway updated to 10s now, take this opportunity to
        update the value in the comment too.

        Signed-off-by: Prashant Malani <pmalani@chromium.org>
        Cc: Benson Leung <bleung@chromium.org>
        Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
        Link: https://lore.kernel.org/r/20210928101932.2543937-4-pmalani@chromium.org
        Signed-off-by: Hans de Goede <hdegoede@redhat.com>
        Signed-off-by: Sasha Levin <sashal@kernel.org>

    commit a5b34409d3fc52114c828be4adbc30744fa3258b
    Author: Zheyu Ma <zheyuma97@gmail.com>
    Date:   Sat Oct 9 11:33:49 2021 +0000

        isdn: mISDN: Fix sleeping function called from invalid context

        [ Upstream commit 6510e80a0b81b5d814e3aea6297ba42f5e76f73c ]

        The driver can call card->isac.release() function from an atomic
        context.

        Fix this by calling this function after releasing the lock.

        The following log reveals it:

        [   44.168226 ] BUG: sleeping function called from invalid context at kernel/workqueue.c:3018
        [   44.168941 ] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 5475, name: modprobe
        [   44.169574 ] INFO: lockdep is tu…
ratatouille100 pushed a commit to ratatouille100/kernel_samsung_universal9611 that referenced this issue Dec 18, 2023
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
roniwae pushed a commit to roniwae/reloaded that referenced this issue Jan 1, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Dheeraj3031A pushed a commit to Dheeraj3031A/kernel_oplus_RMX3461 that referenced this issue Jan 21, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
backslashxx pushed a commit to backslashxx/android_karnol_ximi_fog that referenced this issue Feb 14, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kevios12 pushed a commit to kevios12/android_kernel_samsung_universal7885 that referenced this issue Feb 16, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
RT1648 pushed a commit to RT1648/android_kernel_asus_sdm660 that referenced this issue Feb 17, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
RT1648 pushed a commit to RT1648/android_kernel_asus_sdm660 that referenced this issue Feb 17, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
FlorinelulX pushed a commit to FlorinelulX/android_kernel_huawei_hi6250-8 that referenced this issue Feb 20, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kevios12 pushed a commit to kevios12/android_kernel_samsung_universal7885 that referenced this issue Feb 24, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b623c8 ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Notganesh pushed a commit to Notganesh/kernel_oneplus_ivan-R that referenced this issue Mar 22, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Huawei-Dev pushed a commit to Huawei-Dev/android_kernel_huawei_hi3660 that referenced this issue Apr 13, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Huawei-Dev pushed a commit to Huawei-Dev/android_kernel_huawei_hi3660 that referenced this issue May 20, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Huawei-Dev pushed a commit to Huawei-Dev/android_kernel_huawei_hi3660 that referenced this issue May 21, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Huawei-Dev pushed a commit to Huawei-Dev/android_kernel_huawei_hi3660 that referenced this issue May 21, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Huawei-Dev pushed a commit to Huawei-Dev/android_kernel_huawei_hi3660 that referenced this issue May 21, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
nokidevz pushed a commit to nokidevz/android_kernel_xiaomi_mt6781 that referenced this issue Jun 25, 2024
commit 9d417cbe36eee7afdd85c2e871685f8dab7c2dba upstream.

tglx notes:
  This function [futex_detect_cmpxchg] is only needed when an
  architecture has to runtime discover whether the CPU supports it or
  not.  ARM has unconditional support for this, so the obvious thing to
  do is the below.

Fixes linkage failure from Clang randconfigs:
kernel/futex.o:(.text.fixup+0x5c): relocation truncated to fit: R_ARM_JUMP24 against `.init.text'
and boot failures for CONFIG_THUMB2_KERNEL.

Link: ClangBuiltLinux/linux#325

Comments from Nick Desaulniers:

 See-also: 03b8c7b ("futex: Allow architectures to skip
 futex_atomic_cmpxchg_inatomic() test")

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org # v3.14+
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] linux A bug that should be fixed in the mainline kernel. [CONFIG] allyesconfig Issue affects allyesconfig on certain architectures [FIXED][LINUX] 5.15 This bug was fixed in Linux 5.15
Projects
None yet
Development

No branches or pull requests

4 participants