Skip to content

Commit a16b8d0

Browse files
dhowellsdavem330
authored andcommitted
rxrpc: Work around usercopy check
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 <[email protected]> Signed-off-by: David Howells <[email protected]> Acked-by: Kees Cook <[email protected]> Tested-by: Jonathan Billings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 43a08e0 commit a16b8d0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/rxrpc/recvmsg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,10 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
517517
ret = put_cmsg(msg, SOL_RXRPC, RXRPC_USER_CALL_ID,
518518
sizeof(unsigned int), &id32);
519519
} else {
520+
unsigned long idl = call->user_call_ID;
521+
520522
ret = put_cmsg(msg, SOL_RXRPC, RXRPC_USER_CALL_ID,
521-
sizeof(unsigned long),
522-
&call->user_call_ID);
523+
sizeof(unsigned long), &idl);
523524
}
524525
if (ret < 0)
525526
goto error_unlock_call;

0 commit comments

Comments
 (0)