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: <alpine.DEB.2.02.1307111509000.2458@chino.kir.corp.google.com>
Date:	Thu, 11 Jul 2013 15:13:03 -0700 (PDT)
From:	David Rientjes <rientjes@...gle.com>
To:	Oleg Nesterov <oleg@...hat.com>
cc:	Andrew Morton <akpm@...ux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Mel Gorman <mgorman@...e.de>, Rik van Riel <riel@...hat.com>,
	Andi Kleen <andi@...stfloor.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: mempolicy: turn vma_set_policy() into
 vma_dup_policy()

On Wed, 10 Jul 2013, Oleg Nesterov wrote:

> Simple cleanup. Every user of vma_set_policy() does the same work,
> this looks a bit annoying imho. And the new trivial helper which
> does mpol_dup() + vma_set_policy() to simplify the callers.
> 

Good idea, just a few simple issues to fix.

> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 4baf12e..6b1d426 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -2065,6 +2065,16 @@ retry_cpuset:
>  }
>  EXPORT_SYMBOL(alloc_pages_current);
>  
> +int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
> +{
> +	struct mempolicy *pol = mpol_dup(vma_policy(src));
> +
> +	if (IS_ERR(pol))
> +		return PTR_ERR(pol);

PTR_ERR() returns long, so vma_dup_policy() needs to return long.

> +	dst->vm_policy = pol;
> +	return 0;
> +}
> +
>  /*
>   * If mpol_dup() sees current->cpuset == cpuset_being_rebound, then it
>   * rebinds the mempolicy its copying by calling mpol_rebind_policy()
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 7a1ba76..d8a310b 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2481,7 +2481,6 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
>  static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
>  	      unsigned long addr, int new_below)
>  {
> -	struct mempolicy *pol;
>  	struct vm_area_struct *new;
>  	int err = -ENOMEM;
>  
> @@ -2505,12 +2504,9 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
>  		new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
>  	}
>  
> -	pol = mpol_dup(vma_policy(vma));
> -	if (IS_ERR(pol)) {
> -		err = PTR_ERR(pol);
> +	err = vma_dup_policy(vma, new);
> +	if (err)
>  		goto out_free_vma;
> -	}
> -	vma_set_policy(new, pol);
>  
>  	if (anon_vma_clone(new, vma))
>  		goto out_free_mpol;

This isn't the first occurrence in mm/mmap.c, what about vma_adjust()?  
Probably need to patch 3.10 or later.

Otherwise looks good.
--
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