History

SUNRPC: Do not dereference non-socket transports in sysfs

Do not cast the struct xprt to a sock_xprt unless we know it is a UDP or TCP transport. Otherwise the call to lock the mutex will scribble over whatever structure is actually there. This has been seen to cause hard system lockups when the underlying transport was RDMA.

Trond Myklebust committed 4 years ago

Commit 421ab1b1 parent 1d15d124 files · +54 −31Browse files

Showing the changes to include (2 of 4 files). Show all

Unified · Split

2 files
  1. include/linux/sunrpc/xprt.h +3 −0
  2. include/linux/sunrpc/xprtsock.h +0 −1
include/linux/sunrpc/xprt.h+3−0
@@ -139,6 +139,9 @@ struct rpc_xprt_ops { · 138 unmodified lines
139139 void (*rpcbind)(struct rpc_task *task);
140140 void (*set_port)(struct rpc_xprt *xprt, unsigned short port);
141141 void (*connect)(struct rpc_xprt *xprt, struct rpc_task *task);
142+ int (*get_srcaddr)(struct rpc_xprt *xprt, char *buf,
143+ size_t buflen);
144+ unsigned short (*get_srcport)(struct rpc_xprt *xprt);
142145 int (*buf_alloc)(struct rpc_task *task);
143146 void (*buf_free)(struct rpc_task *task);
144147 void (*prepare_request)(struct rpc_rqst *req);
include/linux/sunrpc/xprtsock.h+0−1
@@ -10,7 +10,6 @@ · 9 unmodified lines
1010
1111 int init_socket_xprt(void);
1212 void cleanup_socket_xprt(void);
13−unsigned short get_srcport(struct rpc_xprt *);
1413
1514 #define RPC_MIN_RESVPORT (1U)
1615 #define RPC_MAX_RESVPORT (65535U)