linux/net
Junling Zheng 5ca74d43d9 net: socket: Fix the wrong returns for recvmsg and sendmsg
Based on 08adb7dabd upstream.

We found that after v3.10.73, recvmsg might return -EFAULT while -EINVAL
was expected.

We tested it through the recvmsg01 testcase come from LTP testsuit. It set
msg->msg_namelen to -1 and the recvmsg syscall returned errno 14, which is
unexpected (errno 22 is expected):

recvmsg01    4  TFAIL  :  invalid socket length ; returned -1 (expected -1),
errno 14 (expected 22)

Linux mainline has no this bug for commit 08adb7dab fixes it accidentally.
However, it is too large and complex to be backported to LTS 3.10.

Commit 281c9c36 (net: compat: Update get_compat_msghdr() to match
copy_msghdr_from_user() behaviour) made get_compat_msghdr() return
error if msg_sys->msg_namelen was negative, which changed the behaviors
of recvmsg and sendmsg syscall in a lib32 system:

Before commit 281c9c36, get_compat_msghdr() wouldn't fail and it would
return -EINVAL in move_addr_to_user() or somewhere if msg_sys->msg_namelen
was invalid and then syscall returned -EINVAL, which is correct.

And now, when msg_sys->msg_namelen is negative, get_compat_msghdr() will
fail and wants to return -EINVAL, however, the outer syscall will return
-EFAULT directly, which is unexpected.

This patch gets the return value of get_compat_msghdr() as well as
copy_msghdr_from_user(), then returns this expected value if
get_compat_msghdr() fails.

