Skip to content
  1. Apr 16, 2018
    • Linus Torvalds's avatar
      Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 68d54d3f
      Linus Torvalds authored
      Pull irq affinity fixes from Thomas Gleixner:
      
        - Fix error path handling in the affinity spreading code
      
        - Make affinity spreading smarter to avoid issues on systems which
          claim to have hotpluggable CPUs while in fact they can't hotplug
          anything.
      
          So instead of trying to spread the vectors (and thereby the
          associated device queues) to all possibe CPUs, spread them on all
          present CPUs first. If there are left over vectors after that first
          step they are spread among the possible, but not present CPUs which
          keeps the code backwards compatible for virtual decives and NVME
          which allocate a queue per possible CPU, but makes the spreading
          smarter for devices which have less queues than possible or present
          CPUs.
      
      * 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        genirq/affinity: Spread irq vectors among present CPUs as far as possible
        genirq/affinity: Allow irq spreading from a given starting point
        genirq/affinity: Move actual irq vector spreading into a helper function
        genirq/affinity: Rename *node_to_possible_cpumask as *node_to_cpumask
        genirq/affinity: Don't return with empty affinity masks on error
      68d54d3f
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://github.com/openrisc/linux · 9dceab89
      Linus Torvalds authored
      Pull OpenRISC fixlet from Stafford Horne:
       "Just one small thing here, it came in a while back but I didnt have
        anything in my 4.16 queue, still its the only thing for 4.17 so
        sending it alone.
      
        Small cleanup: remove unused __ARCH_HAVE_MMU define"
      
      * tag 'for-linus' of git://github.com/openrisc/linux:
        openrisc: remove unused __ARCH_HAVE_MMU define
      9dceab89
    • Linus Torvalds's avatar
      Merge tag 'powerpc-4.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · b1cb4f93
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
      
       - Fix crashes when loading modules built with a different
         CONFIG_RELOCATABLE value by adding CONFIG_RELOCATABLE to vermagic.
      
       - Fix busy loops in the OPAL NVRAM driver if we get certain error
         conditions from firmware.
      
       - Remove tlbie trace points from KVM code that's called in real mode,
         because it causes crashes.
      
       - Fix checkstops caused by invalid tlbiel on Power9 Radix.
      
       - Ensure the set of CPU features we "know" are always enabled is
         actually the minimal set when we build with support for firmware
         supplied CPU features.
      
      Thanks to: Aneesh Kumar K.V, Anshuman Khandual, Nicholas Piggin.
      
      * tag 'powerpc-4.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/64s: Fix CPU_FTRS_ALWAYS vs DT CPU features
        powerpc/mm/radix: Fix checkstops caused by invalid tlbiel
        KVM: PPC: Book3S HV: trace_tlbie must not be called in realmode
        powerpc/8xx: Fix build with hugetlbfs enabled
        powerpc/powernv: Fix OPAL NVRAM driver OPAL_BUSY loops
        powerpc/powernv: define a standard delay for OPAL_BUSY type retry loops
        powerpc/fscr: Enable interrupts earlier before calling get_user()
        powerpc/64s: Fix section mismatch warnings from setup_rfi_flush()
        powerpc/modules: Fix crashes by adding CONFIG_RELOCATABLE to vermagic
      b1cb4f93
  2. Apr 14, 2018
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · 18b7fd1c
      Linus Torvalds authored
      Merge yet more updates from Andrew Morton:
      
       - various hotfixes
      
       - kexec_file updates and feature work
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (27 commits)
        kernel/kexec_file.c: move purgatories sha256 to common code
        kernel/kexec_file.c: allow archs to set purgatory load address
        kernel/kexec_file.c: remove mis-use of sh_offset field during purgatory load
        kernel/kexec_file.c: remove unneeded variables in kexec_purgatory_setup_sechdrs
        kernel/kexec_file.c: remove unneeded for-loop in kexec_purgatory_setup_sechdrs
        kernel/kexec_file.c: split up __kexec_load_puragory
        kernel/kexec_file.c: use read-only sections in arch_kexec_apply_relocations*
        kernel/kexec_file.c: search symbols in read-only kexec_purgatory
        kernel/kexec_file.c: make purgatory_info->ehdr const
        kernel/kexec_file.c: remove checks in kexec_purgatory_load
        include/linux/kexec.h: silence compile warnings
        kexec_file, x86: move re-factored code to generic side
        x86: kexec_file: clean up prepare_elf64_headers()
        x86: kexec_file: lift CRASH_MAX_RANGES limit on crash_mem buffer
        x86: kexec_file: remove X86_64 dependency from prepare_elf64_headers()
        x86: kexec_file: purge system-ram walking from prepare_elf64_headers()
        kexec_file,x86,powerpc: factor out kexec_file_ops functions
        kexec_file: make use of purgatory optional
        proc: revalidate misc dentries
        mm, slab: reschedule cache_reap() on the same CPU
        ...
      18b7fd1c
    • Philipp Rudo's avatar
      kernel/kexec_file.c: move purgatories sha256 to common code · df6f2801
      Philipp Rudo authored
      The code to verify the new kernels sha digest is applicable for all
      architectures.  Move it to common code.
      
      One problem is the string.c implementation on x86.  Currently sha256
      includes x86/boot/string.h which defines memcpy and memset to be gcc
      builtins.  By moving the sha256 implementation to common code and
      changing the include to linux/string.h both functions are no longer
      defined.  Thus definitions have to be provided in x86/purgatory/string.c
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-12-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      df6f2801
    • Philipp Rudo's avatar
      kernel/kexec_file.c: allow archs to set purgatory load address · 3be3f61d
      Philipp Rudo authored
      For s390 new kernels are loaded to fixed addresses in memory before they
      are booted.  With the current code this is a problem as it assumes the
      kernel will be loaded to an 'arbitrary' address.  In particular,
      kexec_locate_mem_hole searches for a large enough memory region and sets
      the load address (kexec_bufer->mem) to it.
      
      Luckily there is a simple workaround for this problem.  By returning 1
      in arch_kexec_walk_mem, kexec_locate_mem_hole is turned off.  This
      allows the architecture to set kbuf->mem by hand.  While the trick works
      fine for the kernel it does not for the purgatory as here the
      architectures don't have access to its kexec_buffer.
      
      Give architectures access to the purgatories kexec_buffer by changing
      kexec_load_purgatory to take a pointer to it.  With this change
      architectures have access to the buffer and can edit it as they need.
      
      A nice side effect of this change is that we can get rid of the
      purgatory_info->purgatory_load_address field.  As now the information
      stored there can directly be accessed from kbuf->mem.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-11-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Reviewed-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3be3f61d
    • Philipp Rudo's avatar
      kernel/kexec_file.c: remove mis-use of sh_offset field during purgatory load · 8da0b724
      Philipp Rudo authored
      The current code uses the sh_offset field in purgatory_info->sechdrs to
      store a pointer to the current load address of the section.  Depending
      whether the section will be loaded or not this is either a pointer into
      purgatory_info->purgatory_buf or kexec_purgatory.  This is not only a
      violation of the ELF standard but also makes the code very hard to
      understand as you cannot tell if the memory you are using is read-only
      or not.
      
      Remove this misuse and store the offset of the section in
      pugaroty_info->purgatory_buf in sh_offset.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-10-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8da0b724
    • Philipp Rudo's avatar
      kernel/kexec_file.c: remove unneeded variables in kexec_purgatory_setup_sechdrs · 620f697c
      Philipp Rudo authored
      The main loop currently uses quite a lot of variables to update the
      section headers.  Some of them are unnecessary.  So clean them up a
      little.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-9-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      620f697c
    • Philipp Rudo's avatar
      kernel/kexec_file.c: remove unneeded for-loop in kexec_purgatory_setup_sechdrs · f1b1cca3
      Philipp Rudo authored
      To update the entry point there is an extra loop over all section
      headers although this can be done in the main loop.  So move it there
      and eliminate the extra loop and variable to store the 'entry section
      index'.
      
      Also, in the main loop, move the usual case, i.e.  non-bss section, out
      of the extra if-block.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-8-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Reviewed-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f1b1cca3
    • Philipp Rudo's avatar
      kernel/kexec_file.c: split up __kexec_load_puragory · 93045705
      Philipp Rudo authored
      When inspecting __kexec_load_purgatory you find that it has two tasks
      
      	1) setting up the kexec_buffer for the new kernel and,
      	2) setting up pi->sechdrs for the final load address.
      
      The two tasks are independent of each other.  To improve readability
      split up __kexec_load_purgatory into two functions, one for each task,
      and call them directly from kexec_load_purgatory.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-7-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      93045705
    • Philipp Rudo's avatar
      kernel/kexec_file.c: use read-only sections in arch_kexec_apply_relocations* · 8aec395b
      Philipp Rudo authored
      When the relocations are applied to the purgatory only the section the
      relocations are applied to is writable.  The other sections, i.e.  the
      symtab and .rel/.rela, are in read-only kexec_purgatory.  Highlight this
      by marking the corresponding variables as 'const'.
      
      While at it also change the signatures of arch_kexec_apply_relocations* to
      take section pointers instead of just the index of the relocation section.
      This removes the second lookup and sanity check of the sections in arch
      code.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-6-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8aec395b
    • Philipp Rudo's avatar
      kernel/kexec_file.c: search symbols in read-only kexec_purgatory · 961d921a
      Philipp Rudo authored
      The stripped purgatory does not contain a symtab.  So when looking for
      symbols this is done in read-only kexec_purgatory.  Highlight this by
      marking the corresponding variables as 'const'.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-5-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      961d921a
    • Philipp Rudo's avatar
      kernel/kexec_file.c: make purgatory_info->ehdr const · 65c225d3
      Philipp Rudo authored
      The kexec_purgatory buffer is read-only.  Thus all pointers into
      kexec_purgatory are read-only, too.  Point this out by explicitly
      marking purgatory_info->ehdr as 'const' and update the comments in
      purgatory_info.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-4-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      65c225d3
    • Philipp Rudo's avatar
      kernel/kexec_file.c: remove checks in kexec_purgatory_load · d2b8178c
      Philipp Rudo authored
      Before the purgatory is loaded several checks are done whether the ELF
      file in kexec_purgatory is valid or not.  These checks are incomplete.
      For example they don't check for the total size of the sections defined
      in the section header table or if the entry point actually points into
      the purgatory.
      
      On the other hand the purgatory, although an ELF file on its own, is
      part of the kernel.  Thus not trusting the purgatory means not trusting
      the kernel build itself.
      
      So remove all validity checks on the purgatory and just trust the kernel
      build.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-3-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d2b8178c
    • Philipp Rudo's avatar
      include/linux/kexec.h: silence compile warnings · ee6ebeda
      Philipp Rudo authored
      Patch series "kexec_file: Clean up purgatory load", v2.
      
      Following the discussion with Dave and AKASHI, here are the common code
      patches extracted from my recent patch set (Add kexec_file_load support
      to s390) [1].  The patches were extracted to allow upstream integration
      together with AKASHI's common code patches before the arch code gets
      adjusted to the new base.
      
      The reason for this series is to prepare common code for adding
      kexec_file_load to s390 as well as cleaning up the mis-use of the
      sh_offset field during purgatory load.  In detail this series contains:
      
      Patch #1&2: Minor cleanups/fixes.
      
      Patch #3-9: Clean up the purgatory load/relocation code.  Especially
      remove the mis-use of the purgatory_info->sechdrs->sh_offset field,
      currently holding a pointer into either kexec_purgatory (ro) or
      purgatory_buf (rw) depending on the section.  With these patches the
      section address will be calculated verbosely and sh_offset will contain
      the offset of the section in the stripped purgatory binary
      (purgatory_buf).
      
      Patch #10: Allows architectures to set the purgatory load address.  This
      patch is important for s390 as the kernel and purgatory have to be
      loaded to fixed addresses.  In current code this is impossible as the
      purgatory load is opaque to the architecture.
      
      Patch #11: Moves x86 purgatories sha implementation to common lib/
      directory to allow reuse in other architectures.
      
      This patch (of 11)
      
      When building the kernel with CONFIG_KEXEC_FILE enabled gcc prints a
      compile warning multiple times.
      
        In file included from <path>/linux/init/initramfs.c:526:0:
        <path>/include/linux/kexec.h:120:9: warning: `struct kimage' declared inside parameter list [enabled by default]
                 unsigned long cmdline_len);
                 ^
      
      This is because the typedefs for kexec_file_load uses struct kimage
      before it is declared.  Fix this by simply forward declaring struct
      kimage.
      
      Link: http://lkml.kernel.org/r/20180321112751.22196-2-prudo@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarPhilipp Rudo <prudo@linux.vnet.ibm.com>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ee6ebeda
    • AKASHI Takahiro's avatar
      kexec_file, x86: move re-factored code to generic side · babac4a8
      AKASHI Takahiro authored
      In the previous patches, commonly-used routines, exclude_mem_range() and
      prepare_elf64_headers(), were carved out.  Now place them in kexec
      common code.  A prefix "crash_" is given to each of their names to avoid
      possible name collisions.
      
      Link: http://lkml.kernel.org/r/20180306102303.9063-8-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      babac4a8
    • AKASHI Takahiro's avatar
      x86: kexec_file: clean up prepare_elf64_headers() · eb7dae94
      AKASHI Takahiro authored
      Removing bufp variable in prepare_elf64_headers() makes the code simpler
      and more understandable.
      
      Link: http://lkml.kernel.org/r/20180306102303.9063-7-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      eb7dae94
    • AKASHI Takahiro's avatar
      x86: kexec_file: lift CRASH_MAX_RANGES limit on crash_mem buffer · 8d5f894a
      AKASHI Takahiro authored
      While CRASH_MAX_RANGES (== 16) seems to be good enough, fixed-number
      array is not a good idea in general.
      
      In this patch, size of crash_mem buffer is calculated as before and the
      buffer is now dynamically allocated.  This change also allows removing
      crash_elf_data structure.
      
      Link: http://lkml.kernel.org/r/20180306102303.9063-6-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8d5f894a
    • AKASHI Takahiro's avatar
      x86: kexec_file: remove X86_64 dependency from prepare_elf64_headers() · c72c7e67
      AKASHI Takahiro authored
      The code guarded by CONFIG_X86_64 is necessary on some architectures
      which have a dedicated kernel mapping outside of linear memory mapping.
      (arm64 is among those.)
      
      In this patch, an additional argument, kernel_map, is added to enable/
      disable the code removing #ifdef.
      
      Link: http://lkml.kernel.org/r/20180306102303.9063-5-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c72c7e67
    • AKASHI Takahiro's avatar
      x86: kexec_file: purge system-ram walking from prepare_elf64_headers() · cbe66016
      AKASHI Takahiro authored
      While prepare_elf64_headers() in x86 looks pretty generic for other
      architectures' use, it contains some code which tries to list crash
      memory regions by walking through system resources, which is not always
      architecture agnostic.  To make this function more generic, the related
      code should be purged.
      
      In this patch, prepare_elf64_headers() simply scans crash_mem buffer
      passed and add all the listed regions to elf header as a PT_LOAD
      segment.  So walk_system_ram_res(prepare_elf64_headers_callback) have
      been moved forward before prepare_elf64_headers() where the callback,
      prepare_elf64_headers_callback(), is now responsible for filling up
      crash_mem buffer.
      
      Meanwhile exclude_elf_header_ranges() used to be called every time in
      this callback it is rather redundant and now called only once in
      prepare_elf_headers() as well.
      
      Link: http://lkml.kernel.org/r/20180306102303.9063-4-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cbe66016
    • AKASHI Takahiro's avatar
      kexec_file,x86,powerpc: factor out kexec_file_ops functions · 9ec4ecef
      AKASHI Takahiro authored
      As arch_kexec_kernel_image_{probe,load}(),
      arch_kimage_file_post_load_cleanup() and arch_kexec_kernel_verify_sig()
      are almost duplicated among architectures, they can be commonalized with
      an architecture-defined kexec_file_ops array.  So let's factor them out.
      
      Link: http://lkml.kernel.org/r/20180306102303.9063-3-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9ec4ecef
    • AKASHI Takahiro's avatar
      kexec_file: make use of purgatory optional · b799a09f
      AKASHI Takahiro authored
      Patch series "kexec_file, x86, powerpc: refactoring for other
      architecutres", v2.
      
      This is a preparatory patchset for adding kexec_file support on arm64.
      
      It was originally included in a arm64 patch set[1], but Philipp is also
      working on their kexec_file support on s390[2] and some changes are now
      conflicting.
      
      So these common parts were extracted and put into a separate patch set
      for better integration.  What's more, my original patch#4 was split into
      a few small chunks for easier review after Dave's comment.
      
      As such, the resulting code is basically identical with my original, and
      the only *visible* differences are:
      
       - renaming of _kexec_kernel_image_probe() and  _kimage_file_post_load_cleanup()
      
       - change one of types of arguments at prepare_elf64_headers()
      
      Those, unfortunately, require a couple of trivial changes on the rest
      (#1, #6 to #13) of my arm64 kexec_file patch set[1].
      
      Patch #1 allows making a use of purgatory optional, particularly useful
      for arm64.
      
      Patch #2 commonalizes arch_kexec_kernel_{image_probe, image_load,
      verify_sig}() and arch_kimage_file_post_load_cleanup() across
      architectures.
      
      Patches #3-#7 are also intended to generalize parse_elf64_headers(),
      along with exclude_mem_range(), to be made best re-use of.
      
      [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-February/561182.html
      [2] http://lkml.iu.edu//hypermail/linux/kernel/1802.1/02596.html
      
      This patch (of 7):
      
      On arm64, crash dump kernel's usable memory is protected by *unmapping*
      it from kernel virtual space unlike other architectures where the region
      is just made read-only.  It is highly unlikely that the region is
      accidentally corrupted and this observation rationalizes that digest
      check code can also be dropped from purgatory.  The resulting code is so
      simple as it doesn't require a bit ugly re-linking/relocation stuff,
      i.e.  arch_kexec_apply_relocations_add().
      
      Please see:
      
         http://lists.infradead.org/pipermail/linux-arm-kernel/2017-December/545428.html
      
      All that the purgatory does is to shuffle arguments and jump into a new
      kernel, while we still need to have some space for a hash value
      (purgatory_sha256_digest) which is never checked against.
      
      As such, it doesn't make sense to have trampline code between old kernel
      and new kernel on arm64.
      
      This patch introduces a new configuration, ARCH_HAS_KEXEC_PURGATORY, and
      allows related code to be compiled in only if necessary.
      
      [takahiro.akashi@linaro.org: fix trivial screwup]
        Link: http://lkml.kernel.org/r/20180309093346.GF25863@linaro.org
      Link: http://lkml.kernel.org/r/20180306102303.9063-2-takahiro.akashi@linaro.org
      
      
      Signed-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
      Acked-by: default avatarDave Young <dyoung@redhat.com>
      Tested-by: default avatarDave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b799a09f
    • Alexey Dobriyan's avatar
      proc: revalidate misc dentries · 1da4d377
      Alexey Dobriyan authored
      If module removes proc directory while another process pins it by
      chdir'ing to it, then subsequent recreation of proc entry and all
      entries down the tree will not be visible to any process until pinning
      process unchdir from directory and unpins everything.
      
      Steps to reproduce:
      
      	proc_mkdir("aaa", NULL);
      	proc_create("aaa/bbb", ...);
      
      		chdir("/proc/aaa");
      
      	remove_proc_entry("aaa/bbb", NULL);
      	remove_proc_entry("aaa", NULL);
      
      	proc_mkdir("aaa", NULL);
      	# inaccessible because "aaa" dentry still points
      	# to the original "aaa".
      	proc_create("aaa/bbb", ...);
      
      Fix is to implement ->d_revalidate and ->d_delete.
      
      Link: http://lkml.kernel.org/r/20180312201938.GA4871@avx2
      
      
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1da4d377
    • Vlastimil Babka's avatar
      mm, slab: reschedule cache_reap() on the same CPU · a9f2a846
      Vlastimil Babka authored
      cache_reap() is initially scheduled in start_cpu_timer() via
      schedule_delayed_work_on(). But then the next iterations are scheduled
      via schedule_delayed_work(), i.e. using WORK_CPU_UNBOUND.
      
      Thus since commit ef557180 ("workqueue: schedule WORK_CPU_UNBOUND
      work on wq_unbound_cpumask CPUs") there is no guarantee the future
      iterations will run on the originally intended cpu, although it's still
      preferred.  I was able to demonstrate this with
      /sys/module/workqueue/parameters/debug_force_rr_cpu.  IIUC, it may also
      happen due to migrating timers in nohz context.  As a result, some cpu's
      would be calling cache_reap() more frequently and others never.
      
      This patch uses schedule_delayed_work_on() with the current cpu when
      scheduling the next iteration.
      
      Link: http://lkml.kernel.org/r/20180411070007.32225-1-vbabka@suse.cz
      Fixes: ef557180
      
       ("workqueue: schedule WORK_CPU_UNBOUND work on wq_unbound_cpumask CPUs")
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      A...
      a9f2a846
    • Petr Tesarik's avatar
      kexec: export PG_swapbacked to VMCOREINFO · 1cbf29da
      Petr Tesarik authored
      Since commit 6326fec1 ("mm: Use owner_priv bit for PageSwapCache,
      valid when PageSwapBacked"), PG_swapcache is an alias for
      PG_owner_priv_1, which may be also used for other purposes.
      
      To know whether the bit indeed has the PG_swapcache meaning, it is
      necessary to check PG_swapbacked, hence this bit must be exported.
      
      Link: http://lkml.kernel.org/r/20180410161345.142e142d@ezekiel.suse.cz
      
      
      Signed-off-by: default avatarPetr Tesarik <ptesarik@suse.com>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Xunlei Pang <xlpang@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: "Marc-Andr Lureau" <marcandre.lureau@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1cbf29da
    • Eric Biggers's avatar
      ipc/shm: fix use-after-free of shm file via remap_file_pages() · 3f05317d
      Eric Biggers authored
      syzbot reported a use-after-free of shm_file_data(file)->file->f_op in
      shm_get_unmapped_area(), called via sys_remap_file_pages().
      
      Unfortunately it couldn't generate a reproducer, but I found a bug which
      I think caused it.  When remap_file_pages() is passed a full System V
      shared memory segment, the memory is first unmapped, then a new map is
      created using the ->vm_file.  Between these steps, the shm ID can be
      removed and reused for a new shm segment.  But, shm_mmap() only checks
      whether the ID is currently valid before calling the underlying file's
      ->mmap(); it doesn't check whether it was reused.  Thus it can use the
      wrong underlying file, one that was already freed.
      
      Fix this by making the "outer" shm file (the one that gets put in
      ->vm_file) hold a reference to the real shm file, and by making
      __shm_open() require that the file associated with the shm ID matches
      the one associated with the "outer" file.
      
      Taking the reference to the real shm file is needed to fully solve the
      problem, since otherwise sfd->file could point to a freed file, which
      then could be reallocated for the reused shm ID, causing the wrong shm
      segment to be mapped (and without the required permission checks).
      
      Commit 1ac0b6de ("ipc/shm: handle removed segments gracefully in
      shm_mmap()") almost fixed this bug, but it didn't go far enough because
      it didn't consider the case where the shm ID is reused.
      
      The following program usually reproduces this bug:
      
      	#include <stdlib.h>
      	#include <sys/shm.h>
      	#include <sys/syscall.h>
      	#include <unistd.h>
      
      	int main()
      	{
      		int is_parent = (fork() != 0);
      		srand(getpid());
      		for (;;) {
      			int id = shmget(0xF00F, 4096, IPC_CREAT|0700);
      			if (is_parent) {
      				void *addr = shmat(id, NULL, 0);
      				usleep(rand() % 50);
      				while (!syscall(__NR_remap_file_pages, addr, 4096, 0, 0, 0));
      			} else {
      				usleep(rand() % 50);
      				shmctl(id, IPC_RMID, NULL);
      			}
      		}
      	}
      
      It causes the following NULL pointer dereference due to a 'struct file'
      being used while it's being freed.  (I couldn't actually get a KASAN
      use-after-free splat like in the syzbot report.  But I think it's
      possible with this bug; it would just take a more extraordinary race...)
      
      	BUG: unable to handle kernel NULL pointer dereference at 0000000000000058
      	PGD 0 P4D 0
      	Oops: 0000 [#1] SMP NOPTI
      	CPU: 9 PID: 258 Comm: syz_ipc Not tainted 4.16.0-05140-gf8cf2f16a7c95 #189
      	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
      	RIP: 0010:d_inode include/linux/dcache.h:519 [inline]
      	RIP: 0010:touch_atime+0x25/0xd0 fs/inode.c:1724
      	[...]
      	Call Trace:
      	 file_accessed include/linux/fs.h:2063 [inline]
      	 shmem_mmap+0x25/0x40 mm/shmem.c:2149
      	 call_mmap include/linux/fs.h:1789 [inline]
      	 shm_mmap+0x34/0x80 ipc/shm.c:465
      	 call_mmap include/linux/fs.h:1789 [inline]
      	 mmap_region+0x309/0x5b0 mm/mmap.c:1712
      	 do_mmap+0x294/0x4a0 mm/mmap.c:1483
      	 do_mmap_pgoff include/linux/mm.h:2235 [inline]
      	 SYSC_remap_file_pages mm/mmap.c:2853 [inline]
      	 SyS_remap_file_pages+0x232/0x310 mm/mmap.c:2769
      	 do_syscall_64+0x64/0x1a0 arch/x86/entry/common.c:287
      	 entry_SYSCALL_64_after_hwframe+0x42/0xb7
      
      [ebiggers@google.com: add comment]
        Link: http://lkml.kernel.org/r/20180410192850.235835-1-ebiggers3@gmail.com
      Link: http://lkml.kernel.org/r/20180409043039.28915-1-ebiggers3@gmail.com
      
      
      Reported-by: default avatar <syzbot+d11f321e7f1923157eac80aa990b446596f46439@syzkaller.appspotmail.com>
      Fixes: c8d78c18
      
       ("mm: replace remap_file_pages() syscall with emulation")
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Cc: Manfred Spraul <manfred@colorfullife.com>
      Cc: "Eric W . Biederman" <ebiederm@xmission.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3f05317d
    • Arnd Bergmann's avatar
      mm/filemap.c: provide dummy filemap_page_mkwrite() for NOMMU · 45397228
      Arnd Bergmann authored
      Building orangefs on MMU-less machines now results in a link error
      because of the newly introduced use of the filemap_page_mkwrite()
      function:
      
        ERROR: "filemap_page_mkwrite" [fs/orangefs/orangefs.ko] undefined!
      
      This adds a dummy version for it, similar to the existing
      generic_file_mmap and generic_file_readonly_mmap stubs in the same file,
      to avoid the link error without adding #ifdefs in each file system that
      uses these.
      
      Link: http://lkml.kernel.org/r/20180409105555.2439976-1-arnd@arndb.de
      Fixes: a5135eea
      
       ("orangefs: implement vm_ops->fault")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Martin Brandenburg <martin@omnibond.com>
      Cc: Mike Marshall <hubcap@omnibond.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      45397228
    • Michael S. Tsirkin's avatar
      mm/gup.c: document return value · d0811078
      Michael S. Tsirkin authored
      __get_user_pages_fast handles errors differently from
      get_user_pages_fast: the former always returns the number of pages
      pinned, the later might return a negative error code.
      
      Link: http://lkml.kernel.org/r/1522962072-182137-6-git-send-email-mst@redhat.com
      
      
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Huang Ying <ying.huang@intel.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thorsten Leemhuis <regressions@leemhuis.info>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d0811078
    • Michael S. Tsirkin's avatar
      get_user_pages_fast(): return -EFAULT on access_ok failure · c61611f7
      Michael S. Tsirkin authored
      get_user_pages_fast is supposed to be a faster drop-in equivalent of
      get_user_pages.  As such, callers expect it to return a negative return
      code when passed an invalid address, and never expect it to return 0
      when passed a positive number of pages, since its documentation says:
      
       * Returns number of pages pinned. This may be fewer than the number
       * requested. If nr_pages is 0 or negative, returns 0. If no pages
       * were pinned, returns -errno.
      
      When get_user_pages_fast fall back on get_user_pages this is exactly
      what happens.  Unfortunately the implementation is inconsistent: it
      returns 0 if passed a kernel address, confusing callers: for example,
      the following is pretty common but does not appear to do the right thing
      with a kernel address:
      
              ret = get_user_pages_fast(addr, 1, writeable, &page);
              if (ret < 0)
                      return ret;
      
      Change get_user_pages_fast to return -EFAULT when supplied a kernel
      address to make it match expectations.
      
      All callers have been audited for consistency with the documented
      semantics.
      
      Link: http://lkml.kernel.org/r/1522962072-182137-4-git-send-email-mst@redhat.com
      Fixes: 5b65c467
      
       ("mm, x86/mm: Fix performance regression in get_user_pages_fast()")
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reported-by: default avatar <syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Huang Ying <ying.huang@intel.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thorsten Leemhuis <regressions@leemhuis.info>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c61611f7
    • Michael S. Tsirkin's avatar
      mm/gup_benchmark: handle gup failures · 09e35a4a
      Michael S. Tsirkin authored
      Patch series "mm/get_user_pages_fast fixes, cleanups", v2.
      
      Turns out get_user_pages_fast and __get_user_pages_fast return different
      values on error when given a single page: __get_user_pages_fast returns
      0.  get_user_pages_fast returns either 0 or an error.
      
      Callers of get_user_pages_fast expect an error so fix it up to return an
      error consistently.
      
      Stress the difference between get_user_pages_fast and
      __get_user_pages_fast to make sure callers aren't confused.
      
      This patch (of 3):
      
      __gup_benchmark_ioctl does not handle the case where get_user_pages_fast
      fails:
      
       - a negative return code will cause a buffer overrun
      
       - returning with partial success will cause use of uninitialized
         memory.
      
      [akpm@linux-foundation.org: simplification]
      Link: http://lkml.kernel.org/r/1522962072-182137-3-git-send-email-mst@redhat.com
      
      
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Huang Ying <ying.huang@intel.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thorsten Leemhuis <regressions@leemhuis.info>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      09e35a4a
    • Takashi Iwai's avatar
      resource: fix integer overflow at reallocation · 60bb83b8
      Takashi Iwai authored
      We've got a bug report indicating a kernel panic at booting on an x86-32
      system, and it turned out to be the invalid PCI resource assigned after
      reallocation.  __find_resource() first aligns the resource start address
      and resets the end address with start+size-1 accordingly, then checks
      whether it's contained.  Here the end address may overflow the integer,
      although resource_contains() still returns true because the function
      validates only start and end address.  So this ends up with returning an
      invalid resource (start > end).
      
      There was already an attempt to cover such a problem in the commit
      47ea91b4 ("Resource: fix wrong resource window calculation"), but
      this case is an overseen one.
      
      This patch adds the validity check of the newly calculated resource for
      avoiding the integer overflow problem.
      
      Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1086739
      Link: http://lkml.kernel.org/r/s5hpo37d5l8.wl-tiwai@suse.de
      Fixes: 23c570a6
      
       ("resource: ability to resize an allocated resource")
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Reported-by: default avatarMichael Henders <hendersm@shaw.ca>
      Tested-by: default avatarMichael Henders <hendersm@shaw.ca>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      60bb83b8
    • Linus Torvalds's avatar
      Merge branch 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs · 48023102
      Linus Torvalds authored
      Pull overlayfs updates from Miklos Szeredi:
       "In addition to bug fixes and cleanups there are two new features from
        Amir:
      
         - Consistent inode number support for the case when layers are not
           all on the same filesystem (feature is dubbed "xino").
      
         - Optimize overlayfs file handle decoding. This one touches the
           exportfs interface to allow detecting the disconnected directory
           case"
      
      * 'overlayfs-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
        ovl: update documentation w.r.t "xino" feature
        ovl: add support for "xino" mount and config options
        ovl: consistent d_ino for non-samefs with xino
        ovl: consistent i_ino for non-samefs with xino
        ovl: constant st_ino for non-samefs with xino
        ovl: allocate anon bdev per unique lower fs
        ovl: factor out ovl_map_dev_ino() helper
        ovl: cleanup ovl_update_time()
        ovl: add WARN_ON() for non-dir redirect cases
        ovl: cleanup setting OVL_INDEX
        ovl: set d->is_dir and d->opaque for last path element
        ovl: Do not check for redirect if this is last layer
        ovl: lookup in inode cache first when decoding lower file handle
        ovl: do not try to reconnect a disconnected origin dentry
        ovl: disambiguate ovl_encode_fh()
        ovl: set lower layer st_dev only if setting lower st_ino
        ovl: fix lookup with middle layer opaque dir and absolute path redirects
        ovl: Set d->last properly during lookup
        ovl: set i_ino to the value of st_ino for NFS export
      48023102
    • Linus Torvalds's avatar
      Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux · ba2b137d
      Linus Torvalds authored
      Pull thermal management update from Zhang Rui:
      
       - Fix race condition in imx_thermal_probe() (Mikhail Lappo)
      
       - Add cooling device's statistics in sysfs (Viresh Kumar)
      
      * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
        thermal: Add cooling device's statistics in sysfs
        thermal: imx: Fix race condition in imx_thermal_probe()
      ba2b137d
    • Linus Torvalds's avatar
      Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging · 71893f11
      Linus Torvalds authored
      Pull dmi updates from Jean Delvare.
      
      * 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
        firmware: dmi_scan: Use lowercase letters for UUID
        firmware: dmi_scan: Add DMI_OEM_STRING support to dmi_matches
        firmware: dmi_scan: Fix UUID length safety check
      71893f11
    • Linus Torvalds's avatar
      Merge tag 'chrome-platform-for-linus-4.17' of... · f6811370
      Linus Torvalds authored
      Merge tag 'chrome-platform-for-linus-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform
      
      Pull chrome platform updates from Benson Leung:
      
       - a series from Dmitry to remove platform data from chromeos_laptop.c,
         which was the only user of platform data for the atmel_mxt_ts driver.
      
       - a series to clean up sysfs and debugfs for cros_ec
      
       - other misc cleanups
      
      * tag 'chrome-platform-for-linus-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform: (22 commits)
        platform/chrome: mfd/cros_ec_dev: Add sysfs entry to set keyboard wake lid angle
        platform/chrome: cros_ec_debugfs: Add PD port info to debugfs
        platform/chrome: cros_ec_debugfs: Use octal permissions '0444'
        platform/chrome: cros_ec_sysfs: use permission-specific DEVICE_ATTR variants
        platform/chrome: cros_ec_sysfs: introduce to_cros_ec_dev define.
        platform/chrome: cros_ec_sysfs: Modify error handling
        platform/chrome: cros_ec_lpc: Add support for Google devices using custom coreboot firmware
        platform/chrome: cros_ec_lpc: wake up from s2idle on Chrome EC
        Input: atmel_mxt_ts - remove platform data support
        platform/chrome: chromeos_laptop - discard data for unneeded boards
        platform/chrome: chromeos_laptop - use device properties for Pixel
        platform/chrome: chromeos_laptop - rely on I2C to set up interrupt trigger
        platform/chrome: chromeos_laptop - use I2C notifier to create devices
        platform/chrome: chromeos_laptop - parse DMI IRQ data once
        platform/chrome: chromeos_laptop - rework i2c peripherals initialization
        platform/chrome: chromeos_laptop - factor out getting IRQ from DMI
        platform/chrome: chromeos_laptop - introduce pr_fmt()
        platform/chrome: chromeos_laptop - stop setting suspend mode for Atmel devices
        platform/chrome: chromeos_laptop - add SPDX identifier
        Input: atmel_mxt_ts - switch ChromeOS ACPI devices to generic props
        ...
      f6811370
    • Linus Torvalds's avatar
      Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · ca4e7c51
      Linus Torvalds authored
      Pull clk updates from Stephen Boyd:
       "The large diff this time around is from the addition of a new clk
        driver for the TI Davinci family of SoCs. So far those clks have been
        supported with a custom implementation of the clk API in the arch port
        instead of in the CCF. With this driver merged we're one step closer
        to having a single clk API implementation.
      
        The other large diff is from the Amlogic clk driver that underwent
        some major surgery to use regmap. Beyond that, the biggest hitter is
        Samsung which needed some reworks to properly handle clk provider
        power domains and a bunch of PLL rate updates.
      
        The core framework was fairly quiet this round, just getting some
        cleanups and small fixes for some of the more esoteric features. And
        the usual set of driver non-critical fixes, cleanups, and minor
        additions are here as well.
      
        Core:
         - Rejig clk_ops::init() to be a little earlier for phase/accuracy ops
         - debugfs ops macroized to shave some lines of boilerplate code
         - Always calculate the phase instead of caching it in clk_get_phase()
         - More __must_check on bulk clk APIs
      
        New Drivers:
         - TI's Davinci family of SoCs
         - Intel's Stratix10 SoC
         - stm32mp157 SoC
         - Allwinner H6 CCU
         - Silicon Labs SI544 clock generator chip
         - Renesas R-Car M3-N and V3H SoCs
         - i.MX6SLL SoCs
      
        Removed Drivers:
         - ST-Ericsson AB8540/9540
      
        Updates:
         - Mediatek MT2701 and MT7622 audsys support and MT2712 updates
         - STM32F469 DSI and STM32F769 sdmmc2 support
         - GPIO clks can sleep now
         - Spreadtrum SC9860 RTC clks
         - Nvidia Tegra MBIST workarounds and various minor fixes
         - Rockchip phase handling fixes and a memory leak plugged
         - Renesas drivers switch to readl/writel from clk_readl/clk_writel
         - Renesas gained CPU (Z/Z2) and watchdog support
         - Rockchip rk3328 display clks and rk3399 1.6GHz PLL support
         - Qualcomm PM8921 PMIC XO buffers
         - Amlogic migrates to regmap APIs
         - TI Keystone clk latching support
         - Allwinner H3 and H5 video clk fixes
         - Broadcom BCM2835 PLLs needed another bit to enable
         - i.MX6SX CKO mux fix and i.MX7D Video PLL divider fix
         - i.MX6UL/ULL epdc_podf support
         - Hi3798CV200 COMBPHY0 and USB2_OTG_UTMI and phase support for eMMC"
      
      * tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (233 commits)
        clk: davinci: add a reset lookup table for psc0
        clk: imx: add clock driver for imx6sll
        dt-bindings: imx: update clock doc for imx6sll
        clk: imx: add new gate/gate2 wrapper funtion
        clk: imx: Add CLK_IS_CRITICAL flag for busy divider and busy mux
        clk: cs2000: set pm_ops in hibernate-compatible way
        clk: bcm2835: De-assert/assert PLL reset signal when appropriate
        clk: imx7d: Move clks_init_on before any clock operations
        clk: imx7d: Correct ahb clk parent select
        clk: imx7d: Correct dram pll type
        clk: imx7d: Add USB clock information
        clk: socfpga: stratix10: add clock driver for Stratix10 platform
        dt-bindings: documentation: add clock bindings information for Stratix10
        clk: ti: fix flag space conflict with clkctrl clocks
        clk: uniphier: add additional ethernet clock lines for Pro4
        clk: uniphier: add SATA clock control support
        clk: uniphier: add PCIe clock control support
        clk: Add driver for the si544 clock generator chip
        clk: davinci: Remove redundant dev_err calls
        clk: uniphier: add ethernet clock control support for PXs3
        ...
      ca4e7c51
    • Linus Torvalds's avatar
      Merge tag 'pwm/for-4.17-rc1' of... · daf3ef6e
      Linus Torvalds authored
      Merge tag 'pwm/for-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
      
      Pull pwm updates from Thierry Reding:
       "This set of changes adds support for more generations of the RCar
        controller as well as runtime PM support. The JZ4740 driver gains
        support for device tree and can now be used on all Ingenic SoCs.
      
        Rounding things off is a random assortment of fixes and cleanups all
        across the board"
      
      * tag 'pwm/for-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (29 commits)
        pwm: rcar: Add suspend/resume support
        pwm: rcar: Use PM Runtime to control module clock
        dt-bindings: pwm: rcar: Add bindings for R-Car M3N support
        pwm: rcar: Fix a condition to prevent mismatch value setting to duty
        pwm: sysfs: Use put_device() instead of kfree()
        dt-bindings: pwm: sunxi: Add new compatible strings
        pwm: sun4i: Simplify controller mapping
        pwm: sun4i: Drop unused .has_rdy member
        pwm: sun4i: Properly check current state
        pwm: Remove depends on AVR32
        pwm: stm32: LPTimer: Use 3 cells ->of_xlate()
        dt-bindings: pwm-stm32-lp: Add #pwm-cells
        pwm: stm32: Protect common prescaler for all channels
        pwm: stm32: Remove unused struct device
        pwm: mediatek: Improve precision in rate calculation
        pwm: mediatek: Remove redundant MODULE_ALIAS entries
        pwm: mediatek: Fix up PWM4 and PWM5 malfunction on MT7623
        pwm: jz4740: Enable for all Ingenic SoCs
        pwm: jz4740: Add support for devicetree
        pwm: jz4740: Implement ->set_polarity()
        ...
      daf3ef6e
    • Linus Torvalds's avatar
      Merge tag 'linux-watchdog-4.17-rc1' of git://www.linux-watchdog.org/linux-watchdog · 41531f58
      Linus Torvalds authored
      Pull watchdog updates from Wim Van Sebroeck:
      
       - Add Nuvoton NPCM watchdog driver
      
       - renesas_wdt: Add R-Car Gen2 support
      
       - renesas_wdt: add suspend/resume and restart handler support
      
       - hpwdt: convert to watchdog core and improve NMI
      
       - improve timeout setting/handling in various drivers
      
       - coh901327: make license text and module licence match
      
       - fix error handling in asm9260_wdt, sprd_wdt and davinci_wdt
      
       - aspeed imrovements
      
       - dw improvements (for control register & suspend/resume)
      
       - add SPDX identifiers for watchdog subsystem
      
      * tag 'linux-watchdog-4.17-rc1' of git://www.linux-watchdog.org/linux-watchdog: (35 commits)
        watchdog: davinci_wdt: fix error handling in davinci_wdt_probe()
        watchdog: add SPDX identifiers for watchdog subsystem
        watchdog: aspeed: Allow configuring for alternate boot
        watchdog: Add Nuvoton NPCM watchdog driver
        dt-bindings: watchdog: Add Nuvoton NPCM description
        watchdog: dw: save/restore control and timeout across suspend/resume
        watchdog: dw: RMW the control register
        watchdog: sprd_wdt: Fix error handling in sprd_wdt_enable()
        watchdog: aspeed: Fix translation of reset mode to ctrl register
        watchdog: renesas_wdt: Add restart handler
        watchdog: renesas_wdt: Add R-Car Gen2 support
        watchdog: renesas_wdt: Add suspend/resume support
        watchdog: f71808e_wdt: Fix WD_EN register read
        watchdog: hpwdt: Update driver version.
        watchdog: hpwdt: Add dynamic debug
        watchdog: hpwdt: Programable Pretimeout NMI
        watchdog: hpwdt: remove allow_kdump module parameter.
        watchdog: hpwdt: condition early return of NMI handler on iLO5
        watchdog: hpwdt: Modify to use watchdog core.
        watchdog: hpwdt: Update nmi_panic message.
        ...
      41531f58
    • Linus Torvalds's avatar
      Merge tag 'apparmor-pr-2018-04-10' of... · 80a17a5f
      Linus Torvalds authored
      Merge tag 'apparmor-pr-2018-04-10' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor
      
      Pull apparmor updates from John Johansen:
       "Features:
        - add base infrastructure for socket mediation. ABI bump and
          additional checks to ensure only v8 compliant policy uses socket af
          mediation.
        - improve and cleanup dfa verification
        - improve profile attachment logic
           - improve overlapping expression handling
           - add the xattr matching to the attachment logic
        - improve signal mediation handling with stacked labels
        - improve handling of no_new_privs in a label stack
      
        Cleanups and changes:
        - use dfa to parse string split
        - bounded version of label_parse
        - proper line wrap nulldfa.in
        - split context out into task and cred naming to better match usage
        - simplify code in aafs
      
        Bug fixes:
        - fix display of .ns_name for containers
        - fix resource audit messages when auditing peer
        - fix logging of the existence test for signals
        - fix resource audit messages when auditing peer
        - fix display of .ns_name for containers
        - fix an error code in verify_table_headers()
        - fix memory leak on buffer on error exit path
        - fix error returns checks by making size a ssize_t"
      
      * tag 'apparmor-pr-2018-04-10' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor: (36 commits)
        apparmor: fix memory leak on buffer on error exit path
        apparmor: fix dangling symlinks to policy rawdata after replacement
        apparmor: Fix an error code in verify_table_headers()
        apparmor: fix error returns checks by making size a ssize_t
        apparmor: update MAINTAINERS file git and wiki locations
        apparmor: remove POLICY_MEDIATES_SAFE
        apparmor: add base infastructure for socket mediation
        apparmor: improve overlapping domain attachment resolution
        apparmor: convert attaching profiles via xattrs to use dfa matching
        apparmor: Add support for attaching profiles via xattr, presence and value
        apparmor: cleanup: simplify code to get ns symlink name
        apparmor: cleanup create_aafs() error path
        apparmor: dfa split verification of table headers
        apparmor: dfa add support for state differential encoding
        apparmor: dfa move character match into a macro
        apparmor: update domain transitions that are subsets of confinement at nnp
        apparmor: move context.h to cred.h
        apparmor: move task related defines and fns to task.X files
        apparmor: cleanup, drop unused fn __aa_task_is_confined()
        apparmor: cleanup fixup description of aa_replace_profiles
        ...
      80a17a5f
    • Linus Torvalds's avatar
      Merge tag 'for-linus-20180413' of git://git.kernel.dk/linux-block · edda4153
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
       "Followup fixes for this merge window. This contains:
      
         - Series from Ming, fixing corner cases in our CPU <-> queue mapping.
      
           This triggered repeated warnings on especially s390, but I also hit
           it in cpu hot plug/unplug testing while doing IO on NVMe on x86-64.
      
         - Another fix from Ming, ensuring that we always order budget and
           driver tag identically, avoiding a deadlock on QD=1 devices.
      
         - Loop locking regression fix from this merge window, from Omar.
      
         - Another loop locking fix, this time missing an unlock, from Tetsuo
           Handa.
      
         - Fix for racing IO submission with device removal from Bart.
      
         - sr reference fix from me, fixing a case where disk change or
           getevents can race with device removal.
      
         - Set of nvme fixes by way of Keith, from various contributors"
      
      * tag 'for-linus-20180413' of git://git.kernel.dk/linux-block: (28 commits)
        nvme: expand nvmf_check_if_ready checks
        nvme: Use admin command effects for admin commands
        nvmet: fix space padding in serial number
        nvme: check return value of init_srcu_struct function
        nvmet: Fix nvmet_execute_write_zeroes sector count
        nvme-pci: Separate IO and admin queue IRQ vectors
        nvme-pci: Remove unused queue parameter
        nvme-pci: Skip queue deletion if there are no queues
        nvme: target: fix buffer overflow
        nvme: don't send keep-alives to the discovery controller
        nvme: unexport nvme_start_keep_alive
        nvme-loop: fix kernel oops in case of unhandled command
        nvme: enforce 64bit offset for nvme_get_log_ext fn
        sr: get/drop reference to device in revalidate and check_events
        blk-mq: Revert "blk-mq: reimplement blk_mq_hw_queue_mapped"
        blk-mq: Avoid that submitting a bio concurrently with device removal triggers a crash
        backing: silence compiler warning using __printf
        blk-mq: remove code for dealing with remapping queue
        blk-mq: reimplement blk_mq_hw_queue_mapped
        blk-mq: don't check queue mapped in __blk_mq_delay_run_hw_queue()
        ...
      edda4153