All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
@ 2007-02-02  7:54 Adrian Hunter
  2007-02-05  6:38 ` Kyungmin Park
  0 siblings, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2007-02-02  7:54 UTC (permalink / raw)
  To: linux-mtd

>From ba01b89188f21ca9a982e33452217e5c6874fd0b Mon Sep 17 00:00:00 2001
From: Adrian Hunter <ext-adrian.hunter@nokia.com>
Date: Thu, 1 Feb 2007 16:04:50 +0200
Subject: [MTD] OneNAND: Do not allow oob write past end of page

OneNAND can write oob to successive pages, but NAND
does not do that.  For compatibility, disallow OneNAND
from writing past the end of the page.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
---
 drivers/mtd/onenand/onenand_base.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 9ec28bb..b7da84a 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1191,6 +1191,13 @@ static int onenand_do_write_oob(struct m
 		return -EINVAL;
 	}
 
+	/* For compatibility with NAND: Do not allow write past end of page */
+	if (column + len > oobsize) {
+		DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: "
+		      "Attempt to write past end of page\n");
+		return -EINVAL;
+	}
+
 	/* Do not allow reads past end of device */
 	if (unlikely(to >= mtd->size ||
 		     column + len > ((mtd->size >> this->page_shift) -
-- 
1.4.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-02  7:54 [PATCH] [MTD] OneNAND: Do not allow oob write past end of page Adrian Hunter
@ 2007-02-05  6:38 ` Kyungmin Park
  2007-02-05  7:22   ` Adrian Hunter
  0 siblings, 1 reply; 8+ messages in thread
From: Kyungmin Park @ 2007-02-05  6:38 UTC (permalink / raw)
  To: 'Adrian Hunter', linux-mtd

Hi Adrian

Umm Why is it required in OneNAND? Even though OneNAND is based on NAND. We
regard it as NOR
So we don't need this patch.

Thank you,
Kyungmin Park

> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org 
> [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of 
> Adrian Hunter
> Sent: Friday, February 02, 2007 4:55 PM
> To: linux-mtd@lists.infradead.org
> Subject: [PATCH] [MTD] OneNAND: Do not allow oob write past 
> end of page
> 
> >From ba01b89188f21ca9a982e33452217e5c6874fd0b Mon Sep 17 
> 00:00:00 2001
> From: Adrian Hunter <ext-adrian.hunter@nokia.com>
> Date: Thu, 1 Feb 2007 16:04:50 +0200
> Subject: [MTD] OneNAND: Do not allow oob write past end of page
> 
> OneNAND can write oob to successive pages, but NAND does not 
> do that.  For compatibility, disallow OneNAND from writing 
> past the end of the page.
> 
> Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
> ---
>  drivers/mtd/onenand/onenand_base.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mtd/onenand/onenand_base.c 
> b/drivers/mtd/onenand/onenand_base.c
> index 9ec28bb..b7da84a 100644
> --- a/drivers/mtd/onenand/onenand_base.c
> +++ b/drivers/mtd/onenand/onenand_base.c
> @@ -1191,6 +1191,13 @@ static int onenand_do_write_oob(struct m
>  		return -EINVAL;
>  	}
>  
> +	/* For compatibility with NAND: Do not allow write past 
> end of page */
> +	if (column + len > oobsize) {
> +		DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: "
> +		      "Attempt to write past end of page\n");
> +		return -EINVAL;
> +	}
> +
>  	/* Do not allow reads past end of device */
>  	if (unlikely(to >= mtd->size ||
>  		     column + len > ((mtd->size >> this->page_shift) -
> --
> 1.4.3
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-05  6:38 ` Kyungmin Park
@ 2007-02-05  7:22   ` Adrian Hunter
  2007-02-05  7:44     ` Kyungmin Park
  0 siblings, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2007-02-05  7:22 UTC (permalink / raw)
  To: linux-mtd

ext Kyungmin Park wrote:
> Umm Why is it required in OneNAND? Even though OneNAND is based on NAND. We
> regard it as NOR

I am not sure what you mean.  In onenand_base.c it has:

	mtd->type = MTD_NANDFLASH;

