linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Pratyush Yadav <p.yadav@ti.com>
Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
	Tudor Ambarus <tudor.ambarus@microchip.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>
Subject: Re: [PATCH 1/2] mtd: spi-nor: sfdp: save a copy of the SFDP data
Date: Mon, 22 Mar 2021 16:48:31 +0100	[thread overview]
Message-ID: <9690ceb44cb1a09c03e2ac16569f3c6d@walle.cc> (raw)
In-Reply-To: <0efba47de8737059b4f3c593c26297bf@walle.cc>

Am 2021-03-22 16:32, schrieb Michael Walle:
>>> +
>>> +	sfdp->num_dwords = DIV_ROUND_UP(sfdp_size, sizeof(*sfdp->dwords));
>> 
>> The SFDP spec says that Parameter Table Pointer should be DWORD 
>> aligned
>> and Parameter Table length is specified in number of DWORDs. So,
>> sfdp_size should always be a multiple of 4. Any SFDP table where this 
>> is
>> not true is an invalid one.
>> 
>> Also, the spec says "Device behavior when the Read SFDP command 
>> crosses
>> the SFDP structure boundary is not defined".
>> 
>> So I think this should be a check for alignment instead of a round-up.
> 
> Well, that woundn't help for debugging. I.e. you also want the SFDP 
> data
> in cases like this. IMHO we should try hard enough to actually get a
> reasonable dump.
> 
> OTOH we also rely on the header and the pointers in the header. Any
> other ideas, but just to chicken out?

Oh, forgot to mention, sfdp_size is used to read the data. I just want
to make sure, the allocated area is large enough. We shouldn't hit the
undefined behavior by reading past the SFDP.

Maybe that check should be part of the parsing code.

-michael

  reply	other threads:[~2021-03-22 15:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18  9:24 [PATCH 0/2] mtd: spi-nor: support dumping sfdp tables Michael Walle
2021-03-18  9:24 ` [PATCH 1/2] mtd: spi-nor: sfdp: save a copy of the SFDP data Michael Walle
2021-03-22 14:21   ` Pratyush Yadav
2021-03-22 15:32     ` Michael Walle
2021-03-22 15:48       ` Michael Walle [this message]
2021-03-22 18:42       ` Pratyush Yadav
2021-03-22 22:31         ` Michael Walle
2021-03-23  9:37           ` Pratyush Yadav
2021-04-05 13:11   ` Tudor.Ambarus
2021-04-05 15:07     ` Michael Walle
2021-04-05 15:42       ` Tudor.Ambarus
2021-04-05 16:03         ` Michael Walle
2021-03-18  9:24 ` [PATCH 2/2] mtd: spi-nor: add initial sysfs support Michael Walle
2021-03-20  4:16   ` Yicong Yang
2021-03-20 19:17     ` Michael Walle
2021-03-22 14:43   ` Pratyush Yadav
2021-03-22 14:57     ` Michael Walle
2021-04-06  7:56   ` Vignesh Raghavendra
2021-04-06  8:47     ` Michael Walle
2021-04-06 11:43       ` Vignesh Raghavendra
2021-04-29 15:37   ` Alexander Williams
2021-04-29 15:46     ` Michael Walle

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=9690ceb44cb1a09c03e2ac16569f3c6d@walle.cc \
    --to=michael@walle.cc \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=p.yadav@ti.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@microchip.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).