Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Aug 19, 2024
  2. Aug 15, 2024
  3. Aug 13, 2024
  4. Aug 12, 2024
  5. Aug 11, 2024
  6. Aug 10, 2024
    • Ravi Minnikanti's avatar
      ubifs: mount fails after power cycle · cf7ea719
      Ravi Minnikanti authored
      
      When kernel uses file system encryption, fscrypt on UBIFS v5,
      after a hard power cycle UBIFS journal replay fails which results in mount failure.
      
      Failure logs:
      UBIFS: recovery needed
      UBIFS error (pid 0): ubifs_validate_entry: bad directory entry node
      UBIFS error (pid 0): replay_bud: bad node is at LEB 890:24576
      UBIFS error (pid 0): ubifs_mount: Error reading superblock on volume 'ubi0:rootfs' errno=-22!
      
      This change is ported from kernel:
      commit id: 304790c038bc4af4f19774705409db27eafb09fc
      
      Kernel commit description:
          Kernel commit description:
          ubifs: Relax checks in ubifs_validate_entry()
      
          With encrypted filenames we store raw binary data, doing
          string tests is no longer possible.
      
      Signed-off-by: default avatarrminnikanti <rminnikanti@marvell.com>
      Reviewed-by: default avatarHeiko Schocher <hs@denx.de>
      cf7ea719
    • Alexander Dahl's avatar
      fs: ubifs: Add volume mounted check · ca1f11d8
      Alexander Dahl authored
      
      Safety guard in the U-Boot filesystem glue code, because these functions
      are called from different parts of the codebase.  For generic filesystem
      handling this should have been checked in blk_get_device_part_str()
      already.  Commands from cmd/ubifs.c should also check this before
      calling those functions, but you never know?!
      
      Signed-off-by: default avatarAlexander Dahl <ada@thorsis.com>
      ca1f11d8
    • Alexander Dahl's avatar
      fs: ubifs: Make k(z)alloc/kfree symmetric · 0989033d
      Alexander Dahl authored
      
      Although kfree() is in fact only a slim wrapper to free() in U-Boot, use
      kfree() here, because those structs where allocated with kalloc() or
      kzalloc().
      
      Signed-off-by: default avatarAlexander Dahl <ada@thorsis.com>
      0989033d
    • Alexander Dahl's avatar
      fs: ubifs: Set pointers to NULL after free · 573dae50
      Alexander Dahl authored
      
      Global superblock pointer 'ubifs_sb' and volume pointer 'ubi' of type
      struct ubi_volume_desc in private member sb->s_fs_info of type struct
      ubifs_info, can be allocated and freed at runtime, and allocated and
      freed again, depending which console or script commands are run.  In
      some cases ubifs_sb is even tested to determine if the filesystem is
      mounted.  Reset those pointers to NULL after free to clearly mark them
      as not valid.  This avoids potential double free on invalid pointers.
      
      (The ubifs_sb pointer was already reset, but that statement was moved
      now to directly after the free() to make it easier to understand.)
      
      Signed-off-by: default avatarAlexander Dahl <ada@thorsis.com>
      573dae50
    • Alexander Dahl's avatar
      fs: ubifs: Fix memleak and double free in u-boot wrapper functions · df86e81f
      Alexander Dahl authored
      When mounting ubifs e.g. through command 'ubifsmount' one global static
      superblock 'ubifs_sb' is used _and_ the requested volume is opened (like
      in Linux).  The pointer returned by 'ubifs_open_volume()' is stored in
      that superblock struct and freed later on cmd 'ubifsumount' or another
      call to 'ubifsmount' with a different volume, through ubifs_umount() and
      ubi_close_volume().
      
      In ubifs_ls(), ubifs_exists(), ubifs_size(), and ubifs_read() the volume
      was opened again, which is technically no problem with regard to
      refcounting, but here the still valid pointer in sb was overwritten,
      leading to a memory leak.  Even worse, when using one of those
      functions and calling ubifsumount later, ubi_close_volume() was called
      again but now on an already freed pointer, leading to a double free.
      This actually crashed with different invalid memory accesses on a board
      using the old distro boot and a rather long script handling RAUC
      updates.
      
      Example:
      
          > ubi part UBI
          > ubifsmount ubi0:boot
          > test -e ubi ubi0:boot /boot.scr.uimg
          > ubifsumount
      
      The ubifs specific commands 'ubifsls' and 'ubifsload' check for a
      mounted volume by themselves, for the generic fs variants 'ls', 'load',
      (and 'size', and 'test -e') this is covered by special ubifs handling in
      fs_set_blk_dev() and deeper down blk_get_device_part_str() then.  So for
      ubifs_ls(), ubifs_exists(), ubifs_size(), and ubifs_read() we can be
      sure the volume is opened and the necessary struct pointer in sb is
      valid, so it is not needed to open volume again.
      
      Fixes: 9eefe2a2 ("UBIFS: Implement read-only UBIFS support in U-Boot")
      Fixes: 29cc5bca
      
       ("ubifs: Add functions for generic fs use")
      Signed-off-by: default avatarAlexander Dahl <ada@thorsis.com>
      df86e81f
  7. Aug 09, 2024