[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251002135908.GE3195829@ziepe.ca>
Date: Thu, 2 Oct 2025 10:59:08 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: Shigeru Yoshida <syoshida@...hat.com>
Cc: glider@...gle.com, elver@...gle.com, dvyukov@...gle.com,
akpm@...ux-foundation.org, leon@...nel.org,
m.szyprowski@...sung.com, kasan-dev@...glegroups.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kmsan: fix kmsan_handle_dma() to avoid false positives
On Thu, Oct 02, 2025 at 02:10:24PM +0900, Shigeru Yoshida wrote:
> KMSAN reports an uninitialized value issue in dma_map_phys()[1]. This
> is a false positive caused by the way the virtual address is handled
> in kmsan_handle_dma(). Fix it by translating the physical address to
> a virtual address using phys_to_virt().
This is the same sort of thinko as was found on the alpha patch, it is
tricky!
Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
> @@ -339,13 +339,12 @@ static void kmsan_handle_dma_page(const void *addr, size_t size,
> void kmsan_handle_dma(phys_addr_t phys, size_t size,
> enum dma_data_direction dir)
> {
> - struct page *page = phys_to_page(phys);
This throws away the page_offset encoded in phys
> u64 page_offset, to_go;
> void *addr;
>
> if (PhysHighMem(phys))
> return;
> - addr = page_to_virt(page);
And this gives an addr that is now 0 page_offset, which is not right.
> + addr = phys_to_virt(phys);
Make more sense anyhow when combined with PhysHighMem() and gives the
right page_offset.
Jason
Powered by blists - more mailing lists