15 Sep, 2018

1 commit

  • [ Upstream commit df865e8337c397471b95f51017fea559bc8abb4a ]

    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
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    James Morse
     

21 Jun, 2018

1 commit

  • [ Upstream commit 3955333df9a50e8783d115613a397ae55d905080 ]

    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
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Laura Abbott
     

26 Apr, 2018

1 commit

  • [ Upstream commit 595dd46ebfc10be041a365d0a3fa99df50b6ba73 ]

    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
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jia Zhang
     

17 Feb, 2018

1 commit

  • commit d0290bc20d4739b7a900ae37eb5d4cc3be2b393f upstream.

    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
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    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

2 commits


28 Feb, 2013

1 commit

  • - use pr_foo() throughout

    - remove a couple of duplicated KERN_WARNINGs, via WARN(KERN_WARNING "...")

    - nuke a few warnings which I've never seen happen, ever.

    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

13 Dec, 2012

1 commit

  • N_HIGH_MEMORY stands for the nodes that has normal or high memory.
    N_MEMORY stands for the nodes that has any memory.

    The code here need to handle with the nodes which have memory, we should
    use N_MEMORY instead.

    Signed-off-by: Lai Jiangshan
    Acked-by: Hillf Danton
    Signed-off-by: Wen Congyang
    Cc: Christoph Lameter
    Cc: Lin Feng
    Cc: David Rientjes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lai Jiangshan
     

24 Mar, 2012

1 commit


20 Mar, 2012

1 commit


14 Jan, 2011

1 commit

  • Commit 34aacb2920 ("procfs: Use generic_file_llseek in /proc/kcore") broke
    seeking on /proc/kcore. This changes it back to use default_llseek in
    order to restore the original behavior.

    The problem with generic_file_llseek is that it only allows seeks up to
    inode->i_sb->s_maxbytes, which is 2GB-1 on procfs, where the memory file
    offset values in the /proc/kcore PT_LOAD segments may exceed or start
    beyond that offset value.

    A similar revert was made for /proc/vmcore.

    Signed-off-by: Dave Anderson
    Acked-by: Frederic Weisbecker
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dave Anderson
     

28 May, 2010

1 commit

  • Extend KCORE_TEXT to cover the pages between _text and _stext, to allow
    examining some important page table pages.

    `readelf -a` output on x86_64 before and after patch:
    Type Offset VirtAddr PhysAddr
    before LOAD 0x00007fff8100c000 0xffffffff81009000 0x0000000000000000
    after LOAD 0x00007fff81003000 0xffffffff81000000 0x0000000000000000

    The newly covered pages are:

    0xffffffff81000000 etc.
    0xffffffff81001000
    0xffffffff81002000
    0xffffffff81003000
    0xffffffff81004000
    0xffffffff81005000
    0xffffffff81006000
    0xffffffff81007000
    0xffffffff81008000

    Before patch, /proc/kcore shows outdated contents for the above page
    table pages, for example:

    (gdb) p level3_ident_pgt
    $1 = {} 0xffffffff81002000
    (gdb) p/x *((pud_t *)&level3_ident_pgt)@512
    $2 = {{pud = 0x1006063}, {pud = 0x0} }

    while the real content is:

    root@hp /home/wfg# hexdump -s 0x1002000 -n 4096 /dev/mem
    1002000 6063 0100 0000 0000 8067 0000 0000 0000
    1002010 0000 0000 0000 0000 0000 0000 0000 0000
    *
    1003000

    That is, on a x86_64 box with 2GB memory, we can see first-1GB / full-2GB
    identity mapping before/after patch:

    (gdb) p/x *((pud_t *)&level3_ident_pgt)@512
    before $1 = {{pud = 0x1006063}, {pud = 0x0} }
    after $1 = {{pud = 0x1006063}, {pud = 0x8067}, {pud = 0x0} }

    Obviously the content before patch is wrong.

    Signed-off-by: Wu Fengguang
    Cc: Andi Kleen
    Cc: KAMEZAWA Hiroyuki
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wu Fengguang
     

20 May, 2010

1 commit


09 Apr, 2010