So mtd sees it as NAND.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-05  7:22   ` Adrian Hunter
@ 2007-02-05  7:44     ` Kyungmin Park
  2007-02-05  8:30       ` Artem Bityutskiy
  0 siblings, 1 reply; 8+ messages in thread
From: Kyungmin Park @ 2007-02-05  7:44 UTC (permalink / raw)
  To: 'Adrian Hunter', linux-mtd


> ext Kyungmin Park wrote:
> > Umm Why is it required in OneNAND? Even though OneNAND is based on 
> > NAND. We regard it as NOR
> 
> I am not sure what you mean.  In onenand_base.c it has:
> 
> 	mtd->type = MTD_NANDFLASH;
> 
> So mtd sees it as NAND.

I mean that in the view point of software OnenNAND is NAND, but the one of
hardware it is NOR.
So we don't need to work it as NAND. I think we don't need to restrict the
OneNAND

Thank you,
Kyungmin Park

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-05  7:44     ` Kyungmin Park
@ 2007-02-05  8:30       ` Artem Bityutskiy
  2007-02-06  2:15         ` Kyungmin Park
  0 siblings, 1 reply; 8+ messages in thread
From: Artem Bityutskiy @ 2007-02-05  8:30 UTC (permalink / raw)
  To: kmpark; +Cc: linux-mtd, 'Adrian Hunter'

On Mon, 2007-02-05 at 16:44 +0900, Kyungmin Park wrote:
> I mean that in the view point of software OnenNAND is NAND, but the one of
> hardware it is NOR.
> So we don't need to work it as NAND. I think we don't need to restrict the
> OneNAND

OneNAND stuff which we have now is _part of MTD_. MTD has its interface,
its model of the device. As long as we are part of this infrastructure,
we have to obey MTD's interface, rules and restrictions.

The whole idea of MTD is to make upper layers to access flashes in a
uniform layer. MTD achieves this at certain extent. There are flaws, but
anyway. So basically OneNAND implements more then NAND in this OOB
handling stuff. And it is bad. It encourages other people to write
OneNAND-only software, incompatible with NAND, which is totally
unreasonable in this case.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-05  8:30       ` Artem Bityutskiy
@ 2007-02-06  2:15         ` Kyungmin Park
  2007-02-08 14:11           ` Adrian Hunter
  0 siblings, 1 reply; 8+ messages in thread
From: Kyungmin Park @ 2007-02-06  2:15 UTC (permalink / raw)
  To: dedekind; +Cc: linux-mtd, 'Adrian Hunter'

Hi Adrian,

> 
> OneNAND stuff which we have now is _part of MTD_. MTD has its 
> interface, its model of the device. As long as we are part of 
> this infrastructure, we have to obey MTD's interface, rules 
> and restrictions.
> 
> The whole idea of MTD is to make upper layers to access 
> flashes in a uniform layer. MTD achieves this at certain 
> extent. There are flaws, but anyway. So basically OneNAND 
> implements more then NAND in this OOB handling stuff. And it 
> is bad. It encourages other people to write OneNAND-only 
> software, incompatible with NAND, which is totally 
> unreasonable in this case.
> 

I will push it.

BTW, after patch, we got dead code.
I downloaded oobtest again, re-run it and see that it trigger exception
code in onenand_do_write_oob
But it don't touch following codes whether include your patch or not.

        /* Do not allow write past end of device */
        if (unlikely(to >= mtd->size ||
            column + len > ((mtd->size >> this->page_shift) -
                                (to >> this->page_shift)) * oobsize)) {
                DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: Attempted to
write past end of device\n");
                return -EINVAL;
        }

Please check oobtest program.

Thank you,
Kyungmin Park

--

oobtest: Test 4 of 5
oobtest: erasing
oobtest: erased 0
oobtest: erased 128
oobtest: Attempting to start write past end of oob
oobtest: An error is expected...
oobtest: Error occurred as expected
oobtest: Attempting to start read past end of oob
oobtest: An error is expected...
oobtest: Error occurred as expected
oobtest: Attempting to write past end of device
oobtest: An error is expected...
-> onenand_write_oob: Attempt to write past end of page
oobtest: Error occurred as expected
oobtest: Attempting to read past end of device
oobtest: An error is expected...
oobtest: error: read past end of device
oobtest: Attempting to write past end of device
oobtest: An error is expected...
-> onenand_write_oob: Attempt to write past end of page
oobtest: Error occurred as expected
oobtest: Attempting to read past end of device
oobtest: An error is expected...
oobtest: error: read past end of device

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-06  2:15         ` Kyungmin Park
@ 2007-02-08 14:11           ` Adrian Hunter
  2007-02-09  0:20             ` Kyungmin Park
  0 siblings, 1 reply; 8+ messages in thread
From: Adrian Hunter @ 2007-02-08 14:11 UTC (permalink / raw)
  To: linux-mtd

