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: <1261915391.15854.31.camel@laptop>
Date:	Sun, 27 Dec 2009 13:03:11 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	"minchan.kim@...il.com" <minchan.kim@...il.com>,
	cl@...ux-foundation.org
Subject: Re: [RFC PATCH] asynchronous page fault.

On Fri, 2009-12-25 at 10:51 +0900, KAMEZAWA Hiroyuki wrote:
>  /*
> + * Returns vma which contains given address. This scans rb-tree in speculative
> + * way and increment a reference count if found. Even if vma exists in rb-tree,
> + * this function may return NULL in racy case. So, this function cannot be used
> + * for checking whether given address is valid or not.
> + */
> +struct vm_area_struct *
> +find_vma_speculative(struct mm_struct *mm, unsigned long addr)
> +{
> +       struct vm_area_struct *vma = NULL;
> +       struct vm_area_struct *vma_tmp;
> +       struct rb_node *rb_node;
> +
> +       if (unlikely(!mm))
> +               return NULL;;
> +
> +       rcu_read_lock();
> +       rb_node = rcu_dereference(mm->mm_rb.rb_node);
> +       vma = NULL;
> +       while (rb_node) {
> +               vma_tmp = rb_entry(rb_node, struct vm_area_struct, vm_rb);
> +
> +               if (vma_tmp->vm_end > addr) {
> +                       vma = vma_tmp;
> +                       if (vma_tmp->vm_start <= addr)
> +                               break;
> +                       rb_node = rcu_dereference(rb_node->rb_left);
> +               } else
> +                       rb_node = rcu_dereference(rb_node->rb_right);
> +       }
> +       if (vma) {
> +               if ((vma->vm_start <= addr) && (addr < vma->vm_end)) {
> +                       if (!atomic_inc_not_zero(&vma->refcnt))

And here you destroy pretty much all advantage of having done the
lockless lookup ;-)

The idea is to let the RCU lock span whatever length you need the vma
for, the easy way is to simply use PREEMPT_RCU=y for now, the hard way
is to also incorporate the drop-mmap_sem on blocking patches from a
while ago.

> +                               vma = NULL;
> +               } else
> +                       vma = NULL;
> +       }
> +       rcu_read_unlock();
> +       return vma;
> +} 

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