Re: flush_kernel_dcache_page fixes and removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 12, 2021 at 08:09:22AM +0200, Christoph Hellwig wrote:
> while looking to convert the block layer away from kmap_atomic towards
> kmap_local_page and prefeably the helpers that abstract it away I noticed
> that a few block drivers directly or implicitly call
> flush_kernel_dcache_page before kunmapping a page that has been written
> to.  flush_kernel_dcache_page is documented to to be used in such cases,
> but flush_dcache_page is actually required when the page could be in
> the page cache and mapped to userspace, which is pretty much always the
> case when kmapping an arbitrary page.  Unfortunately the documentation
> doesn't exactly make that clear, which lead to this misused.  And it turns
> out that only the copy_strings / copy_string_kernel in the exec code
> were actually correct users of flush_kernel_dcache_page, which is why
> I think we should just remove it and eat the very minor overhead in
> exec rather than confusing poor driver writers.

I think you need to be careful - I seem to have a recollection that the
reason we ended up with flush_kernel_dcache_page() was the need to avoid
the taking of the mmap lock for 32-bit ARM VIVT based CPUs in
flush_dcache_page(). 32-bit ARM flush_dcache_page() can block.

If you're sure that all these changes you're making do not end up
calling flush_dcache_page() from a path where we are atomic, then fine.

The second issue I have is that, when we are reading a page into a page
cache page, how can that page be mapped to userspace? Isn't that a
violation of semantics? If the page is mapped to userspace but does not
contain data from the underlying storage device, then the page contains
stale data (if it's a new page, lets hope that's zeroed and not some
previous contents - which would be a massive security hole.) As I
understand it, the flush_kernel_dcache_page() calls in the block layer
are primarily there to cope with drivers that do PIO read to write to a
page cache page to ensure that later userspace mappings can see the data
in the page cache page - by ensuring that the page cache pages are in
the same state as far as caches go as if they had been DMA'd to.

We know that the current implementation works fine - you're now
proposing to radically change it, asserting that it's buggy. I'm
nervous about this change.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux