KASAN: slab-out-of-bounds Read in cap_convert_nscap

20 views
Skip to first unread message

syzbot

unread,
Jan 2, 2018, 4:58:02 AM1/2/18
to james.l...@oracle.com, linux-...@vger.kernel.org, linux-secu...@vger.kernel.org, se...@hallyn.com, syzkall...@googlegroups.com
Hello,

syzkaller hit the following crash on
5aa90a84589282b87666f92b6c3c917c8080a9bf
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.
C reproducer is attached
syzkaller reproducer is attached. See https://goo.gl/kgGztJ
for information about syzkaller reproducers


IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+7bf529...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for
details.
If you forward the report, please keep this part and the footer.

audit: type=1400 audit(1514639069.283:7): avc: denied { map } for
pid=3182 comm="syzkaller986771" path="/root/syzkaller986771207" dev="sda1"
ino=16481 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: slab-out-of-bounds in cap_convert_nscap+0x501/0x610
security/commoncap.c:498
Read of size 4 at addr ffff8801c96ae080 by task syzkaller986771/3182

CPU: 1 PID: 3182 Comm: syzkaller986771 Not tainted 4.15.0-rc5+ #152
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:53
print_address_description+0x73/0x250 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x25b/0x340 mm/kasan/report.c:409
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
cap_convert_nscap+0x501/0x610 security/commoncap.c:498
setxattr+0x365/0x400 fs/xattr.c:446
SYSC_fsetxattr fs/xattr.c:508 [inline]
SyS_fsetxattr+0x130/0x190 fs/xattr.c:497
do_syscall_32_irqs_on arch/x86/entry/common.c:327 [inline]
do_fast_syscall_32+0x3ee/0xf9d arch/x86/entry/common.c:389
entry_SYSENTER_compat+0x54/0x63 arch/x86/entry/entry_64_compat.S:129
RIP: 0023:0xf7fdcc79
RSP: 002b:00000000ffa1511c EFLAGS: 00000282 ORIG_RAX: 00000000000000e4
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000020f4c000
RDX: 00000000208c4fe9 RSI: 0000000000000001 RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 3182:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
__do_kmalloc_node mm/slab.c:3672 [inline]
__kmalloc_node+0x47/0x70 mm/slab.c:3679
kmalloc_node include/linux/slab.h:541 [inline]
kvmalloc_node+0x99/0xd0 mm/util.c:397
kvmalloc include/linux/mm.h:541 [inline]
setxattr+0x152/0x400 fs/xattr.c:435
SYSC_fsetxattr fs/xattr.c:508 [inline]
SyS_fsetxattr+0x130/0x190 fs/xattr.c:497
do_syscall_32_irqs_on arch/x86/entry/common.c:327 [inline]
do_fast_syscall_32+0x3ee/0xf9d arch/x86/entry/common.c:389
entry_SYSENTER_compat+0x54/0x63 arch/x86/entry/entry_64_compat.S:129

Freed by task 1661:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3488 [inline]
kfree+0xd6/0x260 mm/slab.c:3803
selinux_sk_free_security+0x4f/0x60 security/selinux/hooks.c:4908
security_sk_free+0x48/0x80 security/security.c:1431
sk_prot_free net/core/sock.c:1502 [inline]
__sk_destruct+0x609/0x910 net/core/sock.c:1585
sk_destruct+0x47/0x80 net/core/sock.c:1593
__sk_free+0x57/0x230 net/core/sock.c:1601
sk_free+0x2a/0x40 net/core/sock.c:1612
sock_put include/net/sock.h:1656 [inline]
unix_release_sock+0x644/0xc10 net/unix/af_unix.c:566
unix_stream_connect+0x884/0x1580 net/unix/af_unix.c:1375
SYSC_connect+0x213/0x4a0 net/socket.c:1619
SyS_connect+0x24/0x30 net/socket.c:1600
entry_SYSCALL_64_fastpath+0x1f/0x96

The buggy address belongs to the object at ffff8801c96ae080
which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
32-byte region [ffff8801c96ae080, ffff8801c96ae0a0)
The buggy address belongs to the page:
page:000000006bd0ad6a count:1 mapcount:0 mapping:00000000e71de2e0
index:0xffff8801c96aefc1
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801c96ae000 ffff8801c96aefc1 000000010000003f
raw: ffffea000725abe0 ffffea00072083e0 ffff8801dac001c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801c96adf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8801c96ae000: 00 00 00 fc fc fc fc fc fb fb fb fb fc fc fc fc
> ffff8801c96ae080: 01 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc
^
ffff8801c96ae100: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
ffff8801c96ae180: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzk...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.
config.txt
raw.log
repro.txt
repro.c

Eric Biggers

unread,
Jan 2, 2018, 12:00:46 PM1/2/18
to syzbot, james.l...@oracle.com, linux-...@vger.kernel.org, linux-secu...@vger.kernel.org, se...@hallyn.com, syzkall...@googlegroups.com
Looks like the same bug I sent out a fix for yesterday.

#syz fix: capabilities: fix buffer overread on very short xattr

https://marc.info/?l=linux-kernel&m=151488700301705
Reply all
Reply to author
Forward
0 new messages