1. Mar 05, 2024
  2. Feb 22, 2024
  3. Feb 21, 2024
  4. Feb 19, 2024
  5. Feb 12, 2024
    • Jan Kara's avatar
      quota: Detect loops in quota tree · a898cb62
      Jan Kara authored
      
      
      Syzbot has found that when it creates corrupted quota files where the
      quota tree contains a loop, we will deadlock when tryling to insert a
      dquot. Add loop detection into functions traversing the quota tree.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      a898cb62
  6. Feb 08, 2024
  7. Feb 05, 2024
    • Jan Kara's avatar
      udf: Avoid invalid LVID used on mount · c8f1140c
      Jan Kara authored
      
      
      udf_load_logicalvolint() loads logical volume integrity descriptors.
      Since there can be multiple blocks with LVIDs, we verify the contents of
      only the last (prevailing) LVID found. However if we fail to load the
      last LVID (either due to IO error or because it's checksum fails to
      match), we never perform the verification of validity of the LVID we are
      going to use. If such LVID contains invalid data, we can hit
      out-of-bounds access or similar issues. Fix the problem by verifying
      each LVID we are potentially going to accept.
      
      Reported-by: default avatarRobert Morris <rtm@csail.mit.edu>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      c8f1140c
    • Wang Jianjian's avatar
      quota: Fix potential NULL pointer dereference · d0aa7260
      Wang Jianjian authored
      
      
      Below race may cause NULL pointer dereference
      
      P1					P2
      dquot_free_inode			quota_off
      					  drop_dquot_ref
      					   remove_dquot_ref
      					   dquots = i_dquot(inode)
        dquots = i_dquot(inode)
        srcu_read_lock
        dquots[cnt]) != NULL (1)
      					     dquots[type] = NULL (2)
        spin_lock(&dquots[cnt]->dq_dqb_lock) (3)
         ....
      
      If dquot_free_inode(or other routines) checks inode's quota pointers (1)
      before quota_off sets it to NULL(2) and use it (3) after that, NULL pointer
      dereference will be triggered.
      
      So let's fix it by using a temporary pointer to avoid this issue.
      
      Signed-off-by: default avatarWang Jianjian <wangjianjian3@huawei.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Message-Id: <20240202081852.2514092-1-wangjianjian3@huawei.com>
      d0aa7260
  8. Jan 24, 2024
    • Jan Kara's avatar
      quota: Drop GFP_NOFS instances under dquot->dq_lock and dqio_sem · a1e1b2be
      Jan Kara authored
      
      
      Quota code acquires dquot->dq_lock whenever reading / writing dquot.
      When reading / writing quota info we hold dqio_sem.  Since these locks
      can be acquired during inode reclaim (through dquot_drop() -> dqput() ->
      dquot_release()) we are setting nofs allocation context whenever
      acquiring these locks. Hence there's no need to use GFP_NOFS allocations
      in quota code doing IO. Just switch it to GFP_KERNEL.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      a1e1b2be
    • Jan Kara's avatar
      quota: Set nofs allocation context when acquiring dqio_sem · 6c5026c1
      Jan Kara authored
      
      
      dqio_sem can be acquired during inode reclaim through dquot_drop() ->
      dqput() -> dquot_release() -> write_file_info() context. In some cases
      (most notably through dquot_get_next_id()) it can be acquired without
      holding dquot->dq_lock (which already sets nofs allocation context). So
      we need to set nofs allocation context when acquiring it as well.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      6c5026c1
    • Jan Kara's avatar
      ext2: Remove GFP_NOFS use in ext2_xattr_cache_insert() · c3e637c7
      Jan Kara authored
      
      
      ext2_xattr_cache_insert() calls mb_cache_entry_create() with GFP_NOFS
      because it is called under EXT2_I(inode)->xattr_sem. However xattr_sem
      or any higher ranking lock is not acquired on fs reclaim path for ext2
      at least since we don't do page writeback from direct reclaim.  Thus
      GFP_NOFS is not needed.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      c3e637c7
    • Jan Kara's avatar
      ext2: Drop GFP_NOFS use in ext2_get_blocks() · 36975616
      Jan Kara authored
      
      
      ext2_get_blocks() calls sb_issue_zeroout() with GFP_NOFS flag. However
      the call is performed under inode->i_rwsem and
      EXT2_I(inode)->i_truncate_mutex neither of which is acquired during
      direct fs reclaim. So it is safe to change the gfp mask to GFP_KERNEL.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      36975616
    • Jan Kara's avatar
      ext2: Drop GFP_NOFS allocation from ext2_init_block_alloc_info() · dbc056f8
      Jan Kara authored
      
      
      The allocation happens under inode->i_rwsem and
      EXT2_I(inode)->i_truncate_mutex. Neither of them is acquired during
      direct fs reclaim so the allocation can be changed to GFP_KERNEL.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      dbc056f8
    • Jan Kara's avatar
      udf: Remove GFP_NOFS allocation in udf_expand_file_adinicb() · 38f8af2a
      Jan Kara authored
      
      
      udf_expand_file_adinicb() is called under inode->i_rwsem and
      mapping->invalidate_lock. i_rwsem is safe wrt fs reclaim,
      invalidate_lock on this inode is safe as well (we hold inode reference
      so reclaim will not touch it, furthermore even lockdep should not
      complain as invalidate_lock is acquired from udf_evict_inode() only when
      truncating inode which should not happen from fs reclaim).
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      38f8af2a
    • Jan Kara's avatar
      udf: Avoid GFP_NOFS allocation in udf_load_pvoldesc() · b27ffdc1
      Jan Kara authored
      
      
      udf_load_pvoldesc() is called only during mount when it is safe to
      enter fs reclaim (we hold only s_umount semaphore). Change GFP_NOFS to
      GFP_KERNEL allocation.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      b27ffdc1
    • Jan Kara's avatar
      udf: Avoid GFP_NOFS allocation in udf_symlink() · 2ed0d3d4
      Jan Kara authored
      
      
      The GFP_NOFS allocation in udf_symlink() is called only under
      inode->i_rwsem and UDF_I(inode)->i_data_sem. The first is safe wrt
      reclaim, the second should be as well but allocating unde this lock is
      actually unnecessary. Move the allocation from under i_data_sem and
      change it to GFP_KERNEL.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      2ed0d3d4
    • Jan Kara's avatar
      udf: Remove GFP_NOFS from dir iteration code · f6766303
      Jan Kara authored
      
      
      Directory iteration code was using GFP_NOFS allocations in two places.
      However the code is called only under inode->i_rwsem which is generally
      safe wrt reclaim. So we can do the allocations with GFP_KERNEL instead.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      f6766303
  9. Jan 22, 2024