18 Jun, 2020

1 commit


04 Feb, 2020

1 commit

  • The most notable change is DEFINE_SHOW_ATTRIBUTE macro split in
    seq_file.h.

    Conversion rule is:

    llseek => proc_lseek
    unlocked_ioctl => proc_ioctl

    xxx => proc_xxx

    delete ".owner = THIS_MODULE" line

    [akpm@linux-foundation.org: fix drivers/isdn/capi/kcapi_proc.c]
    [sfr@canb.auug.org.au: fix kernel/sched/psi.c]
    Link: http://lkml.kernel.org/r/20200122180545.36222f50@canb.auug.org.au
    Link: http://lkml.kernel.org/r/20191225172546.GB13378@avx2
    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

20 Aug, 2019

2 commits

  • Print the content of current->comm in messages generated by lockdown to
    indicate a restriction that was hit. This makes it a bit easier to find
    out what caused the message.

    The message now patterned something like:

    Lockdown: : is restricted; see man kernel_lockdown.7

    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    Matthew Garrett
     
  • Disallow access to /proc/kcore when the kernel is locked down to prevent
    access to cryptographic data. This is limited to lockdown
    confidentiality mode and is still permitted in integrity mode.

    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    David Howells
     

30 Mar, 2019

1 commit

  • Fix sparse warning:

    fs/proc/kcore.c:591:19: warning:
    symbol 'kcore_modules' was not declared. Should it be static?

    Link: http://lkml.kernel.org/r/20190320135417.13272-1-yuehaibing@huawei.com
    Signed-off-by: YueHaibing
    Acked-by: Mukesh Ojha
    Cc: Alexey Dobriyan
    Cc: Omar Sandoval
    Cc: James Morse
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    YueHaibing
     

23 Mar, 2019

1 commit

  • On machines where the GART aperture is mapped over physical RAM,
    /proc/kcore contains the GART aperture range. Accessing the GART range via
    /proc/kcore results in a kernel crash.

    vmcore used to have the same issue, until it was fixed with commit
    2a3e83c6f96c ("x86/gart: Exclude GART aperture from vmcore")', leveraging
    existing hook infrastructure in vmcore to let /proc/vmcore return zeroes
    when attempting to read the aperture region, and so it won't read from the
    actual memory.

    Apply the same workaround for kcore. First implement the same hook
    infrastructure for kcore, then reuse the hook functions introduced in the
    previous vmcore fix. Just with some minor adjustment, rename some functions
    for more general usage, and simplify the hook infrastructure a bit as there
    is no module usage yet.

    Suggested-by: Baoquan He
    Signed-off-by: Kairui Song
    Signed-off-by: Thomas Gleixner
    Reviewed-by: Jiri Bohac
    Acked-by: Baoquan He
    Cc: Borislav Petkov
    Cc: "H. Peter Anvin"
    Cc: Alexey Dobriyan
    Cc: Andrew Morton
    Cc: Omar Sandoval
    Cc: Dave Young
    Link: https://lkml.kernel.org/r/20190308030508.13548-1-kasong@redhat.com

    Kairui Song
     

31 Oct, 2018

1 commit

  • Move remaining definitions and declarations from include/linux/bootmem.h
    into include/linux/memblock.h and remove the redundant header.

    The includes were replaced with the semantic patch below and then
    semi-automated removal of duplicated '#include

    @@
    @@
    - #include
    + #include

    [sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h]
    Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au
    [sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h]
    Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au
    [sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal]
    Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au
    Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com
    Signed-off-by: Mike Rapoport
    Signed-off-by: Stephen Rothwell
    Acked-by: Michal Hocko
    Cc: Catalin Marinas
    Cc: Chris Zankel
    Cc: "David S. Miller"
    Cc: Geert Uytterhoeven
    Cc: Greentime Hu
    Cc: Greg Kroah-Hartman
    Cc: Guan Xuetao
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Jonas Bonn
    Cc: Jonathan Corbet
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Martin Schwidefsky
    Cc: Matt Turner
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Palmer Dabbelt
    Cc: Paul Burton
    Cc: Richard Kuo
    Cc: Richard Weinberger
    Cc: Rich Felker
    Cc: Russell King
    Cc: Serge Semin
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Cc: Vineet Gupta
    Cc: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

21 Sep, 2018

