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:	Mon, 30 Jan 2012 09:15:58 -0800
From:	Tejun Heo <tj@...nel.org>
To:	Dmitry Antipov <dmitry.antipov@...aro.org>
Cc:	Christoph Lameter <cl@...ux-foundation.org>,
	Rusty Russell <rusty@...tcorp.com.au>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, patches@...aro.org,
	linaro-dev@...ts.linaro.org
Subject: Re: [PATCH 1/3] percpu: use ZERO_SIZE_PTR / ZERO_OR_NULL_PTR

On Mon, Jan 30, 2012 at 12:37:34PM +0400, Dmitry Antipov wrote:
> Fix pcpu_alloc() to return ZERO_SIZE_PTR if requested size is 0;
> fix free_percpu() to check passed pointer with ZERO_OR_NULL_PTR.
> 
> Signed-off-by: Dmitry Antipov <dmitry.antipov@...aro.org>
> ---
>  mm/percpu.c |   16 +++++++++++-----
>  1 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index f47af91..e903a19 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -702,7 +702,8 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
>   * Does GFP_KERNEL allocation.
>   *
>   * RETURNS:
> - * Percpu pointer to the allocated area on success, NULL on failure.
> + * ZERO_SIZE_PTR if @size is zero, percpu pointer to the
> + * allocated area on success or NULL on failure.
>   */
>  static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
>  {
> @@ -713,7 +714,10 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
>  	unsigned long flags;
>  	void __percpu *ptr;
>  
> -	if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE)) {
> +	if (unlikely(!size))
> +		return ZERO_SIZE_PTR;

Percpu pointers are in a different address space and using
ZERO_SIZE_PTR directly will trigger sparse address space warning.
Also, I'm not entirely sure whether 16 is guaranteed to be unused in
percpu address space (maybe it is but I don't think we have anything
enforcing that).

Thanks.

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