ext Kyungmin Park wrote:
> BTW, after patch, we got dead code.
> I downloaded oobtest again, re-run it and see that it trigger exception
> code in onenand_do_write_oob
> But it don't touch following codes whether include your patch or not.
> 
>         /* Do not allow write past end of device */
>         if (unlikely(to >= mtd->size ||
>             column + len > ((mtd->size >> this->page_shift) -
>                                 (to >> this->page_shift)) * oobsize)) {
>                 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_oob: Attempted to
> write past end of device\n");
>                 return -EINVAL;
>         }
> 
> Please check oobtest program.
> 
> Thank you,
> Kyungmin Park
> 
> --
> 
> oobtest: Test 4 of 5
> oobtest: erasing
> oobtest: erased 0
> oobtest: erased 128
> oobtest: Attempting to start write past end of oob
> oobtest: An error is expected...
> oobtest: Error occurred as expected
> oobtest: Attempting to start read past end of oob
> oobtest: An error is expected...
> oobtest: Error occurred as expected
> oobtest: Attempting to write past end of device
> oobtest: An error is expected...
> -> onenand_write_oob: Attempt to write past end of page
> oobtest: Error occurred as expected
> oobtest: Attempting to read past end of device
> oobtest: An error is expected...
> oobtest: error: read past end of device
> oobtest: Attempting to write past end of device
> oobtest: An error is expected...
> -> onenand_write_oob: Attempt to write past end of page
> oobtest: Error occurred as expected
> oobtest: Attempting to read past end of device
> oobtest: An error is expected...
> oobtest: error: read past end of device
> 

Seems ok for me:

oobtest: Attempting to start write past end of oob
oobtest: An error is expected...
onenand_write_oob: Attempted to start write outside oob
oobtest: Error occurred as expected
oobtest: Attempting to start read past end of oob
oobtest: An error is expected...
onenand_read_oob: Attempted to start read outside oob
oobtest: Error occurred as expected
oobtest: Attempting to write past end of device
oobtest: An error is expected...
onenand_write_oob: Attempted to write past end of device
oobtest: Error occurred as expected
oobtest: Attempting to read past end of device
oobtest: An error is expected...
onenand_read_oob: Attempted to read beyond end of device
oobtest: Error occurred as expected
oobtest: Attempting to write past end of device
oobtest: An error is expected...
onenand_write_oob: Attempted to write past end of device
oobtest: Error occurred as expected
oobtest: Attempting to read past end of device
oobtest: An error is expected...
onenand_read_oob: Attempted to read beyond end of device
oobtest: Error occurred as expected

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] [MTD] OneNAND: Do not allow oob write past end of page
  2007-02-08 14:11           ` Adrian Hunter
@ 2007-02-09  0:20             ` Kyungmin Park
  0 siblings, 0 replies; 8+ messages in thread
From: Kyungmin Park @ 2007-02-09  0:20 UTC (permalink / raw)
  To: 'Adrian Hunter', linux-mtd

With new oobtest it's passed.
It's same as you

Thank you,
Kyungmin Park

> 
> Seems ok for me:
> 
> oobtest: Attempting to start write past end of oob
> oobtest: An error is expected...
> onenand_write_oob: Attempted to start write outside oob
> oobtest: Error occurred as expected
> oobtest: Attempting to start read past end of oob
> oobtest: An error is expected...
> onenand_read_oob: Attempted to start read outside oob
> oobtest: Error occurred as expected
> oobtest: Attempting to write past end of device
> oobtest: An error is expected...
> onenand_write_oob: Attempted to write past end of device
> oobtest: Error occurred as expected
> oobtest: Attempting to read past end of device
> oobtest: An error is expected...
> onenand_read_oob: Attempted to read beyond end of device
> oobtest: Error occurred as expected
> oobtest: Attempting to write past end of device
> oobtest: An error is expected...
> onenand_write_oob: Attempted to write past end of device
> oobtest: Error occurred as expected
> oobtest: Attempting to read past end of device
> oobtest: An error is expected...
> onenand_read_oob: Attempted to read beyond end of device
> oobtest: Error occurred as expected
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-02-09  0:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-02  7:54 [PATCH] [MTD] OneNAND: Do not allow oob write past end of page Adrian Hunter
2007-02-05  6:38 ` Kyungmin Park
2007-02-05  7:22   ` Adrian Hunter
2007-02-05  7:44     ` Kyungmin Park
2007-02-05  8:30       ` Artem Bityutskiy
2007-02-06  2:15         ` Kyungmin Park
2007-02-08 14:11           ` Adrian Hunter
2007-02-09  0:20             ` Kyungmin Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.