Commit 7484e15
Al Viro
replace collect_mounts()/drop_collected_mounts() with a safer variant
collect_mounts() has several problems - one can't iterate over the results
directly, so it has to be done with callback passed to iterate_mounts();
it has an oopsable race with d_invalidate(); it creates temporary clones
of mounts invisibly for sync umount (IOW, you can have non-lazy umount
succeed leaving filesystem not mounted anywhere and yet still busy).
A saner approach is to give caller an array of struct path that would pin
every mount in a subtree, without cloning any mounts.
* collect_mounts()/drop_collected_mounts()/iterate_mounts() is gone
* collect_paths(where, preallocated, size) gives either ERR_PTR(-E...) or
a pointer to array of struct path, one for each chunk of tree visible under
'where' (i.e. the first element is a copy of where, followed by (mount,root)
for everything mounted under it - the same set collect_mounts() would give).
Unlike collect_mounts(), the mounts are *not* cloned - we just get pinning
references to the roots of subtrees in the caller's namespace.
Array is terminated by {NULL, NULL} struct path. If it fits into
preallocated array (on-stack, normally), that's where it goes; otherwise
it's allocated by kmalloc_array(). Passing 0 as size means that 'preallocated'
is ignored (and expected to be NULL).
* drop_collected_paths(paths, preallocated) is given the array returned
by an earlier call of collect_paths() and the preallocated array passed to that
call. All mount/dentry references are dropped and array is kfree'd if it's not
equal to 'preallocated'.
* instead of iterate_mounts(), users should just iterate over array
of struct path - nothing exotic is needed for that. Existing users (all in
audit_tree.c) are converted.
[folded a fix for braino reported by Venkat Rao Bagalkote <[email protected]>]
Fixes: 80b5dce ("vfs: Add a function to lazily unmount all mounts from any dentry")
Tested-by: Venkat Rao Bagalkote <[email protected]>
Signed-off-by: Al Viro <[email protected]>1 parent 19272b3 commit 7484e15
File tree
5 files changed
+104
-73
lines changed- Documentation/filesystems
- fs
- include/linux
- kernel
5 files changed
+104
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1249 | 1249 | | |
1250 | 1250 | | |
1251 | 1251 | | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2310 | 2310 | | |
2311 | 2311 | | |
2312 | 2312 | | |
2313 | | - | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
2314 | 2328 | | |
2315 | | - | |
| 2329 | + | |
| 2330 | + | |
2316 | 2331 | | |
2317 | | - | |
2318 | | - | |
2319 | | - | |
2320 | | - | |
2321 | | - | |
2322 | | - | |
2323 | | - | |
2324 | | - | |
2325 | | - | |
2326 | | - | |
2327 | | - | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
2328 | 2369 | | |
2329 | 2370 | | |
2330 | 2371 | | |
| |||
2401 | 2442 | | |
2402 | 2443 | | |
2403 | 2444 | | |
2404 | | - | |
2405 | | - | |
2406 | | - | |
2407 | | - | |
2408 | | - | |
2409 | | - | |
2410 | | - | |
2411 | | - | |
2412 | | - | |
2413 | 2445 | | |
2414 | 2446 | | |
2415 | 2447 | | |
| |||
2511 | 2543 | | |
2512 | 2544 | | |
2513 | 2545 | | |
2514 | | - | |
2515 | | - | |
2516 | | - | |
2517 | | - | |
2518 | | - | |
2519 | | - | |
2520 | | - | |
2521 | | - | |
2522 | | - | |
2523 | | - | |
2524 | | - | |
2525 | | - | |
2526 | | - | |
2527 | | - | |
2528 | | - | |
2529 | 2546 | | |
2530 | 2547 | | |
2531 | 2548 | | |
| |||
6262 | 6279 | | |
6263 | 6280 | | |
6264 | 6281 | | |
6265 | | - | |
| 6282 | + | |
| 6283 | + | |
| 6284 | + | |
| 6285 | + | |
| 6286 | + | |
6266 | 6287 | | |
6267 | 6288 | | |
6268 | 6289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 119 | + | |
| 120 | + | |
123 | 121 | | |
124 | 122 | | |
125 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | 671 | | |
678 | 672 | | |
679 | 673 | | |
| |||
683 | 677 | | |
684 | 678 | | |
685 | 679 | | |
686 | | - | |
687 | 680 | | |
| 681 | + | |
| 682 | + | |
688 | 683 | | |
689 | 684 | | |
690 | 685 | | |
| |||
696 | 691 | | |
697 | 692 | | |
698 | 693 | | |
699 | | - | |
| 694 | + | |
700 | 695 | | |
701 | | - | |
| 696 | + | |
702 | 697 | | |
703 | 698 | | |
704 | 699 | | |
705 | 700 | | |
706 | 701 | | |
707 | 702 | | |
708 | 703 | | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
713 | 711 | | |
714 | 712 | | |
715 | 713 | | |
716 | | - | |
| 714 | + | |
717 | 715 | | |
718 | 716 | | |
719 | 717 | | |
| |||
742 | 740 | | |
743 | 741 | | |
744 | 742 | | |
745 | | - | |
| 743 | + | |
746 | 744 | | |
747 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
748 | 751 | | |
749 | 752 | | |
750 | 753 | | |
| |||
801 | 804 | | |
802 | 805 | | |
803 | 806 | | |
804 | | - | |
| 807 | + | |
| 808 | + | |
805 | 809 | | |
806 | 810 | | |
807 | 811 | | |
| |||
828 | 832 | | |
829 | 833 | | |
830 | 834 | | |
831 | | - | |
| 835 | + | |
832 | 836 | | |
833 | | - | |
834 | | - | |
| 837 | + | |
| 838 | + | |
835 | 839 | | |
836 | 840 | | |
837 | 841 | | |
838 | 842 | | |
839 | | - | |
840 | | - | |
| 843 | + | |
| 844 | + | |
841 | 845 | | |
842 | 846 | | |
843 | 847 | | |
| |||
872 | 876 | | |
873 | 877 | | |
874 | 878 | | |
875 | | - | |
| 879 | + | |
| 880 | + | |
876 | 881 | | |
877 | 882 | | |
878 | 883 | | |
879 | 884 | | |
880 | 885 | | |
881 | | - | |
| 886 | + | |
882 | 887 | | |
883 | | - | |
884 | | - | |
| 888 | + | |
| 889 | + | |
885 | 890 | | |
886 | 891 | | |
887 | 892 | | |
888 | | - | |
| 893 | + | |
889 | 894 | | |
890 | 895 | | |
891 | 896 | | |
| |||
914 | 919 | | |
915 | 920 | | |
916 | 921 | | |
917 | | - | |
| 922 | + | |
918 | 923 | | |
919 | 924 | | |
920 | 925 | | |
| |||
955 | 960 | | |
956 | 961 | | |
957 | 962 | | |
958 | | - | |
| 963 | + | |
959 | 964 | | |
960 | 965 | | |
961 | 966 | | |
| |||
0 commit comments