Skip to content
Snippets Groups Projects
  1. Jan 02, 2024
    • Kevin Hao's avatar
      jfs: Add missing set_freezable() for freezable kthread · a280c9ce
      Kevin Hao authored
      
      The kernel thread function jfs_lazycommit() and jfs_sync() invoke the
      try_to_freeze() in its loop. But all the kernel threads are no-freezable
      by default. So if we want to make a kernel thread to be freezable, we have
      to invoke set_freezable() explicitly.
      
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      a280c9ce
    • Edward Adam Davis's avatar
      jfs: fix array-index-out-of-bounds in diNewExt · 49f9637a
      Edward Adam Davis authored
      
      [Syz report]
      UBSAN: array-index-out-of-bounds in fs/jfs/jfs_imap.c:2360:2
      index -878706688 is out of range for type 'struct iagctl[128]'
      CPU: 1 PID: 5065 Comm: syz-executor282 Not tainted 6.7.0-rc4-syzkaller-00009-gbee0e7762ad2 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
       ubsan_epilogue lib/ubsan.c:217 [inline]
       __ubsan_handle_out_of_bounds+0x11c/0x150 lib/ubsan.c:348
       diNewExt+0x3cf3/0x4000 fs/jfs/jfs_imap.c:2360
       diAllocExt fs/jfs/jfs_imap.c:1949 [inline]
       diAllocAG+0xbe8/0x1e50 fs/jfs/jfs_imap.c:1666
       diAlloc+0x1d3/0x1760 fs/jfs/jfs_imap.c:1587
       ialloc+0x8f/0x900 fs/jfs/jfs_inode.c:56
       jfs_mkdir+0x1c5/0xb90 fs/jfs/namei.c:225
       vfs_mkdir+0x2f1/0x4b0 fs/namei.c:4106
       do_mkdirat+0x264/0x3a0 fs/namei.c:4129
       __do_sys_mkdir fs/namei.c:4149 [inline]
       __se_sys_mkdir fs/namei.c:4147 [inline]
       __x64_sys_mkdir+0x6e/0x80 fs/namei.c:4147
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x45/0x110 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      RIP: 0033:0x7fcb7e6a0b57
      Code: ff ff 77 07 31 c0 c3 0f 1f 40 00 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 b8 53 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffd83023038 EFLAGS: 00000286 ORIG_RAX: 0000000000000053
      RAX: ffffffffffffffda RBX: 00000000ffffffff RCX: 00007fcb7e6a0b57
      RDX: 00000000000a1020 RSI: 00000000000001ff RDI: 0000000020000140
      RBP: 0000000020000140 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000286 R12: 00007ffd830230d0
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      
      [Analysis]
      When the agstart is too large, it can cause agno overflow.
      
      [Fix]
      After obtaining agno, if the value is invalid, exit the subsequent process.
      
      Reported-and-tested-by: default avatar <syzbot+553d90297e6d2f50dbc7@syzkaller.appspotmail.com>
      Signed-off-by: default avatarEdward Adam Davis <eadavis@qq.com>
      
      Modified the test from agno > MAXAG to agno >= MAXAG based on linux-next
      report by kernel test robot (Dan Carpenter).
      
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      49f9637a
  2. Nov 21, 2023
    • Manas Ghandat's avatar
      jfs: fix shift-out-of-bounds in dbJoin · cca974da
      Manas Ghandat authored
      
      Currently while joining the leaf in a buddy system there is shift out
      of bound error in calculation of BUDSIZE. Added the required check
      to the BUDSIZE and fixed the documentation as well.
      
      Reported-by: default avatar <syzbot+411debe54d318eaed386@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=411debe54d318eaed386
      
      
      Signed-off-by: default avatarManas Ghandat <ghandatmanas@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      cca974da
    • Edward Adam Davis's avatar
      jfs: fix uaf in jfs_evict_inode · e0e1958f
      Edward Adam Davis authored
      
      When the execution of diMount(ipimap) fails, the object ipimap that has been
      released may be accessed in diFreeSpecial(). Asynchronous ipimap release occurs
      when rcu_core() calls jfs_free_node().
      
      Therefore, when diMount(ipimap) fails, sbi->ipimap should not be initialized as
      ipimap.
      
      Reported-and-tested-by: default avatar <syzbot+01cf2dbcbe2022454388@syzkaller.appspotmail.com>
      Signed-off-by: default avatarEdward Adam Davis <eadavis@qq.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      e0e1958f
    • Manas Ghandat's avatar
      jfs: fix array-index-out-of-bounds in dbAdjTree · 74ecdda6
      Manas Ghandat authored
      Currently there is a bound check missing in the dbAdjTree while
      accessing the dmt_stree. To add the required check added the bool is_ctl
      which is required to determine the size as suggest in the following
      commit.
      https://lore.kernel.org/linux-kernel-mentees/f9475918-2186-49b8-b801-6f0f9e75f4fa@oracle.com/
      
      
      
      Reported-by: default avatar <syzbot+39ba34a099ac2e9bd3cb@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=39ba34a099ac2e9bd3cb
      
      
      Signed-off-by: default avatarManas Ghandat <ghandatmanas@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      74ecdda6
    • Manas Ghandat's avatar
      jfs: fix slab-out-of-bounds Read in dtSearch · fa5492ee
      Manas Ghandat authored
      
      Currently while searching for current page in the sorted entry table
      of the page there is a out of bound access. Added a bound check to fix
      the error.
      
      Dave:
      Set return code to -EIO
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Closes: https://lore.kernel.org/r/202310241724.Ed02yUz9-lkp@intel.com/
      
      
      Signed-off-by: default avatarManas Ghandat <ghandatmanas@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      fa5492ee
    • Osama Muhammad's avatar
      UBSAN: array-index-out-of-bounds in dtSplitRoot · 27e56f59
      Osama Muhammad authored
      
      Syzkaller reported the following issue:
      
      oop0: detected capacity change from 0 to 32768
      
      UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dtree.c:1971:9
      index -2 is out of range for type 'struct dtslot [128]'
      CPU: 0 PID: 3613 Comm: syz-executor270 Not tainted 6.0.0-syzkaller-09423-g493ffd6605b2 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
       ubsan_epilogue lib/ubsan.c:151 [inline]
       __ubsan_handle_out_of_bounds+0xdb/0x130 lib/ubsan.c:283
       dtSplitRoot+0x8d8/0x1900 fs/jfs/jfs_dtree.c:1971
       dtSplitUp fs/jfs/jfs_dtree.c:985 [inline]
       dtInsert+0x1189/0x6b80 fs/jfs/jfs_dtree.c:863
       jfs_mkdir+0x757/0xb00 fs/jfs/namei.c:270
       vfs_mkdir+0x3b3/0x590 fs/namei.c:4013
       do_mkdirat+0x279/0x550 fs/namei.c:4038
       __do_sys_mkdirat fs/namei.c:4053 [inline]
       __se_sys_mkdirat fs/namei.c:4051 [inline]
       __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4051
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7fcdc0113fd9
      Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffeb8bc67d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fcdc0113fd9
      RDX: 0000000000000000 RSI: 0000000020000340 RDI: 0000000000000003
      RBP: 00007fcdc00d37a0 R08: 0000000000000000 R09: 00007fcdc00d37a0
      R10: 00005555559a72c0 R11: 0000000000000246 R12: 00000000f8008000
      R13: 0000000000000000 R14: 00083878000000f8 R15: 0000000000000000
       </TASK>
      
      The issue is caused when the value of fsi becomes less than -1.
      The check to break the loop when fsi value becomes -1 is present
      but syzbot was able to produce value less than -1 which cause the error.
      This patch simply add the change for the values less than 0.
      
      The patch is tested via syzbot.
      
      Reported-and-tested-by: default avatar <syzbot+d4b1df2e9d4ded6488ec@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?extid=d4b1df2e9d4ded6488ec
      
      
      Signed-off-by: default avatarOsama Muhammad <osmtendev@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      27e56f59
    • Osama Muhammad's avatar
      FS:JFS:UBSAN:array-index-out-of-bounds in dbAdjTree · 9862ec7a
      Osama Muhammad authored
      
      Syzkaller reported the following issue:
      
      UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:2867:6
      index 196694 is out of range for type 's8[1365]' (aka 'signed char[1365]')
      CPU: 1 PID: 109 Comm: jfsCommit Not tainted 6.6.0-rc3-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
       ubsan_epilogue lib/ubsan.c:217 [inline]
       __ubsan_handle_out_of_bounds+0x11c/0x150 lib/ubsan.c:348
       dbAdjTree+0x474/0x4f0 fs/jfs/jfs_dmap.c:2867
       dbJoin+0x210/0x2d0 fs/jfs/jfs_dmap.c:2834
       dbFreeBits+0x4eb/0xda0 fs/jfs/jfs_dmap.c:2331
       dbFreeDmap fs/jfs/jfs_dmap.c:2080 [inline]
       dbFree+0x343/0x650 fs/jfs/jfs_dmap.c:402
       txFreeMap+0x798/0xd50 fs/jfs/jfs_txnmgr.c:2534
       txUpdateMap+0x342/0x9e0
       txLazyCommit fs/jfs/jfs_txnmgr.c:2664 [inline]
       jfs_lazycommit+0x47a/0xb70 fs/jfs/jfs_txnmgr.c:2732
       kthread+0x2d3/0x370 kernel/kthread.c:388
       ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
       </TASK>
      ================================================================================
      Kernel panic - not syncing: UBSAN: panic_on_warn set ...
      CPU: 1 PID: 109 Comm: jfsCommit Not tainted 6.6.0-rc3-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
       panic+0x30f/0x770 kernel/panic.c:340
       check_panic_on_warn+0x82/0xa0 kernel/panic.c:236
       ubsan_epilogue lib/ubsan.c:223 [inline]
       __ubsan_handle_out_of_bounds+0x13c/0x150 lib/ubsan.c:348
       dbAdjTree+0x474/0x4f0 fs/jfs/jfs_dmap.c:2867
       dbJoin+0x210/0x2d0 fs/jfs/jfs_dmap.c:2834
       dbFreeBits+0x4eb/0xda0 fs/jfs/jfs_dmap.c:2331
       dbFreeDmap fs/jfs/jfs_dmap.c:2080 [inline]
       dbFree+0x343/0x650 fs/jfs/jfs_dmap.c:402
       txFreeMap+0x798/0xd50 fs/jfs/jfs_txnmgr.c:2534
       txUpdateMap+0x342/0x9e0
       txLazyCommit fs/jfs/jfs_txnmgr.c:2664 [inline]
       jfs_lazycommit+0x47a/0xb70 fs/jfs/jfs_txnmgr.c:2732
       kthread+0x2d3/0x370 kernel/kthread.c:388
       ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
       </TASK>
      Kernel Offset: disabled
      Rebooting in 86400 seconds..
      
      The issue is caused when the value of lp becomes greater than
      CTLTREESIZE which is the max size of stree. Adding a simple check
      solves this issue.
      
      Dave:
      As the function returns a void, good error handling
      would require a more intrusive code reorganization, so I modified
      Osama's patch at use WARN_ON_ONCE for lack of a cleaner option.
      
      The patch is tested via syzbot.
      
      Reported-by: default avatar <syzbot+39ba34a099ac2e9bd3cb@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?extid=39ba34a099ac2e9bd3cb
      
      
      Signed-off-by: default avatarOsama Muhammad <osmtendev@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      9862ec7a
  3. Oct 28, 2023
  4. Oct 18, 2023
  5. Oct 13, 2023
  6. Oct 09, 2023
  7. Oct 04, 2023
  8. Oct 03, 2023
  9. Aug 30, 2023
  10. Aug 29, 2023
  11. Aug 06, 2023
    • Linus Torvalds's avatar
      vfs: get rid of old '->iterate' directory operation · 3e327154
      Linus Torvalds authored
      
      All users now just use '->iterate_shared()', which only takes the
      directory inode lock for reading.
      
      Filesystems that never got convered to shared mode now instead use a
      wrapper that drops the lock, re-takes it in write mode, calls the old
      function, and then downgrades the lock back to read mode.
      
      This way the VFS layer and other callers no longer need to care about
      filesystems that never got converted to the modern era.
      
      The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
      ntfs, ocfs2, overlayfs, and vboxsf.
      
      Honestly, several of them look like they really could just iterate their
      directories in shared mode and skip the wrapper entirely, but the point
      of this change is to not change semantics or fix filesystems that
      haven't been fixed in the last 7+ years, but to finally get rid of the
      dual iterators.
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      3e327154
  12. Aug 02, 2023
  13. Jul 24, 2023
  14. Jul 18, 2023
    • Liu Shixin via Jfs-discussion's avatar
      jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount · 6e2bda2c
      Liu Shixin via Jfs-discussion authored
      
      syzbot found an invalid-free in diUnmount:
      
      BUG: KASAN: double-free in slab_free mm/slub.c:3661 [inline]
      BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3674
      Free of addr ffff88806f410000 by task syz-executor131/3632
      
       CPU: 0 PID: 3632 Comm: syz-executor131 Not tainted 6.1.0-rc7-syzkaller-00012-gca57f02295f1 #0
       Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
       Call Trace:
        <TASK>
        __dump_stack lib/dump_stack.c:88 [inline]
        dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
        print_address_description+0x74/0x340 mm/kasan/report.c:284
        print_report+0x107/0x1f0 mm/kasan/report.c:395
        kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:460
        ____kasan_slab_free+0xfb/0x120
        kasan_slab_free include/linux/kasan.h:177 [inline]
        slab_free_hook mm/slub.c:1724 [inline]
        slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750
        slab_free mm/slub.c:3661 [inline]
        __kmem_cache_free+0x71/0x110 mm/slub.c:3674
        diUnmount+0xef/0x100 fs/jfs/jfs_imap.c:195
        jfs_umount+0x108/0x370 fs/jfs/jfs_umount.c:63
        jfs_put_super+0x86/0x190 fs/jfs/super.c:194
        generic_shutdown_super+0x130/0x310 fs/super.c:492
        kill_block_super+0x79/0xd0 fs/super.c:1428
        deactivate_locked_super+0xa7/0xf0 fs/super.c:332
        cleanup_mnt+0x494/0x520 fs/namespace.c:1186
        task_work_run+0x243/0x300 kernel/task_work.c:179
        exit_task_work include/linux/task_work.h:38 [inline]
        do_exit+0x664/0x2070 kernel/exit.c:820
        do_group_exit+0x1fd/0x2b0 kernel/exit.c:950
        __do_sys_exit_group kernel/exit.c:961 [inline]
        __se_sys_exit_group kernel/exit.c:959 [inline]
        __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:959
        do_syscall_x64 arch/x86/entry/common.c:50 [inline]
        do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
        entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [...]
      
      JFS_IP(ipimap)->i_imap is not setting to NULL after free in diUnmount.
      If jfs_remount() free JFS_IP(ipimap)->i_imap but then failed at diMount().
      JFS_IP(ipimap)->i_imap will be freed once again.
      Fix this problem by setting JFS_IP(ipimap)->i_imap to NULL after free.
      
      Reported-by: default avatar <syzbot+90a11e6b1e810785c6ff@syzkaller.appspotmail.com>
      Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      6e2bda2c
    • Immad Mir's avatar
      FS: JFS: (trivial) Fix grammatical error in extAlloc · c67235d0
      Immad Mir authored
      
       There is a grammatical error in one the commnents
       in extAlloc function.
      
      Signed-off-by: default avatarImmad Mir <mirimmad17@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      c67235d0
    • Andrew Kanner's avatar
      fs/jfs: prevent double-free in dbUnmount() after failed jfs_remount() · cade5397
      Andrew Kanner authored
      
      Syzkaller reported the following issue:
      ==================================================================
      BUG: KASAN: double-free in slab_free mm/slub.c:3787 [inline]
      BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3800
      Free of addr ffff888086408000 by task syz-executor.4/12750
      [...]
      Call Trace:
       <TASK>
      [...]
       kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:482
       ____kasan_slab_free+0xfb/0x120
       kasan_slab_free include/linux/kasan.h:177 [inline]
       slab_free_hook mm/slub.c:1781 [inline]
       slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807
       slab_free mm/slub.c:3787 [inline]
       __kmem_cache_free+0x71/0x110 mm/slub.c:3800
       dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264
       jfs_umount+0x248/0x3b0 fs/jfs/jfs_umount.c:87
       jfs_put_super+0x86/0x190 fs/jfs/super.c:194
       generic_shutdown_super+0x130/0x310 fs/super.c:492
       kill_block_super+0x79/0xd0 fs/super.c:1386
       deactivate_locked_super+0xa7/0xf0 fs/super.c:332
       cleanup_mnt+0x494/0x520 fs/namespace.c:1291
       task_work_run+0x243/0x300 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop+0x124/0x150 kernel/entry/common.c:171
       exit_to_user_mode_prepare+0xb2/0x140 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x26/0x60 kernel/entry/common.c:296
       do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [...]
       </TASK>
      
      Allocated by task 13352:
       kasan_save_stack mm/kasan/common.c:45 [inline]
       kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
       ____kasan_kmalloc mm/kasan/common.c:371 [inline]
       __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:380
       kmalloc include/linux/slab.h:580 [inline]
       dbMount+0x54/0x980 fs/jfs/jfs_dmap.c:164
       jfs_mount+0x1dd/0x830 fs/jfs/jfs_mount.c:121
       jfs_fill_super+0x590/0xc50 fs/jfs/super.c:556
       mount_bdev+0x26c/0x3a0 fs/super.c:1359
       legacy_get_tree+0xea/0x180 fs/fs_context.c:610
       vfs_get_tree+0x88/0x270 fs/super.c:1489
       do_new_mount+0x289/0xad0 fs/namespace.c:3145
       do_mount fs/namespace.c:3488 [inline]
       __do_sys_mount fs/namespace.c:3697 [inline]
       __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 13352:
       kasan_save_stack mm/kasan/common.c:45 [inline]
       kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
       kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:518
       ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
       kasan_slab_free include/linux/kasan.h:177 [inline]
       slab_free_hook mm/slub.c:1781 [inline]
       slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807
       slab_free mm/slub.c:3787 [inline]
       __kmem_cache_free+0x71/0x110 mm/slub.c:3800
       dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264
       jfs_mount_rw+0x545/0x740 fs/jfs/jfs_mount.c:247
       jfs_remount+0x3db/0x710 fs/jfs/super.c:454
       reconfigure_super+0x3bc/0x7b0 fs/super.c:935
       vfs_fsconfig_locked fs/fsopen.c:254 [inline]
       __do_sys_fsconfig fs/fsopen.c:439 [inline]
       __se_sys_fsconfig+0xad5/0x1060 fs/fsopen.c:314
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [...]
      
      JFS_SBI(ipbmap->i_sb)->bmap wasn't set to NULL after kfree() in
      dbUnmount().
      
      Syzkaller uses faultinject to reproduce this KASAN double-free
      warning. The issue is triggered if either diMount() or dbMount() fail
      in jfs_remount(), since diUnmount() or dbUnmount() already happened in
      such a case - they will do double-free on next execution: jfs_umount
      or jfs_remount.
      
      Tested on both upstream and jfs-next by syzkaller.
      
      Reported-and-tested-by: default avatar <syzbot+6a93efb725385bc4b2e9@syzkaller.appspotmail.com>
      Closes: https://lore.kernel.org/all/000000000000471f2d05f1ce8bad@google.com/T/
      Link: https://syzkaller.appspot.com/bug?extid=6a93efb725385bc4b2e9
      
      
      Signed-off-by: default avatarAndrew Kanner <andrew.kanner@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      cade5397
  15. Jun 23, 2023
  16. Jun 22, 2023
    • Yogesh's avatar
      fs: jfs: Fix UBSAN: array-index-out-of-bounds in dbAllocDmapLev · 4e302336
      Yogesh authored
      
      Syzkaller reported the following issue:
      
      UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:1965:6
      index -84 is out of range for type 's8[341]' (aka 'signed char[341]')
      CPU: 1 PID: 4995 Comm: syz-executor146 Not tainted 6.4.0-rc6-syzkaller-00037-gb6dad5178cea #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
       ubsan_epilogue lib/ubsan.c:217 [inline]
       __ubsan_handle_out_of_bounds+0x11c/0x150 lib/ubsan.c:348
       dbAllocDmapLev+0x3e5/0x430 fs/jfs/jfs_dmap.c:1965
       dbAllocCtl+0x113/0x920 fs/jfs/jfs_dmap.c:1809
       dbAllocAG+0x28f/0x10b0 fs/jfs/jfs_dmap.c:1350
       dbAlloc+0x658/0xca0 fs/jfs/jfs_dmap.c:874
       dtSplitUp fs/jfs/jfs_dtree.c:974 [inline]
       dtInsert+0xda7/0x6b00 fs/jfs/jfs_dtree.c:863
       jfs_create+0x7b6/0xbb0 fs/jfs/namei.c:137
       lookup_open fs/namei.c:3492 [inline]
       open_last_lookups fs/namei.c:3560 [inline]
       path_openat+0x13df/0x3170 fs/namei.c:3788
       do_filp_open+0x234/0x490 fs/namei.c:3818
       do_sys_openat2+0x13f/0x500 fs/open.c:1356
       do_sys_open fs/open.c:1372 [inline]
       __do_sys_openat fs/open.c:1388 [inline]
       __se_sys_openat fs/open.c:1383 [inline]
       __x64_sys_openat+0x247/0x290 fs/open.c:1383
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f1f4e33f7e9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffc21129578 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1f4e33f7e9
      RDX: 000000000000275a RSI: 0000000020000040 RDI: 00000000ffffff9c
      RBP: 00007f1f4e2ff080 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1f4e2ff110
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      The bug occurs when the dbAllocDmapLev()function attempts to access
      dp->tree.stree[leafidx + LEAFIND] while the leafidx value is negative.
      
      To rectify this, the patch introduces a safeguard within the
      dbAllocDmapLev() function. A check has been added to verify if leafidx is
      negative. If it is, the function immediately returns an I/O error, preventing
      any further execution that could potentially cause harm.
      
      Tested via syzbot.
      
      Reported-by: default avatar <syzbot+853a6f4dfa3cf37d3aea@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?extid=ae2f5a27a07ae44b0f17
      
      
      Signed-off-by: default avatarYogesh <yogi.kernel@gmail.com>
      Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      4e302336
  17. Jun 20, 2023
  18. Jun 12, 2023
  19. Jun 05, 2023
  20. Jun 02, 2023
    • Kees Cook's avatar
      jfs: Use unsigned variable for length calculations · 820eb59d
      Kees Cook authored
      
      To avoid confusing the compiler about possible negative sizes, switch
      "ssize" which can never be negative from int to u32.  Seen with GCC 13:
      
      ../fs/jfs/namei.c: In function 'jfs_symlink': ../include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' pointer overflow between offset 0 and size [-2147483648, -1]
      [-Warray-bounds=]
         57 | #define __underlying_memcpy     __builtin_memcpy
            |                                 ^
      ...
      ../fs/jfs/namei.c:950:17: note: in expansion of macro 'memcpy'
        950 |                 memcpy(ip->i_link, name, ssize);
            |                 ^~~~~~
      
      Cc: Dave Kleikamp <shaggy@kernel.org>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Dave Chinner <dchinner@redhat.com>
      Cc: jfs-discussion@lists.sourceforge.net
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJeff Xu <jeffxu@chromium.org>
      Message-Id: <20230204183355.never.877-kees@kernel.org>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      820eb59d
  21. May 31, 2023
  22. May 24, 2023
  23. Mar 28, 2023
    • Christoph Hellwig's avatar
      mm,jfs: move write_one_page/folio_write_one to jfs · 452a8f40
      Christoph Hellwig authored
      The last remaining user of folio_write_one through the write_one_page
      wrapper is jfs, so move the functionality there and hard code the call to
      metapage_writepage.
      
      Note that the use of the pagecache by the JFS 'metapage' buffer cache is a
      bit odd, and we could probably do without VM-level dirty tracking at all,
      but that's a change for another time.
      
      Link: https://lkml.kernel.org/r/20230307143125.27778-4-hch@lst.de
      
      
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Evgeniy Dushistov <dushistov@mail.ru>
      Cc: Gang He <ghe@suse.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jan Kara via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      452a8f40
  24. Mar 13, 2023
Loading