Julian Anastasov
0063faaa86
ipvs: fix buffer overflow with sync daemon and service
[ Upstream commit 52f9675790 ]
syzkaller reports for buffer overflow for interface name
when starting sync daemons [1]
What we do is that we copy user structure into larger stack
buffer but later we search NUL past the stack buffer.
The same happens for sched_name when adding/editing virtual server.
We are restricted by IP_VS_SCHEDNAME_MAXLEN and IP_VS_IFNAME_MAXLEN
being used as size in include/uapi/linux/ip_vs.h, so they
include the space for NUL.
As using strlcpy is wrong for unsafe source, replace it with
strscpy and add checks to return EINVAL if source string is not
NUL-terminated. The incomplete strlcpy fix comes from 2.6.13.
For the netlink interface reduce the len parameter for
IPVS_DAEMON_ATTR_MCAST_IFN and IPVS_SVC_ATTR_SCHED_NAME,
so that we get proper EINVAL.
[1]
kernel BUG at lib/string.c:1052!
invalid opcode: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 373 Comm: syz-executor936 Not tainted 4.17.0-rc4+ #45
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:fortify_panic+0x13/0x20 lib/string.c:1051
RSP: 0018:ffff8801c976f800 EFLAGS: 00010282
RAX: 0000000000000022 RBX: 0000000000000040 RCX: 0000000000000000
RDX: 0000000000000022 RSI: ffffffff8160f6f1 RDI: ffffed00392edef6
RBP: ffff8801c976f800 R08: ffff8801cf4c62c0 R09: ffffed003b5e4fb0
R10: ffffed003b5e4fb0 R11: ffff8801daf27d87 R12: ffff8801c976fa20
R13: ffff8801c976fae4 R14: ffff8801c976fae0 R15: 000000000000048b
FS: 00007fd99f75e700(0000) GS:ffff8801daf00000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000200001c0 CR3: 00000001d6843000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
strlen include/linux/string.h:270 [inline]
strlcpy include/linux/string.h:293 [inline]
do_ip_vs_set_ctl+0x31c/0x1d00 net/netfilter/ipvs/ip_vs_ctl.c:2388
nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
nf_setsockopt+0x7d/0xd0 net/netfilter/nf_sockopt.c:115
ip_setsockopt+0xd8/0xf0 net/ipv4/ip_sockglue.c:1253
udp_setsockopt+0x62/0xa0 net/ipv4/udp.c:2487
ipv6_setsockopt+0x149/0x170 net/ipv6/ipv6_sockglue.c:917
tcp_setsockopt+0x93/0xe0 net/ipv4/tcp.c:3057
sock_common_setsockopt+0x9a/0xe0 net/core/sock.c:3046
__sys_setsockopt+0x1bd/0x390 net/socket.c:1903
__do_sys_setsockopt net/socket.c:1914 [inline]
__se_sys_setsockopt net/socket.c:1911 [inline]
__x64_sys_setsockopt+0xbe/0x150 net/socket.c:1911
do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x447369
RSP: 002b:00007fd99f75dda8 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00000000006e39e4 RCX: 0000000000447369
RDX: 000000000000048b RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000018 R09: 0000000000000000
R10: 00000000200001c0 R11: 0000000000000246 R12: 00000000006e39e0
R13: 75a1ff93f0896195 R14: 6f745f3168746576 R15: 0000000000000001
Code: 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b 48 89 df e8 d2 8f 48 fa eb
de 55 48 89 fe 48 c7 c7 60 65 64 88 48 89 e5 e8 91 dd f3 f9 <0f> 0b 90 90
90 90 90 90 90 90 90 90 90 55 48 89 e5 41 57 41 56
RIP: fortify_panic+0x13/0x20 lib/string.c:1051 RSP: ffff8801c976f800
Reported-and-tested-by: syzbot+aac887f77319868646df@syzkaller.appspotmail.com
Fixes: e4ff675130 ("ipvs: add sync_maxlen parameter for the sync daemon")
Fixes: 4da62fc70d ("[IPVS]: Fix for overflows")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-26 08:08:05 +08:00
..
2016-03-28 17:57:45 +02:00
2018-06-26 08:08:05 +08:00
2017-12-16 16:25:46 +01:00
2016-08-22 11:42:22 +02:00
2016-09-25 23:16:42 +02:00
2015-03-18 10:51:35 +01:00
2015-02-22 15:59:54 -05:00
2011-01-18 18:12:24 +01:00
2018-04-13 19:48:12 +02:00
2017-10-08 10:26:09 +02:00
2017-10-21 17:21:34 +02:00
2017-08-24 17:12:18 -07:00
2016-09-07 10:38:00 +02:00
2016-07-11 12:32:45 +02:00
2016-09-24 21:29:53 +02:00
2008-01-31 19:28:07 -08:00
2018-03-24 11:00:14 +01:00
2016-07-21 02:31:53 +02:00
2014-11-05 14:10:33 -05:00
2016-07-22 17:05:10 +02:00
2011-01-18 18:12:24 +01:00
2018-04-13 19:48:05 +02:00
2016-08-30 11:43:09 +02:00
2016-08-12 00:41:08 +02:00
2016-08-13 13:27:13 +02:00
2016-09-07 10:36:52 +02:00
2016-08-13 13:27:13 +02:00
2016-08-13 13:27:13 +02:00
2016-08-13 13:27:13 +02:00
2016-08-12 00:41:08 +02:00
2016-08-13 13:27:13 +02:00
2016-07-21 02:31:53 +02:00
2016-09-25 14:54:01 +02:00
2017-06-17 06:41:49 +02:00
2013-01-18 00:28:18 +01:00
2016-09-25 14:54:08 +02:00
2016-07-21 02:31:53 +02:00
2015-12-14 12:48:58 +01:00
2013-12-20 14:58:29 +01:00
2016-03-01 17:36:47 -05:00
2016-10-20 19:59:59 +02:00
2016-09-25 23:16:45 +02:00
2017-06-17 06:41:58 +02:00
2013-04-18 20:27:55 +02:00
2017-11-18 11:22:24 +01:00
2013-02-19 02:48:05 +01:00
2013-08-28 00:26:48 +02:00
2014-01-06 14:17:17 +01:00
2018-03-18 11:18:53 +01:00
2015-08-17 21:33:06 -07:00
2014-06-30 11:38:03 +02:00
2015-08-17 21:33:06 -07:00
2015-08-17 21:33:06 -07:00
2015-08-17 21:33:06 -07:00
2012-08-30 03:00:14 +02:00
2015-10-27 06:54:56 +01:00
2014-10-14 02:18:24 +02:00
2013-02-19 02:48:05 +01:00
2016-10-20 19:59:59 +02:00
2014-08-08 16:47:23 +02:00
2015-09-05 21:57:42 -07:00
2018-05-22 16:57:57 +02:00
2016-09-25 23:16:43 +02:00
2016-09-12 19:54:45 +02:00
2016-09-12 19:54:45 +02:00
2016-09-25 23:34:19 +02:00
2016-08-25 13:11:00 +02:00
2018-01-31 12:55:52 +01:00
2017-10-08 10:26:09 +02:00
2016-09-24 21:29:53 +02:00
2017-12-25 14:23:43 +01:00
2016-02-23 00:09:14 -05:00
2016-09-23 09:29:02 +02:00
2016-09-23 09:29:02 +02:00
2016-09-23 09:29:02 +02:00
2016-07-23 12:25:00 +02:00
2016-04-23 20:13:24 -04:00
2016-09-25 14:54:04 +02:00
2016-01-03 21:04:23 +01:00
2018-03-24 11:00:14 +01:00
2016-10-17 17:43:54 +02:00
2016-01-04 17:48:38 +01:00
2016-11-24 14:40:03 +01:00
2016-09-23 09:29:02 +02:00
2016-10-04 08:59:03 +02:00
2017-06-17 06:41:58 +02:00
2016-09-23 09:30:48 +02:00
2016-03-02 20:05:27 +01:00
2017-11-15 15:53:15 +01:00
2015-04-13 17:17:29 +02:00
2016-09-22 16:33:05 +02:00
2016-09-23 09:30:26 +02:00
2017-11-30 08:39:14 +00:00
2016-09-07 11:02:06 +02:00
2016-11-24 14:43:35 +01:00
2015-04-13 17:17:28 +02:00
2016-08-25 12:55:34 +02:00
2016-08-25 12:55:34 +02:00
2016-10-27 18:22:02 +02:00
2017-06-14 15:06:06 +02:00
2018-04-08 12:12:50 +02:00
2015-09-18 21:58:25 +02:00
2014-03-13 14:13:19 +01:00
2014-08-02 15:03:58 -07:00
2018-02-25 11:05:43 +01:00
2010-07-15 17:20:46 +02:00
2010-11-15 13:57:56 +01:00
2014-08-23 12:21:21 -07:00
2010-05-11 18:33:37 +02:00
2014-09-10 12:40:10 -07:00
2016-07-22 17:05:10 +02:00
2016-09-23 09:30:36 +02:00
2016-11-08 23:53:36 +01:00
2010-05-11 18:31:17 +02:00
2016-08-12 00:43:13 +02:00
2011-01-18 06:33:54 +01:00
2018-03-24 11:00:14 +01:00
2010-05-11 18:35:27 +02:00
2011-02-03 00:05:43 +01:00
2010-05-11 18:33:37 +02:00
2014-11-13 12:14:42 +01:00
2011-12-27 20:45:25 +01:00
2010-05-11 18:35:27 +02:00
2018-04-08 12:12:50 +02:00
2016-09-24 21:29:53 +02:00
2011-07-01 16:11:15 -07:00
2011-07-01 16:11:15 -07:00
2014-08-23 12:21:21 -07:00
2018-03-18 11:18:53 +01:00
2016-10-17 17:38:19 +02:00
2011-02-04 14:28:58 -08:00
2015-09-24 09:34:41 +09:00
2014-01-09 21:36:39 +01:00
2018-03-18 11:18:53 +01:00
2010-05-11 18:33:37 +02:00
2013-04-18 20:27:55 +02:00
2015-09-18 21:58:25 +02:00
2012-05-09 20:49:18 -04:00
2015-05-14 13:00:27 +02:00
2010-05-11 18:35:27 +02:00
2012-10-15 13:39:12 +02:00
2012-09-21 12:11:08 +02:00
2016-08-18 00:38:23 +02:00
2016-10-17 17:38:19 +02:00
2013-12-07 23:20:45 +01:00
2018-01-31 12:55:52 +01:00
2016-06-23 13:58:55 +02:00
2016-08-12 00:42:14 +02:00
2010-05-11 18:33:37 +02:00
2010-05-11 18:33:37 +02:00
2011-10-31 19:30:28 -04:00
2013-06-11 02:51:03 -07:00
2018-02-25 11:05:43 +01:00
2010-05-11 18:33:37 +02:00
2018-04-08 12:12:50 +02:00
2014-11-27 13:08:42 +01:00
2014-06-07 11:44:39 -07:00
2016-09-22 03:13:26 -04:00
2010-10-21 10:12:48 +11:00
2015-06-14 10:40:18 +02:00
2016-04-04 22:11:20 -04:00
2010-06-08 16:09:52 +02:00
2014-01-14 15:15:25 -08:00
2015-02-22 15:59:54 -05:00
2010-05-11 18:35:27 +02:00
2017-07-05 14:40:16 +02:00
2015-08-17 21:33:06 -07:00
2016-07-03 10:55:07 +02:00
2016-09-12 19:54:43 +02:00
2012-09-24 14:29:01 +02:00
2016-08-18 00:51:13 +02:00
2016-06-23 13:26:49 +02:00
2010-05-11 18:33:37 +02:00