summaryrefslogtreecommitdiff
path: root/net/rxrpc/proc.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-08-24 14:31:43 +0100
committerDavid Howells <dhowells@redhat.com>2016-08-24 15:15:59 +0100
commitdf5d8bf70f64a2ee34234553eb215418dbc4c8f3 (patch)
tree866b273fb3eb256464fe6d10185b63054601df5a /net/rxrpc/proc.c
parent2266ffdef5737fdfa96005204fc5606dbd559956 (diff)
rxrpc: Make /proc/net/rxrpc_calls safer
Make /proc/net/rxrpc_calls safer by stashing a copy of the peer pointer in the rxrpc_call struct and checking in the show routine that the peer pointer, the socket pointer and the local pointer obtained from the socket pointer aren't NULL before we use them. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'net/rxrpc/proc.c')
-rw-r--r--net/rxrpc/proc.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c
index 31b7f36a39cb..53872631a66d 100644
--- a/net/rxrpc/proc.c
+++ b/net/rxrpc/proc.c
@@ -46,7 +46,9 @@ static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
{
- struct rxrpc_connection *conn;
+ struct rxrpc_local *local;
+ struct rxrpc_sock *rx;
+ struct rxrpc_peer *peer;
struct rxrpc_call *call;
char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
@@ -60,15 +62,24 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
call = list_entry(v, struct rxrpc_call, link);
- sprintf(lbuff, "%pI4:%u",
- &call->socket->local->srx.transport.sin.sin_addr,
- ntohs(call->socket->local->srx.transport.sin.sin_port));
+ rx = READ_ONCE(call->socket);
+ if (rx) {
+ local = READ_ONCE(rx->local);
+ if (local)
+ sprintf(lbuff, "%pI4:%u",
+ &local->srx.transport.sin.sin_addr,
+ ntohs(local->srx.transport.sin.sin_port));
+ else
+ strcpy(lbuff, "no_local");
+ } else {
+ strcpy(lbuff, "no_socket");
+ }
- conn = call->conn;
- if (conn)
+ peer = call->peer;
+ if (peer)
sprintf(rbuff, "%pI4:%u",
- &conn->params.peer->srx.transport.sin.sin_addr,
- ntohs(conn->params.peer->srx.transport.sin.sin_port));
+ &peer->srx.transport.sin.sin_addr,
+ ntohs(peer->srx.transport.sin.sin_port));
else
strcpy(rbuff, "no_connection");