sysprog21 / simplefs

A simple native file system for Linux kernel
Other
362 stars 91 forks source link

Segmentation fault about execute symbolic link and then run ls commad. #30

Closed RoyWFHuang closed 8 months ago

RoyWFHuang commented 1 year ago

By execute make check for checking simplefs, I meet the can't be unload problem. Check the test script every test, I found if I maked the symbolic link test, the test script will run successful.

there are only test symbolic link and ls commnd

$ cd test15; sudo touch file;sudo ln -s file symlink;ls
file  symlink

but when you under the test dirctory and use ls command, you will see the Segmentation fault resoult

$ cd test15
test15$ ls
Segmentation fault

Here is kernel log

[ 1242.539714] usercopy: Kernel memory exposure attempt detected from SLUB object 'simplefs_cache' (offset 4, size 4)!
[ 1242.549642] ------------[ cut here ]------------
[ 1242.549648] kernel BUG at mm/usercopy.c:99!
[ 1242.552914] invalid opcode: 0000 [#1] SMP PTI
[ 1242.556949] CPU: 0 PID: 1812 Comm: ls Tainted: G           OE     5.15.0-78-generic #85-Ubuntu
[ 1242.567873] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
[ 1242.574281] RIP: 0010:usercopy_abort+0x7b/0x7d
[ 1242.577415] Code: 26 5f b3 48 0f 44 d6 49 c7 c3 35 b8 5e b3 50 4c 89 d1 57 48 c7 c6 34 5f 60 b3 48 c7 c7 a0 5e 60 b3 49 0f 44 f3 e8 6e 84 fe ff <0f> 0b 4c 89 e1 4d 89 f0 44 89 ea 31 f6 48 29 c1 48 c7 c7 76 5f 60
[ 1242.591191] RSP: 0018:ffffaa2f80d1bd78 EFLAGS: 00010246
[ 1242.594891] RAX: 0000000000000067 RBX: 0000000000000004 RCX: 0000000000000000
[ 1242.600001] RDX: 0000000000000000 RSI: ffff9960f7c20580 RDI: ffff9960f7c20580
[ 1242.605193] RBP: ffffaa2f80d1bd90 R08: 0000000000000003 R09: 0000000000cdcdcd
[ 1242.610791] R10: ffffffffb32a8600 R11: ffff995fc5acadb0 R12: 0000000000000004
[ 1242.615711] R13: ffff995fc0b40300 R14: 0000000000000001 R15: 00000000000002a0
[ 1242.620522] FS:  00007f61d08a3800(0000) GS:ffff9960f7c00000(0000) knlGS:0000000000000000
[ 1242.625260] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1242.628019] CR2: 0000563e6833a0e2 CR3: 00000001051f2004 CR4: 0000000000370ef0
[ 1242.631398] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1242.634017] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 1242.636512] Call Trace:
[ 1242.637408]  <TASK>
[ 1242.638178]  __check_heap_object+0x174/0x1b0
[ 1242.639708]  __check_object_size.part.0+0x134/0x150
[ 1242.641183]  __check_object_size+0x1d/0x30
[ 1242.642378]  readlink_copy+0x51/0x90
[ 1242.643417]  vfs_readlink+0x5e/0x130
[ 1242.644527]  do_readlinkat+0x105/0x130
[ 1242.645672]  __x64_sys_readlink+0x1e/0x30
[ 1242.646877]  do_syscall_64+0x59/0xc0
[ 1242.647938]  ? irqentry_exit+0x1d/0x30
[ 1242.648848]  ? exc_page_fault+0x89/0x170
[ 1242.649833]  entry_SYSCALL_64_after_hwframe+0x61/0xcb
[ 1242.651299] RIP: 0033:0x7f61d0a531fb
[ 1242.652202] Code: 73 01 c3 48 8b 0d 35 2c 10 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 59 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 05 2c 10 00 f7 d8 64 89 01 48
[ 1242.656628] RSP: 002b:00007ffe8a787798 EFLAGS: 00000202 ORIG_RAX: 0000000000000059
[ 1242.658187] RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007f61d0a531fb
[ 1242.659655] RDX: 0000000000000005 RSI: 0000563e68341fd0 RDI: 00007ffe8a787880
[ 1242.661187] RBP: 00007ffe8a787880 R08: 0000000000000000 R09: 0000563e68341fd0
[ 1242.662649] R10: 0000000000000002 R11: 0000000000000202 R12: 3fffffffffffffff
[ 1242.664218] R13: 0000563e68341fd0 R14: 0000000000000001 R15: 0000563e68341fd0
[ 1242.665678]  </TASK>
[ 1242.666131] Modules linked in: simplefs(OE) isofs binfmt_misc nls_iso8859_1 ppdev kvm_intel kvm input_leds joydev serio_raw parport_pc parport dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua sch_fq_codel drm efi_pstore ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear crct10dif_pclmul crc32_pclmul virtio_net ghash_clmulni_intel net_failover aesni_intel crypto_simd psmouse cryptd failover floppy virtio_scsi
[ 1242.676058] ---[ end trace 02c7e98b44187dc1 ]---
[ 1242.694248] RIP: 0010:usercopy_abort+0x7b/0x7d
[ 1242.696591] Code: 26 5f b3 48 0f 44 d6 49 c7 c3 35 b8 5e b3 50 4c 89 d1 57 48 c7 c6 34 5f 60 b3 48 c7 c7 a0 5e 60 b3 49 0f 44 f3 e8 6e 84 fe ff <0f> 0b 4c 89 e1 4d 89 f0 44 89 ea 31 f6 48 29 c1 48 c7 c7 76 5f 60
[ 1242.702891] RSP: 0018:ffffaa2f80d1bd78 EFLAGS: 00010246
[ 1242.705635] RAX: 0000000000000067 RBX: 0000000000000004 RCX: 0000000000000000
[ 1242.708228] RDX: 0000000000000000 RSI: ffff9960f7c20580 RDI: ffff9960f7c20580
[ 1242.710651] RBP: ffffaa2f80d1bd90 R08: 0000000000000003 R09: 0000000000cdcdcd
[ 1242.713546] R10: ffffffffb32a8600 R11: ffff995fc5acadb0 R12: 0000000000000004
[ 1242.715988] R13: ffff995fc0b40300 R14: 0000000000000001 R15: 00000000000002a0
[ 1242.718359] FS:  00007f61d08a3800(0000) GS:ffff9960f7c00000(0000) knlGS:0000000000000000
[ 1242.721107] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1242.723102] CR2: 0000563e6833a0e2 CR3: 00000001051f2004 CR4: 0000000000370ef0
[ 1242.725792] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1242.728619] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Test environmet: physical PC host: Ubuntu 22.04 kernel 5.15 running environment: multipass running with kernel 5.15

But this test passed on Linux v5.4.