mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
mm: Introduce AS_INACCESSIBLE for encrypted/confidential memory
filemap users like guest_memfd may use page cache pages to allocate/manage memory that is only intended to be accessed by guests via hardware protections like encryption. Writes to memory of this sort in common paths like truncation may cause unexpected behavior such as writing garbage instead of zeros when attempting to zero pages, or worse, triggering hardware protections that are considered fatal as far as the kernel is concerned. Introduce a new address_space flag, AS_INACCESSIBLE, and use this initially to prevent zero'ing of pages during truncation, with the understanding that it is up to the owner of the mapping to handle this specially if needed. This is admittedly a rather blunt solution, but it seems like there are no other places that should take into account the flag to keep its promise. Link: https://lore.kernel.org/lkml/[email protected]/ Cc: Matthew Wilcox <[email protected]> Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Michael Roth <[email protected]> Message-ID: <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
This commit is contained in:
1 parent
2b1f435505
commit
c72ceafbd1
2 files changed
+3
-1
No files matched your search
@@ -207,6 +207,7 @@ enum mapping_flags {
|
||||
AS_STABLE_WRITES, /* must wait for writeback before modifying
|
||||
folio contents */
|
||||
AS_UNMOVABLE, /* The mapping cannot be moved, ever */
|
||||
AS_INACCESSIBLE, /* Do not attempt direct R/W access to the mapping */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+2
-1
@@ -233,7 +233,8 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
|
||||
* doing a complex calculation here, and then doing the zeroing
|
||||
* anyway if the page split fails.
|
||||
*/
|
||||
folio_zero_range(folio, offset, length);
|
||||
if (!(folio->mapping->flags & AS_INACCESSIBLE))
|
||||
folio_zero_range(folio, offset, length);
|
||||
|
||||
if (folio_has_private(folio))
|
||||
folio_invalidate(folio, offset, length);
|
||||
|
||||
Reference in new issue
Block a user