Commit 8dad53a1 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

mm: call flush_dcache_page() in memcpy_to_page() and memzero_page()

memcpy_to_page and memzero_page can write to arbitrary pages, which
could be in the page cache or in high memory, so call
flush_kernel_dcache_pages to flush the dcache.

This is a problem when using these helpers on dcache challeneged
architectures.  Right now there are just a few users, chances are no one
used the PC floppy driver, the aha1542 driver for an ISA SCSI HBA, and a
few advanced and optional btrfs and ext4 features on those platforms yet
since the conversion.

Link: https://lkml.kernel.org/r/20210713055231.137602-2-hch@lst.de
Fixes: bb90d4bc ("mm/highmem: Lift memcpy_[to|from]_page to core")
Fixes: 28961998 ("iov_iter: lift memzero_page() to highmem.h")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 236e9f15
...@@ -318,6 +318,7 @@ static inline void memcpy_to_page(struct page *page, size_t offset, ...@@ -318,6 +318,7 @@ static inline void memcpy_to_page(struct page *page, size_t offset,
VM_BUG_ON(offset + len > PAGE_SIZE); VM_BUG_ON(offset + len > PAGE_SIZE);
memcpy(to + offset, from, len); memcpy(to + offset, from, len);
flush_dcache_page(page);
kunmap_local(to); kunmap_local(to);
} }
...@@ -325,6 +326,7 @@ static inline void memzero_page(struct page *page, size_t offset, size_t len) ...@@ -325,6 +326,7 @@ static inline void memzero_page(struct page *page, size_t offset, size_t len)
{ {
char *addr = kmap_atomic(page); char *addr = kmap_atomic(page);
memset(addr + offset, 0, len); memset(addr + offset, 0, len);
flush_dcache_page(page);
kunmap_atomic(addr); kunmap_atomic(addr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment