linux-stable/net/rxrpc
David Howells f146c6e650 rxrpc: Work around usercopy check
[ Upstream commit a16b8d0cf2 ]

Due to a check recently added to copy_to_user(), it's now not permitted to
copy from slab-held data to userspace unless the slab is whitelisted.  This
affects rxrpc_recvmsg() when it attempts to place an RXRPC_USER_CALL_ID
control message in the userspace control message buffer.  A warning is
generated by usercopy_warn() because the source is the copy of the
user_call_ID retained in the rxrpc_call struct.

Work around the issue by copying the user_call_ID to a variable on the
stack and passing that to put_cmsg().

The warning generated looks like:

	Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLUB object 'dmaengine-unmap-128' (offset 680, size 8)!
	WARNING: CPU: 0 PID: 1401 at mm/usercopy.c:81 usercopy_warn+0x7e/0xa0
	...
	RIP: 0010:usercopy_warn+0x7e/0xa0
	...
	Call Trace:
	 __check_object_size+0x9c/0x1a0
	 put_cmsg+0x98/0x120
	 rxrpc_recvmsg+0x6fc/0x1010 [rxrpc]
	 ? finish_wait+0x80/0x80
	 ___sys_recvmsg+0xf8/0x240
	 ? __clear_rsb+0x25/0x3d
	 ? __clear_rsb+0x15/0x3d
	 ? __clear_rsb+0x25/0x3d
	 ? __clear_rsb+0x15/0x3d
	 ? __clear_rsb+0x25/0x3d
	 ? __clear_rsb+0x15/0x3d
	 ? __clear_rsb+0x25/0x3d
	 ? __clear_rsb+0x15/0x3d
	 ? finish_task_switch+0xa6/0x2b0
	 ? trace_hardirqs_on_caller+0xed/0x180
	 ? _raw_spin_unlock_irq+0x29/0x40
	 ? __sys_recvmsg+0x4e/0x90
	 __sys_recvmsg+0x4e/0x90
	 do_syscall_64+0x7a/0x220
	 entry_SYSCALL_64_after_hwframe+0x26/0x9b

Reported-by: Jonathan Billings <jsbillings@jsbillings.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Kees Cook <keescook@chromium.org>
Tested-by: Jonathan Billings <jsbillings@jsbillings.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-30 07:51:57 +02:00
..
af_rxrpc.c rxrpc: Fix service endpoint expiry 2018-02-03 17:39:01 +01:00
ar-internal.h rxrpc: Fix service endpoint expiry 2018-02-03 17:39:01 +01:00
call_accept.c rxrpc: Provide a different lockdep key for call->user_mutex for kernel calls 2018-02-03 17:39:01 +01:00
call_event.c rxrpc: Use negative error codes in rxrpc_call struct 2017-04-06 10:11:56 +01:00
call_object.c rxrpc: Provide a different lockdep key for call->user_mutex for kernel calls 2018-02-03 17:39:01 +01:00
conn_client.c rxrpc: Fix service endpoint expiry 2018-02-03 17:39:01 +01:00
conn_event.c rxrpc: Don't put crypto buffers on the stack 2018-04-26 11:02:19 +02:00
conn_object.c rxrpc: Fix service endpoint expiry 2018-02-03 17:39:01 +01:00
conn_service.c rxrpc: Make service connection lookup always check for retry 2017-09-05 14:39:17 -07:00
input.c rxrpc: Add service upgrade support for client connections 2017-06-05 14:30:49 +01:00
insecure.c rxrpc: Trace protocol errors in received packets 2017-04-06 11:09:39 +01:00
Kconfig rxrpc: Add config to inject packet loss 2016-09-17 11:24:04 +01:00
key.c rxrpc: Use correct timestamp from Kerberos 5 ticket 2017-08-29 10:55:06 +01:00
local_event.c rxrpc: Fix IPv6 support 2017-08-29 10:55:20 +01:00
local_object.c rxrpc: Permit multiple service binding 2017-06-05 14:30:49 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
misc.c rxrpc: Fix handling of enums-to-string translation in tracing 2017-01-05 10:38:33 +00:00
net_ns.c rxrpc: Fix service endpoint expiry 2018-02-03 17:39:01 +01:00
output.c rxrpc: Fix send in rxrpc_send_data_packet() 2018-03-08 22:41:12 -08:00
peer_event.c rxrpc: Fix IPv6 support 2017-08-29 10:55:20 +01:00
peer_object.c rxrpc: Cache the congestion window setting 2017-06-14 15:42:45 -04:00
proc.c rxrpc: Separate the connection's protocol service ID from the lookup ID 2017-06-05 14:30:49 +01:00
protocol.h rxrpc: Move the packet.h include file into net/rxrpc/ 2017-07-21 11:00:20 +01:00
recvmsg.c rxrpc: Work around usercopy check 2018-05-30 07:51:57 +02:00
rxkad.c rxrpc: Don't put crypto buffers on the stack 2018-04-26 11:02:19 +02:00
security.c rxrpc: Permit multiple service binding 2017-06-05 14:30:49 +01:00
sendmsg.c rxrpc: The mutex lock returned by rxrpc_accept_call() needs releasing 2018-02-03 17:39:00 +01:00
skbuff.c net: convert sk_buff.users from atomic_t to refcount_t 2017-07-01 07:39:07 -07:00
sysctl.c rxrpc: Keep the call timeouts as ktimes rather than jiffies 2016-09-30 14:40:11 +01:00
utils.c rxrpc: Fix IPv6 support 2017-08-29 10:55:20 +01:00