1 commit

  • The 'm' kcore_list item could point to kclist_head, and it is incorrect to
    look at m->addr / m->size in this case.

    There is no choice but to run through the list of entries for every
    address if we did not find any entry in the previous iteration

    Reset 'm' to NULL in that case at Omar Sandoval's suggestion.

    [akpm@linux-foundation.org: add comment]
    Link: http://lkml.kernel.org/r/1536100702-28706-1-git-send-email-asmadeus@codewreck.org
    Fixes: bf991c2231117 ("proc/kcore: optimize multiple page reads")
    Signed-off-by: Dominique Martinet
    Reviewed-by: Andrew Morton
    Cc: Omar Sandoval
    Cc: Alexey Dobriyan
    Cc: Eric Biederman
    Cc: James Morse
    Cc: Bhupesh Sharma
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Dominique Martinet
     

27 Aug, 2018

1 commit

  • Pull perf updates from Thomas Gleixner:
    "Kernel:
    - Improve kallsyms coverage
    - Add x86 entry trampolines to kcore
    - Fix ARM SPE handling
    - Correct PPC event post processing

    Tools:
    - Make the build system more robust
    - Small fixes and enhancements all over the place
    - Update kernel ABI header copies
    - Preparatory work for converting libtraceevnt to a shared library
    - License cleanups"

    * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (100 commits)
    tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy'
    tools arch x86: Update tools's copy of cpufeatures.h
    perf python: Fix pyrf_evlist__read_on_cpu() interface
    perf mmap: Store real cpu number in 'struct perf_mmap'
    perf tools: Remove ext from struct kmod_path
    perf tools: Add gzip_is_compressed function
    perf tools: Add lzma_is_compressed function
    perf tools: Add is_compressed callback to compressions array
    perf tools: Move the temp file processing into decompress_kmodule
    perf tools: Use compression id in decompress_kmodule()
    perf tools: Store compression id into struct dso
    perf tools: Add compression id into 'struct kmod_path'
    perf tools: Make is_supported_compression() static
    perf tools: Make decompress_to_file() function static
    perf tools: Get rid of dso__needs_decompress() call in __open_dso()
    perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble()
    perf tools: Get rid of dso__needs_decompress() call in read_object_code()
    tools lib traceevent: Change to SPDX License format
    perf llvm: Allow passing options to llc in addition to clang
    perf parser: Improve error message for PMU address filters
    ...

    Linus Torvalds
     

23 Aug, 2018

