12 Dec, 2020

1 commit

  • There is only one function in init/initramfs.c that is in the .text
    section, and it is marked __weak. When building with clang-12 and the
    integrated assembler, this leads to a bug with recordmcount:

    ./scripts/recordmcount "init/initramfs.o"
    Cannot find symbol for section 2: .text.
    init/initramfs.o: failed

    I'm not quite sure what exactly goes wrong, but I notice that this
    function is only ever called from an __init function, and normally
    inlined. Marking it __init as well is clearly correct and it leads to
    recordmcount no longer complaining.

    Link: https://lkml.kernel.org/r/20201204165742.3815221-1-arnd@kernel.org
    Signed-off-by: Arnd Bergmann
    Cc: Nathan Chancellor
    Cc: Nick Desaulniers
    Cc: Barret Rhoden
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

05 Sep, 2020

1 commit

  • init_stat() returns 0 on success, same as vfs_lstat(). When it replaced
    vfs_lstat(), the '!' was dropped.

    Fixes: 716308a5331b ("init: add an init_stat helper")
    Signed-off-by: Barret Rhoden
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Linus Torvalds

    Barret Rhoden
     

31 Jul, 2020

12 commits


30 Jul, 2020

2 commits


10 May, 2020

1 commit

  • It seems that for whatever reason, gcc-10 ends up not inlining a couple
    of functions that used to be inlined before. Even if they only have one
    single callsite - it looks like gcc may have decided that the code was
    unlikely, and not worth inlining.

    The code generation difference is harmless, but caused a few new section
    mismatch errors, since the (now no longer inlined) function wasn't in
    the __init section, but called other init functions:

    Section mismatch in reference from the function kexec_free_initrd() to the function .init.text:free_initrd_mem()
    Section mismatch in reference from the function tpm2_calc_event_log_size() to the function .init.text:early_memremap()
    Section mismatch in reference from the function tpm2_calc_event_log_size() to the function .init.text:early_memunmap()

    So add the appropriate __init annotation to make modpost not complain.
    In both cases there were trivially just a single callsite from another
    __init function.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

16 Oct, 2019

1 commit

  • arm64 calls memblock_free() for the initrd area in its implementation of
    free_initrd_mem(), but this call has no actual effect that late in the boot
    process. By the time initrd is freed, all the reserved memory is managed by
    the page allocator and the memblock.reserved is unused, so the only purpose
    of the memblock_free() call is to keep track of initrd memory for debugging
    and accounting.

    Without the memblock_free() call the only difference between arm64 and the
    generic versions of free_initrd_mem() is the memory poisoning.

    Move memblock_free() call to the generic code, enable it there
    for the architectures that define ARCH_KEEP_MEMBLOCK and use the generic
    implementation of free_initrd_mem() on arm64.

    Tested-by: Anshuman Khandual #arm64
    Reviewed-by: Anshuman Khandual
    Acked-by: Will Deacon
    Signed-off-by: Mike Rapoport
    Signed-off-by: Catalin Marinas

    Mike Rapoport
     

29 Jun, 2019

1 commit

  • With gcc-4.6.3:

    WARNING: vmlinux.o(.text.unlikely+0x140): Section mismatch in reference from the function populate_initrd_image() to the variable .init.ramfs.info:__initramfs_size
    The function populate_initrd_image() references
    the variable __init __initramfs_size.
    This is often because populate_initrd_image lacks a __init
    annotation or the annotation of __initramfs_size is wrong.

    WARNING: vmlinux.o(.text.unlikely+0x14c): Section mismatch in reference from the function populate_initrd_image() to the function .init.text:unpack_to_rootfs()
    The function populate_initrd_image() references
    the function __init unpack_to_rootfs().
    This is often because populate_initrd_image lacks a __init
    annotation or the annotation of unpack_to_rootfs is wrong.

    WARNING: vmlinux.o(.text.unlikely+0x198): Section mismatch in reference from the function populate_initrd_image() to the function .init.text:xwrite()
    The function populate_initrd_image() references
    the function __init xwrite().
    This is often because populate_initrd_image lacks a __init
    annotation or the annotation of xwrite is wrong.

    Indeed, if the compiler decides not to inline populate_initrd_image(), a
    warning is generated.

    Fix this by adding the missing __init annotations.

    Link: http://lkml.kernel.org/r/20190617074340.12779-1-geert@linux-m68k.org
    Fixes: 7c184ecd262fe64f ("initramfs: factor out a helper to populate the initrd image")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Geert Uytterhoeven
     

19 May, 2019

