android_kernel_samsung_msm8976/net/irda
Hannes Frederic Sowa 2f73d7fde9 net: rework recvmsg handler msg_name and msg_namelen logic
[ Upstream commit f3d3342602f8bcbf37d7c46641cb9bca7618eb1c ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-08 07:29:25 -08:00
..
ircomm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
irlan irda: Fix typo in irda 2012-07-16 23:23:52 -07:00
irnet irda: buffer overflow in irnet_ctrl_read() 2013-01-27 20:38:19 -05:00
Kconfig
Makefile
af_irda.c net: rework recvmsg handler msg_name and msg_namelen logic 2013-12-08 07:29:25 -08:00
discovery.c net: Add export.h for EXPORT_SYMBOL/THIS_MODULE to non-modules 2011-10-31 19:30:30 -04:00
irda_device.c net: Add export.h for EXPORT_SYMBOL/THIS_MODULE to non-modules 2011-10-31 19:30:30 -04:00
iriap.c irda: small read past the end of array in debug code 2013-04-19 17:32:31 -04:00
iriap_event.c
irias_object.c
irlap.c Fix common misspellings 2011-03-31 11:26:23 -03:00
irlap_event.c irda: irlap_event: Fix set-but-unused variables. 2011-04-17 16:59:09 -07:00
irlap_frame.c net: irda: using kzalloc() instead of kmalloc() to avoid strncpy() issue. 2013-05-19 15:10:47 -07:00
irlmp.c irda: irlmp_reasons[] can be static 2013-04-25 01:42:06 -04:00
irlmp_event.c Fix common misspellings 2011-03-31 11:26:23 -03:00
irlmp_frame.c net: return operator cleanup 2010-09-23 14:33:39 -07:00
irmod.c
irnetlink.c netlink: Rename pid to portid to avoid confusion 2012-09-10 15:30:41 -04:00
irproc.c irda: irproc: Fix set-but-unused variables. 2011-04-17 16:59:50 -07:00
irqueue.c net: Remove casts to same type 2012-06-04 11:45:11 -04:00
irsysctl.c net: Convert all sysctl registrations to register_net_sysctl 2012-04-20 21:22:30 -04:00
irttp.c irda: irttp: fix memory leak in irttp_open_tsap() error path 2012-11-28 11:25:29 -05:00
parameters.c irda: Fix parameter extraction stack overflow 2010-10-11 02:12:17 +02:00
qos.c net: Add export.h for EXPORT_SYMBOL/THIS_MODULE to non-modules 2011-10-31 19:30:30 -04:00
timer.c treewide: Replace incomming with incoming in all comments and strings 2013-01-03 16:15:49 +01:00
wrapper.c