9 commits

  • The vmcoreinfo information is useful for runtime debugging tools, not just
    for crash dumps. A lot of this information can be determined by other
    means, but this is much more convenient, and it only adds a page at most
    to the file.

    Link: http://lkml.kernel.org/r/fddbcd08eed76344863303878b12de1c1e2a04b6.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • The current code does a full search of the segment list every time for
    every page. This is wasteful, since it's almost certain that the next
    page will be in the same segment. Instead, check if the previous segment
    covers the current page before doing the list search.

    Link: http://lkml.kernel.org/r/fd346c11090cf93d867e01b8d73a6567c5ac6361.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • Currently, the ELF file header, program headers, and note segment are
    allocated all at once, in some icky code dating back to 2.3. Programs
    tend to read the file header, then the program headers, then the note
    segment, all separately, so this is a waste of effort. It's cleaner and
    more efficient to handle the three separately.

    Link: http://lkml.kernel.org/r/19c92cbad0e11f6103ff3274b2e7a7e51a1eb74b.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • Now that we're using an rwsem, we can hold it during the entirety of
    read_kcore() and have a common return path. This is preparation for the
    next change.

    [akpm@linux-foundation.org: fix locking bug reported by Tetsuo Handa]
    Link: http://lkml.kernel.org/r/d7cfbc1e8a76616f3b699eaff9df0a2730380534.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Cc: Tetsuo Handa
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • There's a theoretical race condition that will cause /proc/kcore to miss
    a memory hotplug event:

    CPU0 CPU1
    // hotplug event 1
    kcore_need_update = 1

    open_kcore() open_kcore()
    kcore_update_ram() kcore_update_ram()
    // Walk RAM // Walk RAM
    __kcore_update_ram() __kcore_update_ram()
    kcore_need_update = 0

    // hotplug event 2
    kcore_need_update = 1
    kcore_need_update = 0

    Note that CPU1 set up the RAM kcore entries with the state after hotplug
    event 1 but cleared the flag for hotplug event 2. The RAM entries will
    therefore be stale until there is another hotplug event.

    This is an extremely unlikely sequence of events, but the fix makes the
    synchronization saner, anyways: we serialize the entire update sequence,
    which means that whoever clears the flag will always succeed in replacing
    the kcore list.

    Link: http://lkml.kernel.org/r/6106c509998779730c12400c1b996425df7d7089.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • Now we only need kclist_lock from user context and at fs init time, and
    the following changes need to sleep while holding the kclist_lock.

    Link: http://lkml.kernel.org/r/521ba449ebe921d905177410fee9222d07882f0d.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Reviewed-by: Andrew Morton
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • The memory hotplug notifier kcore_callback() only needs kclist_lock to
    prevent races with __kcore_update_ram(), but we can easily eliminate that
    race by using an atomic xchg() in __kcore_update_ram(). This is
    preparation for converting kclist_lock to an rwsem.

    Link: http://lkml.kernel.org/r/0a4bc89f4dbde8b5b2ea309f7b4fb6a85fe29df2.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Reviewed-by: Andrew Morton
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • Patch series "/proc/kcore improvements", v4.

    This series makes a few improvements to /proc/kcore. It fixes a couple of
    small issues in v3 but is otherwise the same. Patches 1, 2, and 3 are
    prep patches. Patch 4 is a fix/cleanup. Patch 5 is another prep patch.
    Patches 6 and 7 are optimizations to ->read(). Patch 8 makes it possible
    to enable CRASH_CORE on any architecture, which is needed for patch 9.
    Patch 9 adds vmcoreinfo to /proc/kcore.

    This patch (of 9):

    kclist_add() is only called at init time, so there's no point in grabbing
    any locks. We're also going to replace the rwlock with a rwsem, which we
    don't want to try grabbing during early boot.

    While we're here, mark kclist_add() with __init so that we'll get a
    warning if it's called from non-init code.

    Link: http://lkml.kernel.org/r/98208db1faf167aa8b08eebfa968d95c70527739.1531953780.git.osandov@fb.com
    Signed-off-by: Omar Sandoval
    Reviewed-by: Andrew Morton
    Reviewed-by: Bhupesh Sharma
    Tested-by: Bhupesh Sharma
    Cc: Alexey Dobriyan
    Cc: Bhupesh Sharma
    Cc: Eric Biederman
    Cc: James Morse
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Omar Sandoval
     
  • elf_kcore_store_hdr() uses __pa() to find the physical address of
    KCORE_RAM or KCORE_TEXT entries exported as program headers.

    This trips CONFIG_DEBUG_VIRTUAL's checks, as the KCORE_TEXT entries are
    not in the linear map.

    Handle these two cases separately, using __pa_symbol() for the KCORE_TEXT
    entries.

    Link: http://lkml.kernel.org/r/20180711131944.15252-1-james.morse@arm.com
    Signed-off-by: James Morse
    Cc: Alexey Dobriyan
    Cc: Omar Sandoval
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    James Morse
     

15 Aug, 2018

