linux-stable/net/nfc
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
..
hci NFC: hci: Fix enable/disable confusion 2013-08-14 01:13:36 +02:00
nci NFC: NCI: Modify NCI SPI to implement CS/INT handshake per the spec 2013-09-25 14:59:56 +02:00
Kconfig NFC Digital: Add NFC-F technology support 2013-09-25 02:02:25 +02:00
Makefile NFC Digital: Add initiator NFC-DEP support 2013-09-25 02:02:27 +02:00
af_nfc.c NFC: Core code identation fixes 2012-03-06 15:16:25 -05:00
core.c NFC: Set active target upon DEP up event reception 2013-09-25 01:35:41 +02:00
digital.h NFC: digital: Remove PR_ERR and PR_DBG macros 2013-09-25 02:02:32 +02:00
digital_core.c NFC: digital: Add newline to pr_* calls 2013-09-25 02:02:34 +02:00
digital_dep.c NFC: digital: Add newline to pr_* calls 2013-09-25 02:02:34 +02:00
digital_technology.c NFC: digital: Fix sens_res endiannes handling 2013-09-25 02:02:42 +02:00
llcp.h NFC: llcp: Fix non blocking sockets connections 2013-06-14 13:45:07 +02:00
llcp_commands.c NFC: Rename nfc_llcp_disconnect() to nfc_llcp_send_disconnect() 2013-06-14 13:45:04 +02:00
llcp_core.c NFC: llcp: Fix the well known services endianness 2013-06-14 13:45:10 +02:00
llcp_sock.c net: rework recvmsg handler msg_name and msg_namelen logic 2013-11-20 21:52:30 -05:00
netlink.c genetlink: make multicast groups const, prevent abuse 2013-11-19 16:39:06 -05:00
nfc.h NFC: netlink: Add result of firmware operation to completion event 2013-08-14 01:12:58 +02:00
rawsock.c net: rework recvmsg handler msg_name and msg_namelen logic 2013-11-20 21:52:30 -05:00