lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48E6604F.8000404@gmail.com>
Date:	Fri, 03 Oct 2008 20:11:27 +0200
From:	Jiri Slaby <jirislaby@...il.com>
To:	Vegard Nossum <vegard.nossum@...il.com>
CC:	Ingo Molnar <mingo@...e.hu>, Andi Kleen <andi@...stfloor.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH -tip] x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y
 (try 2)

Vegard Nossum napsal(a):
> Is this what you had in mind? If not, then I don't know how to do it :-)

Yeah, something like that, but I am not the one you need ACK from ;).

Few notes below.

> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> index 835e062..b20389d 100644
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -45,6 +45,28 @@ unsigned long __phys_addr(unsigned long x)
>  }
>  EXPORT_SYMBOL(__phys_addr);
>  
> +bool __virt_addr_valid(unsigned long x)
> +{
> +	if (x >= __START_KERNEL_map) {
> +		x -= __START_KERNEL_map;
> +		if (x >= KERNEL_IMAGE_SIZE)
> +			return false;
> +		x += phys_base;
> +	} else {
> +		if (x < PAGE_OFFSET)
> +			return false;
> +		x -= PAGE_OFFSET;
> +		if (system_state == SYSTEM_BOOTING
> +			? x > MAXMEM : !phys_addr_valid(x))
> +		{
> +			return false;
> +		}
> +	}
> +
> +	return pfn_valid(x >> PAGE_SHIFT);
> +}
> +EXPORT_SYMBOL(__virt_addr_valid);

Just an implementation note. Still don't expect address for which
__virt_addr_valid() returns true to not cause a page fault. If it is called
e.g. for address between __START_KERNEL_map and
__START_KERNEL_map+KERNEL_IMAGE_SIZE and its pte entry has present bit
unset, it will crash when dereferenced -- unused pages above kernel image
are unmapped during boot.

> +
>  #else
[...]
> +bool __virt_addr_valid(unsigned long x)
> +{
> +	if (x < PAGE_OFFSET)
> +		return false;
> +	if (system_state != SYSTEM_BOOTING && is_vmalloc_addr((void *) x))
> +		return false;
> +	return pfn_valid((x - PAGE_OFFSET) >> PAGE_SHIFT);
> +}

Here too, the mappings at the top are probably returned as true? Absolutely
not sure about this (what returns pfn_valid on those corresponding physical
addresses).

>  #endif
>  
>  int page_is_ram(unsigned long pagenr)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