android_kernel_oneplus_msm8998/net/sctp
Xin Long 03328716cb sctp: initialize _pad of sockaddr_in before copying to user memory
[ Upstream commit 09279e615c81ce55e04835970601ae286e3facbe ]

Syzbot report a kernel-infoleak:

  BUG: KMSAN: kernel-infoleak in _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
  Call Trace:
    _copy_to_user+0x16b/0x1f0 lib/usercopy.c:32
    copy_to_user include/linux/uaccess.h:174 [inline]
    sctp_getsockopt_peer_addrs net/sctp/socket.c:5911 [inline]
    sctp_getsockopt+0x1668e/0x17f70 net/sctp/socket.c:7562
    ...
  Uninit was stored to memory at:
    sctp_transport_init net/sctp/transport.c:61 [inline]
    sctp_transport_new+0x16d/0x9a0 net/sctp/transport.c:115
    sctp_assoc_add_peer+0x532/0x1f70 net/sctp/associola.c:637
    sctp_process_param net/sctp/sm_make_chunk.c:2548 [inline]
    sctp_process_init+0x1a1b/0x3ed0 net/sctp/sm_make_chunk.c:2361
    ...
  Bytes 8-15 of 16 are uninitialized

It was caused by that th _pad field (the 8-15 bytes) of a v4 addr (saved in
struct sockaddr_in) wasn't initialized, but directly copied to user memory
in sctp_getsockopt_peer_addrs().

So fix it by calling memset(addr->v4.sin_zero, 0, 8) to initialize _pad of
sockaddr_in before copying it to user memory in sctp_v4_addr_to_user(), as
sctp_v6_addr_to_user() does.

Reported-by: syzbot+86b5c7c236a22616a72f@syzkaller.appspotmail.com
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Tested-by: Alexander Potapenko <glider@google.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-27 09:33:55 +02:00
..
associola.c sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer 2018-12-01 09:46:33 +01:00
auth.c
bind_addr.c
chunk.c
debug.c net: sctp: fix array overrun read on sctp_timer_tbl 2017-12-09 18:42:42 +01:00
endpointola.c
input.c
inqueue.c sctp: fix the issue that the cookie-ack with auth can't get processed 2018-05-26 08:48:48 +02:00
ipv6.c sctp: allocate sctp_sockaddr_entry with kzalloc 2019-01-26 09:42:51 +01:00
Kconfig
Makefile
objcnt.c
output.c
outqueue.c
primitive.c
probe.c
proc.c
protocol.c sctp: initialize _pad of sockaddr_in before copying to user memory 2019-04-27 09:33:55 +02:00
sm_make_chunk.c fixup: sctp: verify size of a new chunk in _sctp_make_chunk() 2018-03-18 11:17:54 +01:00
sm_sideeffect.c
sm_statefuns.c sctp: delay the authentication for the duplicated cookie-echo chunk 2018-05-26 08:48:49 +02:00
sm_statetable.c
socket.c sctp: fix race on sctp_id2asoc 2018-11-10 07:41:42 -08:00
ssnmap.c
sysctl.c
transport.c
tsnmap.c
ulpevent.c
ulpqueue.c