linux/net/atm
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
Makefile
addr.c
addr.h
atm_misc.c atm: eliminate atm_guess_pdu2truesize() 2011-11-26 16:40:30 -05:00
atm_sysfs.c atm: use scnprintf() instead of sprintf() 2012-12-17 20:50:51 -08:00
br2684.c br2684: allow assign only on a connected socket 2012-12-02 00:05:19 +00:00
clip.c net: always pass struct netdev_notifier_info to netdevice notifiers 2013-05-28 21:58:54 -07:00
common.c net: rework recvmsg handler msg_name and msg_namelen logic 2013-11-20 21:52:30 -05:00
common.h atm: Introduce vcc_process_recv_queue 2011-11-22 16:15:42 -05:00
ioctl.c net: Convert net_ratelimit uses to net_<level>_ratelimited 2012-05-15 13:45:03 -04:00
lec.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
lec.h net: add ETH_P_802_3_MIN 2013-03-28 01:20:42 -04:00
lec_arpc.h
mpc.c net: pass info struct via netdevice notifier 2013-05-28 13:11:01 -07:00
mpc.h
mpoa_caches.c
mpoa_caches.h
mpoa_proc.c net: cleanup unsigned to unsigned int 2012-04-15 12:44:40 -04:00
pppoatm.c pppoatm: optimise PPP channel wakeups after sock_owned_by_user() 2012-12-02 00:05:20 +00:00
proc.c procfs: new helper - PDE_DATA(inode) 2013-04-09 14:13:32 -04:00
protocols.h
pvc.c atm: fix info leak via getsockname() 2012-08-15 21:36:30 -07:00
raw.c
resources.c net🏧fix up ENOIOCTLCMD error handling 2012-08-31 16:14:33 -04:00
resources.h
signaling.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
signaling.h
svc.c net: Add export.h for EXPORT_SYMBOL/THIS_MODULE to non-modules 2011-10-31 19:30:30 -04:00