From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Stefan Agner <stefan@agner.ch>
Cc: boris.brezillon@free-electrons.com, richard@nod.at,
dwmw2@infradead.org, computersforpeace@gmail.com,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: nand: warn if hamming layout is used with too large ECC
Date: Mon, 12 Feb 2018 10:34:06 +0100 [thread overview]
Message-ID: <20180212103406.34f0dae4@bbrezillon> (raw)
In-Reply-To: <475d5f62d1cc95e38da0c7dc2e37a511@agner.ch>
On Fri, 09 Feb 2018 12:55:49 +0100
Stefan Agner <stefan@agner.ch> wrote:
> On 09.02.2018 10:58, Boris Brezillon wrote:
> > On Fri, 09 Feb 2018 10:20:37 +0100
> > Stefan Agner <stefan@agner.ch> wrote:
> >
> >>
> >> But some kind of sanity check somewhere might be worthwhile, I was a bit
> >> surprised that this overflowing happens on a driver in operational use
> >> and goes unnoticed. I realize that this patch is not ideal. Maybe making
> >> length signed, then we could sanity check in
> >> mtd_ooblayout_count_bytes...
> >
> > Something like that should help us detect this unexpected case:
> >
>
> It is less generic than making length signed and checking for positive
> length, but fine for me.
It's just easier for callers if they only have to check the return
code instead of having to check both the return code and the oobregion
fields.
Would you mind modifying your patch accordingly and sending a v2?
Thanks,
Boris
>
> --
> Stefan
>
> > --->8---
> > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > index 66b67014508f..ada2e709743f 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -201,6 +201,9 @@ static int nand_ooblayout_free_lp_hamming(struct
> > mtd_info *mtd, int section, oobregion->offset = 2;
> > oobregion->length = ecc_offset - 2;
> > } else {
> > + if (ecc_offset + ecc->total > mtd->oobsize)
> > + return -EINVAL;
> > +
> > oobregion->offset = ecc_offset + ecc->total;
> > oobregion->length = mtd->oobsize - oobregion->offset;
> > }
--
Boris Brezillon, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
prev parent reply other threads:[~2018-02-12 9:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-08 23:33 [PATCH] mtd: nand: warn if hamming layout is used with too large ECC Stefan Agner
2018-02-09 8:50 ` Boris Brezillon
2018-02-09 9:20 ` Stefan Agner
2018-02-09 9:34 ` Boris Brezillon
2018-02-09 9:54 ` Boris Brezillon
2018-02-09 11:51 ` Stefan Agner
2018-02-09 9:58 ` Boris Brezillon
2018-02-09 11:55 ` Stefan Agner
2018-02-12 9:34 ` Boris Brezillon [this message]
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=20180212103406.34f0dae4@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=stefan@agner.ch \
/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