From: Florian Fainelli <ffainelli@freebox.fr>
To: Kees Cook <keescook@chromium.org>
Cc: cbouatmailru@gmail.com, ccross@android.com, tony.luck@intel.com,
linux-kernel@vger.kernel.org, Maxime Bizon <mbizon@freebox.fr>,
stable@vger.kernel.org
Subject: Re: [PATCH] pstore/ram: fix undefined usage of rounddown_pow_of_two.
Date: Mon, 22 Oct 2012 10:37:10 +0200 [thread overview]
Message-ID: <1807287.lsQvlHRIOP@flexo> (raw)
In-Reply-To: <CAGXu5j+sNV2XCBCA4HQOXyS66MVzzcJDottFdh9hDW5LcD45HA@mail.gmail.com>
On Friday 19 October 2012 09:03:12 Kees Cook wrote:
> On Fri, Oct 19, 2012 at 4:59 AM, Florian Fainelli <ffainelli@freebox.fr> wrote:
> > From: Maxime Bizon <mbizon@freebox.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@freebox.fr>
> > Signed-off-by: Florian Fainelli <ffainelli@freebox.fr>
> > CC: stable@vger.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
next prev parent reply other threads:[~2012-10-22 8:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-19 11:59 [PATCH] pstore/ram: fix undefined usage of rounddown_pow_of_two Florian Fainelli
2012-10-19 16:03 ` Kees Cook
2012-10-22 8:37 ` Florian Fainelli [this message]
2012-10-22 9:19 ` [PATCH v2] pstore/ram: fix undefined usage of rounddown_pow_of_two(0) Florian Fainelli
2012-10-22 15:17 ` Kees Cook
2012-11-18 1:42 ` Anton Vorontsov
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=1807287.lsQvlHRIOP@flexo \
--to=ffainelli@freebox.fr \
--cc=cbouatmailru@gmail.com \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbizon@freebox.fr \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.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