1. 09 4月, 2021 14 次提交
  2. 28 1月, 2021 4 次提交
  3. 18 1月, 2021 3 次提交
    • Y
      ext4: fix bug for rename with RENAME_WHITEOUT · 64f16f0a
      yangerkun 提交于
      mainline inclusion
      from mainline-5.11-rc4
      commit 6b4b8e6b
      category: bugfix
      bugzilla: 47416
      CVE: NA
      ---------------------------
      
      We got a "deleted inode referenced" warning cross our fsstress test. The
      bug can be reproduced easily with following steps:
      
        cd /dev/shm
        mkdir test/
        fallocate -l 128M img
        mkfs.ext4 -b 1024 img
        mount img test/
        dd if=/dev/zero of=test/foo bs=1M count=128
        mkdir test/dir/ && cd test/dir/
        for ((i=0;i<1000;i++)); do touch file$i; done # consume all block
        cd ~ && renameat2(AT_FDCWD, /dev/shm/test/dir/file1, AT_FDCWD,
          /dev/shm/test/dir/dst_file, RENAME_WHITEOUT) # ext4_add_entry in
          ext4_rename will return ENOSPC!!
        cd /dev/shm/ && umount test/ && mount img test/ && ls -li test/dir/file1
        We will get the output:
        "ls: cannot access 'test/dir/file1': Structure needs cleaning"
        and the dmesg show:
        "EXT4-fs error (device loop0): ext4_lookup:1626: inode #2049: comm ls:
        deleted inode referenced: 139"
      
      ext4_rename will create a special inode for whiteout and use this 'ino'
      to replace the source file's dir entry 'ino'. Once error happens
      latter(the error above was the ENOSPC return from ext4_add_entry in
      ext4_rename since all space has been consumed), the cleanup do drop the
      nlink for whiteout, but forget to restore 'ino' with source file. This
      will trigger the bug describle as above.
      Signed-off-by: Nyangerkun <yangerkun@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Cc: stable@vger.kernel.org
      Fixes: cd808dec ("ext4: support RENAME_WHITEOUT")
      Link: https://lore.kernel.org/r/20210105062857.3566-1-yangerkun@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: Nyangerkun <yangerkun@huawei.com>
      Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      64f16f0a
    • C
      ext4: avoid s_mb_prefetch to be zero in individual scenarios · 643c24ff
      Chunguang Xu 提交于
      stable inclusion
      from stable-5.10.5
      commit aceb8ae8e3b10503a2b82b17f626c9278fe792b4
      bugzilla: 46931
      
      --------------------------------
      
      [ Upstream commit 82ef1370 ]
      
      Commit cfd73237 ("ext4: add prefetching for block allocation
      bitmaps") introduced block bitmap prefetch, and expects to read block
      bitmaps of flex_bg through an IO.  However, it seems to ignore the
      value range of s_log_groups_per_flex.  In the scenario where the value
      of s_log_groups_per_flex is greater than 27, s_mb_prefetch or
      s_mb_prefetch_limit will overflow, cause a divide zero exception.
      
      In addition, the logic of calculating nr is also flawed, because the
      size of flexbg is fixed during a single mount, but s_mb_prefetch can
      be modified, which causes nr to fail to meet the value condition of
      [1, flexbg_size].
      
      To solve this problem, we need to set the upper limit of
      s_mb_prefetch.  Since we expect to load block bitmaps of a flex_bg
      through an IO, we can consider determining a reasonable upper limit
      among the IO limit parameters.  After consideration, we chose
      BLK_MAX_SEGMENT_SIZE.  This is a good choice to solve divide zero
      problem and avoiding performance degradation.
      
      [ Some minor code simplifications to make the changes easy to follow -- TYT ]
      Reported-by: NTosk Robot <tencent_os_robot@tencent.com>
      Signed-off-by: NChunguang Xu <brookxu@tencent.com>
      Reviewed-by: NSamuel Liao <samuelliao@tencent.com>
      Reviewed-by: NAndreas Dilger <adilger@dilger.ca>
      Link: https://lore.kernel.org/r/1607051143-24508-1-git-send-email-brookxu@tencent.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      643c24ff
    • T
      ext4: check for invalid block size early when mounting a file system · ac832d34
      Theodore Ts'o 提交于
      stable inclusion
      from stable-5.10.5
      commit 721972b8665f784f6d840d9ef563a8971565c569
      bugzilla: 46931
      
      --------------------------------
      
      commit c9200760 upstream.
      
      Check for valid block size directly by validating s_log_block_size; we
      were doing this in two places.  First, by calculating blocksize via
      BLOCK_SIZE << s_log_block_size, and then checking that the blocksize
      was valid.  And then secondly, by checking s_log_block_size directly.
      
      The first check is not reliable, and can trigger an UBSAN warning if
      s_log_block_size on a maliciously corrupted superblock is greater than
      22.  This is harmless, since the second test will correctly reject the
      maliciously fuzzed file system, but to make syzbot shut up, and
      because the two checks are duplicative in any case, delete the
      blocksize check, and move the s_log_block_size earlier in
      ext4_fill_super().
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Reported-by: syzbot+345b75652b1d24227443@syzkaller.appspotmail.com
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
      ac832d34
  4. 12 1月, 2021 4 次提交
  5. 07 1月, 2021 1 次提交
  6. 20 11月, 2020 2 次提交
  7. 12 11月, 2020 2 次提交
  8. 07 11月, 2020 10 次提交