1 commit

  • Since commit 54c7a8916a88 ("initramfs: free initrd memory if opening
    /initrd.image fails"), the kernel has unconditionally attempted to free
    the initrd even if it doesn't exist.

    In the non-existent case this causes a boot-time splat if
    CONFIG_DEBUG_VIRTUAL is enabled due to a call to virt_to_phys() with a
    NULL address.

    Instead we should check that the initrd actually exists and only attempt
    to free it if it does.

    Link: http://lkml.kernel.org/r/20190516143125.48948-1-steven.price@arm.com
    Fixes: 54c7a8916a88 ("initramfs: free initrd memory if opening /initrd.image fails")
    Signed-off-by: Steven Price
    Reported-by: Mark Rutland
    Tested-by: Mark Rutland
    Reviewed-by: Mike Rapoport
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Steven Price
     

15 May, 2019

7 commits

  • Various architectures including x86 poison the freed initrd memory. Do
    the same in the generic free_initrd_mem implementation and switch a few
    more architectures that are identical to the generic code over to it now.

    Link: http://lkml.kernel.org/r/20190213174621.29297-9-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Acked-by: Mike Rapoport
    Cc: Catalin Marinas [arm64]
    Cc: Geert Uytterhoeven [m68k]
    Cc: Steven Price
    Cc: Alexander Viro
    Cc: Guan Xuetao
    Cc: Russell King
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • For most architectures free_initrd_mem just expands to the same
    free_reserved_area call. Provide that as a generic implementation marked
    __weak.

    Link: http://lkml.kernel.org/r/20190213174621.29297-8-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Acked-by: Geert Uytterhoeven [m68k]
    Acked-by: Mike Rapoport
    Cc: Catalin Marinas [arm64]
    Cc: Steven Price
    Cc: Alexander Viro
    Cc: Guan Xuetao
    Cc: Russell King
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • No need to handle the freeing disable in arch code when we already have a
    core hook (and a different name for the option) for it.

    Link: http://lkml.kernel.org/r/20190213174621.29297-7-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Acked-by: Catalin Marinas [arm64]
    Acked-by: Mike Rapoport
    Cc: Geert Uytterhoeven [m68k]
    Cc: Steven Price
    Cc: Alexander Viro
    Cc: Guan Xuetao
    Cc: Russell King
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • The code for kernels that support ramdisks or not is mostly the same.
    Unify it by using an IS_ENABLED for the info message, and moving the error
    message into a stub for populate_initrd_image.

    [cai@lca.pw: fix a compilation error]
    Link: http://lkml.kernel.org/r/20190328014806.36375-1-cai@lca.pw
    Link: http://lkml.kernel.org/r/20190213174621.29297-6-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Qian Cai
    Acked-by: Mike Rapoport
    Cc: Catalin Marinas [arm64]
    Cc: Geert Uytterhoeven [m68k]
    Cc: Steven Price
    Cc: Alexander Viro
    Cc: Guan Xuetao
    Cc: Russell King
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • This will allow for cleaner code sharing in the caller.

    Link: http://lkml.kernel.org/r/20190213174621.29297-5-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Acked-by: Mike Rapoport
    Cc: Catalin Marinas [arm64]
    Cc: Geert Uytterhoeven [m68k]
    Cc: Steven Price
    Cc: Alexander Viro
    Cc: Guan Xuetao
    Cc: Russell King
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • Factor the kexec logic into a separate helper, and then inline the rest of
    free_initrd into the only caller.

    Link: http://lkml.kernel.org/r/20190213174621.29297-4-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Acked-by: Mike Rapoport
    Cc: Catalin Marinas [arm64]
    Cc: Geert Uytterhoeven [m68k]
    Cc: Steven Price
    Cc: Alexander Viro
    Cc: Guan Xuetao
    Cc: Russell King
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • Patch series "initramfs tidyups".

    I've spent some time chasing down behavior in initramfs and found
    plenty of opportunity to improve the code. A first stab on that is
    contained in this series.

    This patch (of 7):

    We free the initrd memory for all successful or error cases except for the
    case where opening /initrd.image fails, which looks like an oversight.

    Steven said:

    : This also changes the behaviour when CONFIG_INITRAMFS_FORCE is enabled
    : - specifically it means that the initrd is freed (previously it was
    : ignored and never freed). But that seems like reasonable behaviour and
    : the previous behaviour looks like another oversight.

    Link: http://lkml.kernel.org/r/20190213174621.29297-3-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Steven Price
    Acked-by: Mike Rapoport
    Cc: Catalin Marinas [arm64]
    Cc: Geert Uytterhoeven [m68k]
    Cc: Alexander Viro
    Cc: Russell King
    Cc: Will Deacon
    Cc: Guan Xuetao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

08 Mar, 2019

1 commit

  • Use distinct error messages when archive decompression failed.

    Link: http://lkml.kernel.org/r/20190212075635.7373-1-david.engraf@sysgo.com
    Signed-off-by: David Engraf
    Reviewed-by: Andrew Morton
    Tested-by: Andy Shevchenko
    Cc: Dominik Brodowski
    Cc: Greg Kroah-Hartman
    Cc: Philippe Ombredanne
    Cc: Arnd Bergmann
    Cc: Luc Van Oostenryck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Engraf
     

22 Feb, 2019

1 commit

  • Revert ff1522bb7d9845 ("initramfs: cleanup incomplete rootfs").

    Andy reports

    : This breaks my setup where I have U-boot provided more size of initramfs
    : than needed. This allows a bit of flexibility to increase or decrease
    : initramfs compressed image without taking care of bootloader. The proper
    : solution is to do this if we sure that we didn't get enough memory,
    : otherwise I can't consider the error fatal to clean up rootfs.

    Fixes: ff1522bb7d9845 ("initramfs: cleanup incomplete rootfs")
    Reported-by: Andy Shevchenko
    Tested-by: Andy Shevchenko
    Cc: David Engraf
    Cc: Dominik Brodowski
    Cc: Greg Kroah-Hartman
    Cc: Philippe Ombredanne
    Cc: Arnd Bergmann
    Cc: Luc Van Oostenryck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

05 Jan, 2019

1 commit

  • Unpacking an external initrd may fail e.g. not enough memory. This
    leads to an incomplete rootfs because some files might be extracted
    already. Fixed by cleaning the rootfs so the kernel is not using an
    incomplete rootfs.

    Link: http://lkml.kernel.org/r/20181030151805.5519-1-david.engraf@sysgo.com
    Signed-off-by: David Engraf
    Cc: Dominik Brodowski
    Cc: Greg Kroah-Hartman
    Cc: Philippe Ombredanne
    Cc: Arnd Bergmann
    Cc: Luc Van Oostenryck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Engraf
     

05 Dec, 2018

1 commit

  • Pull in v4.20-rc5, solving a conflict we'll otherwise get in aio.c and
    also getting the merge fix that went into mainline that users are
    hitting testing for-4.21/block and/or for-next.

    * tag 'v4.20-rc5': (664 commits)
    Linux 4.20-rc5
    PCI: Fix incorrect value returned from pcie_get_speed_cap()
    MAINTAINERS: Update linux-mips mailing list address
    ocfs2: fix potential use after free
    mm/khugepaged: fix the xas_create_range() error path
    mm/khugepaged: collapse_shmem() do not crash on Compound
    mm/khugepaged: collapse_shmem() without freezing new_page
    mm/khugepaged: minor reorderings in collapse_shmem()
    mm/khugepaged: collapse_shmem() remember to clear holes
    mm/khugepaged: fix crashes due to misaccounted holes
    mm/khugepaged: collapse_shmem() stop if punched or truncated
    mm/huge_memory: fix lockdep complaint on 32-bit i_size_read()
    mm/huge_memory: splitting set mapping+index before unfreeze
    mm/huge_memory: rename freeze_page() to unmap_page()
    initramfs: clean old path before creating a hardlink
    kernel/kcov.c: mark funcs in __sanitizer_cov_trace_pc() as notrace
    psi: make disabling/enabling easier for vendor kernels
    proc: fixup map_files test on arm
    debugobjects: avoid recursive calls with kmemleak
    userfaultfd: shmem: UFFDIO_COPY: set the page dirty if VM_WRITE is not set
    ...

    Jens Axboe
     

01 Dec, 2018

1 commit

  • sys_link() can fail due to the new path already existing. This case
    ofen occurs when we use a concated initrd, for example:

    1) prepare a basic rootfs, it contains a regular files rc.local
    lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
    #!/bin/sh
    echo "Running /etc/rc.local..."
    yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n -9 >../rootfs.cgz

    2) create a extra initrd which also includes a etc/rc.local
    lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
    lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
    append initrd
    lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
    append initrd
    lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
    File: 'rc.local'
    Size: 14 Blocks: 8 IO Block: 4096 regular file
    Device: 801h/2049d Inode: 11296086 Links: 2
    Access: (0664/-rw-rw-r--) Uid: ( 1002/lizhijian) Gid: ( 1002/lizhijian)
    Access: 2018-11-15 16:08:28.654464815 +0800
    Modify: 2018-11-15 16:07:57.514903210 +0800
    Change: 2018-11-15 16:08:24.180228872 +0800
    Birth: -
    File: 'rc.local.hardlink'
    Size: 14 Blocks: 8 IO Block: 4096 regular file
    Device: 801h/2049d Inode: 11296086 Links: 2
    Access: (0664/-rw-rw-r--) Uid: ( 1002/lizhijian) Gid: ( 1002/lizhijian)
    Access: 2018-11-15 16:08:28.654464815 +0800
    Modify: 2018-11-15 16:07:57.514903210 +0800
    Change: 2018-11-15 16:08:24.180228872 +0800
    Birth: -

    lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n -9 >../rc-local.cgz
    lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
    .
    etc
    etc/rc.local.hardlink <<< it will be extracted first at this initrd
    etc/rc.local

    3) concate 2 initrds and boot
    lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
    lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 1024 -kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 earlyprint=ttyS0 ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio -nodefaults

    In this case, sys_link(2) will fail and return -EEXIST, so we can only get
    the rc.local at rootfs.cgz instead of rc-local.cgz

    [akpm@linux-foundation.org: move code to avoid forward declaration]
    Link: http://lkml.kernel.org/r/1542352368-13299-1-git-send-email-lizhijian@cn.fujitsu.com
    Signed-off-by: Li Zhijian
    Cc: Philip Li
    Cc: Dominik Brodowski
    Cc: Li Zhijian
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zhijian
     

