]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.112/sctp-initialize-_pad-of-sockaddr_in-before-copying-to-user-memory.patch
Linux 4.9.169
[thirdparty/kernel/stable-queue.git] / releases / 4.14.112 / sctp-initialize-_pad-of-sockaddr_in-before-copying-to-user-memory.patch
1 From foo@baz Mon Apr 15 07:47:06 CEST 2019
2 From: Xin Long <lucien.xin@gmail.com>
3 Date: Sun, 31 Mar 2019 16:58:15 +0800
4 Subject: sctp: initialize _pad of sockaddr_in before copying to user memory
5
6 From: Xin Long <lucien.xin@gmail.com>
7
8 [ Upstream commit 09279e615c81ce55e04835970601ae286e3facbe ]
9
10 Syzbot report a kernel-infoleak:
11
12 BUG: KMSAN: kernel-infoleak in _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
13 Call Trace:
14 _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
15 copy_to_user include/linux/uaccess.h:174 [inline]
16 sctp_getsockopt_peer_addrs net/sctp/socket.c:5911 [inline]
17 sctp_getsockopt+0x1668e/0x17f70 net/sctp/socket.c:7562
18 ...
19 Uninit was stored to memory at:
20 sctp_transport_init net/sctp/transport.c:61 [inline]
21 sctp_transport_new+0x16d/0x9a0 net/sctp/transport.c:115
22 sctp_assoc_add_peer+0x532/0x1f70 net/sctp/associola.c:637
23 sctp_process_param net/sctp/sm_make_chunk.c:2548 [inline]
24 sctp_process_init+0x1a1b/0x3ed0 net/sctp/sm_make_chunk.c:2361
25 ...
26 Bytes 8-15 of 16 are uninitialized
27
28 It was caused by that th _pad field (the 8-15 bytes) of a v4 addr (saved in
29 struct sockaddr_in) wasn't initialized, but directly copied to user memory
30 in sctp_getsockopt_peer_addrs().
31
32 So fix it by calling memset(addr->v4.sin_zero, 0, 8) to initialize _pad of
33 sockaddr_in before copying it to user memory in sctp_v4_addr_to_user(), as
34 sctp_v6_addr_to_user() does.
35
36 Reported-by: syzbot+86b5c7c236a22616a72f@syzkaller.appspotmail.com
37 Signed-off-by: Xin Long <lucien.xin@gmail.com>
38 Tested-by: Alexander Potapenko <glider@google.com>
39 Acked-by: Neil Horman <nhorman@tuxdriver.com>
40 Signed-off-by: David S. Miller <davem@davemloft.net>
41 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
42 ---
43 net/sctp/protocol.c | 1 +
44 1 file changed, 1 insertion(+)
45
46 --- a/net/sctp/protocol.c
47 +++ b/net/sctp/protocol.c
48 @@ -605,6 +605,7 @@ out:
49 static int sctp_v4_addr_to_user(struct sctp_sock *sp, union sctp_addr *addr)
50 {
51 /* No address mapping for V4 sockets */
52 + memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero));
53 return sizeof(struct sockaddr_in);
54 }
55