WSL2-Linux-Kernel/net/llc
Hannes Frederic Sowa f3d3342602 net: rework recvmsg handler msg_name and msg_namelen logic
This patch now always passes msg->msg_namelen as 0. recvmsg handlers must
set msg_namelen to the proper size <= sizeof(struct sockaddr_storage)
to return msg_name to the user.

This prevents numerous uninitialized memory leaks we had in the
recvmsg handlers and makes it harder for new code to accidentally leak
uninitialized memory.

Optimize for the case recvfrom is called with NULL as address. We don't
need to copy the address at all, so set it to NULL before invoking the
recvmsg handler. We can do so, because all the recvmsg handlers must
cope with the case a plain read() is called on them. read() also sets
msg_name to NULL.

Also document these changes in include/linux/net.h as suggested by David
Miller.

Changes since RFC:

Set msg->msg_name = NULL if user specified a NULL in msg_name but had a
non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
affect sendto as it would bail out earlier while trying to copy-in the
address. It also more naturally reflects the logic by the callers of
verify_iovec.

With this change in place I could remove "
if (!uaddr || msg_sys->msg_namelen == 0)
	msg->msg_name = NULL
".

This change does not alter the user visible error logic as we ignore
msg_namelen as long as msg_name is NULL.

Also remove two unnecessary curly brackets in ___sys_recvmsg and change
comments to netdev style.

Cc: David Miller <davem@davemloft.net>
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-11-20 21:52:30 -05:00
..
Kconfig Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Makefile [LLC]: Add sysctl support for the LLC timeouts 2005-09-22 04:30:44 -03:00
af_llc.c net: rework recvmsg handler msg_name and msg_namelen logic 2013-11-20 21:52:30 -05:00
llc_c_ac.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
llc_c_ev.c net: replace remaining __FUNCTION__ occurrences 2008-03-05 20:47:47 -08:00
llc_c_st.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_conn.c llc: Use normal etherdevice.h tests 2013-09-03 22:34:47 -04:00
llc_core.c llc: cleanup: remove dead code from llc_init() 2010-03-24 13:34:08 -07:00
llc_if.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
llc_input.c llc: Fix races between llc2 handler use and (un)registration 2012-08-14 16:52:02 -07:00
llc_output.c net: delete all instances of special processing for token ring 2012-05-15 20:14:35 -04:00
llc_pdu.c [LLC]: skb allocation size for responses 2008-03-31 21:02:47 -07:00
llc_proc.c net: proc_fs: trivial: print UIDs as unsigned int 2013-08-15 14:37:46 -07:00
llc_s_ac.c [LLC]: skb allocation size for responses 2008-03-31 21:02:47 -07:00
llc_s_ev.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_s_st.c [NET] LLC: Fix whitespace errors. 2007-02-10 23:19:53 -08:00
llc_sap.c llc: Use normal etherdevice.h tests 2013-09-03 22:34:47 -04:00
llc_station.c llc2: Collapse remainder of state machine into simple if-else if-statement 2012-09-17 13:04:19 -04:00
sysctl_net_llc.c llc: Remove stray reference to sysctl_llc_station_ack_timeout. 2012-09-17 13:13:24 -04:00