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: <1303850332.9308.17366.camel@nimitz>
Date:	Tue, 26 Apr 2011 13:38:52 -0700
From:	Dave Hansen <dave@...ux.vnet.ibm.com>
To:	Eric Paris <eparis@...hat.com>
Cc:	steffen.klassert@...unet.com, akpm@...ux-foundation.org,
	linux-kernel@...r.kernel.org,
	linux-security-module@...r.kernel.org, selinux@...ho.nsa.gov,
	sds@...ho.nsa.gov
Subject: Re: [PATCH 2/3] flex_arrays: allow zero length flex arrays

On Mon, 2011-04-25 at 21:45 -0400, Eric Paris wrote:
> Just like kmalloc will allow one to allocate a 0 length segment of memory
> flex arrays should do the same thing.  It should bomb if you try to use
> something, but it should at least allow the allocation.
> 
> Based-on-patch-by: Steffen Klassert <steffen.klassert@...unet.com>
> Signed-off-by: Eric Paris <eparis@...hat.com>
> ---
> 
>  lib/flex_array.c |   11 ++++++++++-
>  1 files changed, 10 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/flex_array.c b/lib/flex_array.c
> index 0c33b24..2554a5f 100644
> --- a/lib/flex_array.c
> +++ b/lib/flex_array.c
> @@ -253,9 +253,16 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
>  	unsigned int end;
>  	struct flex_array_part *part;
> 
> +	if (!fa->total_nr_elements && !start)
> +		return 0;

I guess it works either way, but I'd say that checking for a zero 'len'
prealloc would be more important (and meaningful) than checking a zero
'start'.

If someone passed start=0 and len=44 for a fa->total_nr_elements=0
array, I'd expect -ENOSPC, but this would return 0.

-- Dave

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