1 commit

  • Without program headers for PTI entry trampoline pages, the trampoline
    virtual addresses do not map to anything.

    Example before:

    sudo gdb --quiet vmlinux /proc/kcore
    Reading symbols from vmlinux...done.
    [New process 1]
    Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.16.0 root=UUID=a6096b83-b763-4101-807e-f33daff63233'.
    #0 0x0000000000000000 in irq_stack_union ()
    (gdb) x /21ib 0xfffffe0000006000
    0xfffffe0000006000: Cannot access memory at address 0xfffffe0000006000
    (gdb) quit

    After:

    sudo gdb --quiet vmlinux /proc/kcore
    [sudo] password for ahunter:
    Reading symbols from vmlinux...done.
    [New process 1]
    Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.16.0-fix-4-00005-gd6e65a8b4072 root=UUID=a6096b83-b7'.
    #0 0x0000000000000000 in irq_stack_union ()
    (gdb) x /21ib 0xfffffe0000006000
    0xfffffe0000006000: swapgs
    0xfffffe0000006003: mov %rsp,-0x3e12(%rip) # 0xfffffe00000021f8
    0xfffffe000000600a: xchg %ax,%ax
    0xfffffe000000600c: mov %cr3,%rsp
    0xfffffe000000600f: bts $0x3f,%rsp
    0xfffffe0000006014: and $0xffffffffffffe7ff,%rsp
    0xfffffe000000601b: mov %rsp,%cr3
    0xfffffe000000601e: mov -0x3019(%rip),%rsp # 0xfffffe000000300c
    0xfffffe0000006025: pushq $0x2b
    0xfffffe0000006027: pushq -0x3e35(%rip) # 0xfffffe00000021f8
    0xfffffe000000602d: push %r11
    0xfffffe000000602f: pushq $0x33
    0xfffffe0000006031: push %rcx
    0xfffffe0000006032: push %rdi
    0xfffffe0000006033: mov $0xffffffff91a00010,%rdi
    0xfffffe000000603a: callq 0xfffffe0000006046
    0xfffffe000000603f: pause
    0xfffffe0000006041: lfence
    0xfffffe0000006044: jmp 0xfffffe000000603f
    0xfffffe0000006046: mov %rdi,(%rsp)
    0xfffffe000000604a: retq
    (gdb) quit

    In addition, entry trampolines all map to the same page. Represent that
    by giving the corresponding program headers in kcore the same offset.

    This has the benefit that, when perf tools uses /proc/kcore as a source
    for kernel object code, samples from different CPU trampolines are
    aggregated together. Note, such aggregation is normal for profiling
    i.e. people want to profile the object code, not every different virtual
    address the object code might be mapped to (across different processes
    for example).

    Notes by PeterZ:

    This also adds the KCORE_REMAP functionality.

    Signed-off-by: Adrian Hunter
    Acked-by: Andi Kleen
    Acked-by: Peter Zijlstra (Intel)
    Cc: Alexander Shishkin
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: H. Peter Anvin
    Cc: Jiri Olsa
    Cc: Joerg Roedel
    Cc: Thomas Gleixner
    Cc: x86@kernel.org
    Link: http://lkml.kernel.org/r/1528289651-4113-4-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

12 May, 2018

1 commit

  • The existing kcore code checks for bad addresses against __va(0) with
    the assumption that this is the lowest address on the system. This may
    not hold true on some systems (e.g. arm64) and produce overflows and
    crashes. Switch to using other functions to validate the address range.

    It's currently only seen on arm64 and it's not clear if anyone wants to
    use that particular combination on a stable release. So this is not
    urgent for stable.

    Link: http://lkml.kernel.org/r/20180501201143.15121-1-labbott@redhat.com
    Signed-off-by: Laura Abbott
    Tested-by: Dave Anderson
    Cc: Kees Cook
    Cc: Ard Biesheuvel
    Cc: Ingo Molnar
    Cc: Andi Kleen
    Cc: Alexey Dobriyan a
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Laura Abbott
     

13 Feb, 2018

1 commit

  • Commit:

    df04abfd181a ("fs/proc/kcore.c: Add bounce buffer for ktext data")

    ... introduced a bounce buffer to work around CONFIG_HARDENED_USERCOPY=y.
    However, accessing the vsyscall user page will cause an SMAP fault.

    Replace memcpy() with copy_from_user() to fix this bug works, but adding
    a common way to handle this sort of user page may be useful for future.

    Currently, only vsyscall page requires KCORE_USER.

    Signed-off-by: Jia Zhang
    Reviewed-by: Jiri Olsa
    Cc: Al Viro
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: jolsa@redhat.com
    Link: http://lkml.kernel.org/r/1518446694-21124-2-git-send-email-zhang.jia@linux.alibaba.com
    Signed-off-by: Ingo Molnar

    Jia Zhang
     

07 Feb, 2018