Fixes: 281c9c36 (net: compat: Update get_compat_msghdr() to match copy_msghdr_from_user() behaviour)
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Hanbing Xu <xuhanbing@huawei.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-06-06 08:19:31 -07:00
..
9p 9p/trans_virtio.c: Fix broken zero-copy on vmalloc() buffers 2014-02-10 17:48:54 -08:00
802 neigh: use NEIGH_VAR_INIT in ndo_neigh_setup functions. 2014-01-16 11:31:58 -08:00
8021q net: Always untag vlan-tagged traffic on input. 2014-10-15 08:36:40 +02:00
appletalk appletalk: Fix socket referencing in skb 2014-07-28 08:06:00 -07:00
atm net: Fix some fallout from the etner_addr_copy() changes. 2014-01-21 18:57:26 -08:00
ax25 net: add build-time checks for msg->msg_name size 2014-01-18 23:04:16 -08:00
batman-adv batman-adv: avoid NULL dereferences and fix if check 2015-01-27 08:18:53 -08:00
bluetooth Bluetooth: Fix incorrect LE CoC PDU length restriction based on HCI MTU 2014-10-30 09:38:23 -07:00
bridge bridge: Fix br_should_learn to check vlan_enabled 2014-10-15 08:36:41 +02:00
caif caif: fix MSG_OOB test in caif_seqpkt_recvmsg() 2015-03-26 15:06:50 +01:00
can can: add missing initialisations in CAN related skbuffs 2015-03-26 15:06:54 +01:00
ceph libceph: fix double __remove_osd() problem 2015-03-06 14:43:25 -08:00
core net: fix crash in build_skb() 2015-05-06 21:59:07 +02:00
dcb net: Use netlink_ns_capable to verify the permisions of netlink messages 2014-06-26 15:15:38 -04:00
dccp dccp: re-enable debug macro 2014-02-16 23:45:00 -05:00
decnet net: Use netlink_ns_capable to verify the permisions of netlink messages 2014-06-26 15:15:38 -04:00
dns_resolver dns_resolver: Null-terminate the right string 2014-07-28 08:06:01 -07:00
dsa dsa: Use ether_addr_copy 2014-01-21 18:13:05 -08:00
ethernet net: eth_type_trans() should use skb_header_pointer() 2014-01-16 15:30:31 -08:00
hsr hsr: off by one sanity check in hsr_register_frame_in() 2014-03-03 15:29:42 -05:00
ieee802154 6lowpan: fix lockdep splats 2014-02-10 17:51:29 -08:00
ipv4 ipv4: Missing sk_nulls_node_init() in ping_unhash(). 2015-05-13 05:16:56 -07:00
ipv6 ipv6: protect skb->sk accesses from recursive dereference inside the stack 2015-04-29 10:31:46 +02:00
ipx ipx: fix locking regression in ipx_sendmsg and ipx_recvmsg 2014-12-06 15:55:34 -08:00
irda net: irda: fix wait_until_sent poll timeout 2015-03-18 13:31:29 +01:00
iucv af_iucv: wrong mapping of sent and confirmed skbs 2014-06-30 20:11:51 -07:00
key selinux: add gfp argument to security_xfrm_policy_alloc and fix callers 2014-03-10 08:30:02 +01:00
l2tp l2tp: fix race while getting PMTU on PPP pseudo-wire 2014-10-15 08:36:41 +02:00
lapb net/lapb: re-send packets on timeout 2013-09-23 16:52:45 -04:00
llc net: llc: use correct size for sysctl timeout entries 2015-04-19 10:11:09 +02:00
mac80211 mac80211: drop unencrypted frames in mesh fwding 2015-04-13 14:03:00 +02:00
mac802154 mac802154: fix following checkpath.pl warning Prefer pr_warn(... to pr_warning(... 2013-12-22 18:53:08 -05:00
mpls ipip: add GSO/TSO support 2013-10-19 19:36:19 -04:00
netfilter netfilter: conntrack: disable generic tracking for known protocols 2015-04-29 10:31:53 +02:00
netlabel netlabel: Fix FSF address in file headers 2013-12-06 12:37:56 -05:00
netlink net: fix crash in build_skb() 2015-05-06 21:59:07 +02:00
netrom net: add build-time checks for msg->msg_name size 2014-01-18 23:04:16 -08:00
nfc NFC: NCI: Fix NULL pointer dereference 2014-02-23 23:14:45 +01:00
openvswitch openvswitch: fix panic with multiple vlan headers 2014-10-15 08:36:41 +02:00
packet packet: handle too big packets for PACKET_V3 2014-10-15 08:36:40 +02:00
phonet net: Use netlink_ns_capable to verify the permisions of netlink messages 2014-06-26 15:15:38 -04:00
rds net: rds: use correct size for max unacked packets and bytes 2015-04-19 10:11:09 +02:00
rfkill Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-01-25 11:17:34 -08:00
rose net: add build-time checks for msg->msg_name size 2014-01-18 23:04:16 -08:00
rxrpc rxrpc: bogus MSG_PEEK test in rxrpc_recvmsg() 2015-03-26 15:06:50 +01:00
sched ematch: Fix auto-loading of ematch modules. 2015-03-18 13:31:21 +01:00
sctp net: sctp: fix passing wrong parameter header to param_type2af in sctp_process_param 2015-02-26 17:50:12 -08:00
sunrpc sunrpc: fix braino in ->poll() 2015-03-18 13:31:31 +01:00
tipc tipc: clear 'next'-pointer of message fragments before reassembly 2014-07-28 08:06:01 -07:00
unix net: unix: non blocking recvmsg() should not return -EINTR 2014-03-26 17:05:40 -04:00
vmw_vsock vsock: Make transport the proto owner 2014-05-31 13:20:36 -07:00
wimax wimax: remove dead code 2013-11-21 13:09:42 -05:00
wireless nl80211: ignore HT/VHT capabilities without QoS/WMM 2015-04-13 14:03:00 +02:00
x25 net: add build-time checks for msg->msg_name size 2014-01-18 23:04:16 -08:00
xfrm xfrm: Generate queueing routes only from route lookup functions 2014-10-15 08:36:42 +02:00
Kconfig net: netprio: rename config to be more consistent with cgroup configs 2014-01-03 23:41:42 +01:00
Makefile net: move 6lowpan compression code to separate module 2014-01-15 15:36:38 -08:00
compat.c net: compat: Update get_compat_msghdr() to match copy_msghdr_from_user() behaviour 2015-03-26 15:06:51 +01:00
nonet.c
socket.c net: socket: Fix the wrong returns for recvmsg and sendmsg 2015-06-06 08:19:31 -07:00
sysctl_net.c net: Update the sysctl permissions handler to test effective uid/gid 2013-10-07 15:57:56 -04:00