Repository navigation
Commit 766a74a
committed
virtiofs: reach a node whose last name is gone only through its handles
A request about a node whose names the guest had all removed, by
FUSE_UNLINK, FUSE_RMDIR, or a FUSE_RENAME over the last one, acted on
whatever object had since appeared at the node's former path
(microsoft/nvx#1623). Through such a file node, GETATTR and STATX
reported that object's attributes under the node's inode number, OPEN
opened it, SETATTR truncated it or changed its mode, and the extended
attribute requests read and changed its attributes. Through such a
directory node, OPENDIR listed that directory, and LOOKUP, CREATE,
MKDIR, MKNOD, SYMLINK, LINK, UNLINK, RMDIR, and RENAME looked up,
created, moved, and removed its entries. The object could be a
read-only file whose host hard link inside a writable path the guest
had renamed over the node's name: the node, writable through its
former name, then truncated the file, which a request through the
file's own node refuses with EROFS.
VirtioFsInode::remove_alias_prefix keeps an inode's path when it
removes the last alias, and every path-based operation of
VirtioFsInode used that path, except VirtioFsInode::link, which
microsoft/nvx#1608's fix made take its target's path from
VirtioFsInode::object_path, which fails with ENOENT once the guest
knows no name for the object.
Every other operation of VirtioFsInode that reaches its object by its
path now takes the path from object_path too: object_stat, get_attr,
get_statx, set_attr, open, read_link, stat_fs, get_xattr, set_xattr,
list_xattr, remove_xattr, and check_directory_handle; and so does
child_path, through which lookup_child, create, mkdir, mknod, symlink,
link, unlink, and rename reach a directory's entries. A request about
such a node that names no handle thus fails with ENOENT, as one
through an unlinked file's former name does, and as Linux refuses to
look up, create, or list entries of a removed directory, while
requests through the node's open handles, which VirtioFs::get_file
serves without a path, still reach its object.
object_path now checks that the path is one of the names that the
guest knows, rather than that there is one. VirtioFsInode::add_alias,
which records a FUSE_LINK's name after the host link, makes that name
the path when the path no longer is one, as when a FUSE_UNLINK of the
node's other name on another request queue records its removal first;
object_path would otherwise use the removed name, or now fail. The
microVM profile's confinement check, which validated the former name
as well because operations used it, thus validates only the names, so
the former name no longer decides whether a request about the node
fails, or with which error.
a_file_whose_names_are_gone_is_reached_only_through_its_handles and
a_directory_whose_names_are_gone_reaches_no_entry remove the last name
of a file's and a directory's node, on a share with and without the
microVM profile, either by unlinking or removing it and creating
another at its name, or by renaming another entry over it, and send
every request about the node that names no handle.
a_link_that_an_unlink_of_the_other_name_overtakes_keeps_the_new_name
records the removal of a node's other name before a link's new name.
Without the fix, at e3b20ae, microsoft/nvx#1609's fix, which stacks
on microsoft/nvx#1608's, on Windows and on a Linux KVM host, every
request of the first two tests but FUSE_LINK reaches the new object:
READLINK and GETXATTR fail with its errors, EINVAL and ENODATA, and
the others succeed, so the file node truncates the file renamed over
its name, which the microVM share makes read-only; and the third
test's node keeps the removed name. With the fix, each request fails
with ENOENT and changes nothing, the node's handle still reads and
stats its file, the linked node reaches its object through the new
name, and the package's tests pass on both hosts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 8ce4155 commit 766a74a
3 files changed
Lines changed: 260 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
| 448 | + | |
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | | - | |
| 569 | + | |
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
599 | | - | |
| 599 | + | |
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | | - | |
| 622 | + | |
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
628 | | - | |
| 628 | + | |
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
648 | 652 | | |
649 | | - | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
650 | 659 | | |
651 | 660 | | |
652 | 661 | | |
| |||
716 | 725 | | |
717 | 726 | | |
718 | 727 | | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
719 | 732 | | |
720 | 733 | | |
721 | 734 | | |
| |||
731 | 744 | | |
732 | 745 | | |
733 | 746 | | |
734 | | - | |
| 747 | + | |
735 | 748 | | |
736 | 749 | | |
737 | 750 | | |
| |||
743 | 756 | | |
744 | 757 | | |
745 | 758 | | |
746 | | - | |
| 759 | + | |
| 760 | + | |
747 | 761 | | |
748 | 762 | | |
749 | 763 | | |
750 | 764 | | |
751 | 765 | | |
752 | | - | |
753 | | - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
754 | 769 | | |
755 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
756 | 773 | | |
757 | 774 | | |
758 | | - | |
| 775 | + | |
759 | 776 | | |
760 | 777 | | |
761 | 778 | | |
| |||
831 | 848 | | |
832 | 849 | | |
833 | 850 | | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
834 | 872 | | |
835 | 873 | | |
836 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
198 | 196 | | |
199 | 197 | | |
200 | 198 | | |
| |||
0 commit comments