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]
Date:	Tue, 20 Mar 2007 16:32:02 +0100
From:	Pierre Peiffer <pierre.peiffer@...l.net>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	mingo@...e.hu, drepper@...hat.com, linux-kernel@...r.kernel.org,
	Jean-Pierre Dion <jean-pierre.dion@...l.net>
Subject: Re: [PATCH 2.6.21-rc3-mm2 3/4] futex_requeue_pi optimization

Peter Zijlstra a écrit :
>> +static void *get_futex_address(union futex_key *key)
>> +{
>> +	void *uaddr;
>> +
>> +	if (key->both.offset & 1) {
>> +		/* shared mapping */
>> +		uaddr = (void*)((key->shared.pgoff << PAGE_SHIFT)
>> +				+ key->shared.offset - 1);
>> +	} else {
>> +		/* private mapping */
>> +		uaddr = (void*)(key->private.address + key->private.offset);
>> +	}
>> +
>> +	return uaddr;
>> +}
> 
> This will not work for nonlinear vmas, granted, not a lot of ppl stick
> futexes in nonlinear vmas, but the futex_key stuff handles it, this
> doesn't.

Indeed ! Thanks for pointing me to this.

Since I'm not familiar with vmm, does this code look more correct to you ?

static void *get_futex_address(union futex_key *key)
{
	void *uaddr;
	struct vm_area_struct *vma = current->mm->mmap;

	if (key->both.offset & 1) {
		/* shared mapping */
		struct file * vmf;

		do {
			if ((vmf = vma->vm_file)
			    && (key->shared.inode == vmf->f_dentry->d_inode))
				break;
			vma = vma->vm_next;
		} while (vma);

		if (likely(!(vma->vm_flags & VM_NONLINEAR)))
			uaddr = (void*)((key->shared.pgoff << PAGE_SHIFT)
					+ key->shared.offset - 1);
		else
			uaddr = (void*) vma->vm_start
				+ ((key->shared.pgoff - vma->vm_pgoff)
				   << PAGE_SHIFT)
				+ key->shared.offset - 1;
	} else {
		/* private mapping */
		uaddr = (void*)(key->private.address + key->private.offset);
	}

	return uaddr;
}

Or is there a more direct way to retrieve the vma corresponding to the given inode ?

Thanks,

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