Skip to content

Commit 3ec7dbb

Browse files
kcp-gitgerd-rausch
authored andcommitted
rds: Node crashes when trace buffer is opened
The problem is that trace_printk() cannot handle a format string like %p* which prints out the content from a pointer. It stores the pointer value. When the trace file is opened, that pointer is de-referenced and causes problems. To use ftrace with such format string, __trace_printk() needs to be used. It stores the formatted string in the trace buffer instead. Orabug: 27708872 Signed-off-by: Ka-Cheong Poon <[email protected]> Reviewed-by: Yuval Shaia <[email protected]> Reviewed-by: Tom Hromatka <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent f5a131d commit 3ec7dbb

File tree

6 files changed

+115
-110
lines changed

6 files changed

+115
-110
lines changed

net/rds/connection.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This software is available to you under a choice of one of two
55
* licenses. You may choose to be licensed under the terms of the GNU
@@ -387,11 +387,12 @@ void rds_conn_shutdown(struct rds_conn_path *cp)
387387

388388
/* shut it down unless it's down already */
389389
if (!rds_conn_path_transition(cp, RDS_CONN_DOWN, RDS_CONN_DOWN)) {
390-
rds_rtd(RDS_RTD_CM_EXT,
391-
"RDS/%s: shutdown init <%pI6c,%pI6c,%d>, cn %p, cn->c_p %p\n",
392-
conn->c_trans->t_type == RDS_TRANS_TCP ? "TCP" : "IB",
393-
&conn->c_laddr, &conn->c_faddr,
394-
conn->c_tos, conn, conn->c_passive);
390+
rds_rtd_ptr(RDS_RTD_CM_EXT,
391+
"RDS/%s: shutdown init <%pI6c,%pI6c,%d>, cn %p, cn->c_p %p\n",
392+
conn->c_trans->t_type == RDS_TRANS_TCP ? "TCP" :
393+
"IB",
394+
&conn->c_laddr, &conn->c_faddr,
395+
conn->c_tos, conn, conn->c_passive);
395396
/*
396397
* Quiesce the connection mgmt handlers before we start tearing
397398
* things down. We don't hold the mutex for the entire
@@ -518,9 +519,9 @@ void rds_conn_destroy(struct rds_connection *conn, int shutdown)
518519
int i;
519520
int npaths = (conn->c_trans->t_mp_capable ? RDS_MPATH_WORKERS : 1);
520521

521-
rds_rtd(RDS_RTD_CM, "freeing conn %p <%pI6c,%pI6c,%d>\n",
522-
conn, &conn->c_laddr, &conn->c_faddr,
523-
conn->c_tos);
522+
rds_rtd_ptr(RDS_RTD_CM, "freeing conn %p <%pI6c,%pI6c,%d>\n",
523+
conn, &conn->c_laddr, &conn->c_faddr,
524+
conn->c_tos);
524525

525526
conn->c_destroy_in_prog = 1;
526527
/* Ensure conn will not be scheduled for reconnect */
@@ -987,11 +988,11 @@ void rds_conn_path_drop(struct rds_conn_path *cp, int reason)
987988

988989
atomic_set(&cp->cp_state, RDS_CONN_ERROR);
989990

990-
rds_rtd(RDS_RTD_CM_EXT,
991-
"RDS/%s: queueing shutdown work, conn %p, <%pI6c,%pI6c,%d>\n",
992-
conn->c_trans->t_type == RDS_TRANS_TCP ? "TCP" : "IB",
993-
conn, &conn->c_laddr, &conn->c_faddr,
994-
conn->c_tos);
991+
rds_rtd_ptr(RDS_RTD_CM_EXT,
992+
"RDS/%s: queueing shutdown work, conn %p, <%pI6c,%pI6c,%d>\n",
993+
conn->c_trans->t_type == RDS_TRANS_TCP ? "TCP" : "IB",
994+
conn, &conn->c_laddr, &conn->c_faddr,
995+
conn->c_tos);
995996

996997
queue_work(cp->cp_wq, &cp->cp_down_w);
997998
}
@@ -1014,10 +1015,10 @@ void rds_conn_path_connect_if_down(struct rds_conn_path *cp)
10141015

10151016
if (rds_conn_path_state(cp) == RDS_CONN_DOWN &&
10161017
!test_and_set_bit(RDS_RECONNECT_PENDING, &cp->cp_flags)) {
1017-
rds_rtd(RDS_RTD_CM_EXT,
1018-
"queueing connect work, conn %p, <%pI6c,%pI6c,%d>\n",
1019-
conn, &conn->c_laddr, &conn->c_faddr,
1020-
conn->c_tos);
1018+
rds_rtd_ptr(RDS_RTD_CM_EXT,
1019+
"queueing connect work, conn %p, <%pI6c,%pI6c,%d>\n",
1020+
conn, &conn->c_laddr, &conn->c_faddr,
1021+
conn->c_tos);
10211022
queue_delayed_work(cp->cp_wq, &cp->cp_conn_w, 0);
10221023
}
10231024
}

