1. 15 10月, 2021 2 次提交
  2. 12 10月, 2021 2 次提交
  3. 04 10月, 2021 1 次提交
    • C
      elf: don't use MAP_FIXED_NOREPLACE for elf interpreter mappings · 9b2f72cc
      Chen Jingwen 提交于
      In commit b212921b ("elf: don't use MAP_FIXED_NOREPLACE for elf
      executable mappings") we still leave MAP_FIXED_NOREPLACE in place for
      load_elf_interp.
      
      Unfortunately, this will cause kernel to fail to start with:
      
          1 (init): Uhuuh, elf segment at 00003ffff7ffd000 requested but the memory is mapped already
          Failed to execute /init (error -17)
      
      The reason is that the elf interpreter (ld.so) has overlapping segments.
      
        readelf -l ld-2.31.so
        Program Headers:
          Type           Offset             VirtAddr           PhysAddr
                         FileSiz            MemSiz              Flags  Align
          LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                         0x000000000002c94c 0x000000000002c94c  R E    0x10000
          LOAD           0x000000000002dae0 0x000000000003dae0 0x000000000003dae0
                         0x00000000000021e8 0x0000000000002320  RW     0x10000
          LOAD           0x000000000002fe00 0x000000000003fe00 0x000000000003fe00
                         0x00000000000011ac 0x0000000000001328  RW     0x10000
      
      The reason for this problem is the same as described in commit
      ad55eac7 ("elf: enforce MAP_FIXED on overlaying elf segments").
      
      Not only executable binaries, elf interpreters (e.g. ld.so) can have
      overlapping elf segments, so we better drop MAP_FIXED_NOREPLACE and go
      back to MAP_FIXED in load_elf_interp.
      
      Fixes: 4ed28639 ("fs, elf: drop MAP_FIXED usage from elf_map")
      Cc: <stable@vger.kernel.org> # v4.19
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: NChen Jingwen <chenjingwen6@huawei.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9b2f72cc
  4. 02 10月, 2021 1 次提交
  5. 01 10月, 2021 7 次提交
    • Z
      ext4: recheck buffer uptodate bit under buffer lock · f2c77973
      Zhang Yi 提交于
      Commit 8e33fadf ("ext4: remove an unnecessary if statement in
      __ext4_get_inode_loc()") forget to recheck buffer's uptodate bit again
      under buffer lock, which may overwrite the buffer if someone else have
      already brought it uptodate and changed it.
      
      Fixes: 8e33fadf ("ext4: remove an unnecessary if statement in __ext4_get_inode_loc()")
      Cc: stable@kernel.org
      Signed-off-by: NZhang Yi <yi.zhang@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210910080316.70421-1-yi.zhang@huawei.com
      f2c77973
    • Y
      ext4: fix potential infinite loop in ext4_dx_readdir() · 42cb4474
      yangerkun 提交于
      When ext4_htree_fill_tree() fails, ext4_dx_readdir() can run into an
      infinite loop since if info->last_pos != ctx->pos this will reset the
      directory scan and reread the failing entry.  For example:
      
      1. a dx_dir which has 3 block, block 0 as dx_root block, block 1/2 as
         leaf block which own the ext4_dir_entry_2
      2. block 1 read ok and call_filldir which will fill the dirent and update
         the ctx->pos
      3. block 2 read fail, but we has already fill some dirent, so we will
         return back to userspace will a positive return val(see ksys_getdents64)
      4. the second ext4_dx_readdir will reset the world since info->last_pos
         != ctx->pos, and will also init the curr_hash which pos to block 1
      5. So we will read block1 too, and once block2 still read fail, we can
         only fill one dirent because the hash of the entry in block1(besides
         the last one) won't greater than curr_hash
      6. this time, we forget update last_pos too since the read for block2
         will fail, and since we has got the one entry, ksys_getdents64 can
         return success
      7. Latter we will trapped in a loop with step 4~6
      
      Cc: stable@kernel.org
      Signed-off-by: Nyangerkun <yangerkun@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210914111415.3921954-1-yangerkun@huawei.com
      42cb4474
    • Y
      ext4: flush s_error_work before journal destroy in ext4_fill_super · bb9464e0
      yangerkun 提交于
      The error path in ext4_fill_super forget to flush s_error_work before
      journal destroy, and it may trigger the follow bug since
      flush_stashed_error_work can run concurrently with journal destroy
      without any protection for sbi->s_journal.
      
      [32031.740193] EXT4-fs (loop66): get root inode failed
      [32031.740484] EXT4-fs (loop66): mount failed
      [32031.759805] ------------[ cut here ]------------
      [32031.759807] kernel BUG at fs/jbd2/transaction.c:373!
      [32031.760075] invalid opcode: 0000 [#1] SMP PTI
      [32031.760336] CPU: 5 PID: 1029268 Comm: kworker/5:1 Kdump: loaded
      4.18.0
      [32031.765112] Call Trace:
      [32031.765375]  ? __switch_to_asm+0x35/0x70
      [32031.765635]  ? __switch_to_asm+0x41/0x70
      [32031.765893]  ? __switch_to_asm+0x35/0x70
      [32031.766148]  ? __switch_to_asm+0x41/0x70
      [32031.766405]  ? _cond_resched+0x15/0x40
      [32031.766665]  jbd2__journal_start+0xf1/0x1f0 [jbd2]
      [32031.766934]  jbd2_journal_start+0x19/0x20 [jbd2]
      [32031.767218]  flush_stashed_error_work+0x30/0x90 [ext4]
      [32031.767487]  process_one_work+0x195/0x390
      [32031.767747]  worker_thread+0x30/0x390
      [32031.768007]  ? process_one_work+0x390/0x390
      [32031.768265]  kthread+0x10d/0x130
      [32031.768521]  ? kthread_flush_work_fn+0x10/0x10
      [32031.768778]  ret_from_fork+0x35/0x40
      
      static int start_this_handle(...)
          BUG_ON(journal->j_flags & JBD2_UNMOUNT); <---- Trigger this
      
      Besides, after we enable fast commit, ext4_fc_replay can add work to
      s_error_work but return success, so the latter journal destroy in
      ext4_load_journal can trigger this problem too.
      
      Fix this problem with two steps:
      1. Call ext4_commit_super directly in ext4_handle_error for the case
         that called from ext4_fc_replay
      2. Since it's hard to pair the init and flush for s_error_work, we'd
         better add a extras flush_work before journal destroy in
         ext4_fill_super
      
      Besides, this patch will call ext4_commit_super in ext4_handle_error for
      any nojournal case too. But it seems safe since the reason we call
      schedule_work was that we should save error info to sb through journal
      if available. Conversely, for the nojournal case, it seems useless delay
      commit superblock to s_error_work.
      
      Fixes: c92dc856 ("ext4: defer saving error info from atomic context")
      Fixes: 2d01ddc8 ("ext4: save error info to sb through journal if available")
      Cc: stable@kernel.org
      Signed-off-by: Nyangerkun <yangerkun@huawei.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210924093917.1953239-1-yangerkun@huawei.com
      bb9464e0
    • R
      ext4: fix loff_t overflow in ext4_max_bitmap_size() · 75ca6ad4
      Ritesh Harjani 提交于
      We should use unsigned long long rather than loff_t to avoid
      overflow in ext4_max_bitmap_size() for comparison before returning.
      w/o this patch sbi->s_bitmap_maxbytes was becoming a negative
      value due to overflow of upper_limit (with has_huge_files as true)
      
      Below is a quick test to trigger it on a 64KB pagesize system.
      
      sudo mkfs.ext4 -b 65536 -O ^has_extents,^64bit /dev/loop2
      sudo mount /dev/loop2 /mnt
      sudo echo "hello" > /mnt/hello 	-> This will error out with
      				"echo: write error: File too large"
      Signed-off-by: NRitesh Harjani <riteshh@linux.ibm.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Link: https://lore.kernel.org/r/594f409e2c543e90fd836b78188dfa5c575065ba.1622867594.git.riteshh@linux.ibm.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      75ca6ad4
    • J
      ext4: fix reserved space counter leakage · 6fed8395
      Jeffle Xu 提交于
      When ext4_insert_delayed block receives and recovers from an error from
      ext4_es_insert_delayed_block(), e.g., ENOMEM, it does not release the
      space it has reserved for that block insertion as it should. One effect
      of this bug is that s_dirtyclusters_counter is not decremented and
      remains incorrectly elevated until the file system has been unmounted.
      This can result in premature ENOSPC returns and apparent loss of free
      space.
      
      Another effect of this bug is that
      /sys/fs/ext4/<dev>/delayed_allocation_blocks can remain non-zero even
      after syncfs has been executed on the filesystem.
      
      Besides, add check for s_dirtyclusters_counter when inode is going to be
      evicted and freed. s_dirtyclusters_counter can still keep non-zero until
      inode is written back in .evict_inode(), and thus the check is delayed
      to .destroy_inode().
      
      Fixes: 51865fda ("ext4: let ext4 maintain extent status tree")
      Cc: stable@kernel.org
      Suggested-by: NGao Xiang <hsiangkao@linux.alibaba.com>
      Signed-off-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Reviewed-by: NEric Whitney <enwlinux@gmail.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210823061358.84473-1-jefflexu@linux.alibaba.com
      6fed8395
    • H
      ext4: limit the number of blocks in one ADD_RANGE TLV · a2c2f082
      Hou Tao 提交于
      Now EXT4_FC_TAG_ADD_RANGE uses ext4_extent to track the
      newly-added blocks, but the limit on the max value of
      ee_len field is ignored, and it can lead to BUG_ON as
      shown below when running command "fallocate -l 128M file"
      on a fast_commit-enabled fs:
      
        kernel BUG at fs/ext4/ext4_extents.h:199!
        invalid opcode: 0000 [#1] SMP PTI
        CPU: 3 PID: 624 Comm: fallocate Not tainted 5.14.0-rc6+ #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
        RIP: 0010:ext4_fc_write_inode_data+0x1f3/0x200
        Call Trace:
         ? ext4_fc_write_inode+0xf2/0x150
         ext4_fc_commit+0x93b/0xa00
         ? ext4_fallocate+0x1ad/0x10d0
         ext4_sync_file+0x157/0x340
         ? ext4_sync_file+0x157/0x340
         vfs_fsync_range+0x49/0x80
         do_fsync+0x3d/0x70
         __x64_sys_fsync+0x14/0x20
         do_syscall_64+0x3b/0xc0
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Simply fixing it by limiting the number of blocks
      in one EXT4_FC_TAG_ADD_RANGE TLV.
      
      Fixes: aa75f4d3 ("ext4: main fast-commit commit path")
      Cc: stable@kernel.org
      Signed-off-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210820044505.474318-1-houtao1@huawei.com
      a2c2f082
    • D
      ksmbd: missing check for NULL in convert_to_nt_pathname() · 87ffb310
      Dan Carpenter 提交于
      The kmalloc() does not have a NULL check.  This code can be re-written
      slightly cleaner to just use the kstrdup().
      
      Fixes: 265fd199 ("ksmbd: use LOOKUP_BENEATH to prevent the out of share access")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Acked-by: NHyunchul Lee <hyc.lee@gmail.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      87ffb310
  6. 30 9月, 2021 6 次提交
  7. 29 9月, 2021 2 次提交
    • E
      ksmbd: fix documentation for 2 functions · 1018bf24
      Enzo Matsumiya 提交于
      ksmbd_kthread_fn() and create_socket() returns 0 or error code, and not
      task_struct/ERR_PTR.
      Signed-off-by: NEnzo Matsumiya <ematsumiya@suse.de>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      1018bf24
    • H
      kernfs: also call kernfs_set_rev() for positive dentry · df38d852
      Hou Tao 提交于
      A KMSAN warning is reported by Alexander Potapenko:
      
      BUG: KMSAN: uninit-value in kernfs_dop_revalidate+0x61f/0x840
      fs/kernfs/dir.c:1053
       kernfs_dop_revalidate+0x61f/0x840 fs/kernfs/dir.c:1053
       d_revalidate fs/namei.c:854
       lookup_dcache fs/namei.c:1522
       __lookup_hash+0x3a6/0x590 fs/namei.c:1543
       filename_create+0x312/0x7c0 fs/namei.c:3657
       do_mkdirat+0x103/0x930 fs/namei.c:3900
       __do_sys_mkdir fs/namei.c:3931
       __se_sys_mkdir fs/namei.c:3929
       __x64_sys_mkdir+0xda/0x120 fs/namei.c:3929
       do_syscall_x64 arch/x86/entry/common.c:51
      
      It seems a positive dentry in kernfs becomes a negative dentry directly
      through d_delete() in vfs_rmdir(). dentry->d_time is uninitialized
      when accessing it in kernfs_dop_revalidate(), because it is only
      initialized when created as negative dentry in kernfs_iop_lookup().
      
      The problem can be reproduced by the following command:
      
        cd /sys/fs/cgroup/pids && mkdir hi && stat hi && rmdir hi && stat hi
      
      A simple fixes seems to be initializing d->d_time for positive dentry
      in kernfs_iop_lookup() as well. The downside is the negative dentry
      will be revalidated again after it becomes negative in d_delete(),
      because the revison of its parent must have been increased due to
      its removal.
      
      Alternative solution is implement .d_iput for kernfs, and assign d_time
      for the newly-generated negative dentry in it. But we may need to
      take kernfs_rwsem to protect again the concurrent kernfs_link_sibling()
      on the parent directory, it is a little over-killing. Now the simple
      fix is chosen.
      
      Link: https://marc.info/?l=linux-fsdevel&m=163249838610499
      Fixes: c7e7c042 ("kernfs: use VFS negative dentry caching")
      Reported-by: NAlexander Potapenko <glider@google.com>
      Signed-off-by: NHou Tao <houtao1@huawei.com>
      Link: https://lore.kernel.org/r/20210928140750.1274441-1-houtao1@huawei.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df38d852
  8. 28 9月, 2021 2 次提交
  9. 27 9月, 2021 2 次提交
  10. 25 9月, 2021 12 次提交
  11. 24 9月, 2021 3 次提交