d5a5451
From 74e98eb085889b0d2d4908f59f6e00026063014f Mon Sep 17 00:00:00 2001
d5a5451
From: Sasha Levin <sasha.levin@oracle.com>
d5a5451
Date: Tue, 8 Sep 2015 10:53:40 -0400
d5a5451
Subject: [PATCH] RDS: verify the underlying transport exists before creating a
d5a5451
 connection
d5a5451
d5a5451
There was no verification that an underlying transport exists when creating
d5a5451
a connection, this would cause dereferencing a NULL ptr.
d5a5451
d5a5451
It might happen on sockets that weren't properly bound before attempting to
d5a5451
send a message, which will cause a NULL ptr deref:
d5a5451
d5a5451
[135546.047719] kasan: GPF could be caused by NULL-ptr deref or user memory accessgeneral protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC KASAN
d5a5451
[135546.051270] Modules linked in:
d5a5451
[135546.051781] CPU: 4 PID: 15650 Comm: trinity-c4 Not tainted 4.2.0-next-20150902-sasha-00041-gbaa1222-dirty #2527
d5a5451
[135546.053217] task: ffff8800835bc000 ti: ffff8800bc708000 task.ti: ffff8800bc708000
d5a5451
[135546.054291] RIP: __rds_conn_create (net/rds/connection.c:194)
d5a5451
[135546.055666] RSP: 0018:ffff8800bc70fab0  EFLAGS: 00010202
d5a5451
[135546.056457] RAX: dffffc0000000000 RBX: 0000000000000f2c RCX: ffff8800835bc000
d5a5451
[135546.057494] RDX: 0000000000000007 RSI: ffff8800835bccd8 RDI: 0000000000000038
d5a5451
[135546.058530] RBP: ffff8800bc70fb18 R08: 0000000000000001 R09: 0000000000000000
d5a5451
[135546.059556] R10: ffffed014d7a3a23 R11: ffffed014d7a3a21 R12: 0000000000000000
d5a5451
[135546.060614] R13: 0000000000000001 R14: ffff8801ec3d0000 R15: 0000000000000000
d5a5451
[135546.061668] FS:  00007faad4ffb700(0000) GS:ffff880252000000(0000) knlGS:0000000000000000
d5a5451
[135546.062836] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
d5a5451
[135546.063682] CR2: 000000000000846a CR3: 000000009d137000 CR4: 00000000000006a0
d5a5451
[135546.064723] Stack:
d5a5451
[135546.065048]  ffffffffafe2055c ffffffffafe23fc1 ffffed00493097bf ffff8801ec3d0008
d5a5451
[135546.066247]  0000000000000000 00000000000000d0 0000000000000000 ac194a24c0586342
d5a5451
[135546.067438]  1ffff100178e1f78 ffff880320581b00 ffff8800bc70fdd0 ffff880320581b00
d5a5451
[135546.068629] Call Trace:
d5a5451
[135546.069028] ? __rds_conn_create (include/linux/rcupdate.h:856 net/rds/connection.c:134)
d5a5451
[135546.069989] ? rds_message_copy_from_user (net/rds/message.c:298)
d5a5451
[135546.071021] rds_conn_create_outgoing (net/rds/connection.c:278)
d5a5451
[135546.071981] rds_sendmsg (net/rds/send.c:1058)
d5a5451
[135546.072858] ? perf_trace_lock (include/trace/events/lock.h:38)
d5a5451
[135546.073744] ? lockdep_init (kernel/locking/lockdep.c:3298)
d5a5451
[135546.074577] ? rds_send_drop_to (net/rds/send.c:976)
d5a5451
[135546.075508] ? __might_fault (./arch/x86/include/asm/current.h:14 mm/memory.c:3795)
d5a5451
[135546.076349] ? __might_fault (mm/memory.c:3795)
d5a5451
[135546.077179] ? rds_send_drop_to (net/rds/send.c:976)
d5a5451
[135546.078114] sock_sendmsg (net/socket.c:611 net/socket.c:620)
d5a5451
[135546.078856] SYSC_sendto (net/socket.c:1657)
d5a5451
[135546.079596] ? SYSC_connect (net/socket.c:1628)
d5a5451
[135546.080510] ? trace_dump_stack (kernel/trace/trace.c:1926)
d5a5451
[135546.081397] ? ring_buffer_unlock_commit (kernel/trace/ring_buffer.c:2479 kernel/trace/ring_buffer.c:2558 kernel/trace/ring_buffer.c:2674)
d5a5451
[135546.082390] ? trace_buffer_unlock_commit (kernel/trace/trace.c:1749)
d5a5451
[135546.083410] ? trace_event_raw_event_sys_enter (include/trace/events/syscalls.h:16)
d5a5451
[135546.084481] ? do_audit_syscall_entry (include/trace/events/syscalls.h:16)
d5a5451
[135546.085438] ? trace_buffer_unlock_commit (kernel/trace/trace.c:1749)
d5a5451
[135546.085515] rds_ib_laddr_check(): addr 36.74.25.172 ret -99 node type -1
d5a5451
d5a5451
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
d5a5451
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
d5a5451
Signed-off-by: David S. Miller <davem@davemloft.net>
d5a5451
---
d5a5451
 net/rds/connection.c | 6 ++++++
d5a5451
 1 file changed, 6 insertions(+)
d5a5451
d5a5451
diff --git a/net/rds/connection.c b/net/rds/connection.c
d5a5451
index 9b2de5e67d79..49adeef8090c 100644
d5a5451
--- a/net/rds/connection.c
d5a5451
+++ b/net/rds/connection.c
d5a5451
@@ -190,6 +190,12 @@ new_conn:
d5a5451
 		}
d5a5451
 	}
d5a5451
 
d5a5451
+	if (trans == NULL) {
d5a5451
+		kmem_cache_free(rds_conn_slab, conn);
d5a5451
+		conn = ERR_PTR(-ENODEV);
d5a5451
+		goto out;
d5a5451
+	}
d5a5451
+
d5a5451
 	conn->c_trans = trans;
d5a5451
 
d5a5451
 	ret = trans->conn_alloc(conn, gfp);
d5a5451
-- 
d5a5451
2.4.3
d5a5451