1
0
Fork 0
alistair23-linux/drivers/isdn
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
..
act2000 isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
capi isdn/kcapi: fix a small underflow 2013-05-20 13:38:14 -07:00
divert ISDN:divert: beautify code: useless 'break', 'return (0)', additional comments. 2013-04-02 14:31:24 -04:00
gigaset Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
hardware isdn: remove deprecated IRQF_DISABLED 2013-10-17 15:13:20 -04:00
hisax isdn: clean up debug format string usage 2013-09-13 20:02:50 -04:00
hysdn procfs: new helper - PDE_DATA(inode) 2013-04-09 14:13:32 -04:00
i4l isdn: Correct comparison of skb->tail and skb-transport_header 2013-05-28 23:49:06 -07:00
icn isdn: icn: NULL dereference printing error message 2013-11-07 19:11:13 -05:00
isdnloop isdnloop: use strlcpy() instead of strcpy() 2013-11-14 16:50:20 -05:00
mISDN net: rework recvmsg handler msg_name and msg_namelen logic 2013-11-20 21:52:30 -05:00
pcbit isdn: Fix typo in drivers/isdn 2012-11-09 17:10:16 -05:00
sc isdn: remove deprecated IRQF_DISABLED 2013-10-17 15:13:20 -04:00
Kconfig tty: Added a CONFIG_TTY option to allow removal of TTY 2013-01-18 16:15:27 -08:00
Makefile mISDN fix main ISDN Makefile 2008-08-02 16:28:20 +02:00