* [PATCH] mtd: Fix mtd_check_oob_ops()
@ 2017-12-18 7:26 Miquel Raynal
2017-12-18 7:55 ` Richard Weinberger
2017-12-18 8:14 ` Boris Brezillon
0 siblings, 2 replies; 3+ messages in thread
From: Miquel Raynal @ 2017-12-18 7:26 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen
Cc: linux-mtd, Miquel Raynal
The mtd_check_oob_ops() helper verifies if the operation defined by the
user is correct.
Fix the check that verifies if the entire requested area exists. This
check is too restrictive and will fail anytime the last data byte of the
very last page is included in an operation.
Fixes: 5cdd929da53d ("mtd: Add sanity checks in mtd_write/read_oob()")
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
---
drivers/mtd/mtdcore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index f80e911b8843..73b605577447 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1114,7 +1114,7 @@ static int mtd_check_oob_ops(struct mtd_info *mtd, loff_t offs,
if (!ops->oobbuf)
ops->ooblen = 0;
- if (offs < 0 || offs + ops->len >= mtd->size)
+ if (offs < 0 || offs + ops->len > mtd->size)
return -EINVAL;
if (ops->ooblen) {
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: Fix mtd_check_oob_ops()
2017-12-18 7:26 [PATCH] mtd: Fix mtd_check_oob_ops() Miquel Raynal
@ 2017-12-18 7:55 ` Richard Weinberger
2017-12-18 8:14 ` Boris Brezillon
1 sibling, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2017-12-18 7:55 UTC (permalink / raw)
To: Miquel Raynal
Cc: Boris Brezillon, David Woodhouse, Brian Norris, Marek Vasut,
Cyrille Pitchen, linux-mtd
Am Montag, 18. Dezember 2017, 08:26:28 CET schrieb Miquel Raynal:
> The mtd_check_oob_ops() helper verifies if the operation defined by the
> user is correct.
>
> Fix the check that verifies if the entire requested area exists. This
> check is too restrictive and will fail anytime the last data byte of the
> very last page is included in an operation.
>
> Fixes: 5cdd929da53d ("mtd: Add sanity checks in mtd_write/read_oob()")
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Thanks for spotting and fixing this, Miquel.
> ---
> drivers/mtd/mtdcore.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index f80e911b8843..73b605577447 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1114,7 +1114,7 @@ static int mtd_check_oob_ops(struct mtd_info *mtd,
> loff_t offs, if (!ops->oobbuf)
> ops->ooblen = 0;
>
> - if (offs < 0 || offs + ops->len >= mtd->size)
> + if (offs < 0 || offs + ops->len > mtd->size)
> return -EINVAL;
>
> if (ops->ooblen) {
Thanks,
//richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: Fix mtd_check_oob_ops()
2017-12-18 7:26 [PATCH] mtd: Fix mtd_check_oob_ops() Miquel Raynal
2017-12-18 7:55 ` Richard Weinberger
@ 2017-12-18 8:14 ` Boris Brezillon
1 sibling, 0 replies; 3+ messages in thread
From: Boris Brezillon @ 2017-12-18 8:14 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Cyrille Pitchen, linux-mtd
Hi Miquel,
On Mon, 18 Dec 2017 08:26:28 +0100
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> The mtd_check_oob_ops() helper verifies if the operation defined by the
> user is correct.
>
> Fix the check that verifies if the entire requested area exists. This
> check is too restrictive and will fail anytime the last data byte of the
> very last page is included in an operation.
>
> Fixes: 5cdd929da53d ("mtd: Add sanity checks in mtd_write/read_oob()")
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
and thanks for fixing my mess.
Richard, feel free to queue it for the next -rc.
Boris
> ---
> drivers/mtd/mtdcore.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index f80e911b8843..73b605577447 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1114,7 +1114,7 @@ static int mtd_check_oob_ops(struct mtd_info *mtd, loff_t offs,
> if (!ops->oobbuf)
> ops->ooblen = 0;
>
> - if (offs < 0 || offs + ops->len >= mtd->size)
> + if (offs < 0 || offs + ops->len > mtd->size)
> return -EINVAL;
>
> if (ops->ooblen) {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-18 8:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-18 7:26 [PATCH] mtd: Fix mtd_check_oob_ops() Miquel Raynal
2017-12-18 7:55 ` Richard Weinberger
2017-12-18 8:14 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox