Skip to content
  1. May 15, 2020
    • Daniel Borkmann's avatar
      bpf: Restrict bpf_probe_read{, str}() only to archs where they work · 0ebeea8c
      Daniel Borkmann authored
      
      
      Given the legacy bpf_probe_read{,str}() BPF helpers are broken on archs
      with overlapping address ranges, we should really take the next step to
      disable them from BPF use there.
      
      To generally fix the situation, we've recently added new helper variants
      bpf_probe_read_{user,kernel}() and bpf_probe_read_{user,kernel}_str().
      For details on them, see 6ae08ae3 ("bpf: Add probe_read_{user, kernel}
      and probe_read_{user,kernel}_str helpers").
      
      Given bpf_probe_read{,str}() have been around for ~5 years by now, there
      are plenty of users at least on x86 still relying on them today, so we
      cannot remove them entirely w/o breaking the BPF tracing ecosystem.
      
      However, their use should be restricted to archs with non-overlapping
      address ranges where they are working in their current form. Therefore,
      move this behind a CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE and
      have x86, arm64, arm select it (other archs supporting it can follow-up
      on it as well).
      
      For the remaining archs, they can workaround easily by relying on the
      feature probe from bpftool which spills out defines that can be used out
      of BPF C code to implement the drop-in replacement for old/new kernels
      via: bpftool feature probe macro
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/bpf/20200515101118.6508-2-daniel@iogearbox.net
      0ebeea8c
  2. May 14, 2020
    • Kefeng Wang's avatar
      riscv: mmiowb: Fix implicit declaration of function 'smp_processor_id' · ed1ed4c0
      Kefeng Wang authored
      
      
      In file included from ./../include/linux/compiler_types.h:68,
                       from <command-line>:
      ../include/asm-generic/mmiowb.h: In function ‘mmiowb_set_pending’:
      ../include/asm-generic/percpu.h:34:38: error: implicit declaration of function ‘smp_processor_id’; did you mean ‘raw_smp_processor_id’? [-Werror=implicit-function-declaration]
       #define my_cpu_offset per_cpu_offset(smp_processor_id())
                                            ^~~~~~~~~~~~~~~~
      ../include/linux/compiler-gcc.h:58:26: note: in definition of macro ‘RELOC_HIDE’
        (typeof(ptr)) (__ptr + (off));     \
                                ^~~
      ../include/linux/percpu-defs.h:249:2: note: in expansion of macro ‘SHIFT_PERCPU_PTR’
        SHIFT_PERCPU_PTR(ptr, my_cpu_offset);    \
        ^~~~~~~~~~~~~~~~
      ../include/asm-generic/percpu.h:34:23: note: in expansion of macro ‘per_cpu_offset’
       #define my_cpu_offset per_cpu_offset(smp_processor_id())
                             ^~~~~~~~~~~~~~
      ../include/linux/percpu-defs.h:249:24: note: in expansion of macro ‘my_cpu_offset’
        SHIFT_PERCPU_PTR(ptr, my_cpu_offset);    \
                              ^~~~~~~~~~~~~
      ../include/asm-generic/mmiowb.h:30:26: note: in expansion of macro ‘this_cpu_ptr’
       #define __mmiowb_state() this_cpu_ptr(&__mmiowb_state)
                                ^~~~~~~~~~~~
      ../include/asm-generic/mmiowb.h:37:28: note: in expansion of macro ‘__mmiowb_state’
        struct mmiowb_state *ms = __mmiowb_state();
                                  ^~~~~~~~~~~~~~
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      ed1ed4c0
    • Kefeng Wang's avatar
      riscv: pgtable: Fix __kernel_map_pages build error if NOMMU · 9a6630ae
      Kefeng Wang authored
      
      
      riscv64-none-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
      page_alloc.c:(.text+0xd34): undefined reference to `__kernel_map_pages'
      riscv64-none-linux-gnu-ld: page_alloc.c:(.text+0x104a): undefined reference to `__kernel_map_pages'
      riscv64-none-linux-gnu-ld: mm/page_alloc.o: in function `__pageblock_pfn_to_page':
      page_alloc.c:(.text+0x145e): undefined reference to `__kernel_map_pages'
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      9a6630ae
  3. May 13, 2020
  4. May 12, 2020
    • Kefeng Wang's avatar
      riscv: Fix unmet direct dependencies built based on SOC_VIRT · ab7fbad0
      Kefeng Wang authored
      
      
      Fix unmet direct dependencies Warning and fix Kconfig indent.
      
      WARNING: unmet direct dependencies detected for POWER_RESET_SYSCON
        Depends on [n]: POWER_RESET [=n] && OF [=y] && HAS_IOMEM [=y]
        Selected by [y]:
        - SOC_VIRT [=y]
      
      WARNING: unmet direct dependencies detected for POWER_RESET_SYSCON_POWEROFF
        Depends on [n]: POWER_RESET [=n] && OF [=y] && HAS_IOMEM [=y]
        Selected by [y]:
        - SOC_VIRT [=y]
      
      WARNING: unmet direct dependencies detected for RTC_DRV_GOLDFISH
        Depends on [n]: RTC_CLASS [=n] && OF [=y] && HAS_IOMEM [=y] && (GOLDFISH [=y] || COMPILE_TEST [=n])
        Selected by [y]:
        - SOC_VIRT [=y]
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      ab7fbad0
    • Kefeng Wang's avatar
      riscv: perf: RISCV_BASE_PMU should be independent · 48084c35
      Kefeng Wang authored
      
      
      Selecting PERF_EVENTS without selecting RISCV_BASE_PMU results in a build
      error.
      
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      [Palmer: commit text]
      Fixes: 178e9fc4("perf: riscv: preliminary RISC-V support")
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      48084c35
    • Steven Rostedt (VMware)'s avatar
      x86/ftrace: Have ftrace trampolines turn read-only at the end of system boot up · 59566b0b
      Steven Rostedt (VMware) authored
      Booting one of my machines, it triggered the following crash:
      
       Kernel/User page tables isolation: enabled
       ftrace: allocating 36577 entries in 143 pages
       Starting tracer 'function'
       BUG: unable to handle page fault for address: ffffffffa000005c
       #PF: supervisor write access in kernel mode
       #PF: error_code(0x0003) - permissions violation
       PGD 2014067 P4D 2014067 PUD 2015063 PMD 7b253067 PTE 7b252061
       Oops: 0003 [#1] PREEMPT SMP PTI
       CPU: 0 PID: 0 Comm: swapper Not tainted 5.4.0-test+ #24
       Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS SDBLI944.86P 05/08/2007
       RIP: 0010:text_poke_early+0x4a/0x58
       Code: 34 24 48 89 54 24 08 e8 bf 72 0b 00 48 8b 34 24 48 8b 4c 24 08 84 c0 74 0b 48 89 df f3 a4 48 83 c4 10 5b c3 9c 58 fa 48 89 df <f3> a4 50 9d 48 83 c4 10 5b e9 d6 f9 ff ff
      0 41 57 49
       RSP: 0000:ffffffff82003d38 EFLAGS: 00010046
       RAX: 0000000000000046 RBX: ffffffffa000005c RCX: 0000000000000005
       RDX: 0000000000000005 RSI: ffffffff825b9a90 RDI: ffffffffa000005c
       RBP: ffffffffa000005c R08: 0000000000000000 R09: ffffffff8206e6e0
       R10: ffff88807b01f4c0 R11: ffffffff8176c106 R12: ffffffff8206e6e0
       R13: ffffffff824f2440 R14: 0000000000000000 R15: ffffffff8206eac0
       FS:  0000000000000000(0000) GS:ffff88807d400000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: ffffffffa000005c CR3: 0000000002012000 CR4: 00000000000006b0
       Call Trace:
        text_poke_bp+0x27/0x64
        ? mutex_lock+0x36/0x5d
        arch_ftrace_update_trampoline+0x287/0x2d5
        ? ftrace_replace_code+0x14b/0x160
        ? ftrace_update_ftrace_func+0x65/0x6c
        __register_ftrace_function+0x6d/0x81
        ftrace_startup+0x23/0xc1
        register_ftrace_function+0x20/0x37
        func_set_flag+0x59/0x77
        __set_tracer_option.isra.19+0x20/0x3e
        trace_set_options+0xd6/0x13e
        apply_trace_boot_options+0x44/0x6d
        register_tracer+0x19e/0x1ac
        early_trace_init+0x21b/0x2c9
        start_kernel+0x241/0x518
        ? load_ucode_intel_bsp+0x21/0x52
        secondary_startup_64+0xa4/0xb0
      
      I was able to trigger it on other machines, when I added to the kernel
      command line of both "ftrace=function" and "trace_options=func_stack_trace".
      
      The cause is the "ftrace=function" would register the function tracer
      and create a trampoline, and it will set it as executable and
      read-only. Then the "trace_options=func_stack_trace" would then update
      the same trampoline to include the stack tracer version of the function
      tracer. But since the trampoline already exists, it updates it with
      text_poke_bp(). The problem is that text_poke_bp() called while
      system_state == SYSTEM_BOOTING, it will simply do a memcpy() and not
      the page mapping, as it would think that the text is still read-write.
      But in this case it is not, and we take a fault and crash.
      
      Instead, lets keep the ftrace trampolines read-write during boot up,
      and then when the kernel executable text is set to read-only, the
      ftrace trampolines get set to read-only as well.
      
      Link: https://lkml.kernel.org/r/20200430202147.4dc6e2de@oasis.local.home
      
      
      
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: stable@vger.kernel.org
      Fixes: 768ae440 ("x86/ftrace: Use text_poke()")
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      59566b0b
    • Clay McClure's avatar
      net: ethernet: ti: Remove TI_CPTS_MOD workaround · 92db978f
      Clay McClure authored
      
      
      My recent commit b6d49cab ("net: Make PTP-specific drivers depend on
      PTP_1588_CLOCK") exposes a missing dependency in defconfigs that select
      TI_CPTS without selecting PTP_1588_CLOCK, leading to linker errors of the
      form:
      
      drivers/net/ethernet/ti/cpsw.o: in function `cpsw_ndo_stop':
      cpsw.c:(.text+0x680): undefined reference to `cpts_unregister'
       ...
      
      That's because TI_CPTS_MOD (which is the symbol gating the _compilation_ of
      cpts.c) now depends on PTP_1588_CLOCK, and so is not enabled in these
      configurations, but TI_CPTS (which is the symbol gating _calls_ to the cpts
      functions) _is_ enabled. So we end up compiling calls to functions that
      don't exist, resulting in the linker errors.
      
      This patch fixes build errors and restores previous behavior by:
       - ensure PTP_1588_CLOCK=y in TI specific configs and CPTS will be built
       - remove TI_CPTS_MOD and, instead, add dependencies from CPTS in
         TI_CPSW/TI_KEYSTONE_NETCP/TI_CPSW_SWITCHDEV as below:
      
         config TI_CPSW_SWITCHDEV
         ...
          depends on TI_CPTS || !TI_CPTS
      
         which will ensure proper dependencies PTP_1588_CLOCK -> TI_CPTS ->
      TI_CPSW/TI_KEYSTONE_NETCP/TI_CPSW_SWITCHDEV and build type selection.
      
      Note. For NFS boot + CPTS all of above configs have to be built-in.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dan Murphy <dmurphy@ti.com>
      Cc: Tony Lindgren <tony@atomide.com>
      Fixes: b6d49cab ("net: Make PTP-specific drivers depend on PTP_1588_CLOCK")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarClay McClure <clay@daemons.net>
      [grygorii.strashko@ti.com: rewording, add deps cpsw/netcp from cpts, drop IS_REACHABLE]
      Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Tested-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      92db978f
  5. May 11, 2020
    • Kefeng Wang's avatar
      riscv: perf_event: Make some funciton static · e7b146a8
      Kefeng Wang authored
      
      
      Fixes the following warning detected when running make with W=1,
      ../arch/riscv/kernel/perf_event.c:150:5: warning: no previous prototype for ‘riscv_map_cache_decode’ [-Wmissing-prototypes]
       int riscv_map_cache_decode(u64 config, unsigned int *type,
           ^~~~~~~~~~~~~~~~~~~~~~
      ../arch/riscv/kernel/perf_event.c:345:13: warning: no previous prototype for ‘riscv_base_pmu_handle_irq’ [-Wmissing-prototypes]
       irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
      ../arch/riscv/kernel/perf_event.c:364:6: warning: no previous prototype for ‘release_pmc_hardware’ [-Wmissing-prototypes]
       void release_pmc_hardware(void)
            ^~~~~~~~~~~~~~~~~~~~
      ../arch/riscv/kernel/perf_event.c:467:12: warning: no previous prototype for ‘init_hw_perf_events’ [-Wmissing-prototypes]
       int __init init_hw_perf_events(void)
                  ^~~~~~~~~~~~~~~~~~~
      
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      e7b146a8
    • Christoph Hellwig's avatar
      arm64: fix the flush_icache_range arguments in machine_kexec · d51c2145
      Christoph Hellwig authored
      
      
      The second argument is the end "pointer", not the length.
      
      Fixes: d28f6df1 ("arm64/kexec: Add core kexec support")
      Cc: <stable@vger.kernel.org> # 4.8.x-
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      d51c2145
  6. May 08, 2020
  7. May 07, 2020
    • Mark Rutland's avatar
      arm64: hugetlb: avoid potential NULL dereference · 027d0c71
      Mark Rutland authored
      
      
      The static analyzer in GCC 10 spotted that in huge_pte_alloc() we may
      pass a NULL pmdp into pte_alloc_map() when pmd_alloc() returns NULL:
      
      |   CC      arch/arm64/mm/pageattr.o
      |   CC      arch/arm64/mm/hugetlbpage.o
      |                  from arch/arm64/mm/hugetlbpage.c:10:
      | arch/arm64/mm/hugetlbpage.c: In function ‘huge_pte_alloc’:
      | ./arch/arm64/include/asm/pgtable-types.h:28:24: warning: dereference of NULL ‘pmdp’ [CWE-690] [-Wanalyzer-null-dereference]
      | ./arch/arm64/include/asm/pgtable.h:436:26: note: in expansion of macro ‘pmd_val’
      | arch/arm64/mm/hugetlbpage.c:242:10: note: in expansion of macro ‘pte_alloc_map’
      |     |arch/arm64/mm/hugetlbpage.c:232:10:
      |     |./arch/arm64/include/asm/pgtable-types.h:28:24:
      | ./arch/arm64/include/asm/pgtable.h:436:26: note: in expansion of macro ‘pmd_val’
      | arch/arm64/mm/hugetlbpage.c:242:10: note: in expansion of macro ‘pte_alloc_map’
      
      This can only occur when the kernel cannot allocate a page, and so is
      unlikely to happen in practice before other systems start failing.
      
      We can avoid this by bailing out if pmd_alloc() fails, as we do earlier
      in the function if pud_alloc() fails.
      
      Fixes: 66b3923a ("arm64: hugetlb: add support for PTE contiguous bit")
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reported-by: default avatarKyrill Tkachov <kyrylo.tkachov@arm.com>
      Cc: <stable@vger.kernel.org> # 4.5.x-
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      027d0c71
  8. May 06, 2020
    • Thomas Gleixner's avatar
      ARM: futex: Address build warning · 8101b5a1
      Thomas Gleixner authored
      
      
      Stephen reported the following build warning on a ARM multi_v7_defconfig
      build with GCC 9.2.1:
      
      kernel/futex.c: In function 'do_futex':
      kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized]
       1676 |   return oldval == cmparg;
            |          ~~~~~~~^~~~~~~~~
      kernel/futex.c:1652:6: note: 'oldval' was declared here
       1652 |  int oldval, ret;
            |      ^~~~~~
      
      introduced by commit a08971e9 ("futex: arch_futex_atomic_op_inuser()
      calling conventions change").
      
      While that change should not make any difference it confuses GCC which
      fails to work out that oldval is not referenced when the return value is
      not zero.
      
      GCC fails to properly analyze arch_futex_atomic_op_inuser(). It's not the
      early return, the issue is with the assembly macros. GCC fails to detect
      that those either set 'ret' to 0 and set oldval or set 'ret' to -EFAULT
      which makes oldval uninteresting. The store to the callsite supplied oldval
      pointer is conditional on ret == 0.
      
      The straight forward way to solve this is to make the store unconditional.
      
      Aside of addressing the build warning this makes sense anyway because it
      removes the conditional from the fastpath. In the error case the stored
      value is uninteresting and the extra store does not matter at all.
      
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/87pncao2ph.fsf@nanos.tec.linutronix.de
      8101b5a1
    • Peter Xu's avatar
      KVM: X86: Declare KVM_CAP_SET_GUEST_DEBUG properly · 495907ec
      Peter Xu authored
      
      
      KVM_CAP_SET_GUEST_DEBUG should be supported for x86 however it's not declared
      as supported.  My wild guess is that userspaces like QEMU are using "#ifdef
      KVM_CAP_SET_GUEST_DEBUG" to check for the capability instead, but that could be
      wrong because the compilation host may not be the runtime host.
      
      The userspace might still want to keep the old "#ifdef" though to not break the
      guest debug on old kernels.
      
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <20200505154750.126300-1-peterx@redhat.com>
      [Do the same for PPC and s390. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      495907ec
    • Paolo Bonzini's avatar
      kvm: x86: Use KVM CPU capabilities to determine CR4 reserved bits · 139f7425
      Paolo Bonzini authored
      
      
      Using CPUID data can be useful for the processor compatibility
      check, but that's it.  Using it to compute guest-reserved bits
      can have both false positives (such as LA57 and UMIP which we
      are already handling) and false negatives: in particular, with
      this patch we don't allow anymore a KVM guest to set CR4.PKE
      when CR4.PKE is clear on the host.
      
      Fixes: b9dd21e1 ("KVM: x86: simplify handling of PKRU")
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Tested-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      139f7425
    • Sean Christopherson's avatar
      KVM: VMX: Explicitly clear RFLAGS.CF and RFLAGS.ZF in VM-Exit RSB path · c7cb2d65
      Sean Christopherson authored
      
      
      Clear CF and ZF in the VM-Exit path after doing __FILL_RETURN_BUFFER so
      that KVM doesn't interpret clobbered RFLAGS as a VM-Fail.  Filling the
      RSB has always clobbered RFLAGS, its current incarnation just happens
      clear CF and ZF in the processs.  Relying on the macro to clear CF and
      ZF is extremely fragile, e.g. commit 089dd8e5 ("x86/speculation:
      Change FILL_RETURN_BUFFER to work with objtool") tweaks the loop such
      that the ZF flag is always set.
      
      Reported-by: default avatarQian Cai <cai@lca.pw>
      Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: f2fde6a5 ("KVM: VMX: Move RSB stuffing to before the first RET after VM-Exit")
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200506035355.2242-1-sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c7cb2d65
    • Atish Patra's avatar
      RISC-V: Remove unused code from STRICT_KERNEL_RWX · 73cb8e2a
      Atish Patra authored
      
      
      This patch removes the unused functions set_kernel_text_rw/ro.
      Currently, it is not being invoked from anywhere and no other architecture
      (except arm) uses this code. Even in ARM, these functions are not invoked
      from anywhere currently.
      
      Fixes: d27c3c90 ("riscv: add STRICT_KERNEL_RWX support")
      Signed-off-by: default avatarAtish Patra <atish.patra@wdc.com>
      Reviewed-by: default avatarZong Li <zong.li@sifive.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      73cb8e2a
  9. May 05, 2020
  10. May 04, 2020
  11. May 03, 2020
  12. May 01, 2020
  13. Apr 30, 2020
Loading