Commit 95f9eb1
Revert "NFSD: Defer sub-object cleanup in export put callbacks"
commit 516403d upstream.
This reverts commit 48db892.
Commit 48db892 ("NFSD: Defer sub-object cleanup in export
put callbacks") moved path_put() and auth_domain_put() out of
svc_export_put() and expkey_put() and behind queue_rcu_work() to
close a claimed use-after-free in e_show() and c_show() against
ex_path and ex_client->name. Discussion in [1] shows neither
the diagnosis nor the remedy survives review.
The downstream teardown of both sub-objects is already RCU-deferred.
auth_domain_put() reaches svcauth_unix_domain_release(), which frees
the unix_domain and its ->name through call_rcu(). path_put()
reaches dentry_free(), which frees the dentry through call_rcu(),
and prepend_path() is already structured to tolerate concurrent
dentry teardown. A reader in cache_seq_start_rcu() therefore
observes both sub-objects through the next grace period regardless
of whether svc_export_put() runs synchronously, so the synchronous
form was never unsafe.
The crash signature in the report cited by commit 48db892
("NFSD: Defer sub-object cleanup in export put callbacks") has a
different root cause: a /proc/net/rpc cache file held open across
network-namespace exit lets cache_destroy_net() free cd->hash_table
while a reader is still walking it. The correct fix pins cd->net for
the open fd's lifetime and does not require any deferral inside
svc_export_put().
Meanwhile, deferring path_put() out of svc_export_put() reintroduces
the regression that commit 69d803c ("nfsd: Revert "nfsd:
release svc_expkey/svc_export with rcu_work"") repaired: after
"exportfs -r" drops the last cache reference, the mount reference
held through ex_path lingers in the workqueue, so a subsequent
umount fails with EBUSY.
Restore the synchronous path_put() and auth_domain_put() in
svc_export_put() and expkey_put() and the call_rcu()/kfree_rcu()
free of the containing structures. The unrelated fix for
ex_uuid/ex_stats from commit 2530766 ("nfsd: fix UAF when
access ex_uuid or ex_stats") is preserved.
Link: https://lore.kernel.org/all/10019b42-4589-4f9f-8d5b-d8197db1ce3c@huawei.com/ [1]
Fixes: 48db892 ("NFSD: Defer sub-object cleanup in export put callbacks")
Cc: stable@vger.kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Tested-by: Alexandr Alexandrov <alexandr.alexandrov@oracle.com>
Signed-off-by: Yang Erkun <yangerkun@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent af28922 commit 95f9eb1
3 files changed
Lines changed: 12 additions & 66 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | | - | |
| 43 | + | |
46 | 44 | | |
47 | | - | |
48 | | - | |
| 45 | + | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
52 | 49 | | |
53 | 50 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 51 | + | |
63 | 52 | | |
64 | 53 | | |
65 | 54 | | |
| |||
364 | 353 | | |
365 | 354 | | |
366 | 355 | | |
367 | | - | |
| 356 | + | |
368 | 357 | | |
369 | | - | |
370 | | - | |
| 358 | + | |
| 359 | + | |
371 | 360 | | |
372 | | - | |
373 | | - | |
374 | 361 | | |
375 | 362 | | |
376 | 363 | | |
| |||
382 | 369 | | |
383 | 370 | | |
384 | 371 | | |
385 | | - | |
386 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
387 | 375 | | |
388 | 376 | | |
389 | 377 | | |
| |||
1490 | 1478 | | |
1491 | 1479 | | |
1492 | 1480 | | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
1514 | | - | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | 1481 | | |
1524 | 1482 | | |
1525 | 1483 | | |
| |||
1581 | 1539 | | |
1582 | 1540 | | |
1583 | 1541 | | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | 1542 | | |
1588 | 1543 | | |
1589 | 1544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
79 | | - | |
| 78 | + | |
80 | 79 | | |
81 | 80 | | |
82 | 81 | | |
| |||
93 | 92 | | |
94 | 93 | | |
95 | 94 | | |
96 | | - | |
| 95 | + | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| |||
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
114 | | - | |
115 | | - | |
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2262 | 2262 | | |
2263 | 2263 | | |
2264 | 2264 | | |
2265 | | - | |
2266 | | - | |
2267 | | - | |
2268 | 2265 | | |
2269 | 2266 | | |
2270 | | - | |
| 2267 | + | |
2271 | 2268 | | |
2272 | 2269 | | |
2273 | 2270 | | |
| |||
2296 | 2293 | | |
2297 | 2294 | | |
2298 | 2295 | | |
2299 | | - | |
2300 | | - | |
2301 | 2296 | | |
2302 | 2297 | | |
2303 | 2298 | | |
| |||
2318 | 2313 | | |
2319 | 2314 | | |
2320 | 2315 | | |
2321 | | - | |
2322 | 2316 | | |
2323 | 2317 | | |
2324 | 2318 | | |
| |||
0 commit comments