
felixandGreg Kroah-Hartman
7749fd2dbe
SUNRPC: Fix RPC client cleaned up the freed pipefs dentries
[ Upstream commit bfca5fb4e9 ]
RPC client pipefs dentries cleanup is in separated rpc_remove_pipedir()
workqueue,which takes care about pipefs superblock locking.
In some special scenarios, when kernel frees the pipefs sb of the
current client and immediately alloctes a new pipefs sb,
rpc_remove_pipedir function would misjudge the existence of pipefs
sb which is not the one it used to hold. As a result,
the rpc_remove_pipedir would clean the released freed pipefs dentries.
To fix this issue, rpc_remove_pipedir should check whether the
current pipefs sb is consistent with the original pipefs sb.
This error can be catched by KASAN:
=========================================================
[ 250.497700] BUG: KASAN: slab-use-after-free in dget_parent+0x195/0x200
[ 250.498315] Read of size 4 at addr ffff88800a2ab804 by task kworker/0:18/106503
[ 250.500549] Workqueue: events rpc_free_client_work
[ 250.501001] Call Trace:
[ 250.502880] kasan_report+0xb6/0xf0
[ 250.503209] ? dget_parent+0x195/0x200
[ 250.503561] dget_parent+0x195/0x200
[ 250.503897] ? __pfx_rpc_clntdir_depopulate+0x10/0x10
[ 250.504384] rpc_rmdir_depopulate+0x1b/0x90
[ 250.504781] rpc_remove_client_dir+0xf5/0x150
[ 250.505195] rpc_free_client_work+0xe4/0x230
[ 250.505598] process_one_work+0x8ee/0x13b0
...
[ 22.039056] Allocated by task 244:
[ 22.039390] kasan_save_stack+0x22/0x50
[ 22.039758] kasan_set_track+0x25/0x30
[ 22.040109] __kasan_slab_alloc+0x59/0x70
[ 22.040487] kmem_cache_alloc_lru+0xf0/0x240
[ 22.040889] __d_alloc+0x31/0x8e0
[ 22.041207] d_alloc+0x44/0x1f0
[ 22.041514] __rpc_lookup_create_exclusive+0x11c/0x140
[ 22.041987] rpc_mkdir_populate.constprop.0+0x5f/0x110
[ 22.042459] rpc_create_client_dir+0x34/0x150
[ 22.042874] rpc_setup_pipedir_sb+0x102/0x1c0
[ 22.043284] rpc_client_register+0x136/0x4e0
[ 22.043689] rpc_new_client+0x911/0x1020
[ 22.044057] rpc_create_xprt+0xcb/0x370
[ 22.044417] rpc_create+0x36b/0x6c0
...
[ 22.049524] Freed by task 0:
[ 22.049803] kasan_save_stack+0x22/0x50
[ 22.050165] kasan_set_track+0x25/0x30
[ 22.050520] kasan_save_free_info+0x2b/0x50
[ 22.050921] __kasan_slab_free+0x10e/0x1a0
[ 22.051306] kmem_cache_free+0xa5/0x390
[ 22.051667] rcu_core+0x62c/0x1930
[ 22.051995] __do_softirq+0x165/0x52a
[ 22.052347]
[ 22.052503] Last potentially related work creation:
[ 22.052952] kasan_save_stack+0x22/0x50
[ 22.053313] __kasan_record_aux_stack+0x8e/0xa0
[ 22.053739] __call_rcu_common.constprop.0+0x6b/0x8b0
[ 22.054209] dentry_free+0xb2/0x140
[ 22.054540] __dentry_kill+0x3be/0x540
[ 22.054900] shrink_dentry_list+0x199/0x510
[ 22.055293] shrink_dcache_parent+0x190/0x240
[ 22.055703] do_one_tree+0x11/0x40
[ 22.056028] shrink_dcache_for_umount+0x61/0x140
[ 22.056461] generic_shutdown_super+0x70/0x590
[ 22.056879] kill_anon_super+0x3a/0x60
[ 22.057234] rpc_kill_sb+0x121/0x200
Fixes: 0157d021d2 ("SUNRPC: handle RPC client pipefs dentries by network namespace aware routines")
Signed-off-by: felix <fuzhen5@huawei.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 17:07:04 +00:00
..
2023-07-19 16:21:11 +02:00
2023-02-22 12:59:45 +01:00
2023-07-19 16:22:06 +02:00
2023-06-28 11:12:35 +02:00
2023-10-25 12:03:09 +02:00
2023-03-30 12:49:23 +02:00
2023-05-11 23:03:40 +09:00
2023-03-11 13:55:28 +01:00
2023-11-20 11:52:08 +01:00
2023-03-10 09:33:08 +01:00
2023-06-21 16:01:00 +02:00
2023-07-19 16:21:10 +02:00
2023-01-18 11:58:24 +01:00
2023-10-10 22:00:43 +02:00
2023-02-01 08:34:33 +01:00
2023-05-30 14:03:21 +01:00
2023-10-10 22:00:40 +02:00
2023-09-23 11:11:00 +02:00
2023-06-21 16:00:51 +02:00
2023-11-28 17:07:04 +00:00
2023-09-23 11:11:07 +02:00
2023-09-23 11:11:00 +02:00
2023-03-30 12:49:05 +02:00
2023-02-01 08:34:46 +01:00
2023-05-30 14:03:22 +01:00
2023-09-13 09:43:03 +02:00
2023-05-24 17:32:36 +01:00
2023-07-19 16:21:58 +02:00
2023-07-23 13:49:21 +02:00
2023-05-11 23:03:00 +09:00
2023-07-19 16:20:55 +02:00
2023-09-13 09:42:40 +02:00
2023-07-19 16:22:15 +02:00
2023-03-11 13:55:32 +01:00
2023-07-19 16:21:17 +02:00
2023-09-19 12:28:03 +02:00
2023-10-10 22:00:40 +02:00
2023-10-06 14:57:04 +02:00
2023-09-23 11:11:08 +02:00
2022-12-09 18:41:17 -08:00
2023-11-20 11:51:56 +01:00
2023-08-30 16:11:12 +02:00
2023-03-30 12:49:13 +02:00
2023-03-30 12:49:13 +02:00
2023-08-16 18:27:25 +02:00
2023-11-20 11:52:00 +01:00
2023-08-30 16:11:10 +02:00
2023-05-17 11:53:40 +02:00
2022-12-31 13:31:58 +01:00
2023-01-07 11:11:40 +01:00
2023-04-13 16:55:17 +02:00
2023-03-10 09:33:37 +01:00
2023-05-24 17:32:31 +01:00
2023-04-13 16:55:17 +02:00
2023-04-13 16:55:17 +02:00
2023-04-13 16:55:17 +02:00
2023-04-13 16:55:17 +02:00
2023-04-13 16:55:17 +02:00
2023-09-23 11:11:08 +02:00
2023-10-19 23:08:57 +02:00
2023-02-09 11:28:17 +01:00
2023-01-18 11:58:12 +01:00
2023-01-04 11:28:48 +01:00
2023-08-27 21:01:31 +02:00
2023-03-22 13:34:04 +01:00
2022-12-31 13:32:31 +01:00
2023-10-25 12:03:12 +02:00
2023-01-07 11:11:59 +01:00
2023-10-25 12:03:04 +02:00
2023-04-13 16:55:32 +02:00
2023-03-10 09:33:37 +01:00
2023-11-28 17:06:54 +00:00
2023-10-25 12:03:14 +02:00
2023-02-09 11:28:23 +01:00
2023-07-01 13:16:22 +02:00
2023-11-20 11:52:06 +01:00
2023-11-02 09:35:24 +01:00
2023-11-20 11:52:04 +01:00
2022-12-31 13:32:56 +01:00
2023-11-20 11:52:16 +01:00
2023-07-19 16:21:10 +02:00
2023-09-13 09:43:03 +02:00
2023-10-06 14:56:41 +02:00
2023-05-24 17:32:32 +01:00
2023-03-10 09:34:15 +01:00
2023-09-23 11:11:09 +02:00
2023-03-22 13:33:57 +01:00
2023-10-06 14:57:03 +02:00
2023-04-06 12:10:51 +02:00
2023-08-23 17:52:20 +02:00
2023-09-13 09:42:46 +02:00
2023-07-19 16:22:00 +02:00
2023-10-10 22:00:37 +02:00
2023-08-30 16:10:58 +02:00
2023-10-25 12:03:16 +02:00
2023-11-02 09:35:29 +01:00
2023-03-10 09:32:51 +01:00
2023-09-13 09:42:53 +02:00
2023-04-26 14:28:41 +02:00
2023-03-10 09:33:29 +01:00
2023-03-10 09:34:13 +01:00
2023-10-19 23:08:50 +02:00
2023-03-10 09:34:20 +01:00
2022-11-30 14:49:42 -08:00
2023-09-13 09:42:28 +02:00
2023-01-07 11:12:02 +01:00
2023-10-19 23:08:56 +02:00
2023-10-06 14:57:03 +02:00
2023-03-17 08:50:19 +01:00
2023-09-19 12:28:02 +02:00
2023-09-19 12:27:54 +02:00
2023-04-13 16:55:40 +02:00
2023-10-10 22:00:35 +02:00
2023-09-19 12:27:54 +02:00
2023-09-02 09:16:18 +02:00
2023-05-30 14:03:22 +01:00
2023-11-20 11:51:55 +01:00
2023-03-11 13:55:24 +01:00
2023-10-06 14:56:31 +02:00
2023-10-15 18:32:41 +02:00
2023-03-10 09:33:24 +01:00
2023-09-13 09:42:48 +02:00
2023-09-13 09:42:22 +02:00
2023-07-19 16:21:08 +02:00
2023-02-25 11:25:41 +01:00
2023-11-20 11:51:50 +01:00
2023-03-30 12:49:09 +02:00
2023-07-23 13:49:25 +02:00
2023-02-09 11:28:24 +01:00
2023-03-30 12:49:05 +02:00
2023-06-14 11:15:29 +02:00
2023-11-20 11:52:09 +01:00
2023-01-24 07:24:41 +01:00
2023-11-08 14:11:03 +01:00
2023-04-13 16:55:24 +02:00
2023-09-13 09:42:46 +02:00
2023-10-25 12:03:15 +02:00
2022-11-30 14:49:41 -08:00
2023-04-13 16:55:20 +02:00
2023-07-19 16:20:54 +02:00
2023-05-24 17:32:43 +01:00
2023-03-10 09:33:46 +01:00
2023-05-11 23:03:00 +09:00
2023-11-08 14:11:02 +01:00
2023-01-07 11:11:39 +01:00
2023-11-28 17:07:03 +00:00
2022-12-31 13:32:09 +01:00
2023-07-27 08:50:38 +02:00
2023-07-27 08:50:38 +02:00
2023-11-28 17:07:03 +00:00
2023-10-19 23:08:50 +02:00
2023-10-19 23:08:50 +02:00
2023-08-30 16:11:12 +02:00
2023-07-19 16:22:11 +02:00
2023-02-25 11:25:39 +01:00
2023-03-10 09:33:48 +01:00
2023-10-06 14:57:03 +02:00
2023-07-23 13:49:46 +02:00
2023-03-10 09:34:25 +01:00
2023-03-10 09:32:42 +01:00
2023-08-30 16:11:11 +02:00
2023-09-13 09:42:28 +02:00
2023-10-06 14:56:41 +02:00
2023-07-23 13:49:43 +02:00
2023-07-19 16:21:54 +02:00
2023-02-22 12:59:46 +01:00
2023-09-19 12:27:58 +02:00
2023-08-16 18:27:26 +02:00
2023-11-28 17:06:56 +00:00
2023-03-30 12:49:05 +02:00
2023-11-28 17:06:57 +00:00
2022-12-09 18:41:16 -08:00
2023-03-30 12:49:22 +02:00
2023-09-19 12:27:59 +02:00
2023-07-27 08:50:49 +02:00
2023-02-01 08:34:26 +01:00
2023-05-11 23:03:01 +09:00
2022-12-31 13:31:56 +01:00
2023-01-18 11:58:10 +01:00
2023-08-16 18:27:20 +02:00
2023-09-13 09:42:30 +02:00
2023-04-20 12:35:12 +02:00
2023-03-22 13:33:59 +01:00
2023-03-10 09:33:34 +01:00
2023-03-10 09:33:52 +01:00
2023-02-09 11:28:04 +01:00
2023-05-30 14:03:20 +01:00
2023-02-09 11:28:01 +01:00
2023-11-20 11:52:04 +01:00
2023-08-23 17:52:35 +02:00
2023-11-20 11:52:17 +01:00
2023-05-11 23:03:28 +09:00
2023-03-10 09:34:34 +01:00
2023-07-19 16:22:10 +02:00
2023-11-28 17:06:55 +00:00