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: <20090424010326.e85ddb93.akpm@linux-foundation.org>
Date:	Fri, 24 Apr 2009 01:03:26 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Markus Metzger <markus.t.metzger@...el.com>
Cc:	a.p.zijlstra@...llo.nl, markus.t.metzger@...il.com,
	roland@...hat.com, eranian@...glemail.com, oleg@...hat.com,
	juan.villacis@...el.com, ak@...ux.jf.intel.com,
	linux-kernel@...r.kernel.org, mingo@...e.hu, tglx@...utronix.de,
	hpa@...or.com
Subject: Re: [rfc 1/2] x86, bts, mm: buffer allocation

On Fri, 24 Apr 2009 09:51:43 +0200 Markus Metzger <markus.t.metzger@...el.com> wrote:

> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -629,38 +629,36 @@ void user_shm_unlock(size_t size, struct
>  	free_uid(user);
>  }
>  
> -void *alloc_locked_buffer(size_t size)
> +int account_locked_memory(struct mm_struct *mm, struct rlimit *rlim,
> +			  size_t size)
>  {
> -	unsigned long rlim, vm, pgsz;
> -	void *buffer = NULL;
> +	unsigned long lim, vm, pgsz;
> +	int error = -ENOMEM;
>  
>  	pgsz = PAGE_ALIGN(size) >> PAGE_SHIFT;
>  
> -	down_write(&current->mm->mmap_sem);
> -
> -	rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
> -	vm   = current->mm->total_vm + pgsz;
> -	if (rlim < vm)
> -		goto out;
> +	down_write(&mm->mmap_sem);
>  
> -	rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
> -	vm   = current->mm->locked_vm + pgsz;
> -	if (rlim < vm)
> +	lim = rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
> +	vm   = mm->total_vm + pgsz;
> +	if (lim < vm)
>  		goto out;
>  
> -	buffer = kzalloc(size, GFP_KERNEL);
> -	if (!buffer)
> +	lim = rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
> +	vm   = mm->locked_vm + pgsz;
> +	if (lim < vm)
>  		goto out;
>  
> -	current->mm->total_vm  += pgsz;
> -	current->mm->locked_vm += pgsz;
> +	mm->total_vm  += pgsz;
> +	mm->locked_vm += pgsz;
>  
> +	error = 0;
>   out:
> -	up_write(&current->mm->mmap_sem);
> -	return buffer;
> +	up_write(&mm->mmap_sem);
> +	return error;
>  }

Looks OK to me.  Getting that GFP_KERNEL allocation out from inside
mmap_sem can only be 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