[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1807287.lsQvlHRIOP@flexo>
Date: Mon, 22 Oct 2012 10:37:10 +0200
From: Florian Fainelli <ffainelli@...ebox.fr>
To: Kees Cook <keescook@...omium.org>
Cc: cbouatmailru@...il.com, ccross@...roid.com, tony.luck@...el.com,
linux-kernel@...r.kernel.org, Maxime Bizon <mbizon@...ebox.fr>,
stable@...r.kernel.org
Subject: Re: [PATCH] pstore/ram: fix undefined usage of rounddown_pow_of_two.
On Friday 19 October 2012 09:03:12 Kees Cook wrote:
> On Fri, Oct 19, 2012 at 4:59 AM, Florian Fainelli <ffainelli@...ebox.fr> wrote:
> > From: Maxime Bizon <mbizon@...ebox.fr>
> >
> > record_size / console_size / ftrace_size can be 0 (this is how you
> > disable the feature), but rounddown_pow_of_two(0) is undefined. This problem
> > has been present since commit 1894a253 (ramoops: Move to fs/pstore/ram.c).
> >
> > Signed-off-by: Maxime Bizon <mbizon@...ebox.fr>
> > Signed-off-by: Florian Fainelli <ffainelli@...ebox.fr>
> > CC: stable@...r.kernel.org
> > ---
> > fs/pstore/ram.c | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> > index 1a4f6da..0c2ae26 100644
> > --- a/fs/pstore/ram.c
> > +++ b/fs/pstore/ram.c
> > @@ -374,10 +374,14 @@ static int __devinit ramoops_probe(struct platform_device *pdev)
> > goto fail_out;
> > }
> >
> > - pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
> > - pdata->record_size = rounddown_pow_of_two(pdata->record_size);
> > - pdata->console_size = rounddown_pow_of_two(pdata->console_size);
> > - pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
> > + if (pdata->mem_size)
> > + pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
>
> Nice catch!
>
> Instead of the == 0 check, what about using !is_power_of_2(size) ?
That would work equally well, I will resubmit with this then.
--
Florian
--
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