linux-stable/net/sunrpc
Zhang Xiaoxu d59722d088 SUNRPC: Fix null-ptr-deref when xps sysfs alloc failed
[ Upstream commit cbdeaee94a ]

There is a null-ptr-deref when xps sysfs alloc failed:
  BUG: KASAN: null-ptr-deref in sysfs_do_create_link_sd+0x40/0xd0
  Read of size 8 at addr 0000000000000030 by task gssproxy/457

  CPU: 5 PID: 457 Comm: gssproxy Not tainted 6.0.0-09040-g02357b27ee03 #9
  Call Trace:
   <TASK>
   dump_stack_lvl+0x34/0x44
   kasan_report+0xa3/0x120
   sysfs_do_create_link_sd+0x40/0xd0
   rpc_sysfs_client_setup+0x161/0x1b0
   rpc_new_client+0x3fc/0x6e0
   rpc_create_xprt+0x71/0x220
   rpc_create+0x1d4/0x350
   gssp_rpc_create+0xc3/0x160
   set_gssp_clnt+0xbc/0x140
   write_gssp+0x116/0x1a0
   proc_reg_write+0xd6/0x130
   vfs_write+0x177/0x690
   ksys_write+0xb9/0x150
   do_syscall_64+0x35/0x80
   entry_SYSCALL_64_after_hwframe+0x46/0xb0

When the xprt_switch sysfs alloc failed, should not add xprt and
switch sysfs to it, otherwise, maybe null-ptr-deref; also initialize
the 'xps_sysfs' to NULL to avoid oops when destroy it.

Fixes: 2a338a5431 ("sunrpc: add a symlink from rpc-client directory to the xprt_switch")
Fixes: d408ebe04a ("sunrpc: add add sysfs directory per xprt under each xprt_switch")
Fixes: baea99445d ("sunrpc: add xprt_switch direcotry to sunrpc's sysfs")
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-10 18:15:26 +01:00
..
auth_gss SUNRPC: Ensure that the gssproxy client can start in a connected state 2022-05-18 10:26:56 +02:00
xprtrdma SUNRPC: Trap RDMA segment overflows 2022-06-14 18:36:16 +02:00
addr.c nfsd: don't alloc under spinlock in rpc_parse_scope_id 2021-11-18 19:16:58 +01:00
auth.c sunrpc: fix expiry of auth creds 2022-08-25 11:40:05 +02:00
auth_null.c
auth_unix.c
backchannel_rqst.c SUNRPC: Reinitialise the backchannel request buffers before reuse 2022-08-25 11:40:05 +02:00
cache.c SUNRPC: improve error response to over-size gss credential 2021-09-03 13:38:11 -04:00
clnt.c SUNRPC: RPC level errors should set task->tk_rpc_status 2022-08-31 17:16:37 +02:00
debugfs.c NFS Client Updates for Linux 5.15 2021-09-04 10:25:26 -07:00
fail.h SUNRPC: Server-side disconnect injection 2021-08-20 13:50:33 -04:00
Kconfig SUNRPC: remove RC4-HMAC-MD5 support from KerberosV 2020-09-11 14:39:15 +10:00
Makefile sunrpc: Create a sunrpc directory under /sys/kernel/ 2021-07-08 14:03:23 -04:00
netns.h
rpc_pipe.c fsnotify: fix fsnotify hooks in pseudo filesystems 2022-02-01 17:27:01 +01:00
rpcb_clnt.c sunrpc: honor rpc_task's timeout value in rpcb_create() 2021-04-05 09:04:21 -04:00
sched.c SUNRPC: remove scheduling boost for "SWAPPER" tasks. 2022-04-13 20:59:12 +02:00
socklib.c skb_copy_and_csum_bits(): don't bother with the last argument 2020-08-20 15:45:13 -04:00
socklib.h
stats.c
sunrpc.h Replace HTTP links with HTTPS ones: NFS, SUNRPC, and LOCKD clients 2020-09-21 10:21:10 -04:00
sunrpc_syms.c sunrpc: add IDs to multipath 2021-07-08 14:03:23 -04:00
svc.c NFSD: Have legacy NFSD WRITE decoders use xdr_stream_subsegment() 2022-03-08 19:12:33 +01:00
svc_xprt.c SUNRPC: Fix NFSD's request deferral on RDMA transports 2022-04-20 09:34:18 +02:00
svcauth.c SUNRPC: Add svc_rqst::rq_auth_stat 2021-08-10 14:18:35 -04:00
svcauth_unix.c SUNRPC: Set rq_auth_stat in the pg_authenticate() callout 2021-08-10 14:18:35 -04:00
svcsock.c SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec() 2022-04-13 20:59:20 +02:00
sysctl.c net/sunrpc: fix useless comparison in proc_do_xprt() 2020-11-08 16:28:25 -05:00
sysfs.c SUNRPC: Fix null-ptr-deref when xps sysfs alloc failed 2022-11-10 18:15:26 +01:00
sysfs.h SUNRPC: take a xprt offline using sysfs 2021-07-08 14:03:24 -04:00
timer.c
xdr.c SUNRPC: Fix READ_PLUS crasher 2022-07-07 17:53:25 +02:00
xprt.c SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() 2022-05-18 10:26:57 +02:00
xprtmultipath.c SUNRPC keep track of number of transports to unique addresses 2021-08-27 16:36:53 -04:00
xprtsock.c SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() 2022-05-18 10:26:57 +02:00