Repository navigation
Commit 899dcd6
committed
virtiofs: stop microVM READDIRPLUS from aliasing the listed node
A microVM READDIRPLUS looks each name of its directory listing other
than . and .. up, and a lookup that reaches the object of a node
returns that node, with one more lookup reference and with the name's
path as the node's path. A listed name can reach the object of the
very node whose handle the guest lists (microsoft/nvx#1634): a bind
mount of a directory on one of its own subdirectories does, and so
does the node's directory once the host moves it into a new directory
at the node's path, since a handle that the guest then opens on the
node lists that new directory. READDIRPLUS then handed the guest the
listed node as an entry below itself, which the guest cannot hold, and
moved the node to the name's path, at which it looked the rest of the
listing up: in the moved directory, which lacks the listed names, so
READDIRPLUS dropped them as gone, or through the bind mount, so that
the node, even the share's root, stayed at a path that names another
directory once the host unmounts the bind mount.
write_microvm_entry_plus now checks, after the lookup and the check
that the name still reaches the listed object, whether the lookup
reached the object of the handle's node, by the dedup key and file
type by which the inode map would alias it. Such an entry hands the
guest no node, which FUSE allows for a READDIRPLUS entry, as for . and
.., so it takes no lookup reference and leaves the node as it was, and
it lists the name as READDIR does, by the listed number and type. The
issue proposes to forget the entry's reference and stop the listing,
with EIO if the entry is the first of a read; but the lookup has moved
the node by then, and since each later read starts at the entry, the
guest could never list the rest of the directory.
Tests, in virtiofs' microVM tests: a READDIRPLUS of the directory that
the host made at a node's path, which lists the node's moved directory
before a file, lists both, the moved directory without a node, and
leaves the node's path, aliases, and lookup count as they were; and, on
Linux, a READDIRPLUS of a share whose root is bind mounted on one of
its own subdirectories, in user and mount namespaces of the test's own,
lists the mount point without a node, by its READDIR number and type,
and leaves the root at its path. Without the fix, on top of the
microsoft/nvx#1605 fix, the first lists no file on Windows and on
Linux (Azure Linux 3, kernel 6.18, tmpfs and ext4), and on Windows it
hands the moved directory the listed node and moves the node to
listed\moved with two lookups; the second hands the mount point the
root's node and moves the root to loop. With the fix, both and the
package's other tests pass there.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent c0efd6c commit 899dcd6
2 files changed
Lines changed: 169 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
| |||
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
218 | 238 | | |
219 | 239 | | |
220 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
842 | 990 | | |
843 | 991 | | |
844 | 992 | | |
| |||
0 commit comments