WSL2-Linux-Kernel/drivers/isdn/mISDN
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 trivial: fix typos/grammar errors in Kconfig texts 2009-03-30 15:22:01 +02:00
Makefile mISDN: Add ISDN sample clock API to mISDN core 2009-01-09 22:44:27 +01:00
clock.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
core.c ISDN: convert class code to use dev_groups 2013-07-26 18:05:17 -07:00
core.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp.h mISDN: DSP scheduling fix (version 2) 2012-04-26 03:10:45 -04:00
dsp_audio.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp_biquad.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp_blowfish.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp_cmx.c mISDN: DSP scheduling fix (version 2) 2012-04-26 03:10:45 -04:00
dsp_core.c mISDN: return -EINVAL on error in dsp_control_req() 2013-08-30 17:52:44 -04:00
dsp_dtmf.c mISDN: Fix division by zero 2012-04-26 03:10:45 -04:00
dsp_ecdis.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp_hwec.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp_hwec.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
dsp_pipeline.c drivers: avoid format string in dev_set_name 2013-07-03 16:07:41 -07:00
dsp_tones.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
fsm.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
fsm.h Add mISDN core files 2008-07-27 01:54:58 +02:00
hwchannel.c Merge branch 'for-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq 2012-10-02 09:54:49 -07:00
l1oip.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
l1oip_codec.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
l1oip_core.c Merge branch 'master' into for-next 2013-01-29 10:48:30 +01:00
layer1.c mISDN: Layer1 statemachine fix 2012-05-04 11:55:39 -04:00
layer1.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
layer2.c mISDN: Bugfix for layer2 fixed TEI mode 2012-08-06 13:22:50 -07:00
layer2.h isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
socket.c net: rework recvmsg handler msg_name and msg_namelen logic 2013-11-20 21:52:30 -05:00
stack.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
tei.c mISDN: improve bitops usage 2012-11-30 12:10:57 -05:00
timerdev.c mISDN: grabbing/dropping reference to THIS_MODULE in open/release is racy 2013-04-29 15:41:49 -04:00