All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stein, Alexander" <Alexander.Stein@tq-group.com>
To: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"Tudor.Ambarus@microchip.com" <Tudor.Ambarus@microchip.com>
Cc: "michael@walle.cc" <michael@walle.cc>,
	"p.yadav@ti.com" <p.yadav@ti.com>,
	"vigneshr@ti.com" <vigneshr@ti.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] mtd: spi-nor: Fix shift-out-of-bounds
Date: Mon, 23 Jan 2023 15:02:45 +0000	[thread overview]
Message-ID: <5642351.DvuYhMxLoT@steina-w> (raw)
In-Reply-To: <b8d01f36-663a-928a-6dbe-64952b5bd8d0@microchip.com>

Hi Tudor,

Am Mittwoch, 16. März 2022, 08:47:40 CET schrieb Tudor.Ambarus@microchip.com:
> On 3/16/22 09:39, Alexander Stein wrote:
> 
> > [You don't often get email from alexander.stein@tq-group.com. Learn why
> > this is important at http://aka.ms/LearnAboutSenderIdentification.]
 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> > content is safe
 
> > Hello,
> 
> 
> hi,
> 
> 
> > 
> > Am Samstag, 6. November 2021, 08:56:15 CET schrieb Tudor Ambarus:
> > 
> >> When paring SFDP we may choose to mask out an erase type, passing
> >> an erase size of zero to spi_nor_set_erase_type().
> >> Fix shift-out-of-bounds and just clear the erase params when
> >> passing zero for erase size.
> >> While here avoid a superfluous dereference and use 'size' directly.
> >>
> >>
> >>
> >> UBSAN: shift-out-of-bounds in drivers/mtd/spi-nor/core.c:2237:24
> >> shift exponent 4294967295 is too large for 32-bit type 'int'
> >>
> >>
> >>
> >> Fixes: 5390a8df769e ("mtd: spi-nor: add support to non-uniform SFDP SPI
> >> NOR
 flash memories") Reported-by: Alexander Stein
> >> <Alexander.Stein@tq-group.com>
> >> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> >> ---
> >> 
> >>  drivers/mtd/spi-nor/core.c | 9 +++++++--
> >>  1 file changed, 7 insertions(+), 2 deletions(-)
> >>
> >>
> >>
> >> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> >> index 3d97c189c332..a1b5d5432f41 100644
> >> --- a/drivers/mtd/spi-nor/core.c
> >> +++ b/drivers/mtd/spi-nor/core.c
> >> @@ -2230,8 +2230,13 @@ void spi_nor_set_erase_type(struct
> >> spi_nor_erase_type
 *erase, u32 size, erase->size = size;
> >> 
> >>       erase->opcode = opcode;
> >>       /* JEDEC JESD216B Standard imposes erase sizes to be power of 2.
> >>       */
> >> 
> >> -     erase->size_shift = ffs(erase->size) - 1;
> >> -     erase->size_mask = (1 << erase->size_shift) - 1;
> >> +     if (size) {
> >> +             erase->size_shift = ffs(size) - 1;
> >> +             erase->size_mask = (1 << erase->size_shift) - 1;
> >> +     } else {
> >> +             erase->size_shift = 0;
> >> +             erase->size_mask = 0;
> >> +     }
> >> 
> >>  }
> >>
> >>
> >>
> >>  /**
> > 
> > 
> > What is the status of this patch? It is not applied up until now, no? Has
> > it
 been superseeded?
> > 
> 
> 
> I think it's marked with "changes requested". I'm going to send a v2.

Is there a v2 somewhere?

Best regards,
Alexander

WARNING: multiple messages have this Message-ID (diff)
From: "Stein, Alexander" <Alexander.Stein@tq-group.com>
To: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"Tudor.Ambarus@microchip.com" <Tudor.Ambarus@microchip.com>
Cc: "michael@walle.cc" <michael@walle.cc>,
	"p.yadav@ti.com" <p.yadav@ti.com>,
	"vigneshr@ti.com" <vigneshr@ti.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] mtd: spi-nor: Fix shift-out-of-bounds
Date: Mon, 23 Jan 2023 15:02:45 +0000	[thread overview]
Message-ID: <5642351.DvuYhMxLoT@steina-w> (raw)
In-Reply-To: <b8d01f36-663a-928a-6dbe-64952b5bd8d0@microchip.com>

Hi Tudor,

Am Mittwoch, 16. März 2022, 08:47:40 CET schrieb Tudor.Ambarus@microchip.com:
> On 3/16/22 09:39, Alexander Stein wrote:
> 
> > [You don't often get email from alexander.stein@tq-group.com. Learn why
> > this is important at http://aka.ms/LearnAboutSenderIdentification.]
 
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> > content is safe
 
> > Hello,
> 
> 
> hi,
> 
> 
> > 
> > Am Samstag, 6. November 2021, 08:56:15 CET schrieb Tudor Ambarus:
> > 
> >> When paring SFDP we may choose to mask out an erase type, passing
> >> an erase size of zero to spi_nor_set_erase_type().
> >> Fix shift-out-of-bounds and just clear the erase params when
> >> passing zero for erase size.
> >> While here avoid a superfluous dereference and use 'size' directly.
> >>
> >>
> >>
> >> UBSAN: shift-out-of-bounds in drivers/mtd/spi-nor/core.c:2237:24
> >> shift exponent 4294967295 is too large for 32-bit type 'int'
> >>
> >>
> >>
> >> Fixes: 5390a8df769e ("mtd: spi-nor: add support to non-uniform SFDP SPI
> >> NOR
 flash memories") Reported-by: Alexander Stein
> >> <Alexander.Stein@tq-group.com>
> >> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> >> ---
> >> 
> >>  drivers/mtd/spi-nor/core.c | 9 +++++++--
> >>  1 file changed, 7 insertions(+), 2 deletions(-)
> >>
> >>
> >>
> >> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> >> index 3d97c189c332..a1b5d5432f41 100644
> >> --- a/drivers/mtd/spi-nor/core.c
> >> +++ b/drivers/mtd/spi-nor/core.c
> >> @@ -2230,8 +2230,13 @@ void spi_nor_set_erase_type(struct
> >> spi_nor_erase_type
 *erase, u32 size, erase->size = size;
> >> 
> >>       erase->opcode = opcode;
> >>       /* JEDEC JESD216B Standard imposes erase sizes to be power of 2.
> >>       */
> >> 
> >> -     erase->size_shift = ffs(erase->size) - 1;
> >> -     erase->size_mask = (1 << erase->size_shift) - 1;
> >> +     if (size) {
> >> +             erase->size_shift = ffs(size) - 1;
> >> +             erase->size_mask = (1 << erase->size_shift) - 1;
> >> +     } else {
> >> +             erase->size_shift = 0;
> >> +             erase->size_mask = 0;
> >> +     }
> >> 
> >>  }
> >>
> >>
> >>
> >>  /**
> > 
> > 
> > What is the status of this patch? It is not applied up until now, no? Has
> > it
 been superseeded?
> > 
> 
> 
> I think it's marked with "changes requested". I'm going to send a v2.

Is there a v2 somewhere?

Best regards,
Alexander

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2023-01-23 15:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-06  7:56 [PATCH 0/2] mtd: spi-nor: Erase fixes Tudor Ambarus
2021-11-06  7:56 ` Tudor Ambarus
2021-11-06  7:56 ` [PATCH 1/2] mtd: spi-nor: Fix shift-out-of-bounds Tudor Ambarus
2021-11-06  7:56   ` Tudor Ambarus
2021-11-08  9:26   ` (EXT) " Stein, Alexander
2021-11-08  9:26     ` Stein, Alexander
2021-11-16 18:36   ` Pratyush Yadav
2021-11-16 18:36     ` Pratyush Yadav
2022-03-16  7:39   ` Alexander Stein
2022-03-16  7:39     ` Alexander Stein
2022-03-16  7:47     ` Tudor.Ambarus
2022-03-16  7:47       ` Tudor.Ambarus
2023-01-23 15:02       ` Stein, Alexander [this message]
2023-01-23 15:02         ` Stein, Alexander
2021-11-06  7:56 ` [PATCH 2/2] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set Tudor Ambarus
2021-11-06  7:56   ` Tudor Ambarus
2021-12-06 18:17   ` Pratyush Yadav
2021-12-06 18:17     ` Pratyush Yadav

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=5642351.DvuYhMxLoT@steina-w \
    --to=alexander.stein@tq-group.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=michael@walle.cc \
    --cc=p.yadav@ti.com \
    --cc=vigneshr@ti.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 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.