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: <20131101084329.GB19466@laptop.lan>
Date:	Fri, 1 Nov 2013 09:43:29 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Yuanhan Liu <yuanhan.liu@...ux.intel.com>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Rik van Riel <riel@...hat.com>,
	Michel Lespinasse <walken@...gle.com>
Subject: Re: [PATCH 1/4] mm/rmap: per anon_vma lock

On Fri, Nov 01, 2013 at 03:54:24PM +0800, Yuanhan Liu wrote:
> @@ -497,15 +495,20 @@ static void vma_rb_erase(struct vm_area_struct *vma, struct rb_root *root)
>   * anon_vma_interval_tree_post_update_vma().
>   *
>   * The entire update must be protected by exclusive mmap_sem and by
> - * the root anon_vma's mutex.
> + * the anon_vma's mutex.
>   */
>  static inline void
>  anon_vma_interval_tree_pre_update_vma(struct vm_area_struct *vma)
>  {
>  	struct anon_vma_chain *avc;
>  
> -	list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
> -		anon_vma_interval_tree_remove(avc, &avc->anon_vma->rb_root);
> +	list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) {
> +		struct anon_vma *anon_vma = avc->anon_vma;
> +
> +		anon_vma_lock_write(anon_vma);
> +		anon_vma_interval_tree_remove(avc, &anon_vma->rb_root);
> +		anon_vma_unlock_write(anon_vma);
> +	}
>  }
>  
>  static inline void
> @@ -513,8 +516,13 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma)
>  {
>  	struct anon_vma_chain *avc;
>  
> -	list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
> -		anon_vma_interval_tree_insert(avc, &avc->anon_vma->rb_root);
> +	list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) {
> +		struct anon_vma *anon_vma = avc->anon_vma;
> +
> +		anon_vma_lock_write(anon_vma);
> +		anon_vma_interval_tree_insert(avc, &anon_vma->rb_root);
> +		anon_vma_unlock_write(anon_vma);
> +	}
>  }
>  
>  static int find_vma_links(struct mm_struct *mm, unsigned long addr,
> @@ -781,7 +789,6 @@ again:			remove_next = 1 + (end > next->vm_end);
>  	if (anon_vma) {
>  		VM_BUG_ON(adjust_next && next->anon_vma &&
>  			  anon_vma != next->anon_vma);
> -		anon_vma_lock_write(anon_vma);
>  		anon_vma_interval_tree_pre_update_vma(vma);
>  		if (adjust_next)
>  			anon_vma_interval_tree_pre_update_vma(next);
> @@ -845,7 +852,6 @@ again:			remove_next = 1 + (end > next->vm_end);
>  		anon_vma_interval_tree_post_update_vma(vma);
>  		if (adjust_next)
>  			anon_vma_interval_tree_post_update_vma(next);
> -		anon_vma_unlock_write(anon_vma);
>  	}
>  	if (mapping)
>  		mutex_unlock(&mapping->i_mmap_mutex);

AFAICT this isn't correct at all. We used to protect the vma interval
tree with the root lock, now we don't. All we've got left is the
mmap_sem, but anon_vma chains can cross address-spaces and thus we're up
some creek without no paddle.
--
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