Sign in
Sign up
Explore
Enterprise
Education
Search
Help
Terms of use
About Us
Explore
Enterprise
Education
Gitee Premium
Gitee AI
AI teammates
Sign in
Sign up
Fetch the repository succeeded.
description of repo status
Open Source
>
Other
>
Operation System
&&
Donate
Please sign in before you donate.
Cancel
Sign in
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
Watch
Unwatch
Watching
Releases Only
Ignoring
128
Star
73
Fork
329
src-openEuler
/
kernel
Closed
Code
Issues
1197
Pull Requests
35
Wiki
Insights
Pipelines
Service
JavaDoc
PHPDoc
Quality Analysis
Jenkins for Gitee
Tencent CloudBase
Tencent Cloud Serverless
悬镜安全
Aliyun SAE
Codeblitz
SBOM
DevLens
Don’t show this again
Update failed. Please try again later!
Remove this flag
Content Risk Flag
This task is identified by
as the content contains sensitive information such as code security bugs, privacy leaks, etc., so it is only accessible to contributors of this repository.
ext4: fix kernel BUG in 'ext4_write_inline_data_end()'
Done
#I8U2KA
Task
chengzhihao
Opened this issue
2024-01-06 12:19
ext4使能inline data后,在空间紧张情况下写文件,达到以下时序可能BUGON ``` ext4_da_write_begin ext4_da_write_inline_data_begin ext4_da_convert_inline_data_to_extent ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); ext4_da_write_end ext4_run_li_request ext4_mb_prefetch ext4_read_block_bitmap_nowait ext4_validate_block_bitmap ext4_mark_group_bitmap_corrupted(sb, block_group, EXT4_GROUP_INFO_BBITMAP_CORRUPT) percpu_counter_sub(&sbi->s_freeclusters_counter,grp->bb_free); -> sbi->s_freeclusters_counter become zero ext4_da_write_begin if (ext4_nonda_switch(inode->i_sb)) -> As freeclusters_counter is zero will return true *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; ext4_write_begin ext4_da_write_end if (write_mode == FALL_BACK_TO_NONDELALLOC) ext4_write_end if (inline_data) ext4_write_inline_data_end ext4_write_inline_data BUG_ON(pos + len > EXT4_I(inode)->i_inline_size); -> As inode is already convert to extent, so 'pos + len' > inline_size -> then trigger BUG. ``` 复现用例 ``` #!/bin/sh umount temp mkfs.ext4 -Oinline_data -F /dev/sda 1M mount /dev/sda temp echo 12 > temp/file ls -li temp/file dd if=/dev/urandom of=temp/file bs=2K count=1 conv=notrunc oflag=append for i in $(seq 1 5) do dd if=/dev/urandom of=temp/$i bs=100K count=1 done dd if=/dev/urandom of=temp/file bs=1 count=1 conv=notrunc oflag=append ``` 复现结果 ``` [ 126.779953][ T9794] ------------[ cut here ]------------ [ 126.780981][ T9794] kernel BUG at fs/ext4/inline.c:234! [ 126.781779][ T9794] invalid opcode: 0000 [#1] PREEMPT SMP [ 126.782506][ T9794] CPU: 2 PID: 9794 Comm: dd Not tainted 5.10.0+ #166 [ 126.783389][ T9794] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject4 [ 126.785236][ T9794] RIP: 0010:ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.786106][ T9794] Code: b8 3c 00 00 00 48 29 d8 4c 63 e8 29 c5 e9 75 ff ff ff e8 f1 0e ad ff 0f 0b 48 c7 c7 80 df 69 86 e8 1a 7c 24 9 [ 126.788641][ T9794] RSP: 0018:ffffc90001d2fb18 EFLAGS: 00010293 [ 126.789433][ T9794] RAX: ffff88811fa08000 RBX: 0000000000000803 RCX: ffffffff8190a8f6 [ 126.790452][ T9794] RDX: 0000000000000000 RSI: ffffffff8190a9f2 RDI: 0000000000000006 [ 126.791482][ T9794] RBP: 0000000000000001 R08: ffff88811fa08000 R09: 0000000000000001 [ 126.792513][ T9794] R10: ffffc90001d2faa8 R11: 6972775f34747865 R12: ffff88812d246098 [ 126.793539][ T9794] R13: 0000000000000804 R14: 000000000000003c R15: ffffc90001d2fb80 [ 126.794563][ T9794] FS: 00007fc05ca4d4c0(0000) GS:ffff888237d00000(0000) knlGS:0000000000000000 [ 126.795714][ T9794] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 126.796567][ T9794] CR2: 00007f566e4ed010 CR3: 0000000120782000 CR4: 00000000000006e0 [ 126.797603][ T9794] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 126.798635][ T9794] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 126.799658][ T9794] Call Trace: [ 126.800086][ T9794] ? __die_body+0x16/0x60 [ 126.800648][ T9794] ? die+0x26/0x40 [ 126.801127][ T9794] ? do_trap+0xe3/0x110 [ 126.801665][ T9794] ? do_error_trap+0x74/0x100 [ 126.802263][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.803060][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.803850][ T9794] ? rcu_is_watching+0xe/0x60 [ 126.804483][ T9794] ? exc_invalid_op+0x4e/0x70 [ 126.805086][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.805872][ T9794] ? asm_exc_invalid_op+0x12/0x20 [ 126.806515][ T9794] ? ext4_write_inline_data.isra.0+0x96/0x1a0 [ 126.807302][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.808090][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.808881][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.809695][ T9794] ext4_write_inline_data_end+0x417/0xc28 [ 126.810437][ T9794] ext4_write_end+0x101/0x820 [ 126.811045][ T9794] ext4_da_write_end+0x709/0x8e0 [ 126.811687][ T9794] generic_perform_write+0x155/0x2a0 [ 126.812375][ T9794] ext4_buffered_write_iter+0xc1/0x1b0 [ 126.813092][ T9794] ext4_file_write_iter+0xb8/0xd20 [ 126.813771][ T9794] new_sync_write+0x1da/0x2c0 [ 126.814389][ T9794] vfs_write+0x43a/0x630 [ 126.814953][ T9794] ksys_write+0xa6/0x170 [ 126.815503][ T9794] do_syscall_64+0x3a/0xb0 [ 126.816074][ T9794] entry_SYSCALL_64_after_hwframe+0x61/0xc6 ```
ext4使能inline data后,在空间紧张情况下写文件,达到以下时序可能BUGON ``` ext4_da_write_begin ext4_da_write_inline_data_begin ext4_da_convert_inline_data_to_extent ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); ext4_da_write_end ext4_run_li_request ext4_mb_prefetch ext4_read_block_bitmap_nowait ext4_validate_block_bitmap ext4_mark_group_bitmap_corrupted(sb, block_group, EXT4_GROUP_INFO_BBITMAP_CORRUPT) percpu_counter_sub(&sbi->s_freeclusters_counter,grp->bb_free); -> sbi->s_freeclusters_counter become zero ext4_da_write_begin if (ext4_nonda_switch(inode->i_sb)) -> As freeclusters_counter is zero will return true *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; ext4_write_begin ext4_da_write_end if (write_mode == FALL_BACK_TO_NONDELALLOC) ext4_write_end if (inline_data) ext4_write_inline_data_end ext4_write_inline_data BUG_ON(pos + len > EXT4_I(inode)->i_inline_size); -> As inode is already convert to extent, so 'pos + len' > inline_size -> then trigger BUG. ``` 复现用例 ``` #!/bin/sh umount temp mkfs.ext4 -Oinline_data -F /dev/sda 1M mount /dev/sda temp echo 12 > temp/file ls -li temp/file dd if=/dev/urandom of=temp/file bs=2K count=1 conv=notrunc oflag=append for i in $(seq 1 5) do dd if=/dev/urandom of=temp/$i bs=100K count=1 done dd if=/dev/urandom of=temp/file bs=1 count=1 conv=notrunc oflag=append ``` 复现结果 ``` [ 126.779953][ T9794] ------------[ cut here ]------------ [ 126.780981][ T9794] kernel BUG at fs/ext4/inline.c:234! [ 126.781779][ T9794] invalid opcode: 0000 [#1] PREEMPT SMP [ 126.782506][ T9794] CPU: 2 PID: 9794 Comm: dd Not tainted 5.10.0+ #166 [ 126.783389][ T9794] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject4 [ 126.785236][ T9794] RIP: 0010:ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.786106][ T9794] Code: b8 3c 00 00 00 48 29 d8 4c 63 e8 29 c5 e9 75 ff ff ff e8 f1 0e ad ff 0f 0b 48 c7 c7 80 df 69 86 e8 1a 7c 24 9 [ 126.788641][ T9794] RSP: 0018:ffffc90001d2fb18 EFLAGS: 00010293 [ 126.789433][ T9794] RAX: ffff88811fa08000 RBX: 0000000000000803 RCX: ffffffff8190a8f6 [ 126.790452][ T9794] RDX: 0000000000000000 RSI: ffffffff8190a9f2 RDI: 0000000000000006 [ 126.791482][ T9794] RBP: 0000000000000001 R08: ffff88811fa08000 R09: 0000000000000001 [ 126.792513][ T9794] R10: ffffc90001d2faa8 R11: 6972775f34747865 R12: ffff88812d246098 [ 126.793539][ T9794] R13: 0000000000000804 R14: 000000000000003c R15: ffffc90001d2fb80 [ 126.794563][ T9794] FS: 00007fc05ca4d4c0(0000) GS:ffff888237d00000(0000) knlGS:0000000000000000 [ 126.795714][ T9794] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 126.796567][ T9794] CR2: 00007f566e4ed010 CR3: 0000000120782000 CR4: 00000000000006e0 [ 126.797603][ T9794] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 126.798635][ T9794] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 126.799658][ T9794] Call Trace: [ 126.800086][ T9794] ? __die_body+0x16/0x60 [ 126.800648][ T9794] ? die+0x26/0x40 [ 126.801127][ T9794] ? do_trap+0xe3/0x110 [ 126.801665][ T9794] ? do_error_trap+0x74/0x100 [ 126.802263][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.803060][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.803850][ T9794] ? rcu_is_watching+0xe/0x60 [ 126.804483][ T9794] ? exc_invalid_op+0x4e/0x70 [ 126.805086][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.805872][ T9794] ? asm_exc_invalid_op+0x12/0x20 [ 126.806515][ T9794] ? ext4_write_inline_data.isra.0+0x96/0x1a0 [ 126.807302][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.808090][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.808881][ T9794] ? ext4_write_inline_data.isra.0+0x192/0x1a0 [ 126.809695][ T9794] ext4_write_inline_data_end+0x417/0xc28 [ 126.810437][ T9794] ext4_write_end+0x101/0x820 [ 126.811045][ T9794] ext4_da_write_end+0x709/0x8e0 [ 126.811687][ T9794] generic_perform_write+0x155/0x2a0 [ 126.812375][ T9794] ext4_buffered_write_iter+0xc1/0x1b0 [ 126.813092][ T9794] ext4_file_write_iter+0xb8/0xd20 [ 126.813771][ T9794] new_sync_write+0x1da/0x2c0 [ 126.814389][ T9794] vfs_write+0x43a/0x630 [ 126.814953][ T9794] ksys_write+0xa6/0x170 [ 126.815503][ T9794] do_syscall_64+0x3a/0xb0 [ 126.816074][ T9794] entry_SYSCALL_64_after_hwframe+0x61/0xc6 ```
Comments (
1
)
Sign in
to comment
Status
Done
Backlog
Doing
Done
Declined
Assignees
Not set
Labels
sig/Kernel
Not set
Projects
Unprojected
Unprojected
Pull Requests
None yet
None yet
Successfully merging a pull request will close this issue.
Branches
No related branch
Branches (
-
)
Tags (
-
)
Planed to start   -   Planed to end
-
Top level
Not Top
Top Level: High
Top Level: Medium
Top Level: Low
Priority
Not specified
Serious
Main
Secondary
Unimportant
Duration
(hours)
参与者(2)
1
https://gitee.com/src-openeuler/kernel.git
git@gitee.com:src-openeuler/kernel.git
src-openeuler
kernel
kernel
Going to Help Center
Search
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register