net/rds/ib_cm.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,10 @@ static void rds_ib_qp_event_handler(struct ib_event *event, void *data)
663663
complete(&ic->i_last_wqe_complete);
664664
break;
665665
default:
666-
rds_rtd(RDS_RTD_ERR,
667-
"Fatal QP Event %u (%s) - connection %pI6c->%pI6c tos %d, reconnecting\n",
668-
event->event, rds_ib_event_str(event->event),
669-
&conn->c_laddr, &conn->c_faddr, conn->c_tos);
666+
rds_rtd_ptr(RDS_RTD_ERR,
667+
"Fatal QP Event %u (%s) - connection %pI6c->%pI6c tos %d, reconnecting\n",
668+
event->event, rds_ib_event_str(event->event),
669+
&conn->c_laddr, &conn->c_faddr, conn->c_tos);
670670
rds_conn_drop(conn, DR_IB_QP_EVENT);
671671
break;
672672
}
@@ -1027,14 +1027,14 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
10271027
daddr6 = &d_mapped_addr;
10281028
}
10291029

1030-
rds_rtd(RDS_RTD_CM,
1031-
"saddr %pI6c daddr %pI6c RDSv%u.%u lguid 0x%llx fguid 0x%llx tos %d\n",
1032-
saddr6, daddr6,
1033-
RDS_PROTOCOL_MAJOR(version),
1034-
RDS_PROTOCOL_MINOR(version),
1035-
(unsigned long long)be64_to_cpu(lguid),
1036-
(unsigned long long)be64_to_cpu(fguid),
1037-
dp_cmn->ricpc_tos);
1030+
rds_rtd_ptr(RDS_RTD_CM,
1031+
"saddr %pI6c daddr %pI6c RDSv%u.%u lguid 0x%llx fguid 0x%llx tos %d\n",
1032+
saddr6, daddr6,
1033+
RDS_PROTOCOL_MAJOR(version),
1034+
RDS_PROTOCOL_MINOR(version),
1035+
(unsigned long long)be64_to_cpu(lguid),
1036+
(unsigned long long)be64_to_cpu(fguid),
1037+
dp_cmn->ricpc_tos);
10381038

10391039
#ifdef CONFIG_RDS_ACL
10401040

net/rds/rdma_transport.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2017 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This software is available to you under a choice of one of two
55
* licenses. You may choose to be licensed under the terms of the GNU
@@ -166,10 +166,10 @@ int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
166166
cm_id->route.path_rec[0].qos_class = conn->c_tos;
167167
ret = trans->cm_initiate_connect(cm_id, isv6);
168168
} else {
169-
rds_rtd(RDS_RTD_CM,
170-
"ROUTE_RESOLVED: calling rds_conn_drop, conn %p <%pI6c,%pI6c,%d>\n",
171-
conn, &conn->c_laddr,
172-
&conn->c_faddr, conn->c_tos);
169+
rds_rtd_ptr(RDS_RTD_CM,
170+
"ROUTE_RESOLVED: calling rds_conn_drop, conn %p <%pI6c,%pI6c,%d>\n",
171+
conn, &conn->c_laddr,
172+
&conn->c_faddr, conn->c_tos);
173173
rds_conn_drop(conn, DR_IB_RDMA_CM_ID_MISMATCH);
174174
}
175175
}
@@ -197,10 +197,10 @@ int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
197197
}
198198

199199
if (conn) {
200-
rds_rtd(RDS_RTD_ERR,
201-
"ROUTE_ERROR: conn %p, calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
202-
conn, &conn->c_laddr,
203-
&conn->c_faddr, conn->c_tos);
200+
rds_rtd_ptr(RDS_RTD_ERR,
201+
"ROUTE_ERROR: conn %p, calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
202+
conn, &conn->c_laddr,
203+
&conn->c_faddr, conn->c_tos);
204204
rds_conn_drop(conn, DR_IB_ROUTE_ERR);
205205
}
206206
break;
@@ -211,10 +211,10 @@ int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
211211

