android_kernel_google_msm/net
Daniel Borkmann 102d68ebe7 net: inet_diag: zero out uninitialized idiag_{src,dst} fields
Jakub reported while working with nlmon netlink sniffer that parts of
the inet_diag_sockid are not initialized when r->idiag_family != AF_INET6.
That is, fields of r->id.idiag_src[1 ... 3], r->id.idiag_dst[1 ... 3].

In fact, it seems that we can leak 6 * sizeof(u32) byte of kernel [slab]
memory through this. At least, in udp_dump_one(), we allocate a skb in ...

  rep = nlmsg_new(sizeof(struct inet_diag_msg) + ..., GFP_KERNEL);

... and then pass that to inet_sk_diag_fill() that puts the whole struct
inet_diag_msg into the skb, where we only fill out r->id.idiag_src[0],
r->id.idiag_dst[0] and leave the rest untouched:

  r->id.idiag_src[0] = inet->inet_rcv_saddr;
  r->id.idiag_dst[0] = inet->inet_daddr;

struct inet_diag_msg embeds struct inet_diag_sockid that is correctly /
fully filled out in IPv6 case, but for IPv4 not.

So just zero them out by using plain memset (for this little amount of
bytes it's probably not worth the extra check for idiag_family == AF_INET).

Similarly, fix also other places where we fill that out.

[Upstream commit b1aac815c0]

Change-Id: Ief40178e5bc9b4e9c207607e4c05970371d1e6f8
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
2016-10-29 23:12:34 +08:00
..
9p
802
8021q
appletalk
atm
ax25 net: add validation for the socket syscall protocol argument 2016-10-29 23:12:11 +08:00
batman-adv
bluetooth bluetooth: Validate socket address length in sco_sock_bind(). 2016-10-29 23:12:11 +08:00
bridge
caif
can
ceph
core net: rps: fix cpu unplug 2016-10-29 23:12:26 +08:00
dcb
dccp ipv6: add complete rcu protection around np->opt 2016-06-17 02:54:32 +00:00
decnet net: add validation for the socket syscall protocol argument 2016-10-29 23:12:11 +08:00
dns_resolver
dsa
econet
ethernet
ieee802154
ipv4 net: inet_diag: zero out uninitialized idiag_{src,dst} fields 2016-10-29 23:12:34 +08:00
ipv6 ipv6: clean up anycast when an interface is destroyed 2016-10-29 23:12:33 +08:00
ipx
irda net: add validation for the socket syscall protocol argument 2016-10-29 23:12:11 +08:00
iucv
key
l2tp net/l2tp: don't fall back on UDP [get|set]sockopt 2014-07-24 15:36:39 -07:00
lapb
llc net: llc: use correct size for sysctl timeout entries 2016-10-29 23:12:10 +08:00
mac80211
netfilter netfilter: nf_conntrack_dccp: fix skb_header_pointer API usages 2016-10-29 23:12:11 +08:00
netlabel
netlink
netrom
nfc
openvswitch
packet
phonet
rds
rfkill
rose
rxrpc
sched
sctp
sunrpc sunrpc: Fix possibly uninitialized variable warnings 2016-10-29 23:12:09 +08:00
tipc
unix
wanrouter
wimax
wireless cfg80211: fix possible circular lock on reg_regdb_search() 2016-10-29 23:12:27 +08:00
x25
xfrm
activity_stats.c
compat.c net/compat.c,linux/filter.h: share compat_sock_fprog 2014-10-31 19:46:10 -07:00
Kconfig
Makefile
nonet.c
socket.c net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom 2016-06-15 06:22:38 +00:00
sysctl_net.c