linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Eric Paris <eparis@redhat.com>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org
Subject: Re: [PATCH v2] flex_array: Change behaviour on zero size allocations
Date: Tue, 08 Feb 2011 09:02:41 -0800	[thread overview]
Message-ID: <1297184561.6737.12074.camel@nimitz> (raw)
In-Reply-To: <20110207122903.GO3070@secunet.com>

On Mon, 2011-02-07 at 13:29 +0100, Steffen Klassert wrote:
>  int flex_array_prealloc(struct flex_array *fa, unsigned int start,
> -                       unsigned int end, gfp_t flags)
> +                       unsigned int nr_elements, gfp_t flags)
>  {
>         int start_part;
>         int end_part;
>         int part_nr;
> +       unsigned int end;
>         struct flex_array_part *part;
> 
> -       if (start >= fa->total_nr_elements || end >= fa->total_nr_elements)
> +       if (!fa->total_nr_elements && !start)
> +               return 0;
> +       if (start >= fa->total_nr_elements)
> +               return -ENOSPC;
> +       if (!nr_elements)
> +               return 0;
> +
> +       end = start + nr_elements - 1;
> +
> +       if (end >= fa->total_nr_elements)
>                 return -ENOSPC;
> +       if (!fa->element_size)
> +               return 0; 

The rest of this patch looks good.  When you resend, you need to break
this up in to at least two patches: one to change 'end' to
'nr_elements' (or something else) and the one to handle zero-sized
elements and arrays.

I also think we need to remove the ability to do zero-sized elements.
Unless there's some new code that I'm missing, I don't see any of the
existing security policy code which would be able to do that.

-- Dave


  reply	other threads:[~2011-02-08 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 12:29 [PATCH v2] flex_array: Change behaviour on zero size allocations Steffen Klassert
2011-02-08 17:02 ` Dave Hansen [this message]
2011-02-11  9:25   ` Steffen Klassert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1297184561.6737.12074.camel@nimitz \
    --to=dave@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).