08 Nov, 2018

1 commit

  • This removes a bunch of core and elevator related code. On the core
    front, we remove anything related to queue running, draining,
    initialization, plugging, and congestions. We also kill anything
    related to request allocation, merging, retrieval, and completion.

    Remove any checking for single queue IO schedulers, as they no
    longer exist. This means we can also delete a bunch of code related
    to request issue, adding, completion, etc - and all the SQ related
    ops and helpers.

    Also kill the load_default_modules(), as all that did was provide
    for a way to load the default single queue elevator.

    Tested-by: Ming Lei
    Reviewed-by: Omar Sandoval
    Signed-off-by: Jens Axboe

    Jens Axboe
     

23 Aug, 2018

1 commit

  • Sparse checking used to be disabled on init/do_mounts.c and a few related
    files because "Many of the syscalls used in this file expect some of the
    arguments to be __user pointers not __kernel pointers".

    However since 28128c61e ("kconfig.h: Include compiler types to avoid
    missed struct attributes") the checks are, in fact, not disabled anymore
    because of the more early include of "linux/compiler_types.h"

    So remove the now ineffective #undefery that was done to disable these
    warnings, as well as the associated comment.

    Link: http://lkml.kernel.org/r/20180617115355.53799-1-luc.vanoostenryck@gmail.com
    Signed-off-by: Luc Van Oostenryck
    Cc: Dominik Brodowski
    Cc: Al Viro
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luc Van Oostenryck
     

03 Apr, 2018

6 commits

  • Using this helper allows us to avoid the in-kernel calls to the
    sys_getdents64() syscall. The ksys_ prefix denotes that this function
    is meant as a drop-in replacement for the syscall. In particular, it
    uses the same calling convention as sys_getdents64().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Alexander Viro
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • Using this wrapper allows us to avoid the in-kernel calls to the
    sys_open() syscall. The ksys_ prefix denotes that this function is meant
    as a drop-in replacement for the syscall. In particular, it uses the
    same calling convention as sys_open().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Al Viro
    Cc: Andrew Morton
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • Using the ksys_close() wrapper allows us to get rid of in-kernel calls
    to the sys_close() syscall. The ksys_ prefix denotes that this function
    is meant as a drop-in replacement for the syscall. In particular, it
    uses the same calling convention as sys_close(), with one subtle
    difference:

    The few places which checked the return value did not care about the return
    value re-writing in sys_close(), so simply use a wrapper around
    __close_fd().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Al Viro
    Cc: Andrew Morton
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • Using the ksys_ftruncate() wrapper allows us to get rid of in-kernel
    calls to the sys_ftruncate() syscall. The ksys_ prefix denotes that this
    function is meant as a drop-in replacement for the syscall. In
    particular, it uses the same calling convention as sys_ftruncate().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Al Viro
    Cc: Andrew Morton
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • Using the fs-interal do_fchownat() wrapper allows us to get rid of
    fs-internal calls to the sys_fchownat() syscall.

    Introducing the ksys_fchown() helper and the ksys_{,}chown() wrappers
    allows us to avoid the in-kernel calls to the sys_{,l,f}chown() syscalls.
    The ksys_ prefix denotes that these functions are meant as a drop-in
    replacement for the syscalls. In particular, they use the same calling
    convention as sys_{,l,f}chown().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Al Viro
    Cc: Andrew Morton
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • … in-kernel calls to syscall

    Using the fs-internal do_fchmodat() helper allows us to get rid of
    fs-internal calls to the sys_fchmodat() syscall.

    Introducing the ksys_fchmod() helper and the ksys_chmod() wrapper allows
    us to avoid the in-kernel calls to the sys_fchmod() and sys_chmod()
    syscalls. The ksys_ prefix denotes that these functions are meant as a
    drop-in replacement for the syscalls. In particular, they use the same
    calling convention as sys_fchmod() and sys_chmod().

    This patch is part of a series which removes in-kernel calls to syscalls.
    On this basis, the syscall entry path can be streamlined. For details, see
    http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>

    Dominik Brodowski