From: Richard Weinberger <richard@nod.at>
To: "Michał Kępień" <kernel@kempniu.pl>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
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:18:56 +0100 (CET) [thread overview]
Message-ID: <1173246756.12597.1643879936765.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <20220125104822.8420-5-kernel@kempniu.pl>
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?
> + 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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Richard Weinberger <richard@nod.at>
To: "Michał Kępień" <kernel@kempniu.pl>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
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:18:56 +0100 (CET) [thread overview]
Message-ID: <1173246756.12597.1643879936765.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <20220125104822.8420-5-kernel@kempniu.pl>
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?
> + 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
next prev parent reply other threads:[~2022-02-03 9:19 UTC|newest]
Thread overview: 20+ 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 ` 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 ` 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 ` 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 ` Michał Kępień
2022-01-25 10:48 ` [PATCH v3 4/4] mtdchar: add MEMREAD ioctl Michał Kępień
2022-01-25 10:48 ` Michał Kępień
2022-02-03 9:18 ` Richard Weinberger [this message]
2022-02-03 9:18 ` Richard Weinberger
2022-02-03 9:46 ` Miquel Raynal
2022-02-03 9:46 ` Miquel Raynal
2022-02-03 10:13 ` Richard Weinberger
2022-02-03 10:13 ` Richard Weinberger
2022-02-14 11:18 ` Michał Kępień
2022-02-14 11:18 ` Michał Kępień
2022-02-14 11:15 ` 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=1173246756.12597.1643879936765.JavaMail.zimbra@nod.at \
--to=richard@nod.at \
--cc=boris.brezillon@collabora.com \
--cc=kernel@kempniu.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.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.