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-next>] [day] [month] [year] [list]
Date:	Mon, 22 Nov 2010 12:01:02 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	Naoya Horiguchi <n-horiguchi@...jp.nec.com>
Cc:	LKML <linux-kernel@...r.kernel.org>, linux-mm <linux-mm@...ck.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"Jun'ichi Nomura" <j-nomura@...jp.nec.com>,
	Matt Mackall <mpm@...enic.com>
Subject: Re: [BUGFIX][PATCH] pagemap: set pagemap walk limit to PMD boundary

On Fri, 19 Nov 2010 18:07:45 +0900
Naoya Horiguchi <n-horiguchi@...jp.nec.com> wrote:

> Currently one pagemap_read() call walks in PAGEMAP_WALK_SIZE bytes
> (== 512 pages.)  But there is a corner case where walk_pmd_range()
> accidentally runs over a VMA associated with a hugetlbfs file.
> 
> For example, when a process has mappings to VMAs as shown below:
> 
>   # cat /proc/<pid>/maps
>   ...
>   3a58f6d000-3a58f72000 rw-p 00000000 00:00 0
>   7fbd51853000-7fbd51855000 rw-p 00000000 00:00 0
>   7fbd5186c000-7fbd5186e000 rw-p 00000000 00:00 0
>   7fbd51a00000-7fbd51c00000 rw-s 00000000 00:12 8614   /hugepages/test
> 
> then pagemap_read() goes into walk_pmd_range() path and walks in the range
> 0x7fbd51853000-0x7fbd51a53000, but the hugetlbfs VMA should be handled
> by walk_hugetlb_range(). Otherwise PMD for the hugepage is considered bad
> and cleared, which causes undesirable results.
> 
> This patch fixes it by separating pagemap walk range into one PMD.
> 
> Signed-off-by: Naoya Horiguchi <n-horiguchi@...jp.nec.com>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Jun'ichi Nomura <j-nomura@...jp.nec.com>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> Cc: Matt Mackall <mpm@...enic.com>
> ---
>  fs/proc/task_mmu.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index da6b01d..c126c83 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -706,6 +706,7 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask,
>   * skip over unmapped regions.
>   */
>  #define PAGEMAP_WALK_SIZE	(PMD_SIZE)
> +#define PAGEMAP_WALK_MASK	(PMD_MASK)
>  static ssize_t pagemap_read(struct file *file, char __user *buf,
>  			    size_t count, loff_t *ppos)
>  {
> @@ -776,7 +777,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
>  		unsigned long end;
>  
>  		pm.pos = 0;
> -		end = start_vaddr + PAGEMAP_WALK_SIZE;
> +		end = (start_vaddr + PAGEMAP_WALK_SIZE) & PAGEMAP_WALK_MASK;
>  		/* overflow ? */
>  		if (end < start_vaddr || end > end_vaddr)
>  			end = end_vaddr;

Ack. 

But ALIGN() can't be used ?

Thanks,
-Kame



--
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