1 commit

  • Commit df04abfd181a ("fs/proc/kcore.c: Add bounce buffer for ktext
    data") added a bounce buffer to avoid hardened usercopy checks. Copying
    to the bounce buffer was implemented with a simple memcpy() assuming
    that it is always valid to read from kernel memory iff the
    kern_addr_valid() check passed.

    A simple, but pointless, test case like "dd if=/proc/kcore of=/dev/null"
    now can easily crash the kernel, since the former execption handling on
    invalid kernel addresses now doesn't work anymore.

    Also adding a kern_addr_valid() implementation wouldn't help here. Most
    architectures simply return 1 here, while a couple implemented a page
    table walk to figure out if something is mapped at the address in
    question.

    With DEBUG_PAGEALLOC active mappings are established and removed all the
    time, so that relying on the result of kern_addr_valid() before
    executing the memcpy() also doesn't work.

    Therefore simply use probe_kernel_read() to copy to the bounce buffer.
    This also allows to simplify read_kcore().

    At least on s390 this fixes the observed crashes and doesn't introduce
    warnings that were removed with df04abfd181a ("fs/proc/kcore.c: Add
    bounce buffer for ktext data"), even though the generic
    probe_kernel_read() implementation uses uaccess functions.

    While looking into this I'm also wondering if kern_addr_valid() could be
    completely removed...(?)

    Link: http://lkml.kernel.org/r/20171202132739.99971-1-heiko.carstens@de.ibm.com
    Fixes: df04abfd181a ("fs/proc/kcore.c: Add bounce buffer for ktext data")
    Fixes: f5509cc18daa ("mm: Hardened usercopy")
    Signed-off-by: Heiko Carstens
    Acked-by: Kees Cook
    Cc: Jiri Olsa
    Cc: Al Viro
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

20 Jun, 2017

1 commit

  • Instead of passing each start address into is_vmalloc_or_module_addr()
    to decide whether it falls into either the VMALLOC or the MODULES region,
    we can simply check the type field of the current kcore_list entry, since
    it will be set to KCORE_VMALLOC based on exactly the same conditions.

    As a bonus, when reading the KCORE_TEXT region on architectures that have
    one, this will avoid using vread() on the region if it happens to intersect
    with a KCORE_VMALLOC region. This is due the fact that the KCORE_TEXT
    region is the first one to be added to the kcore region list.

    Reported-by: Tan Xiaojun
    Tested-by: Tan Xiaojun
    Tested-by: Mark Rutland
    Acked-by: Mark Rutland
    Reviewed-by: Laura Abbott
    Reviewed-by: Jiri Olsa
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon

    Ard Biesheuvel
     

02 Mar, 2017

1 commit


28 Feb, 2017

1 commit

  • Currently all the p_paddr of PT_LOAD headers are assigned to 0, which is
    not true and could be misleading, since 0 is a valid physical address.

    User space tools like makedumpfile needs to know physical address for
    PT_LOAD segments of direct mapped regions. Therefore this patch updates
    paddr for such regions. It also sets an invalid paddr (-1) for other
    regions, so that user space tool can know whether a physical address
    provided in PT_LOAD is correct or not.

    I do not know why it was 0, which is a valid physical address. But
    certainly, it might break some user space tools, and those need to be
    fixed. For example, see following code from kexec-tools

    kexec/kexec-elf.c:build_mem_phdrs()

    if ((phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) {
    /* The memory address wraps */
    if (probe_debug) {
    fprintf(stderr, "ELF address wrap around\n");
    }
    return -1;
    }

    We do not need to perform above check for an invalid physical address.

    I think, kexec-tools and makedumpfile will need fixup. I already have
    those fixup which will be sent upstream once this patch makes through.
    Pro with this approach is that, it will help to calculate variable like
    page_offset, phys_base from PT_LOAD even when they are randomized and
    therefore will reduce many variable and version specific values in user
    space tools.

    Having an ASLR offset information can help to translate an identity
    mapped virtual address to a physical address. But that would be an
    additional field in PT_LOAD header structure and an arch dependent
    value.

    Moreover, sending a valid physical address like 0 does not seem right.
    So, IMHO it is better to fix that and send valid physical address when
    available (identity mapped).

    Link: http://lkml.kernel.org/r/f951340d2917cdd2a329fae9837a83f2059dc3b2.1485318868.git.panand@redhat.com
    Signed-off-by: Pratyush Anand
    Cc: Baoquan He
    Cc: Dave Young
    Cc: Dave Anderson
    Cc: Atsushi Kumagai
    Cc: Simon Horman
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pratyush Anand
     

25 Dec, 2016

1 commit


21 Sep, 2016

2 commits

  • We hit hardened usercopy feature check for kernel text access by reading
    kcore file:

    usercopy: kernel memory exposure attempt detected from ffffffff8179a01f () (4065 bytes)
    kernel BUG at mm/usercopy.c:75!

    Bypassing this check for kcore by adding bounce buffer for ktext data.

    Reported-by: Steve Best
    Fixes: f5509cc18daa ("mm: Hardened usercopy")
    Suggested-by: Kees Cook
    Signed-off-by: Jiri Olsa
    Acked-by: Kees Cook
    Signed-off-by: Linus Torvalds

    Jiri Olsa
     
  • Next patch adds bounce buffer for ktext area, so it's
    convenient to have single bounce buffer for both
    vmalloc/module and ktext cases.

    Suggested-by: Linus Torvalds
    Signed-off-by: Jiri Olsa
    Acked-by: Kees Cook
    Signed-off-by: Linus Torvalds

    Jiri Olsa
     

23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

18 Jul, 2015

2 commits

  • Don't burden architectures without dynamic task_struct sizing
    with the overhead of dynamic sizing.

    Also optimize the x86 code a bit by caching task_struct_size.

    Acked-and-Tested-by: Dave Hansen
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Dave Hansen
    Cc: Denys Vlasenko
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1437128892-9831-3-git-send-email-mingo@kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • The FPU rewrite removed the dynamic allocations of 'struct fpu'.
    But, this potentially wastes massive amounts of memory (2k per
    task on systems that do not have AVX-512 for instance).

    Instead of having a separate slab, this patch just appends the
    space that we need to the 'task_struct' which we dynamically
    allocate already. This saves from doing an extra slab
    allocation at fork().

    The only real downside here is that we have to stick everything
    and the end of the task_struct. But, I think the
    BUILD_BUG_ON()s I stuck in there should keep that from being too
    fragile.

    Signed-off-by: Dave Hansen
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Dave Hansen
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1437128892-9831-2-git-send-email-mingo@kernel.org
    Signed-off-by: Ingo Molnar

    Dave Hansen
     

10 Oct, 2014

1 commit

  • On some ARCHs modules range is eauql to vmalloc range. E.g on i686

    "#define MODULES_VADDR VMALLOC_START"
    "#define MODULES_END VMALLOC_END"

    This will cause 2 duplicate program segments in /proc/kcore, and no flag
    to indicate they are different. This is confusing. And usually people
    who need check the elf header or read the content of kcore will check
    memory ranges. Two program segments which are the same are unnecessary.

    So check if the modules range is equal to vmalloc range. If so, just skip
    adding the modules range.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Baoquan He
    Cc: Xishi Qiu
    Cc: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Baoquan He
     

09 Aug, 2014

1 commit


24 Jan, 2014

1 commit

  • PROC_FS is a bool, so this code is either present or absent. It will
    never be modular, so using module_init as an alias for __initcall is
    rather misleading.

    Fix this up now, so that we can relocate module_init from init.h into
    module.h in the future. If we don't do this, we'd have to add module.h to
    obviously non-modular code, and that would be ugly at best.

    Note that direct use of __initcall is discouraged, vs. one of the
    priority categorized subgroups. As __initcall gets mapped onto
    device_initcall, our use of fs_initcall (which makes sense for fs code)
    will thus change these registrations from level 6-device to level 5-fs
    (i.e. slightly earlier). However no observable impact of that small
    difference has been observed during testing, or is expected.

    Also note that this change uncovers a missing semicolon bug in the
    registration of vmcore_init as an initcall.

    Signed-off-by: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Gortmaker
     

13 Nov, 2013

1 commit


04 Jul, 2013

1 commit


02 May, 2013

2 commits

  • Pull VFS updates from Al Viro,

    Misc cleanups all over the place, mainly wrt /proc interfaces (switch
    create_proc_entry to proc_create(), get rid of the deprecated
    create_proc_read_entry() in favor of using proc_create_data() and
    seq_file etc).

    7kloc removed.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
    don't bother with deferred freeing of fdtables
    proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
    proc: Make the PROC_I() and PDE() macros internal to procfs
    proc: Supply a function to remove a proc entry by PDE
    take cgroup_open() and cpuset_open() to fs/proc/base.c
    ppc: Clean up scanlog
    ppc: Clean up rtas_flash driver somewhat
    hostap: proc: Use remove_proc_subtree()
    drm: proc: Use remove_proc_subtree()
    drm: proc: Use minor->index to label things, not PDE->name
    drm: Constify drm_proc_list[]
    zoran: Don't print proc_dir_entry data in debug
    reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
    proc: Supply an accessor for getting the data from a PDE's parent
    airo: Use remove_proc_subtree()
    rtl8192u: Don't need to save device proc dir PDE
    rtl8187se: Use a dir under /proc/net/r8180/
    proc: Add proc_mkdir_data()
    proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
    proc: Move PDE_NET() to fs/proc/proc_net.c
    ...

    Linus Torvalds
     
  • Move non-public declarations and definitions from linux/proc_fs.h to
    fs/proc/internal.h.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     

30 Apr, 2013

1 commit