212212
case RDMA_CM_EVENT_ADDR_ERROR:
213213
if (conn) {
214-
rds_rtd(RDS_RTD_ERR,
215-
"ADDR_ERROR: conn %p, calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
216-
conn, &conn->c_laddr,
217-
&conn->c_faddr, conn->c_tos);
214+
rds_rtd_ptr(RDS_RTD_ERR,
215+
"ADDR_ERROR: conn %p, calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
216+
conn, &conn->c_laddr,
217+
&conn->c_faddr, conn->c_tos);
218218
rds_conn_drop(conn, DR_IB_ADDR_ERR);
219219
}
220220
break;
@@ -223,10 +223,10 @@ int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
223223
case RDMA_CM_EVENT_UNREACHABLE:
224224
case RDMA_CM_EVENT_DEVICE_REMOVAL:
225225
if (conn) {
226-
rds_rtd(RDS_RTD_ERR,
227-
"CONN/UNREACHABLE/RMVAL ERR: conn %p, calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
228-
conn, &conn->c_laddr,
229-
&conn->c_faddr, conn->c_tos);
226+
rds_rtd_ptr(RDS_RTD_ERR,
227+
"CONN/UNREACHABLE/RMVAL ERR: conn %p, calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
228+
conn, &conn->c_laddr,
229+
&conn->c_faddr, conn->c_tos);
230230
rds_conn_drop(conn, DR_IB_CONNECT_ERR);
231231
}
232232
break;
@@ -255,27 +255,27 @@ int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
255255
conn->c_tos);
256256
rds_ib_conn_destroy_init(conn);
257257
} else {
258-
rds_rtd(RDS_RTD_ERR,
259-
"Rejected: *err %d status %d calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
260-
*err, event->status,
261-
&conn->c_laddr,
262-
&conn->c_faddr,
263-
conn->c_tos);
258+
rds_rtd_ptr(RDS_RTD_ERR,
259+
"Rejected: *err %d status %d calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
260+
*err, event->status,
261+
&conn->c_laddr,
262+
&conn->c_faddr,
263+
conn->c_tos);
264264
rds_conn_drop(conn, DR_IB_REJECTED_EVENT);
265265
}
266266
}
267267
break;
268268

