Skip to contentSkip to conversation

rds: do not leak kernel memory to user land

PATCH In review Eric Dumazet 2 participants 2 messages May 2, 2018 – May 3, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rds: do not leak kernel memory to user land

syzbot/KMSAN reported an uninit-value in put_cmsg(), originating from rds_cmsg_recv().

Simply clear the structure, since we have holes there, or since rx_traces might be smaller than RDS_MSG_RX_DGRAM_TRACE_MAX.

BUG: KMSAN: uninit-value in copy_to_user include/linux/uaccess.h:184 [inline]
BUG: KMSAN: uninit-value in put_cmsg+0x600/0x870 net/core/scm.c:242
CPU: 0 PID: 4459 Comm: syz-executor582 Not tainted 4.16.0+ #87
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x185/0x1d0 lib/dump_stack.c:53
 kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
 kmsan_internal_check_memory+0x135/0x1e0 mm/kmsan/kmsan.c:1157
 kmsan_copy_to_user+0x69/0x160 mm/kmsan/kmsan.c:1199
 copy_to_user include/linux/uaccess.h:184 [inline]
 put_cmsg+0x600/0x870 net/core/scm.c:242
 rds_cmsg_recv net/rds/recv.c:570 [inline]
 rds_recvmsg+0x2db5/0x3170 net/rds/recv.c:657
 sock_recvmsg_nosec net/socket.c:803 [inline]
 sock_recvmsg+0x1d0/0x230 net/socket.c:810
 ___sys_recvmsg+0x3fb/0x810 net/socket.c:2205
 __sys_recvmsg net/socket.c:2250 [inline]
 SYSC_recvmsg+0x298/0x3c0 net/socket.c:2262
 SyS_recvmsg+0x54/0x80 net/socket.c:2257
 do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
Fixes 3289025aedc0 ("RDS: add receive message trace used by application")
Cc Santosh Shilimkar <[email protected]>
Cc linux-rdma <[email protected]>
---
 net/rds/recv.c | 1 +
 1 file changed, 1 insertion(+)
net/rds/recv.c +1 -0
index de50e2126e404aed541b8d268a28da08154bf08d..dc67458b52f0043c2328d4a77a43536e7c62b0ed 100644
@@ -558,6 +558,7 @@ static int rds_cmsg_recv(struct rds_incoming *inc, struct msghdr *msg,
 		struct rds_cmsg_rx_trace t;
 		int i, j;
 
+		memset(&t, 0, sizeof(t));
 		inc->i_rx_lat_trace[RDS_MSG_RX_CMSG] = local_clock();
 		t.rx_traces =  rs->rs_rx_traces;
 		for (i = 0; i < rs->rs_rx_traces; i++) {
Signature · 1 line
2.17.0.441.gb46fe60e1d-goog
maintainer
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Wed, 2 May 2018 14:53:39 -0700

Quoted 5 lines

syzbot/KMSAN reported an uninit-value in put_cmsg(), originating from rds_cmsg_recv().

Simply clear the structure, since we have holes there, or since rx_traces might be smaller than RDS_MSG_RX_DGRAM_TRACE_MAX.

...

Quoted 3 lines
Fixes 3289025aedc0 ("RDS: add receive message trace used by application")

Applied and queued up for -stable.