summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf
blob: 051acbdd7199c9d4a7e6966a219469b0a66eaadd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
## @file
# Provide EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instances on virtio-fs devices.
#
# Copyright (C) 2020, Red Hat, Inc.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
# Permission Model of this driver:
#
# Regardless of the UID and GID values this driver send in the FUSE request
# header, the daemon (that is, the Virtio Filesystem device) always acts with
# root privileges on the host side. The only time the daemon considers said UID
# and GID fields is when creating a new file or directory. Thus, the guest
# driver cannot rely on the host for enforcing any file mode permissions,
# regardless of the "personality" that the guest driver poses as, because
# "root" on the host side ignores all file mode bits.
#
# Therefore the guest driver has to do its own permission checking, and use the
# host-side file mode bits only as a kind of "metadata storage" or "reminder"
# -- hopefully in a way that makes some sense on the host side too.
#
# The complete mapping between the EFI_FILE_PROTOCOL and the host-side file
# mode bits is described below.
#
# - The guest driver poses as UID 0, GID 0, PID 1.
#
# - If and only if all "w" bits are missing from a file on the host side, then
#   the file or directory is reported as EFI_FILE_READ_ONLY in the guest. When
#   setting EFI_FILE_READ_ONLY in the guest, all "w" bits (0222) are cleared on
#   the host; when clearing EFI_FILE_READ_ONLY in the guest, all "w" bits are
#   set on the host. Viewed from the host side, this sort of reflects that an
#   EFI_FILE_READ_ONLY file should not be written by anyone.
#
# - The attributes EFI_FILE_HIDDEN, EFI_FILE_SYSTEM, EFI_FILE_RESERVED, and
#   EFI_FILE_ARCHIVE are never reported in the guest, and they are silently
#   ignored when a SetInfo() call or a file-creating Open() call requests them.
#
# - On the host, files are created with 0666 file mode bits, directories are
#   created with 0777 file mode bits.
#
# - In the guest, the EFI_FILE_READ_ONLY attribute only controls the permitted
#   open mode. In particular, on directories, the EFI_FILE_READ_ONLY attribute
#   does not prevent the creation or deletion of entries inside the directory;
#   EFI_FILE_READ_ONLY only prevents the renaming, deleting, flushing (syncing)
#   and touching of the directory itself (with "touching" meaning updating the
#   timestamps). The fact that EFI_FILE_READ_ONLY being set on a directory is
#   irrelevant in the guest with regard to entry creation/deletion, is
#   well-mirrored by the fact that virtiofsd -- which runs as root, regardless
#   of guest driver personality -- ignores the absence of "w" permissions on a
#   host-side directory, when creating or removing entries in it.
#
# - When an EFI_FILE_PROTOCOL is opened read-only, then the Delete(), Write()
#   and Flush() member functions are disabled for it. Additionally, SetInfo()
#   is restricted to flipping the EFI_FILE_READ_ONLY bit (which takes effect at
#   the next Open()).
#
# - As a consequence of the above, for deleting a directory, it must be
#   presented in the guest as openable for writing.
#
# - We diverge from the UEFI spec, and permit Flush() on a directory that has
#   been opened read-write; otherwise the only way to invoke FUSE_FSYNCDIR on a
#   directory would be to Close() it.
#
# - OpenVolume() opens the root directory for read-only access. The Open()
#   member function may open it for read-write access. While the root directory
#   cannot be renamed or deleted, opening it for read-write access is useful
#   for calling Flush(), according to the previous paragraph, or for updating
#   the root directory's timestamps with SetInfo().
##

[Defines]
  INF_VERSION                           = 1.29
  BASE_NAME                             = VirtioFsDxe
  FILE_GUID                             = 7BD9DDF7-8B83-488E-AEC9-24C78610289C
  MODULE_TYPE                           = UEFI_DRIVER
  ENTRY_POINT                           = VirtioFsEntryPoint

[Packages]
  MdePkg/MdePkg.dec
  OvmfPkg/OvmfPkg.dec

[Sources]
  DriverBinding.c
  FuseInit.c
  FuseOpenDir.c
  Helpers.c
  SimpleFsOpenVolume.c
  VirtioFsDxe.h

[LibraryClasses]
  BaseLib
  DebugLib
  MemoryAllocationLib
  UefiBootServicesTableLib
  UefiDriverEntryPoint
  VirtioLib

[Protocols]
  gEfiComponentName2ProtocolGuid        ## PRODUCES
  gEfiDriverBindingProtocolGuid         ## PRODUCES
  gEfiSimpleFileSystemProtocolGuid      ## BY_START
  gVirtioDeviceProtocolGuid             ## TO_START