1. 29 5月, 2023 1 次提交
    • T
      ext4: add EA_INODE checking to ext4_iget() · b3e6bcb9
      Theodore Ts'o 提交于
      Add a new flag, EXT4_IGET_EA_INODE which indicates whether the inode
      is expected to have the EA_INODE flag or not.  If the flag is not
      set/clear as expected, then fail the iget() operation and mark the
      file system as corrupted.
      
      This commit also makes the ext4_iget() always perform the
      is_bad_inode() check even when the inode is already inode cache.  This
      allows us to remove the is_bad_inode() check from the callers of
      ext4_iget() in the ea_inode code.
      
      Reported-by: syzbot+cbb68193bdb95af4340a@syzkaller.appspotmail.com
      Reported-by: syzbot+62120febbd1ee3c3c860@syzkaller.appspotmail.com
      Reported-by: syzbot+edce54daffee36421b4c@syzkaller.appspotmail.com
      Cc: stable@kernel.org
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20230524034951.779531-2-tytso@mit.eduSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      b3e6bcb9
  2. 25 5月, 2023 5 次提交
  3. 24 5月, 2023 1 次提交
  4. 23 5月, 2023 3 次提交
  5. 20 5月, 2023 2 次提交
    • A
      NFSv4.2: Fix a potential double free with READ_PLUS · 43439d85
      Anna Schumaker 提交于
      kfree()-ing the scratch page isn't enough, we also need to set the pointer
      back to NULL to avoid a double-free in the case of a resend.
      
      Fixes: fbd2a05f (NFSv4.2: Rework scratch handling for READ_PLUS)
      Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      43439d85
    • F
      NFS: Convert kmap_atomic() to kmap_local_folio() · 4b71e241
      Fabio M. De Francesco 提交于
      kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().
      
      Therefore, replace kmap_atomic() with kmap_local_folio() in
      nfs_readdir_folio_array_append().
      
      kmap_atomic() disables page-faults and preemption (the latter only for
      !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in
      nfs_readdir_folio_array_append() does not depend on the above-mentioned
      side effects.
      
      Therefore, a mere replacement of the old API with the new one is all that
      is required (i.e., there is no need to explicitly add any calls to
      pagefault_disable() and/or preempt_disable()).
      
      Tested with (x)fstests in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel
      with HIGHMEM64GB enabled.
      
      Cc: Ira Weiny <ira.weiny@intel.com>
      Signed-off-by: NFabio M. De Francesco <fmdefrancesco@gmail.com>
      Fixes: ec108d3c ("NFS: Convert readdir page array functions to use a folio")
      Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      4b71e241
  6. 18 5月, 2023 5 次提交
  7. 17 5月, 2023 5 次提交
    • J
      fs: don't call posix_acl_listxattr in generic_listxattr · 3a7bb21b
      Jeff Layton 提交于
      Commit f2620f16 caused the kernel to start emitting POSIX ACL xattrs
      for NFSv4 inodes, which it doesn't support. The only other user of
      generic_listxattr is HFS (classic) and it doesn't support POSIX ACLs
      either.
      
      Fixes: f2620f16 xattr: simplify listxattr helpers
      Reported-by: NOndrej Valousek <ondrej.valousek.xm@renesas.com>
      Signed-off-by: NJeff Layton <jlayton@kernel.org>
      Message-Id: <20230516124655.82283-1-jlayton@kernel.org>
      Signed-off-by: NChristian Brauner <brauner@kernel.org>
      3a7bb21b
    • I
      statfs: enforce statfs[64] structure initialization · ed40866e
      Ilya Leoshkevich 提交于
      s390's struct statfs and struct statfs64 contain padding, which
      field-by-field copying does not set. Initialize the respective structs
      with zeros before filling them and copying them to userspace, like it's
      already done for the compat versions of these structs.
      
      Found by KMSAN.
      
      [agordeev@linux.ibm.com: fixed typo in patch description]
      Acked-by: NHeiko Carstens <hca@linux.ibm.com>
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: NIlya Leoshkevich <iii@linux.ibm.com>
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Link: https://lore.kernel.org/r/20230504144021.808932-2-iii@linux.ibm.comSigned-off-by: NAlexander Gordeev <agordeev@linux.ibm.com>
      ed40866e
    • J
      btrfs: use nofs when cleaning up aborted transactions · 597441b3
      Josef Bacik 提交于
      Our CI system caught a lockdep splat:
      
        ======================================================
        WARNING: possible circular locking dependency detected
        6.3.0-rc7+ #1167 Not tainted
        ------------------------------------------------------
        kswapd0/46 is trying to acquire lock:
        ffff8c6543abd650 (sb_internal#2){++++}-{0:0}, at: btrfs_commit_inode_delayed_inode+0x5f/0x120
      
        but task is already holding lock:
        ffffffffabe61b40 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat+0x4aa/0x7a0
      
        which lock already depends on the new lock.
      
        the existing dependency chain (in reverse order) is:
      
        -> #1 (fs_reclaim){+.+.}-{0:0}:
      	 fs_reclaim_acquire+0xa5/0xe0
      	 kmem_cache_alloc+0x31/0x2c0
      	 alloc_extent_state+0x1d/0xd0
      	 __clear_extent_bit+0x2e0/0x4f0
      	 try_release_extent_mapping+0x216/0x280
      	 btrfs_release_folio+0x2e/0x90
      	 invalidate_inode_pages2_range+0x397/0x470
      	 btrfs_cleanup_dirty_bgs+0x9e/0x210
      	 btrfs_cleanup_one_transaction+0x22/0x760
      	 btrfs_commit_transaction+0x3b7/0x13a0
      	 create_subvol+0x59b/0x970
      	 btrfs_mksubvol+0x435/0x4f0
      	 __btrfs_ioctl_snap_create+0x11e/0x1b0
      	 btrfs_ioctl_snap_create_v2+0xbf/0x140
      	 btrfs_ioctl+0xa45/0x28f0
      	 __x64_sys_ioctl+0x88/0xc0
      	 do_syscall_64+0x38/0x90
      	 entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
        -> #0 (sb_internal#2){++++}-{0:0}:
      	 __lock_acquire+0x1435/0x21a0
      	 lock_acquire+0xc2/0x2b0
      	 start_transaction+0x401/0x730
      	 btrfs_commit_inode_delayed_inode+0x5f/0x120
      	 btrfs_evict_inode+0x292/0x3d0
      	 evict+0xcc/0x1d0
      	 inode_lru_isolate+0x14d/0x1e0
      	 __list_lru_walk_one+0xbe/0x1c0
      	 list_lru_walk_one+0x58/0x80
      	 prune_icache_sb+0x39/0x60
      	 super_cache_scan+0x161/0x1f0
      	 do_shrink_slab+0x163/0x340
      	 shrink_slab+0x1d3/0x290
      	 shrink_node+0x300/0x720
      	 balance_pgdat+0x35c/0x7a0
      	 kswapd+0x205/0x410
      	 kthread+0xf0/0x120
      	 ret_from_fork+0x29/0x50
      
        other info that might help us debug this:
      
         Possible unsafe locking scenario:
      
      	 CPU0                    CPU1
      	 ----                    ----
          lock(fs_reclaim);
      				 lock(sb_internal#2);
      				 lock(fs_reclaim);
          lock(sb_internal#2);
      
         *** DEADLOCK ***
      
        3 locks held by kswapd0/46:
         #0: ffffffffabe61b40 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat+0x4aa/0x7a0
         #1: ffffffffabe50270 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab+0x113/0x290
         #2: ffff8c6543abd0e0 (&type->s_umount_key#44){++++}-{3:3}, at: super_cache_scan+0x38/0x1f0
      
        stack backtrace:
        CPU: 0 PID: 46 Comm: kswapd0 Not tainted 6.3.0-rc7+ #1167
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
        Call Trace:
         <TASK>
         dump_stack_lvl+0x58/0x90
         check_noncircular+0xd6/0x100
         ? save_trace+0x3f/0x310
         ? add_lock_to_list+0x97/0x120
         __lock_acquire+0x1435/0x21a0
         lock_acquire+0xc2/0x2b0
         ? btrfs_commit_inode_delayed_inode+0x5f/0x120
         start_transaction+0x401/0x730
         ? btrfs_commit_inode_delayed_inode+0x5f/0x120
         btrfs_commit_inode_delayed_inode+0x5f/0x120
         btrfs_evict_inode+0x292/0x3d0
         ? lock_release+0x134/0x270
         ? __pfx_wake_bit_function+0x10/0x10
         evict+0xcc/0x1d0
         inode_lru_isolate+0x14d/0x1e0
         __list_lru_walk_one+0xbe/0x1c0
         ? __pfx_inode_lru_isolate+0x10/0x10
         ? __pfx_inode_lru_isolate+0x10/0x10
         list_lru_walk_one+0x58/0x80
         prune_icache_sb+0x39/0x60
         super_cache_scan+0x161/0x1f0
         do_shrink_slab+0x163/0x340
         shrink_slab+0x1d3/0x290
         shrink_node+0x300/0x720
         balance_pgdat+0x35c/0x7a0
         kswapd+0x205/0x410
         ? __pfx_autoremove_wake_function+0x10/0x10
         ? __pfx_kswapd+0x10/0x10
         kthread+0xf0/0x120
         ? __pfx_kthread+0x10/0x10
         ret_from_fork+0x29/0x50
         </TASK>
      
      This happens because when we abort the transaction in the transaction
      commit path we call invalidate_inode_pages2_range on our block group
      cache inodes (if we have space cache v1) and any delalloc inodes we may
      have.  The plain invalidate_inode_pages2_range() call passes through
      GFP_KERNEL, which makes sense in most cases, but not here.  Wrap these
      two invalidate callees with memalloc_nofs_save/memalloc_nofs_restore to
      make sure we don't end up with the fs reclaim dependency under the
      transaction dependency.
      
      CC: stable@vger.kernel.org # 4.14+
      Signed-off-by: NJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: NDavid Sterba <dsterba@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      597441b3
    • J
      btrfs: handle memory allocation failure in btrfs_csum_one_bio · 806570c0
      Johannes Thumshirn 提交于
      Since f8a53bb5 ("btrfs: handle checksum generation in the storage
      layer") the failures of btrfs_csum_one_bio() are handled via
      bio_end_io().
      
      This means, we can return BLK_STS_RESOURCE from btrfs_csum_one_bio() in
      case the allocation of the ordered sums fails.
      
      This also fixes a syzkaller report, where injecting a failure into the
      kvzalloc() call results in a BUG_ON().
      
      Reported-by: syzbot+d8941552e21eac774778@syzkaller.appspotmail.com
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NAnand Jain <anand.jain@oracle.com>
      Signed-off-by: NJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: NDavid Sterba <dsterba@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      806570c0
    • Q
      btrfs: scrub: try harder to mark RAID56 block groups read-only · 7561551e
      Qu Wenruo 提交于
      Currently we allow a block group not to be marked read-only for scrub.
      
      But for RAID56 block groups if we require the block group to be
      read-only, then we're allowed to use cached content from scrub stripe to
      reduce unnecessary RAID56 reads.
      
      So this patch would:
      
      - Make btrfs_inc_block_group_ro() try harder
        During my tests, for cases like btrfs/061 and btrfs/064, we can hit
        ENOSPC from btrfs_inc_block_group_ro() calls during scrub.
      
        The reason is if we only have one single data chunk, and trying to
        scrub it, we won't have any space left for any newer data writes.
      
        But this check should be done by the caller, especially for scrub
        cases we only temporarily mark the chunk read-only.
        And newer data writes would always try to allocate a new data chunk
        when needed.
      
      - Return error for scrub if we failed to mark a RAID56 chunk read-only
      Signed-off-by: NQu Wenruo <wqu@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      7561551e
  8. 16 5月, 2023 4 次提交
    • G
      ksmbd: smb2: Allow messages padded to 8byte boundary · e7b8b8ed
      Gustav Johansson 提交于
      clc length is now accepted to <= 8 less than length,
      rather than < 8.
      
      Solve issues on some of Axis's smb clients which send
      messages where clc length is 8 bytes less than length.
      
      The specific client was running kernel 4.19.217 with
      smb dialect 3.0.2 on armv7l.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NGustav Johansson <gustajo@axis.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      e7b8b8ed
    • C
      ksmbd: allocate one more byte for implied bcc[0] · 443d61d1
      Chih-Yen Chang 提交于
      ksmbd_smb2_check_message allows client to return one byte more, so we
      need to allocate additional memory in ksmbd_conn_handler_loop to avoid
      out-of-bound access.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChih-Yen Chang <cc85nod@gmail.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      443d61d1
    • C
      ksmbd: fix wrong UserName check in session_user · f0a96d1a
      Chih-Yen Chang 提交于
      The offset of UserName is related to the address of security
      buffer. To ensure the validaty of UserName, we need to compare name_off
      + name_len with secbuf_len instead of auth_msg_len.
      
      [   27.096243] ==================================================================
      [   27.096890] BUG: KASAN: slab-out-of-bounds in smb_strndup_from_utf16+0x188/0x350
      [   27.097609] Read of size 2 at addr ffff888005e3b542 by task kworker/0:0/7
      ...
      [   27.099950] Call Trace:
      [   27.100194]  <TASK>
      [   27.100397]  dump_stack_lvl+0x33/0x50
      [   27.100752]  print_report+0xcc/0x620
      [   27.102305]  kasan_report+0xae/0xe0
      [   27.103072]  kasan_check_range+0x35/0x1b0
      [   27.103757]  smb_strndup_from_utf16+0x188/0x350
      [   27.105474]  smb2_sess_setup+0xaf8/0x19c0
      [   27.107935]  handle_ksmbd_work+0x274/0x810
      [   27.108315]  process_one_work+0x419/0x760
      [   27.108689]  worker_thread+0x2a2/0x6f0
      [   27.109385]  kthread+0x160/0x190
      [   27.110129]  ret_from_fork+0x1f/0x30
      [   27.110454]  </TASK>
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChih-Yen Chang <cc85nod@gmail.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      f0a96d1a
    • C
      ksmbd: fix global-out-of-bounds in smb2_find_context_vals · 02f76c40
      Chih-Yen Chang 提交于
      Add tag_len argument in smb2_find_context_vals() to avoid out-of-bound
      read when create_context's name_len is larger than tag length.
      
      [    7.995411] ==================================================================
      [    7.995866] BUG: KASAN: global-out-of-bounds in memcmp+0x83/0xa0
      [    7.996248] Read of size 8 at addr ffffffff8258d940 by task kworker/0:0/7
      ...
      [    7.998191] Call Trace:
      [    7.998358]  <TASK>
      [    7.998503]  dump_stack_lvl+0x33/0x50
      [    7.998743]  print_report+0xcc/0x620
      [    7.999458]  kasan_report+0xae/0xe0
      [    7.999895]  kasan_check_range+0x35/0x1b0
      [    8.000152]  memcmp+0x83/0xa0
      [    8.000347]  smb2_find_context_vals+0xf7/0x1e0
      [    8.000635]  smb2_open+0x1df2/0x43a0
      [    8.006398]  handle_ksmbd_work+0x274/0x810
      [    8.006666]  process_one_work+0x419/0x760
      [    8.006922]  worker_thread+0x2a2/0x6f0
      [    8.007429]  kthread+0x160/0x190
      [    8.007946]  ret_from_fork+0x1f/0x30
      [    8.008181]  </TASK>
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NChih-Yen Chang <cc85nod@gmail.com>
      Acked-by: NNamjae Jeon <linkinjeon@kernel.org>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      02f76c40
  9. 15 5月, 2023 1 次提交
  10. 14 5月, 2023 13 次提交