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, 31 Jan 2011 08:31:37 -0800
From:	Dave Hansen <dave@...ux.vnet.ibm.com>
To:	Steffen Klassert <steffen.klassert@...unet.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Eric Paris <eparis@...hat.com>, linux-kernel@...r.kernel.org,
	linux-security-module@...r.kernel.org
Subject: Re: [PATCH] flex_array: Change behaviour on zero size allocations

On Mon, 2011-01-31 at 09:52 +0100, Steffen Klassert wrote:
>  int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
>                         gfp_t flags)
>  {
> -       int part_nr = fa_element_to_part_nr(fa, element_nr);
> +       int part_nr;
>         struct flex_array_part *part;
>         void *dst;
> 
> +       if (!fa->element_size)
> +               return 0;
>         if (element_nr >= fa->total_nr_elements)
>                 return -ENOSPC; 

I think this still has some of the issues of the earlier patch.  The
zero-size check needs to be moved after the ->total_nr_elements check.
Otherwise, this won't produce any errors:

	fa = flex_array_alloc(0, 100, GFP_KERNEL);
	flex_array_put(fa, 1001, ptr, GFP_KERNEL);

> @@ -284,6 +297,8 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
>         int part_nr = fa_element_to_part_nr(fa, element_nr);
>         struct flex_array_part *part;
> 
> +       if (!fa->total_nr_elements || !fa->element_size)
> +               return NULL;
>         if (element_nr >= fa->total_nr_elements)
>                 return NULL;
>         if (elements_fit_in_base(fa))

Do you really need to check fa->total_nr_elements both for zero and
against element_nr?  Seems a but superfluous to me.

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