269269
case RDMA_CM_EVENT_ADDR_CHANGE:
270-
rds_rtd(RDS_RTD_CM_EXT,
271-
"ADDR_CHANGE event <%pI6c,%pI6c>\n",
272-
&conn->c_laddr,
273-
&conn->c_faddr);
270+
rds_rtd_ptr(RDS_RTD_CM_EXT,
271+
"ADDR_CHANGE event <%pI6c,%pI6c>\n",
272+
&conn->c_laddr,
273+
&conn->c_faddr);
274274
if (conn) {
275-
rds_rtd(RDS_RTD_CM,
276-
"ADDR_CHANGE: calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
277-
&conn->c_laddr, &conn->c_faddr,
278-
conn->c_tos);
275+
rds_rtd_ptr(RDS_RTD_CM,
276+
"ADDR_CHANGE: calling rds_conn_drop <%pI6c,%pI6c,%d>\n",
277+
&conn->c_laddr, &conn->c_faddr,
278+
conn->c_tos);
279279
if (!rds_conn_self_loopback_passive(conn)) {
280280
queue_delayed_work(conn->c_path[0].cp_wq,
281281
&conn->c_reconn_w,
@@ -286,9 +286,9 @@ int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
286286
break;
287287

288288
case RDMA_CM_EVENT_DISCONNECTED:
289-
rds_rtd(RDS_RTD_CM,
290-
"DISCONNECT event - dropping connection %pI6c->%pI6c tos %d\n",
291-
&conn->c_laddr, &conn->c_faddr, conn->c_tos);
289+
rds_rtd_ptr(RDS_RTD_CM,
290+
"DISCONNECT event - dropping connection %pI6c->%pI6c tos %d\n",
291+
&conn->c_laddr, &conn->c_faddr, conn->c_tos);
292292
rds_conn_drop(conn, DR_IB_DISCONNECTED_EVENT);
293293
break;
294294

net/rds/rds.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ enum {
8888
RDS_RTD_TCP = 1 << 28, /* 0x10000000 */
8989
};
9090

91-
#define rds_rtd_printk(format, arg...) \
92-
trace_printk("%d: " format, __LINE__, ## arg)
93-
9491
#define rds_rtd(enabling_bit, format, arg...) \
9592
do { if (likely(!(enabling_bit & kernel_rds_rt_debug_bitmap))) break;\
96-
rds_rtd_printk(format, ## arg); \
93+
trace_printk("%d: " format, __LINE__, ## arg); \
94+
} while (0)
95+
96+
#define rds_rtd_ptr(enabling_bit, format, arg...) \
97+
do { if (likely(!(enabling_bit & kernel_rds_rt_debug_bitmap))) break; \
98+
__trace_printk(_THIS_IP_, "%d: " format, __LINE__, ## arg); \
9799
} while (0)
98100

99101
/* XXX is there one of these somewhere? */

net/rds/recv.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This software is available to you under a choice of one of two
55
* licenses. You may choose to be licensed under the terms of the GNU
@@ -383,9 +383,9 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr,
383383
skb = alloc_skb(sizeof(struct rds_nf_hdr) * 2, gfp);
384384
if (NULL == skb) {
385385
/* if we have allocation problems, then we just need to depart */
386-
rds_rtd(RDS_RTD_ERR,
387-
"failure to allocate space for inc %p, %pI6c -> %pI6c tos %d\n",
388-
inc, saddr, daddr, conn->c_tos);
386+
rds_rtd_ptr(RDS_RTD_ERR,
387+
"failure to allocate space for inc %p, %pI6c -> %pI6c tos %d\n",
388+
inc, saddr, daddr, conn->c_tos);
389389
rds_recv_local(cp, saddr, daddr, inc, gfp, rs);
390390
/* drop the reference if we had taken one */
391391
if (NULL != rs)
@@ -434,9 +434,9 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr,
434434
}
435435
/* if we had a failure to convert, then just assuming to continue as local */
436436
else {
437-
rds_rtd(RDS_RTD_RCV_EXT,
438-
"failed to create skb form, conn %p, inc %p, %pI6c -> %pI6c tos %d\n",
439-
conn, inc, saddr, daddr, conn->c_tos);
437+
rds_rtd_ptr(RDS_RTD_RCV_EXT,
438+
"failed to create skb form, conn %p, inc %p, %pI6c -> %pI6c tos %d\n",
439+
conn, inc, saddr, daddr, conn->c_tos);
440440
ret = 1;
441441
}
442442

@@ -560,10 +560,10 @@ rds_recv_forward(struct rds_conn_path *cp, struct rds_incoming *inc,
560560
/* find the proper output socket - it should be the local one on which we originated */
561561
rs = rds_find_bound(&dst->saddr, dst->sport, conn->c_dev_if);
562562
if (!rs) {
563-
rds_rtd(RDS_RTD_RCV,
564-
"failed to find output rds_socket dst %pI6c : %u, inc %p, conn %p tos %d\n",
565-
&dst->daddr, dst->dport, inc, conn,
566-
conn->c_tos);
563+
rds_rtd_ptr(RDS_RTD_RCV,
564+
"failed to find output rds_socket dst %pI6c : %u, inc %p, conn %p tos %d\n",
565+
&dst->daddr, dst->dport, inc, conn,
566+
conn->c_tos);
567567
rds_stats_inc(s_recv_drop_no_sock);
568568
goto out;
569569
}
@@ -574,10 +574,10 @@ rds_recv_forward(struct rds_conn_path *cp, struct rds_incoming *inc,
574574
/* now lets see if we can send it all */
575575
ret = rds_send_internal(conn, rs, inc->i_skb, gfp);
576576
if (len != ret) {
577-
rds_rtd(RDS_RTD_RCV,
578-
"failed to send rds_data dst %pI6c : %u, inc %p, conn %p tos %d, len %d != ret %d\n",
579-
&dst->daddr, dst->dport, inc, conn, conn->c_tos,
580-
len, ret);
577+
rds_rtd_ptr(RDS_RTD_RCV,
578+
"failed to send rds_data dst %pI6c : %u, inc %p, conn %p tos %d, len %d != ret %d\n",
579+
&dst->daddr, dst->dport, inc, conn, conn->c_tos,
580+
len, ret);
581581
goto out;
582582
}
583583

@@ -652,11 +652,11 @@ rds_recv_local(struct rds_conn_path *cp, struct in6_addr *saddr,
652652
inc_hdr_h_sequence = be64_to_cpu(inc->i_hdr.h_sequence);
653653

654654
if (inc_hdr_h_sequence != cp->cp_next_rx_seq) {
655-
rds_rtd(RDS_RTD_RCV,
656-
"conn %p <%pI6c,%pI6c,%d> expect seq# %llu, recved seq# %llu, retrans bit %d\n",
657-
conn, &conn->c_laddr, &conn->c_faddr,
658-
conn->c_tos, cp->cp_next_rx_seq, inc_hdr_h_sequence,
659-
inc->i_hdr.h_flags & RDS_FLAG_RETRANSMITTED);
655+
rds_rtd_ptr(RDS_RTD_RCV,
656+
"conn %p <%pI6c,%pI6c,%d> expect seq# %llu, recved seq# %llu, retrans bit %d\n",
657+
conn, &conn->c_laddr, &conn->c_faddr,
658+
conn->c_tos, cp->cp_next_rx_seq, inc_hdr_h_sequence,
659+
inc->i_hdr.h_flags & RDS_FLAG_RETRANSMITTED);
660660
}
661661

662662
if (inc_hdr_h_sequence < cp->cp_next_rx_seq

0 commit comments

Comments
 (0)