1 | ## @file
|
---|
2 | # Provide EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instances on virtio-fs devices.
|
---|
3 | #
|
---|
4 | # Copyright (C) 2020, Red Hat, Inc.
|
---|
5 | #
|
---|
6 | # SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 | #
|
---|
8 | #
|
---|
9 | # Permission Model of this driver:
|
---|
10 | #
|
---|
11 | # Regardless of the UID and GID values this driver send in the FUSE request
|
---|
12 | # header, the daemon (that is, the Virtio Filesystem device) always acts with
|
---|
13 | # root privileges on the host side. The only time the daemon considers said UID
|
---|
14 | # and GID fields is when creating a new file or directory. Thus, the guest
|
---|
15 | # driver cannot rely on the host for enforcing any file mode permissions,
|
---|
16 | # regardless of the "personality" that the guest driver poses as, because
|
---|
17 | # "root" on the host side ignores all file mode bits.
|
---|
18 | #
|
---|
19 | # Therefore the guest driver has to do its own permission checking, and use the
|
---|
20 | # host-side file mode bits only as a kind of "metadata storage" or "reminder"
|
---|
21 | # -- hopefully in a way that makes some sense on the host side too.
|
---|
22 | #
|
---|
23 | # The complete mapping between the EFI_FILE_PROTOCOL and the host-side file
|
---|
24 | # mode bits is described below.
|
---|
25 | #
|
---|
26 | # - The guest driver poses as UID 0, GID 0, PID 1.
|
---|
27 | #
|
---|
28 | # - If and only if all "w" bits are missing from a file on the host side, then
|
---|
29 | # the file or directory is reported as EFI_FILE_READ_ONLY in the guest. When
|
---|
30 | # setting EFI_FILE_READ_ONLY in the guest, all "w" bits (0222) are cleared on
|
---|
31 | # the host; when clearing EFI_FILE_READ_ONLY in the guest, all "w" bits are
|
---|
32 | # set on the host. Viewed from the host side, this sort of reflects that an
|
---|
33 | # EFI_FILE_READ_ONLY file should not be written by anyone.
|
---|
34 | #
|
---|
35 | # - The attributes EFI_FILE_HIDDEN, EFI_FILE_SYSTEM, EFI_FILE_RESERVED, and
|
---|
36 | # EFI_FILE_ARCHIVE are never reported in the guest, and they are silently
|
---|
37 | # ignored when a SetInfo() call or a file-creating Open() call requests them.
|
---|
38 | #
|
---|
39 | # - On the host, files are created with 0666 file mode bits, directories are
|
---|
40 | # created with 0777 file mode bits.
|
---|
41 | #
|
---|
42 | # - In the guest, the EFI_FILE_READ_ONLY attribute only controls the permitted
|
---|
43 | # open mode. In particular, on directories, the EFI_FILE_READ_ONLY attribute
|
---|
44 | # does not prevent the creation or deletion of entries inside the directory;
|
---|
45 | # EFI_FILE_READ_ONLY only prevents the renaming, deleting, flushing (syncing)
|
---|
46 | # and touching of the directory itself (with "touching" meaning updating the
|
---|
47 | # timestamps). The fact that EFI_FILE_READ_ONLY being set on a directory is
|
---|
48 | # irrelevant in the guest with regard to entry creation/deletion, is
|
---|
49 | # well-mirrored by the fact that virtiofsd -- which runs as root, regardless
|
---|
50 | # of guest driver personality -- ignores the absence of "w" permissions on a
|
---|
51 | # host-side directory, when creating or removing entries in it.
|
---|
52 | #
|
---|
53 | # - When an EFI_FILE_PROTOCOL is opened read-only, then the Delete(), Write()
|
---|
54 | # and Flush() member functions are disabled for it. Additionally, SetInfo()
|
---|
55 | # is restricted to flipping the EFI_FILE_READ_ONLY bit (which takes effect at
|
---|
56 | # the next Open()).
|
---|
57 | #
|
---|
58 | # - As a consequence of the above, for deleting a directory, it must be
|
---|
59 | # presented in the guest as openable for writing.
|
---|
60 | #
|
---|
61 | # - We diverge from the UEFI spec, and permit Flush() on a directory that has
|
---|
62 | # been opened read-write; otherwise the only way to invoke FUSE_FSYNCDIR on a
|
---|
63 | # directory would be to Close() it.
|
---|
64 | #
|
---|
65 | # - OpenVolume() opens the root directory for read-only access. The Open()
|
---|
66 | # member function may open it for read-write access. While the root directory
|
---|
67 | # cannot be renamed or deleted, opening it for read-write access is useful
|
---|
68 | # for calling Flush(), according to the previous paragraph, or for updating
|
---|
69 | # the root directory's timestamps with SetInfo().
|
---|
70 | ##
|
---|
71 |
|
---|
72 | [Defines]
|
---|
73 | INF_VERSION = 1.29
|
---|
74 | BASE_NAME = VirtioFsDxe
|
---|
75 | FILE_GUID = 7BD9DDF7-8B83-488E-AEC9-24C78610289C
|
---|
76 | MODULE_TYPE = UEFI_DRIVER
|
---|
77 | ENTRY_POINT = VirtioFsEntryPoint
|
---|
78 |
|
---|
79 | [Packages]
|
---|
80 | EmbeddedPkg/EmbeddedPkg.dec
|
---|
81 | MdePkg/MdePkg.dec
|
---|
82 | OvmfPkg/OvmfPkg.dec
|
---|
83 |
|
---|
84 | [Sources]
|
---|
85 | DriverBinding.c
|
---|
86 | FuseFlush.c
|
---|
87 | FuseForget.c
|
---|
88 | FuseFsync.c
|
---|
89 | FuseGetAttr.c
|
---|
90 | FuseInit.c
|
---|
91 | FuseLookup.c
|
---|
92 | FuseMkDir.c
|
---|
93 | FuseOpen.c
|
---|
94 | FuseOpenDir.c
|
---|
95 | FuseOpenOrCreate.c
|
---|
96 | FuseRead.c
|
---|
97 | FuseRelease.c
|
---|
98 | FuseRename.c
|
---|
99 | FuseSetAttr.c
|
---|
100 | FuseStatFs.c
|
---|
101 | FuseUnlink.c
|
---|
102 | FuseWrite.c
|
---|
103 | Helpers.c
|
---|
104 | SimpleFsClose.c
|
---|
105 | SimpleFsDelete.c
|
---|
106 | SimpleFsFlush.c
|
---|
107 | SimpleFsGetInfo.c
|
---|
108 | SimpleFsGetPosition.c
|
---|
109 | SimpleFsOpen.c
|
---|
110 | SimpleFsOpenVolume.c
|
---|
111 | SimpleFsRead.c
|
---|
112 | SimpleFsSetInfo.c
|
---|
113 | SimpleFsSetPosition.c
|
---|
114 | SimpleFsWrite.c
|
---|
115 | VirtioFsDxe.h
|
---|
116 |
|
---|
117 | [LibraryClasses]
|
---|
118 | BaseLib
|
---|
119 | BaseMemoryLib
|
---|
120 | DebugLib
|
---|
121 | MemoryAllocationLib
|
---|
122 | TimeBaseLib
|
---|
123 | UefiBootServicesTableLib
|
---|
124 | UefiDriverEntryPoint
|
---|
125 | VirtioLib
|
---|
126 |
|
---|
127 | [Protocols]
|
---|
128 | gEfiComponentName2ProtocolGuid ## PRODUCES
|
---|
129 | gEfiDriverBindingProtocolGuid ## PRODUCES
|
---|
130 | gEfiSimpleFileSystemProtocolGuid ## BY_START
|
---|
131 | gVirtioDeviceProtocolGuid ## TO_START
|
---|
132 |
|
---|
133 | [Guids]
|
---|
134 | gEfiFileInfoGuid
|
---|
135 | gEfiFileSystemInfoGuid
|
---|
136 | gEfiFileSystemVolumeLabelInfoIdGuid
|
---|