1 commit

  • /proc/kcore has no llseek and then falls down to use default_llseek.
    This is racy against read_kcore() that directly manipulates fpos
    but it doesn't hold the bkl there so using it in llseek doesn't
    protect anything.

    Let's use generic_file_llseek() instead.

    Signed-off-by: Frederic Weisbecker
    Acked-by: Arnd Bergmann
    Cc: Thomas Gleixner
    Cc: Andrew Morton
    Cc: Ingo Molnar
    Cc: John Kacur
    Cc: KAMEZAWA Hiroyuki
    Cc: Al Viro

    Frederic Weisbecker
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

25 Mar, 2010

1 commit

  • "m" is never NULL here. We need a different test for the end of list
    condition.

    Signed-off-by: Dan Carpenter
    Acked-by: KAMEZAWA Hiroyuki
    Acked-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Carpenter
     

08 Oct, 2009

1 commit


23 Sep, 2009

6 commits

  • After memory hotplug (or other events in future), kcore size can be
    modified.

    To update inode->i_size, we have to know inode/dentry but we can't get it
    from inside /proc directly. But considerinyg memory hotplug, kcore image
    is updated only when it's opened. Then, updating inode->i_size at open()
    is enough.

    Signed-off-by: KAMEZAWA Hiroyuki
    Acked-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • Presently the size of /proc/kcore which can be read by 'ls -l' is 0. But
    it's not the correct value.

    On x86-64, ls -l shows
    ... root root 140737486266368 2009-09-17 10:29 /proc/kcore
    Then, 7FFFFFFE02000. This comes from vmalloc area's size.
    (*) This shows "core" size, not memory size.

    This patch shows the size by updating "size" field in struct
    proc_dir_entry. Later, lookup routine will create inode and fill
    inode->i_size based on this value. Then, this has a problem.

    - Once inode is cached, inode->i_size will never be updated.

    Then, this patch is not memory-hotplug-aware.

    To update inode->i_size, we have to know dentry or inode.
    But there is no way to lookup them by inside kernel. Hmmm....
    Next patch will try it.

    Signed-off-by: KAMEZAWA Hiroyuki
    Acked-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • proc_kcore_init() doesn't check NULL case. fix it and remove unnecessary
    comments.

    Signed-off-by: KAMEZAWA Hiroyuki
    Acked-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • Some archs define MODULED_VADDR/MODULES_END which is not in VMALLOC area.
    This is handled only in x86-64. This patch make it more generic. And we
    can use vread/vwrite to access the area. Fix it.

    Signed-off-by: KAMEZAWA Hiroyuki
    Cc: Jiri Slaby
    Cc: Ralf Baechle
    Cc: Benjamin Herrenschmidt
    Cc: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • Benjamin Herrenschmidt pointed out that vmemmap
    range is not included in KCORE_RAM, KCORE_VMALLOC ....

    This adds KCORE_VMEMMAP if SPARSEMEM_VMEMMAP is used. By this, vmemmap
    can be readable via /proc/kcore

    Because it's not vmalloc area, vread/vwrite cannot be used. But the range
    is static against the memory layout, this patch handles vmemmap area by
    the same scheme with physical memory.

    This patch assumes SPARSEMEM_VMEMMAP range is not in VMALLOC range. It's
    correct now.

    [akpm@linux-foundation.org: fix typo]
    Signed-off-by: KAMEZAWA Hiroyuki
    Cc: Jiri Slaby
    Cc: Ralf Baechle
    Cc: Benjamin Herrenschmidt
    Cc: WANG Cong
    Cc: Benjamin Herrenschmidt
    Cc: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • For /proc/kcore, each arch registers its memory range by kclist_add().
    In usual,

    - range of physical memory
    - range of vmalloc area
    - text, etc...

    are registered but "range of physical memory" has some troubles. It
    doesn't updated at memory hotplug and it tend to include unnecessary
    memory holes. Now, /proc/iomem (kernel/resource.c) includes required
    physical memory range information and it's properly updated at memory
    hotplug. Then, it's good to avoid using its own code(duplicating
    information) and to rebuild kclist for physical memory based on
    /proc/iomem.

    Signed-off-by: KAMEZAWA Hiroyuki
    Signed-off-by: Jiri Slaby
    Cc: Ralf Baechle
    Cc: Benjamin Herrenschmidt
    Cc: WANG Cong
    Cc: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki