Re: [PATCH] x86/mm: fix lookup_address() to handle physical memory holes in direct mapping

From: Jürgen Groß
Date: Mon Jul 01 2024 - 14:40:39 EST


On 01.07.24 19:57, Kalra, Ashish wrote:

On 6/29/2024 5:20 AM, Jürgen Groß wrote:
On 28.06.24 22:52, Ashish Kalra wrote:
From: Ashish Kalra <ashish.kalra@xxxxxxx>

lookup_address_in_pgd_attr() at pte level it is simply returning
pte_offset_kernel() and there does not seem to be a check for
returning NULL if pte_none().

Fix lookup_address_in_pgd_attr() to add check for pte_none()
after pte_offset_kernel() and return NULL if it is true.

Please have a look at the comment above lookup_address(). You should not
break the documented behavior without verifying that no caller is relying
on the current behavior. If this is fine, please update the comment.


I don't get that, in this case the PTE does not exist, so as per the comments here lookup_address() should have returned NULL.

There is a PTE, but it is all 0.

There is no _valid_ PTE. No PTE would mean that the related PMD entry (or any
other higher level entry) is invalid.

Remember that the W^X checking needs to be performed _before_ a new PTE is
written.


Juergen