Re: [PATCH v2] x86/mm: fix kern_addr_valid to cope with existing but not present entries

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

 



On 8/19/21 6:27 AM, Mike Rapoport wrote:
> Such PMDs are created when free_kernel_image_pages() frees regions larger
> than 2Mb. In this case a part of the freed memory is mapped with PMDs and
> the set_memory_np_noalias() -> ... -> __change_page_attr() sequence will
> mark the PMD as not present rather than wipe it completely.
> 
> Make kern_addr_valid() to check whether higher level page table entries are
> present before trying to dereference them to fix this issue and to avoid
> similar issues in the future.
> 
> Reported-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx>	# 4.4...
>  	pmd = pmd_offset(pud, addr);
> -	if (pmd_none(*pmd))
> +	if (!pmd_present(*pmd))
>  		return 0;

Yeah, that seems like the right fix.  The one kern_addr_valid() user is
going to touch the memory so it *better* be present.  p*d_none() was
definitely the wrong check.

Acked-by: Dave Hansen <dave.hansen@xxxxxxxxx>



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux