From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Richard Weinberger <richard@nod.at>
Cc: "Michał Kępień" <kernel@kempniu.pl>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
linux-mtd <linux-mtd@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 4/4] mtdchar: add MEMREAD ioctl
Date: Thu, 3 Feb 2022 10:46:54 +0100 [thread overview]
Message-ID: <20220203104654.6cb43ea3@xps13> (raw)
In-Reply-To: <1173246756.12597.1643879936765.JavaMail.zimbra@nod.at>
Hi Richard,
richard@nod.at wrote on Thu, 3 Feb 2022 10:18:56 +0100 (CET):
> Michał,
>
> ----- Ursprüngliche Mail -----
> > Von: "Michał Kępień" <kernel@kempniu.pl>
> > An: "Miquel Raynal" <miquel.raynal@bootlin.com>, "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>
> > CC: "Boris Brezillon" <boris.brezillon@collabora.com>, "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-kernel"
> > <linux-kernel@vger.kernel.org>
> > Gesendet: Dienstag, 25. Januar 2022 11:48:22
> > Betreff: [PATCH v3 4/4] mtdchar: add MEMREAD ioctl
>
> > + if (req.start + req.len > mtd->size) {
>
> I think this can overflow since both req.start and req.len are u64.
> So an evil-doer might bypass this check.
>
> > + ret = -EINVAL;
> > + goto out;
> > + }
> > +
> > + datbuf_len = min_t(size_t, req.len, mtd->erasesize);
> > + if (datbuf_len > 0) {
> > + datbuf = kmalloc(datbuf_len, GFP_KERNEL);
>
> If mtd->erasesize is large (which is not uncommon these days) you might
> request more from kmalloc() than it can serve.
> Maybe kvmalloc() makes more sense?
Mmmh, I would really like these buffers dma-able.
I just discovered mtd_kmalloc_up_to(). Would this work?
>
> > + if (!datbuf) {
> > + ret = -ENOMEM;
> > + goto out;
> > + }
> > + }
> > +
> > + oobbuf_len = min_t(size_t, req.ooblen, mtd->erasesize);
> > + if (oobbuf_len > 0) {
> > + oobbuf = kmalloc(oobbuf_len, GFP_KERNEL);
>
> Same.
>
> Thanks,
> //richard
Thanks,
Miquèl
next prev parent reply other threads:[~2022-02-03 9:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 10:48 [PATCH v3 0/4] mtdchar: add MEMREAD ioctl Michał Kępień
2022-01-25 10:48 ` [PATCH v3 1/4] mtd: track maximum number of bitflips for each read request Michał Kępień
2022-01-25 10:48 ` [PATCH v3 2/4] mtd: always initialize 'stats' in struct mtd_oob_ops Michał Kępień
2022-01-25 10:48 ` [PATCH v3 3/4] mtd: add ECC error accounting for each read request Michał Kępień
2022-01-25 10:48 ` [PATCH v3 4/4] mtdchar: add MEMREAD ioctl Michał Kępień
2022-02-03 9:18 ` Richard Weinberger
2022-02-03 9:46 ` Miquel Raynal [this message]
2022-02-03 10:13 ` Richard Weinberger
2022-02-14 11:18 ` Michał Kępień
2022-02-14 11:15 ` Michał Kępień
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=20220203104654.6cb43ea3@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=boris.brezillon@collabora.com \
--cc=kernel@kempniu.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--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