2015-06-11 00:21:57

by Seunghun Lee

[permalink] [raw]
Subject: ext4: truncate issue in ext4 encryption.

Hi,

I was running fsstress on encrypted ext4 image,
and I hit BUG_ON(blocksize != PAGE_CACHE_SIZE); in __ext4_block_zero_page_range.

It occurs when I'm using filesytem that has small block size(1024 bytes).

reproducible test case and is below.

root@qemux86:~# mount -t ext4 hi.img tmp -o test_dummy_encryption
root@qemux86:~# echo hello > tmp/testfile
root@qemux86:~# echo 2 > /proc/sys/vm/drop_caches
root@qemux86:~# truncate --size 3 tmp/testfile
[ 361.108795] ------------[ cut here ]------------
[ 361.108990] kernel BUG at fs/ext4/inode.c:3378!
[ 361.109080] invalid opcode: 0000 [#1] SMP
[ 361.109080] Modules linked in:
[ 361.109080] CPU: 0 PID: 1436 Comm: truncate Not tainted 4.1.0-rc4+ #10
[ 361.109080] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
[ 361.109080] task: ffff88001eb2f5d0 ti: ffff88001e130000 task.ti: ffff88001e130000
[ 361.109080] RIP: 0010:[<ffffffff811e94d5>] [<ffffffff811e94d5>] ext4_block_zero_page_range+0x425/0x430
[ 361.109080] RSP: 0018:ffff88001e133d08 EFLAGS: 00000287
[ 361.109080] RAX: 0000000000000001 RBX: ffff88001dd4df08 RCX: 000000000000002b
[ 361.109080] RDX: 0000000000000000 RSI: ffff88001eb2f5d0 RDI: ffff88001de0ec90
[ 361.109080] RBP: ffff88001e133d68 R08: ffff88001e130000 R09: 0000000000000001
[ 361.109080] R10: 000000000000bbe2 R11: 0000000000000400 R12: 00000000000003fd
[ 361.109080] R13: ffff88001de0ec90 R14: 0000000000000003 R15: ffffea00007eeec0
[ 361.109080] FS: 0000000000000000(0000) GS:ffff88001fc00000(0063) knlGS:00000000f770d6c0
[ 361.109080] CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b
[ 361.109080] CR2: 0000000008181004 CR3: 000000001d975000 CR4: 00000000000006f0
[ 361.109080] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 361.109080] DR3: 0000000000000000 DR6: 0000000000000000 DR7: 0000000000000000
[ 361.109080] Stack:
[ 361.109080] ffffffff811eca0d 0000040000000000 0000000000000400 ffff88001dd73810
[ 361.109080] ffff88001e133d78 ffff88001dd4df08 0000000000000004 ffff88001dd73810
[ 361.109080] ffff88001de0ec90 ffff88001de0ede0 0000000000002068 0000000000000000
[ 361.109080] Call Trace:
[ 361.109080] [<ffffffff811eca0d>] ? ext4_truncate+0x12d/0x3d0
[ 361.109080] [<ffffffff811ecbfd>] ext4_truncate+0x31d/0x3d0
[ 361.109080] [<ffffffff81124f78>] ? truncate_pagecache+0x58/0x70
[ 361.109080] [<ffffffff811ee560>] ext4_setattr+0x380/0x730
[ 361.109080] [<ffffffff8118444c>] notify_change+0x1ec/0x3a0
[ 361.109080] [<ffffffff81166a98>] do_truncate+0x68/0xa0
[ 361.109080] [<ffffffff81166dfc>] do_sys_ftruncate.constprop.18+0xfc/0x150
[ 361.109080] [<ffffffff81166e79>] SyS_ftruncate+0x9/0x10
[ 361.109080] [<ffffffff8104cd83>] sys32_ftruncate64+0x13/0x20
[ 361.109080] [<ffffffff8189b715>] ia32_do_call+0x13/0x13
[ 361.109080] Code: fc ff ff 49 8b b5 18 02 00 00 48 8b 7d b8 e8 23 e9 04 00 89 c3 e9 fe fd ff ff b8 f4 ff ff ff e9 06 fe ff ff 0f 0b e8 9a 4d 6a 00 <0f> 0b 0f 0b 0f 1f 80 00 00 00 00 55 b9 0b 00 00 00 48 89 e5 e8
[ 361.109080] RIP [<ffffffff811e94d5>] ext4_block_zero_page_range+0x425/0x430
[ 361.109080] RSP <ffff88001e133d08>
[ 361.116796] ---[ end trace 7f5b0e6b82cd8fc5 ]---
Segmentation fault


Thanks.


2015-06-11 14:22:48

by Theodore Ts'o

[permalink] [raw]
Subject: Re: ext4: truncate issue in ext4 encryption.

On Thu, Jun 11, 2015 at 09:08:36AM +0900, Seunghun Lee wrote:
> Hi,
>
> I was running fsstress on encrypted ext4 image,
> and I hit BUG_ON(blocksize != PAGE_CACHE_SIZE); in __ext4_block_zero_page_range.
>
> It occurs when I'm using filesytem that has small block size(1024 bytes).

Yes, we don't have support for blocksize != pagesize yet. This should
have been prevented when the file system was mounted. I thought we
had that check, but obviously we had forgotten to add it or it had
somehow gotten dropped. Thanks for the bug report.

Regards,

- Ted