VirtioFsDxe.inf 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. [Defines]
  72. INF_VERSION = 1.29
  73. BASE_NAME = VirtioFsDxe
  74. FILE_GUID = 7BD9DDF7-8B83-488E-AEC9-24C78610289C
  75. MODULE_TYPE = UEFI_DRIVER
  76. ENTRY_POINT = VirtioFsEntryPoint
  77. [Packages]
  78. EmbeddedPkg/EmbeddedPkg.dec
  79. MdePkg/MdePkg.dec
  80. OvmfPkg/OvmfPkg.dec
  81. [Sources]
  82. DriverBinding.c
  83. FuseFlush.c
  84. FuseForget.c
  85. FuseFsync.c
  86. FuseGetAttr.c
  87. FuseInit.c
  88. FuseLookup.c
  89. FuseMkDir.c
  90. FuseOpen.c
  91. FuseOpenDir.c
  92. FuseOpenOrCreate.c
  93. FuseRead.c
  94. FuseRelease.c
  95. FuseRename.c
  96. FuseSetAttr.c
  97. FuseStatFs.c
  98. FuseUnlink.c
  99. FuseWrite.c
  100. Helpers.c
  101. SimpleFsClose.c
  102. SimpleFsDelete.c
  103. SimpleFsFlush.c
  104. SimpleFsGetInfo.c
  105. SimpleFsGetPosition.c
  106. SimpleFsOpen.c
  107. SimpleFsOpenVolume.c
  108. SimpleFsRead.c
  109. SimpleFsSetInfo.c
  110. SimpleFsSetPosition.c
  111. SimpleFsWrite.c
  112. VirtioFsDxe.h
  113. [LibraryClasses]
  114. BaseLib
  115. BaseMemoryLib
  116. DebugLib
  117. MemoryAllocationLib
  118. TimeBaseLib
  119. UefiBootServicesTableLib
  120. UefiDriverEntryPoint
  121. VirtioLib
  122. [Protocols]
  123. gEfiComponentName2ProtocolGuid ## PRODUCES
  124. gEfiDriverBindingProtocolGuid ## PRODUCES
  125. gEfiSimpleFileSystemProtocolGuid ## BY_START
  126. gVirtioDeviceProtocolGuid ## TO_START
  127. [Guids]
  128. gEfiFileInfoGuid
  129. gEfiFileSystemInfoGuid
  130. gEfiFileSystemVolumeLabelInfoIdGuid