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, 18 Nov 2008 08:57:07 +0200
From:	"Pekka Enberg" <penberg@...helsinki.fi>
To:	"Lai Jiangshan" <laijs@...fujitsu.com>
Cc:	"Andrew Morton" <akpm@...ux-foundation.org>,
	"David Miller" <davem@...emloft.net>,
	"Dave Airlie" <airlied@...il.com>,
	"Paul Menage" <menage@...gle.com>, kamezawa.hiroyu@...fujitsu.com,
	"Balbir Singh" <balbir@...ux.vnet.ibm.com>,
	"Arjan van de Ven" <arjan@...radead.org>,
	"Jan Kara" <jack@...e.cz>, "Jes Sorensen" <jes@....com>,
	"KOSAKI Motohiro" <kosaki.motohiro@...fujitsu.com>,
	dada1@...mosbay.com, "Alexey Dobriyan" <adobriyan@...il.com>,
	"Jens Axboe" <jens.axboe@...cle.com>,
	"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2 1/1] mm: introduce kvmalloc()/kvfree()

On Mon, Nov 17, 2008 at 2:26 PM, Lai Jiangshan <laijs@...fujitsu.com> wrote:
> @@ -163,6 +165,38 @@ char *strndup_user(const char __user *s, long n)
>  }
>  EXPORT_SYMBOL(strndup_user);
>
> +/**
> + * kvmalloc - allocate memory by kmalloc() or vmalloc()
> + *
> + * if @size <= PAGE_SIZE, memory is allocated by kmalloc(),
> + * otherwise by vmalloc().
> + *
> + * NOTICE: Generally, you should use kmalloc() or vmalloc() directly.
> + * kvmalloc() is provided for some special condition.

You might as well explicitly state what those special conditions are here.

> + */
> +void *kvmalloc(unsigned long size, gfp_t flags)
> +{
> +       if (size <= PAGE_SIZE)
> +               return kmalloc(size, flags & ~__GFP_HIGH);
> +       else
> +               return __vmalloc(size, flags | __GFP_HIGHMEM, PAGE_KERNEL);
> +}
> +EXPORT_SYMBOL(kvmalloc);
> +
> +/**
> + * kvfree - free the memory by kfree(), or vfree() if it is vmalloc addr
> + */
> +void kvfree(void *ptr)
> +{
> +       BUG_ON(in_interrupt());

I wonder if this should be a WARN_ON() to let the machine limp along
for a while if it can. At least in the kfree() case people can catch
the oops trace more easily that way.

> +
> +       if (is_vmalloc_addr(ptr))
> +               vfree(ptr);
> +       else
> +               kfree(ptr);
> +}
> +EXPORT_SYMBOL(kvfree);
> +
>  #ifndef HAVE_ARCH_PICK_MMAP_LAYOUT
>  void arch_pick_mmap_layout(struct mm_struct *mm)
>  {
>
>
> --
> 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/
>
--
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