From: David Woodhouse <dwmw2@infradead.org>
To: Alexander Larsson <alex@cendio.se>
Cc: mtd@infradead.org
Subject: Re: mtd comments
Date: Tue, 07 Mar 2000 19:42:55 +0000 [thread overview]
Message-ID: <1173.952458175@devel2.axiom.internal> (raw)
In-Reply-To: <Pine.LNX.4.10.10003011820470.29074-100000@tammy.signum.se>
(this found in my drafts folder - evidently it never got sent - sorry for the
delay)
> Hi,
>
> I'm just browsing trough the mtd code.
Thanks - it's high time this was done.
> The following code in mtd.c::mtd_read() is pretty bad from a security
> standpoint:
>
> if (!mtd->point || (ret = MTD_POINT(mtd, *ppos, count, &retlen, &mtdbuf)) != 0)
> {
> /* mtd->point() failed; use mtd->read instead */
> ret = MTD_READ(mtd, *ppos, count, &retlen, buf);
>
> The passing of buf, which is a userspace pointer to a kernel API is
> dubious at the very least. And in the case of i.e. slram.c the
> physmem_read() function in fact just does an memcpy leading to a direct
> security problem.
I wasn't sure how to do this at the time I wrote this section of code (about
three years ago), but now I think we ought to declare that the MTD read() et
al. functions ought to take user-space pointers and use verify_area/
copy_{to,from}_user.
If they're actually called with a kernel-space buffer, we use
set_fs(KERNEL_DS) beforehand, which handles the rest of your question.
> Also, what is oob (out of band) blocks?
NAND flash chips have 16 bytes of extra storage per 512-byte block. I'm not
particularly impressed with the 'out-of-band' routines, but I couldn't see a
better way to do it. Suggestions are welcome.
Likewise, the DiskOnChip hardware also does ECC on the blocks it writes to the
flash, and automatically checks the ECC on the blocks it reads back. I'm not
wonderfully happy with the interface I've defined for that either, but the
same applies - suggestions are welcome.
> And how are flash-memories that
> have non-constant erase-sector size (i.e. boot sectors etc.) handled?
I've never met a flash memory with non-constant erase-sector size, and hence
didn't allow for them. Can you provide more information about such beasts?
--
dwmw2
To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org
next prev parent reply other threads:[~2000-03-07 19:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-01 17:47 mtd comments Alexander Larsson
2000-03-07 19:42 ` David Woodhouse [this message]
2000-03-08 9:01 ` Alexander Larsson
2000-03-08 10:15 ` David Woodhouse
2000-03-08 10:21 ` Alexander Larsson
2000-03-14 17:17 ` David Woodhouse
2000-03-14 17:23 ` Alexander Larsson
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=1173.952458175@devel2.axiom.internal \
--to=dwmw2@infradead.org \
--cc=alex@cendio.se \
--cc=mtd@infradead.org \
/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