[PATCH] Debug fault in xattr_set_entry

0 views
Skip to first unread message

Tadeusz Struk

unread,
Sep 22, 2022, 5:28:34 PM9/22/22
to syzbot+70627c...@syzkaller.appspotmail.com, syzkaller-a...@googlegroups.com, tadeus...@linaro.org
#syz test: https://android.googlesource.com/kernel/common android12-5.10-lts

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 5462f26907c1..9c42bd662d88 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1581,8 +1581,10 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
goto update_hash;
}

+printk("In ext4_xattr_set_entry s %lx, last = %lx\n", s, s->first);
/* Compute min_offs and last. */
last = s->first;
+
for (; !IS_LAST_ENTRY(last); last = next) {
next = EXT4_XATTR_NEXT(last);
if ((void *)next >= s->end) {
--
2.37.3

syzbot

unread,
Sep 22, 2022, 5:38:20 PM9/22/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in ext4_xattr_set_entry

In ext4_xattr_set_entry s ffff88810cefc100, last = ffff88811da795a4
In ext4_xattr_set_entry s ffffc90000b57740, last = ffff88810d870020
In ext4_xattr_set_entry s ffffc90000b577a0, last = 0
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 1 PID: 405 Comm: syz-executor.0 Not tainted 5.10.144-syzkaller-987214-g7474313da8d6-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2022
RIP: 0010:ext4_xattr_set_entry+0x858/0x22a0 fs/ext4/xattr.c:1588
Code: e6 31 c0 e8 e7 cb a5 02 48 89 9c 24 b8 00 00 00 42 80 3c 2b 00 74 08 4c 89 e7 e8 73 87 ba ff 4d 8b 24 24 4c 89 e0 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 35 17 00 00 4c 2b b4 24 a0 00 00 00 4c 89
RSP: 0018:ffffc90000b574a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 1ffff9200016aef4 RCX: 3d2ea00db2221f00
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc90000b57638 R08: ffffffff8153d3e8 R09: ffffed103ee6a5e8
R10: ffffed103ee6a5e8 R11: 1ffff1103ee6a5e7 R12: 0000000000000000
R13: dffffc0000000000 R14: 0000000000000000 R15: ffffc90000b57768
FS: 0000555556b76400(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555556b87b78 CR3: 0000000101fef000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
ext4_xattr_ibody_set+0x7c/0x2a0 fs/ext4/xattr.c:2229
ext4_xattr_set_handle+0xc5d/0x15a0 fs/ext4/xattr.c:2386
ext4_initxattrs+0xb2/0x120 fs/ext4/xattr_security.c:43
security_inode_init_security+0x26c/0x3c0 security/security.c:1033
ext4_init_security+0x34/0x40 fs/ext4/xattr_security.c:57
__ext4_new_inode+0x3648/0x4530 fs/ext4/ialloc.c:1322
ext4_mkdir+0x3b3/0xbb0 fs/ext4/namei.c:2947
vfs_mkdir+0x435/0x610 fs/namei.c:3729
do_mkdirat+0x1b6/0x2d0 fs/namei.c:3752
__do_sys_mkdirat fs/namei.c:3763 [inline]
__se_sys_mkdirat fs/namei.c:3761 [inline]
__x64_sys_mkdirat+0x7b/0x90 fs/namei.c:3761
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f7504a27387
Code: 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 02 01 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:00007ffc21ad2558 EFLAGS: 00000202 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007ffc21ad25e0 RCX: 00007f7504a27387
RDX: 00000000000001ff RSI: 00007ffc21ad25e0 RDI: 00000000ffffff9c
RBP: 00007ffc21ad25bc R08: 0000000000000000 R09: 0000000000000003
R10: 00007ffc21ad22f7 R11: 0000000000000202 R12: 0000000000000032
R13: 000000000000901e R14: 0000000000000003 R15: 00007ffc21ad2620
Modules linked in:
---[ end trace 8b9764118d25f940 ]---
RIP: 0010:ext4_xattr_set_entry+0x858/0x22a0 fs/ext4/xattr.c:1588
Code: e6 31 c0 e8 e7 cb a5 02 48 89 9c 24 b8 00 00 00 42 80 3c 2b 00 74 08 4c 89 e7 e8 73 87 ba ff 4d 8b 24 24 4c 89 e0 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 35 17 00 00 4c 2b b4 24 a0 00 00 00 4c 89
RSP: 0018:ffffc90000b574a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 1ffff9200016aef4 RCX: 3d2ea00db2221f00
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffc90000b57638 R08: ffffffff8153d3e8 R09: ffffed103ee6a5e8
R10: ffffed103ee6a5e8 R11: 1ffff1103ee6a5e7 R12: 0000000000000000
R13: dffffc0000000000 R14: 0000000000000000 R15: ffffc90000b57768
FS: 0000555556b76400(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555556b87b78 CR3: 0000000101fef000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: e6 31 out %al,$0x31
2: c0 e8 e7 shr $0xe7,%al
5: cb lret
6: a5 movsl %ds:(%rsi),%es:(%rdi)
7: 02 48 89 add -0x77(%rax),%cl
a: 9c pushfq
b: 24 b8 and $0xb8,%al
d: 00 00 add %al,(%rax)
f: 00 42 80 add %al,-0x80(%rdx)
12: 3c 2b cmp $0x2b,%al
14: 00 74 08 4c add %dh,0x4c(%rax,%rcx,1)
18: 89 e7 mov %esp,%edi
1a: e8 73 87 ba ff callq 0xffba8792
1f: 4d 8b 24 24 mov (%r12),%r12
23: 4c 89 e0 mov %r12,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 8a 04 28 mov (%rax,%r13,1),%al <-- trapping instruction
2e: 84 c0 test %al,%al
30: 0f 85 35 17 00 00 jne 0x176b
36: 4c 2b b4 24 a0 00 00 sub 0xa0(%rsp),%r14
3d: 00
3e: 4c rex.WR
3f: 89 .byte 0x89


Tested on:

commit: 7474313d Merge 5.10.144 into android12-5.10-lts
git tree: android12-5.10-lts
console output: https://syzkaller.appspot.com/x/log.txt?x=12828b8c880000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3f70c59f45da9a3
dashboard link: https://syzkaller.appspot.com/bug?extid=70627ce76b4994c2e0b4
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=14293050880000

Tadeusz Struk

unread,
Sep 22, 2022, 5:47:02 PM9/22/22
to syzbot+70627c...@syzkaller.appspotmail.com, syzkaller-a...@googlegroups.com, tadeus...@linaro.org
#syz test: https://android.googlesource.com/kernel/common android12-5.10-lts

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 5462f26907c1..88c90c2f75b0 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1581,9 +1581,12 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
goto update_hash;
}

+printk("In ext4_xattr_set_entry s %lx, last = %lx, name len %d\n", s, s->first, EXT4_XATTR_LEN((s->first)->e_name_len));
/* Compute min_offs and last. */
last = s->first;
+
for (; !IS_LAST_ENTRY(last); last = next) {
+printk("In next ext4_xattr_set_entry s %lx, name len %d", last, EXT4_XATTR_LEN((last)->e_name_len));
next = EXT4_XATTR_NEXT(last);
if ((void *)next >= s->end) {
EXT4_ERROR_INODE(inode, "corrupted xattr entries");
--
2.37.3

syzbot

unread,
Sep 22, 2022, 6:01:21 PM9/22/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in ext4_xattr_set_entry

In ext4_xattr_set_entry s ffff88810d860700, last = ffff88811dec15a4, name len 24
In next ext4_xattr_set_entry s ffff88811dec15a4, name len 24
In ext4_xattr_set_entry s ffffc90000b17740, last = ffff88810da9c020, name len 16
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 1 PID: 405 Comm: syz-executor.0 Not tainted 5.10.144-syzkaller-987214-g7474313da8d6-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2022
RIP: 0010:ext4_xattr_set_entry+0x983/0x2290 fs/ext4/xattr.c:1584
Code: 03 48 89 84 24 c0 00 00 00 42 80 3c 28 00 4c 8d b4 24 00 01 00 00 74 08 4c 89 ff e8 47 86 ba ff 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 dd 15 00 00 0f b6 0b 83 c1 13 83 e1 fc 48
RSP: 0018:ffffc90000b174a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88810c6d93c0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000001c
RBP: ffffc90000b17638 R08: ffffffff81ec6ae8 R09: ffffed1021d75479
R10: ffffed1021d75479 R11: 1ffff11021d75478 R12: 0000000000000000
R13: dffffc0000000000 R14: ffffc90000b175a0 R15: ffffc90000b177a0
FS: 0000555556525400(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555556536b78 CR3: 0000000101984000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
ext4_xattr_ibody_set+0x7c/0x2a0 fs/ext4/xattr.c:2230
ext4_xattr_set_handle+0xc5d/0x15a0 fs/ext4/xattr.c:2387
ext4_initxattrs+0xb2/0x120 fs/ext4/xattr_security.c:43
security_inode_init_security+0x26c/0x3c0 security/security.c:1033
ext4_init_security+0x34/0x40 fs/ext4/xattr_security.c:57
__ext4_new_inode+0x3648/0x4530 fs/ext4/ialloc.c:1322
ext4_mkdir+0x3b3/0xbb0 fs/ext4/namei.c:2947
vfs_mkdir+0x435/0x610 fs/namei.c:3729
do_mkdirat+0x1b6/0x2d0 fs/namei.c:3752
__do_sys_mkdirat fs/namei.c:3763 [inline]
__se_sys_mkdirat fs/namei.c:3761 [inline]
__x64_sys_mkdirat+0x7b/0x90 fs/namei.c:3761
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f986a88e387
Code: 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 02 01 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:00007ffe2b7285e8 EFLAGS: 00000206 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007ffe2b728670 RCX: 00007f986a88e387
RDX: 00000000000001ff RSI: 00007ffe2b728670 RDI: 00000000ffffff9c
RBP: 00007ffe2b72864c R08: 0000000000000000 R09: 0000000000000003
R10: 00007ffe2b728387 R11: 0000000000000206 R12: 0000000000000032
R13: 00000000000093c2 R14: 0000000000000003 R15: 00007ffe2b7286b0
Modules linked in:
---[ end trace 5f9831cceaaf02b1 ]---
RIP: 0010:ext4_xattr_set_entry+0x983/0x2290 fs/ext4/xattr.c:1584
Code: 03 48 89 84 24 c0 00 00 00 42 80 3c 28 00 4c 8d b4 24 00 01 00 00 74 08 4c 89 ff e8 47 86 ba ff 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 dd 15 00 00 0f b6 0b 83 c1 13 83 e1 fc 48
RSP: 0018:ffffc90000b174a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88810c6d93c0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000001c
RBP: ffffc90000b17638 R08: ffffffff81ec6ae8 R09: ffffed1021d75479
R10: ffffed1021d75479 R11: 1ffff11021d75478 R12: 0000000000000000
R13: dffffc0000000000 R14: ffffc90000b175a0 R15: ffffc90000b177a0
FS: 0000555556525400(0000) GS:ffff8881f7200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055635dfda098 CR3: 0000000101984000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 03 48 89 add -0x77(%rax),%ecx
3: 84 24 c0 test %ah,(%rax,%rax,8)
6: 00 00 add %al,(%rax)
8: 00 42 80 add %al,-0x80(%rdx)
b: 3c 28 cmp $0x28,%al
d: 00 4c 8d b4 add %cl,-0x4c(%rbp,%rcx,4)
11: 24 00 and $0x0,%al
13: 01 00 add %eax,(%rax)
15: 00 74 08 4c add %dh,0x4c(%rax,%rcx,1)
19: 89 ff mov %edi,%edi
1b: e8 47 86 ba ff callq 0xffba8667
20: 49 8b 1f mov (%r15),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 8a 04 28 mov (%rax,%r13,1),%al <-- trapping instruction
2e: 84 c0 test %al,%al
30: 0f 85 dd 15 00 00 jne 0x1613
36: 0f b6 0b movzbl (%rbx),%ecx
39: 83 c1 13 add $0x13,%ecx
3c: 83 e1 fc and $0xfffffffc,%ecx
3f: 48 rex.W


Tested on:

commit: 7474313d Merge 5.10.144 into android12-5.10-lts
git tree: android12-5.10-lts
console output: https://syzkaller.appspot.com/x/log.txt?x=15c8f554880000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3f70c59f45da9a3
dashboard link: https://syzkaller.appspot.com/bug?extid=70627ce76b4994c2e0b4
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=12c8f554880000

Tadeusz Struk

unread,
Sep 22, 2022, 6:13:51 PM9/22/22
to syzbot+70627c...@syzkaller.appspotmail.com, syzkaller-a...@googlegroups.com, tadeus...@linaro.org
#syz test: https://android.googlesource.com/kernel/common android12-5.10-lts

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 5462f26907c1..2a7874c043a2 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1581,9 +1581,12 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
goto update_hash;
}

+printk("In ext4_xattr_set_entry s %lx, last = %lx, lastdefref %lx, name len %d\n", s, s->first,*(__u32 *) s->first, EXT4_XATTR_LEN((s->first)->e_name_len));

syzbot

unread,
Sep 22, 2022, 6:24:23 PM9/22/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in ext4_xattr_set_entry

In next ext4_xattr_set_entry s ffff88811d9b88a4, name len 24
In ext4_xattr_set_entry s ffffc90000bf76a0, last = ffff88810d8e8020, lastdefref 0, name len 16
In ext4_xattr_set_entry s ffff88810c97f700, last = ffff88811d9b85a4, lastdefref 400607, name len 24
In next ext4_xattr_set_entry s ffff88811d9b85a4, name len 24
In ext4_xattr_set_entry s ffffc90000bf7740, last = ffff88810d8ea020, lastdefref 0, name len 16
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 1 PID: 405 Comm: syz-executor.0 Not tainted 5.10.144-syzkaller-987214-g7474313da8d6-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2022
RIP: 0010:ext4_xattr_set_entry+0x983/0x2290 fs/ext4/xattr.c:1584
Code: 03 48 89 84 24 c0 00 00 00 42 80 3c 28 00 4c 8d b4 24 00 01 00 00 74 08 4c 89 ff e8 47 86 ba ff 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 dd 15 00 00 8b 0b 44 0f b6 c1 41 83 c0 13
RSP: 0018:ffffc90000bf74a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff8881019ba780
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000001c
RBP: ffffc90000bf7638 R08: ffffffff81ec6ae8 R09: ffffed10241039a4
R10: ffffed10241039a4 R11: 1ffff110241039a3 R12: 0000000000000000
R13: dffffc0000000000 R14: ffffc90000bf75a0 R15: ffffc90000bf77a0
FS: 0000555556332400(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555556343b78 CR3: 000000010c7d6000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
ext4_xattr_ibody_set+0x7c/0x2a0 fs/ext4/xattr.c:2230
ext4_xattr_set_handle+0xc5d/0x15a0 fs/ext4/xattr.c:2387
ext4_initxattrs+0xb2/0x120 fs/ext4/xattr_security.c:43
security_inode_init_security+0x26c/0x3c0 security/security.c:1033
ext4_init_security+0x34/0x40 fs/ext4/xattr_security.c:57
__ext4_new_inode+0x3648/0x4530 fs/ext4/ialloc.c:1322
ext4_mkdir+0x3b3/0xbb0 fs/ext4/namei.c:2947
vfs_mkdir+0x435/0x610 fs/namei.c:3729
do_mkdirat+0x1b6/0x2d0 fs/namei.c:3752
__do_sys_mkdirat fs/namei.c:3763 [inline]
__se_sys_mkdirat fs/namei.c:3761 [inline]
__x64_sys_mkdirat+0x7b/0x90 fs/namei.c:3761
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7fb0c9da4387
Code: 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 02 01 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:00007ffff766abd8 EFLAGS: 00000206 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007ffff766ac60 RCX: 00007fb0c9da4387
RDX: 00000000000001ff RSI: 00007ffff766ac60 RDI: 00000000ffffff9c
RBP: 00007ffff766ac3c R08: 0000000000000000 R09: 0000000000000003
R10: 00007ffff766a977 R11: 0000000000000206 R12: 0000000000000032
R13: 000000000000972a R14: 0000000000000003 R15: 00007ffff766aca0
Modules linked in:
---[ end trace b70b13fcd2842dc1 ]---
RIP: 0010:ext4_xattr_set_entry+0x983/0x2290 fs/ext4/xattr.c:1584
Code: 03 48 89 84 24 c0 00 00 00 42 80 3c 28 00 4c 8d b4 24 00 01 00 00 74 08 4c 89 ff e8 47 86 ba ff 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 dd 15 00 00 8b 0b 44 0f b6 c1 41 83 c0 13
RSP: 0018:ffffc90000bf74a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff8881019ba780
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000001c
RBP: ffffc90000bf7638 R08: ffffffff81ec6ae8 R09: ffffed10241039a4
R10: ffffed10241039a4 R11: 1ffff110241039a3 R12: 0000000000000000
R13: dffffc0000000000 R14: ffffc90000bf75a0 R15: ffffc90000bf77a0
FS: 0000555556332400(0000) GS:ffff8881f7200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557e00aa0098 CR3: 000000010c7d6000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 03 48 89 add -0x77(%rax),%ecx
3: 84 24 c0 test %ah,(%rax,%rax,8)
6: 00 00 add %al,(%rax)
8: 00 42 80 add %al,-0x80(%rdx)
b: 3c 28 cmp $0x28,%al
d: 00 4c 8d b4 add %cl,-0x4c(%rbp,%rcx,4)
11: 24 00 and $0x0,%al
13: 01 00 add %eax,(%rax)
15: 00 74 08 4c add %dh,0x4c(%rax,%rcx,1)
19: 89 ff mov %edi,%edi
1b: e8 47 86 ba ff callq 0xffba8667
20: 49 8b 1f mov (%r15),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 8a 04 28 mov (%rax,%r13,1),%al <-- trapping instruction
2e: 84 c0 test %al,%al
30: 0f 85 dd 15 00 00 jne 0x1613
36: 8b 0b mov (%rbx),%ecx
38: 44 0f b6 c1 movzbl %cl,%r8d
3c: 41 83 c0 13 add $0x13,%r8d


Tested on:

commit: 7474313d Merge 5.10.144 into android12-5.10-lts
git tree: android12-5.10-lts
console output: https://syzkaller.appspot.com/x/log.txt?x=133b9488880000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3f70c59f45da9a3
dashboard link: https://syzkaller.appspot.com/bug?extid=70627ce76b4994c2e0b4
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=17ee8dd5080000

Tadeusz Struk

unread,
Sep 22, 2022, 7:27:15 PM9/22/22
to syzbot+70627c...@syzkaller.appspotmail.com, syzkaller-a...@googlegroups.com, tadeus...@linaro.org
#syz test: https://android.googlesource.com/kernel/common android12-5.10-lts

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 5462f26907c1..090a4a9d5cc9 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1581,9 +1581,12 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
goto update_hash;
}

+printk("In ext4_xattr_set_entry s %lx, last = %lx, name len %x\n", s, s->first, s->first, EXT4_XATTR_LEN((s->first)->e_name_len));
/* Compute min_offs and last. */
last = s->first;
+
for (; !IS_LAST_ENTRY(last); last = next) {
+printk("In next ext4_xattr_set_entry s %lx, name len %d", last, EXT4_XATTR_LEN((last)->e_name_len));
next = EXT4_XATTR_NEXT(last);
if ((void *)next >= s->end) {
EXT4_ERROR_INODE(inode, "corrupted xattr entries");
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c
index 50fb71393fb6..7bcb40424ece 100644
--- a/fs/ext4/xattr_security.c
+++ b/fs/ext4/xattr_security.c
@@ -40,6 +40,7 @@ ext4_initxattrs(struct inode *inode, const struct xattr *xattr_array,
int err = 0;

for (xattr = xattr_array; xattr->name != NULL; xattr++) {
+printk("!!!ext4_initxattrs set hndl name %s \n", xattr->name);
err = ext4_xattr_set_handle(handle, inode,
EXT4_XATTR_INDEX_SECURITY,
xattr->name, xattr->value,
--
2.37.3

syzbot

unread,
Sep 22, 2022, 7:36:23 PM9/22/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in ext4_xattr_set_entry

!!!ext4_initxattrs set hndl name selinux
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
CPU: 1 PID: 405 Comm: syz-executor.0 Not tainted 5.10.144-syzkaller-987214-g7474313da8d6-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2022
RIP: 0010:ext4_xattr_set_entry+0x983/0x2290 fs/ext4/xattr.c:1584
Code: 03 48 89 84 24 c0 00 00 00 42 80 3c 28 00 4c 8d b4 24 00 01 00 00 74 08 4c 89 ff e8 47 86 ba ff 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 dd 15 00 00 44 0f b6 03 41 83 c0 13 41 83
RSP: 0018:ffffc900009ef4a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88810c432780
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000001c
RBP: ffffc900009ef638 R08: ffffffff81ec6ae8 R09: ffffed10241015f3
R10: ffffed10241015f3 R11: 1ffff110241015f2 R12: 0000000000000000
R13: dffffc0000000000 R14: ffffc900009ef5a0 R15: ffffc900009ef7a0
FS: 000055555602d400(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055555603eb78 CR3: 000000010c556000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
ext4_xattr_ibody_set+0x7c/0x2a0 fs/ext4/xattr.c:2230
ext4_xattr_set_handle+0xc5d/0x15a0 fs/ext4/xattr.c:2387
ext4_initxattrs+0xcd/0x140 fs/ext4/xattr_security.c:44
security_inode_init_security+0x26c/0x3c0 security/security.c:1033
ext4_init_security+0x34/0x40 fs/ext4/xattr_security.c:58
__ext4_new_inode+0x3648/0x4530 fs/ext4/ialloc.c:1322
ext4_mkdir+0x3b3/0xbb0 fs/ext4/namei.c:2947
vfs_mkdir+0x435/0x610 fs/namei.c:3729
do_mkdirat+0x1b6/0x2d0 fs/namei.c:3752
__do_sys_mkdirat fs/namei.c:3763 [inline]
__se_sys_mkdirat fs/namei.c:3761 [inline]
__x64_sys_mkdirat+0x7b/0x90 fs/namei.c:3761
do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f7237736387
Code: 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 02 01 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:00007ffd5bebc528 EFLAGS: 00000206 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007ffd5bebc5b0 RCX: 00007f7237736387
RDX: 00000000000001ff RSI: 00007ffd5bebc5b0 RDI: 00000000ffffff9c
RBP: 00007ffd5bebc58c R08: 0000000000000000 R09: 0000000000000003
R10: 00007ffd5bebc2c7 R11: 0000000000000206 R12: 0000000000000032
R13: 0000000000009ae8 R14: 0000000000000003 R15: 00007ffd5bebc5f0
Modules linked in:
---[ end trace 6102385bb86d719d ]---
RIP: 0010:ext4_xattr_set_entry+0x983/0x2290 fs/ext4/xattr.c:1584
Code: 03 48 89 84 24 c0 00 00 00 42 80 3c 28 00 4c 8d b4 24 00 01 00 00 74 08 4c 89 ff e8 47 86 ba ff 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 dd 15 00 00 44 0f b6 03 41 83 c0 13 41 83
RSP: 0018:ffffc900009ef4a0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff88810c432780
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000000000001c
RBP: ffffc900009ef638 R08: ffffffff81ec6ae8 R09: ffffed10241015f3
R10: ffffed10241015f3 R11: 1ffff110241015f2 R12: 0000000000000000
R13: dffffc0000000000 R14: ffffc900009ef5a0 R15: ffffc900009ef7a0
FS: 000055555602d400(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055555603eb78 CR3: 000000010c556000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 03 48 89 add -0x77(%rax),%ecx
3: 84 24 c0 test %ah,(%rax,%rax,8)
6: 00 00 add %al,(%rax)
8: 00 42 80 add %al,-0x80(%rdx)
b: 3c 28 cmp $0x28,%al
d: 00 4c 8d b4 add %cl,-0x4c(%rbp,%rcx,4)
11: 24 00 and $0x0,%al
13: 01 00 add %eax,(%rax)
15: 00 74 08 4c add %dh,0x4c(%rax,%rcx,1)
19: 89 ff mov %edi,%edi
1b: e8 47 86 ba ff callq 0xffba8667
20: 49 8b 1f mov (%r15),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 8a 04 28 mov (%rax,%r13,1),%al <-- trapping instruction
2e: 84 c0 test %al,%al
30: 0f 85 dd 15 00 00 jne 0x1613
36: 44 0f b6 03 movzbl (%rbx),%r8d
3a: 41 83 c0 13 add $0x13,%r8d
3e: 41 rex.B
3f: 83 .byte 0x83


Tested on:

commit: 7474313d Merge 5.10.144 into android12-5.10-lts
git tree: android12-5.10-lts
console output: https://syzkaller.appspot.com/x/log.txt?x=13fb04ef080000
kernel config: https://syzkaller.appspot.com/x/.config?x=d3f70c59f45da9a3
dashboard link: https://syzkaller.appspot.com/bug?extid=70627ce76b4994c2e0b4
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=14459bf8880000

Reply all
Reply to author
Forward
0 new messages