Skip to content
Snippets Groups Projects
  1. Apr 30, 2024
  2. Feb 08, 2024
  3. Dec 07, 2023
  4. Oct 19, 2023
    • Jianyong Wu's avatar
      init/mount: print pretty name of root device when panics · 84d2b696
      Jianyong Wu authored
      
      Given a wrong root device, current log may not give the pretty name
      which is useful to locate root cause.
      
      For example, there are 2 blk devs in a VM, /dev/vda which has 2 partitials
      /dev/vda1 and /dev/vda2 and /dev/vdb which is blank. /dev/vda2 is the
      right root dev. When set "root=/dev/vdb", we get error log:
      
      [    0.635575] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,16)
      
      It's not straightforward to find out the root cause as there is lack of
      the root devive name therefore hard for people to get those info from the
      device number, in the example, (254,16).
      
      It is more comprehensive way to hint the root cause if pretty name is
      given here, like:
      
      [    0.559887] Kernel panic - not syncing: VFS: Unable to mount root fs on "/dev/vdb" or unknown-block(254,16)
      
      Signed-off-by: default avatarJianyong Wu <jianyong.wu@arm.com>
      Message-Id: <20230907091025.3436878-1-jianyong.wu@arm.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      84d2b696
  5. Aug 15, 2023
    • Loic Poulain's avatar
      init: Add support for rootwait timeout parameter · 45071e1c
      Loic Poulain authored
      
      Add an optional timeout arg to 'rootwait' as the maximum time in
      seconds to wait for the root device to show up before attempting
      forced mount of the root filesystem.
      
      Use case:
      In case of device mapper usage for the rootfs (e.g. root=/dev/dm-0),
      if the mapper is not able to create the virtual block for any reason
      (wrong arguments, bad dm-verity signature, etc), the `rootwait` param
      causes the kernel to wait forever. It may however be desirable to only
      wait for a given time and then panic (force mount) to cause device reset.
      This gives the bootloader a chance to detect the problem and to take some
      measures, such as marking the booted partition as bad (for A/B case) or
      entering a recovery mode.
      
      In success case, mounting happens as soon as the root device is ready,
      unlike the existing 'rootdelay' parameter which performs an unconditional
      pause.
      
      Signed-off-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      Message-Id: <20230813082349.513386-1-loic.poulain@linaro.org>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      45071e1c
  6. Jun 10, 2023
    • Angus Chen's avatar
      init: add bdev fs printk if mount_block_root failed · 6aee6723
      Angus Chen authored
      Booting with the QEMU command line:
      "qemu-system-x86_64 -append root=/dev/vda rootfstype=ext4 ..."
      will panic if ext4 is not builtin and a request to load the ext4 module
      fails.
      
      [    1.729006] VFS: Cannot open root device "vda" or unknown-block(253,0): error -19
      [    1.730603] Please append a correct "root=" boot option; here are the available partitions:
      [    1.732323] fd00          256000 vda
      [    1.732329]  driver: virtio_blk
      [    1.734194] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(253,0)
      [    1.734771] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.4.0-rc2+ #53
      [    1.735194] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-1ubuntu1 04/01/2014
      [    1.735772] Call Trace:
      [    1.735950]  <TASK>
      [    1.736113]  dump_stack_lvl+0x32/0x50
      [    1.736367]  panic+0x108/0x310
      [    1.736570]  mount_block_root+0x161/0x310
      [    1.736849]  ? rdinit_setup+0x40/0x40
      [    1.737088]  prepare_namespace+0x10c/0x180
      [    1.737393]  kernel_init_freeable+0x354/0x450
      [    1.737707]  ? rest_init+0xd0/0xd0
      [    1.737945]  kernel_init+0x16/0x130
      [    1.738196]  ret_from_fork+0x1f/0x30
      
      As a hint, print all the bdev fstypes which are available.
      
      [akpm@linux-foundation.org: fix spelling in printk message]
      Link: https://lkml.kernel.org/r/20230518035321.1672-1-angus.chen@jaguarmicro.com
      
      
      Signed-off-by: default avatarAngus Chen <angus.chen@jaguarmicro.com>
      Acked-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6aee6723
    • Arnd Bergmann's avatar
      init: move cifs_root_data() prototype into linux/mount.h · 73648e6f
      Arnd Bergmann authored
      cifs_root_data() is defined in cifs and called from early init code, but
      lacks a global prototype:
      
      fs/cifs/cifsroot.c:83:12: error: no previous prototype for 'cifs_root_data'
      
      Move the declaration from do_mounts.c into an appropriate header.
      
      Link: https://lkml.kernel.org/r/20230517131102.934196-13-arnd@kernel.org
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      73648e6f
  7. Jun 05, 2023
  8. Sep 12, 2022
  9. Feb 02, 2022
  10. Sep 20, 2021
    • Leon Romanovsky's avatar
      init: don't panic if mount_nodev_root failed · 40c8ee67
      Leon Romanovsky authored and Al Viro's avatar Al Viro committed
      
      Attempt to mount 9p file system as root gives the following kernel panic:
      
       9pnet_virtio: no channels available for device root
       Kernel panic - not syncing: VFS: Unable to mount root "root" (9p), err=-2
       CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.15.0-rc1+ #127
       Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
       Call Trace:
        dump_stack_lvl+0x45/0x59
        panic+0x1e2/0x44b
        ? __warn_printk+0xf3/0xf3
        ? free_unref_page+0x2d4/0x4a0
        ? trace_hardirqs_on+0x32/0x120
        ? free_unref_page+0x2d4/0x4a0
        mount_root+0x189/0x1e0
        prepare_namespace+0x136/0x165
        kernel_init_freeable+0x3b8/0x3cb
        ? rest_init+0x2e0/0x2e0
        kernel_init+0x19/0x130
        ret_from_fork+0x1f/0x30
       Kernel Offset: disabled
       ---[ end Kernel panic - not syncing: VFS: Unable to mount root "root" (9p), err=-2 ]---
      
      QEMU command line:
       "qemu-system-x86_64 -append root=/dev/root rw rootfstype=9p rootflags=trans=virtio ..."
      
      This error is because root_device_name is truncated in prepare_namespace() from
      being "/dev/root" to be "root" prior to call to mount_nodev_root().
      
      As a solution, don't treat errors in mount_nodev_root() as errors that
      require panics and allow failback to the mount flow that existed before
      patch citied in Fixes tag.
      
      Fixes: f9259be6 ("init: allow mounting arbitrary non-blockdevice filesystems as root")
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      40c8ee67
    • Vivek Goyal's avatar
      init/do_mounts.c: Harden split_fs_names() against buffer overflow · b51593c4
      Vivek Goyal authored and Al Viro's avatar Al Viro committed
      
      split_fs_names() currently takes comma separate list of filesystems
      and converts it into individual filesystem strings. Pleaces these
      strings in the input buffer passed by caller and returns number of
      strings.
      
      If caller manages to pass input string bigger than buffer, then we
      can write beyond the buffer. Or if string just fits buffer, we will
      still write beyond the buffer as we append a '\0' byte at the end.
      
      Pass size of input buffer to split_fs_names() and put enough checks
      in place so such buffer overrun possibilities do not occur.
      
      This patch does few things.
      
      - Add a parameter "size" to split_fs_names(). This specifies size
        of input buffer.
      
      - Use strlcpy() (instead of strcpy()) so that we can't go beyond
        buffer size. If input string "names" is larger than passed in
        buffer, input string will be truncated to fit in buffer.
      
      - Stop appending extra '\0' character at the end and avoid one
        possibility of going beyond the input buffer size.
      
      - Do not use extra loop to count number of strings.
      
      - Previously if one passed "rootfstype=foo,,bar", split_fs_names()
        will return only 1 string "foo" (and "bar" will be truncated
        due to extra ,). After this patch, now split_fs_names() will
        return 3 strings ("foo", zero-sized-string, and "bar").
      
        Callers of split_fs_names() have been modified to check for
        zero sized string and skip to next one.
      
      Reported-by: default avatarxu xin <xu.xin16@zte.com.cn>
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      b51593c4
  11. Aug 24, 2021
  12. Aug 23, 2021
  13. Jun 01, 2021
  14. Dec 01, 2020
  15. Jul 31, 2020
  16. Jul 30, 2020
  17. Jul 16, 2020
  18. Mar 24, 2020
    • Christoph Hellwig's avatar
      block: remove __bdevname · ea3edd4d
      Christoph Hellwig authored
      
      There is no good reason for __bdevname to exist.  Just open code
      printing the string in the callers.  For three of them the format
      string can be trivially merged into existing printk statements,
      and in init/do_mounts.c we can at least do the scnprintf once at
      the start of the function, and unconditional of CONFIG_BLOCK to
      make the output for tiny configfs a little more helpful.
      
      Acked-by: Theodore Ts'o <tytso@mit.edu> # for ext4
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      ea3edd4d
Loading