[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1296573623.3145.6.camel@localhost.localdomain>
Date: Tue, 01 Feb 2011 10:20:22 -0500
From: Eric Paris <eparis@...hat.com>
To: Dave Hansen <dave@...ux.vnet.ibm.com>
Cc: Steffen Klassert <steffen.klassert@...unet.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, linux-security-module@...r.kernel.org
Subject: Re: [PATCH] flex_array: Change behaviour on zero size allocations
On Tue, 2011-02-01 at 06:55 -0800, Dave Hansen wrote:
> On Tue, 2011-02-01 at 12:03 +0100, Steffen Klassert wrote:
> > rc = flex_array_prealloc(p->type_val_to_struct_array, 0,
> > p->p_types.nprim - 1, GFP_KERNEL | __GFP_ZERO);
> > if (rc)
> > goto out;
> >
> > If p->p_types.nprim is zero, we allocare with total_nr_elements equal
> > to zerro and then we try to prealloc with p->p_types.nprim - 1.
> > flex_array_prealloc interprets this as an unsigned int and fails,
> > because this is bigger than total_nr_elements, which is correct I
> > think.
> >
> > Thoughts?
>
> The most we ever hold in a flex_array is ~2 million entries. So we have
> plenty of room to use a normal int if you want.
>
> On the other hand, there's only one user of flex_array_prealloc(), and
> making the "end" argument inclusive doesn't seem to be what that user
> wants. We might want to either make flex_array_prealloc() take start
> and length, or instead make "end" be exclusive of the "end" index.
>
> I thought that flex_array_prealloc would say, effectively: "all put()'s
> would work up until 'end'". But, looking at it now, that's probably not
> how people will use it.
I'm fine with any solution. It's obviously broken for SELinux to be
passing -1 even if the library supported it. I guess I don't really
have strong feelings on how to fix it.
1) make end exclusive
2) change 'end' to 'len'
3) just make selinux not prealloc() when the #elements == 0
All seem perfectly reasonable to me, but I'd probably do them in that
order.
-Eric
--
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