summaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorAnna Schumaker <Anna.Schumaker@Netapp.com>2021-10-28 21:17:41 +0200
committerTrond Myklebust <trond.myklebust@hammerspace.com>2021-11-05 00:43:29 +0100
commit17f09d3f619a7ad2d2b021b4e5246f08225b1b0f (patch)
treea4ac765bef9792517d085726aff4dc2093b29ec0 /net/sunrpc
parentnfs: remove unused header <linux/pnfs_osd_xdr.h> (diff)
downloadlinux-17f09d3f619a7ad2d2b021b4e5246f08225b1b0f.tar.xz
linux-17f09d3f619a7ad2d2b021b4e5246f08225b1b0f.zip
SUNRPC: Check if the xprt is connected before handling sysfs reads
xprts don't immediately reconnect when changing the "dstaddr" property, instead this gets handled the next time an operation uses the transport. This could lead to NULL pointer dereferences when trying to read sysfs files between the disconnect and reconnect operations. Fix this by returning an error if the xprt is not connected. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/sysfs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c
index 9a6f17e18f73..2766dd21935b 100644
--- a/net/sunrpc/sysfs.c
+++ b/net/sunrpc/sysfs.c
@@ -109,8 +109,10 @@ static ssize_t rpc_sysfs_xprt_srcaddr_show(struct kobject *kobj,
struct sock_xprt *sock;
ssize_t ret = -1;
- if (!xprt)
- return 0;
+ if (!xprt || !xprt_connected(xprt)) {
+ xprt_put(xprt);
+ return -ENOTCONN;
+ }
sock = container_of(xprt, struct sock_xprt, xprt);
if (kernel_getsockname(sock->sock, (struct sockaddr *)&saddr) < 0)
@@ -129,8 +131,10 @@ static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj,
struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj);
ssize_t ret;
- if (!xprt)
- return 0;
+ if (!xprt || !xprt_connected(xprt)) {
+ xprt_put(xprt);
+ return -ENOTCONN;
+ }
ret = sprintf(buf, "last_used=%lu\ncur_cong=%lu\ncong_win=%lu\n"
"max_num_slots=%u\nmin_num_slots=%u\nnum_reqs=%u\n"