Eric Dumazet
65a1ff925d
net: rose: fix a possible stack overflow
...
[ Upstream commit e5dcc0c3223c45c94100f05f28d8ef814db3d82c ]
rose_write_internal() uses a temp buffer of 100 bytes, but a manual
inspection showed that given arbitrary input, rose_create_facilities()
can fill up to 110 bytes.
Lets use a tailroom of 256 bytes for peace of mind, and remove
the bounce buffer : we can simply allocate a big enough skb
and adjust its length as needed.
syzbot report :
BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:352 [inline]
BUG: KASAN: stack-out-of-bounds in rose_create_facilities net/rose/rose_subr.c:521 [inline]
BUG: KASAN: stack-out-of-bounds in rose_write_internal+0x597/0x15d0 net/rose/rose_subr.c:116
Write of size 7 at addr ffff88808b1ffbef by task syz-executor.0/24854
CPU: 0 PID: 24854 Comm: syz-executor.0 Not tainted 5.0.0+ #97
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
check_memory_region_inline mm/kasan/generic.c:185 [inline]
check_memory_region+0x123/0x190 mm/kasan/generic.c:191
memcpy+0x38/0x50 mm/kasan/common.c:131
memcpy include/linux/string.h:352 [inline]
rose_create_facilities net/rose/rose_subr.c:521 [inline]
rose_write_internal+0x597/0x15d0 net/rose/rose_subr.c:116
rose_connect+0x7cb/0x1510 net/rose/af_rose.c:826
__sys_connect+0x266/0x330 net/socket.c:1685
__do_sys_connect net/socket.c:1696 [inline]
__se_sys_connect net/socket.c:1693 [inline]
__x64_sys_connect+0x73/0xb0 net/socket.c:1693
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x458079
Code: ad b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f47b8d9dc78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000458079
RDX: 000000000000001c RSI: 0000000020000040 RDI: 0000000000000004
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f47b8d9e6d4
R13: 00000000004be4a4 R14: 00000000004ceca8 R15: 00000000ffffffff
The buggy address belongs to the page:
page:ffffea00022c7fc0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x1fffc0000000000()
raw: 01fffc0000000000 0000000000000000 ffffffff022c0101 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88808b1ffa80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88808b1ffb00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 00 00 03
>ffff88808b1ffb80: f2 f2 00 00 00 00 00 00 00 00 00 00 00 00 04 f3
^
ffff88808b1ffc00: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
ffff88808b1ffc80: 00 00 00 00 00 00 00 f1 f1 f1 f1 f1 f1 01 f2 01
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-03 06:24:14 +02:00
..
2018-10-03 17:01:42 -07:00
2019-03-23 13:19:40 +01:00
2018-04-13 19:48:34 +02:00
2016-09-10 21:19:10 -07:00
2018-05-16 10:08:44 +02:00
2019-02-23 09:05:59 +01:00
2019-02-27 10:07:00 +01:00
2019-04-03 06:24:13 +02:00
2019-02-27 10:07:03 +01:00
2018-09-05 09:20:00 +02:00
2019-01-31 08:12:36 +01:00
2019-03-27 14:13:02 +09:00
2019-03-13 14:04:52 -07:00
2018-09-19 22:47:15 +02:00
2019-04-03 06:24:14 +02:00
2018-02-25 11:05:44 +01:00
2018-07-22 14:27:39 +02:00
2019-02-12 19:45:00 +01:00
2017-02-18 15:11:43 +01:00
2019-03-19 13:14:08 +01:00
2019-01-09 16:16:40 +01:00
2019-03-27 14:13:04 +09:00
2019-03-19 13:14:09 +01:00
2017-05-25 15:44:41 +02:00
2018-09-15 09:43:01 +02:00
2018-03-31 18:11:34 +02:00
2018-06-13 16:16:42 +02:00
2018-06-16 09:52:32 +02:00
2019-03-19 13:14:08 +01:00
2016-09-10 23:12:53 -07:00
2018-12-01 09:44:19 +01:00
2019-03-05 17:57:06 +01:00
2018-09-09 20:01:19 +02:00
2018-03-11 16:21:34 +01:00
2016-10-20 11:23:08 -04:00
2019-03-13 14:05:00 -07:00
2019-03-13 14:04:53 -07:00
2018-08-09 12:17:59 +02:00
2019-02-06 17:33:27 +01:00
2019-03-13 14:04:53 -07:00
2019-01-31 08:12:33 +01:00
2019-04-03 06:24:14 +02:00
2019-03-23 13:19:44 +01:00
2018-08-24 13:12:36 +02:00
2019-02-12 19:45:00 +01:00
2018-05-16 10:08:43 +02:00
2019-04-03 06:24:14 +02:00
2019-03-19 13:14:10 +01:00
2019-03-13 14:04:53 -07:00
2019-02-27 10:07:01 +01:00
2018-04-29 11:32:02 +02:00
2019-01-23 08:10:55 +01:00
2016-10-19 10:58:04 -04:00
2019-01-23 08:10:56 +01:00
2019-03-19 13:14:10 +01:00
2019-03-13 14:05:00 -07:00
2019-04-03 06:24:14 +02:00
2019-03-19 13:14:09 +01:00
2019-02-15 08:07:39 +01:00
2019-01-09 16:16:41 +01:00
2018-11-10 07:42:58 -08:00
2016-10-06 09:52:23 -07:00