From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux1394-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] firewire: prevent integer overflow on 32bit systems
Date: Tue, 2 Mar 2021 22:19:11 +0100 [thread overview]
Message-ID: <20210302221911.6c1582e2@kant> (raw)
In-Reply-To: <YD4e9XOD8JPlJzxW@mwanda>
On Mar 02 Dan Carpenter wrote:
> In TCODE_STREAM_DATA mode, on 32bit systems, the "sizeof(*e) +
> request->length" operation can overflow leading to memory corruption.
>
> Fixes: 18e9b10fcdc0 ("firewire: cdev: add closure to async stream ioctl")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/firewire/core-cdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
> index fb6c651214f3..314de0384035 100644
> --- a/drivers/firewire/core-cdev.c
> +++ b/drivers/firewire/core-cdev.c
> @@ -587,6 +587,9 @@ static int init_request(struct client *client,
> request->length < 4)
> return -EINVAL;
>
> + if (request->length > ULONG_MAX - sizeof(*e))
> + return -EINVAL;
> +
> e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL);
> if (e == NULL)
> return -ENOMEM;
There is already a length check for asynchronous stream requests.
It happens in ioctl_send_stream_packet().
--
Stefan Richter
-======--=-= --== ---=-
http://arcgraph.de/sr/
next prev parent reply other threads:[~2021-03-02 22:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 11:18 [PATCH] firewire: prevent integer overflow on 32bit systems Dan Carpenter
2021-03-02 21:19 ` Stefan Richter [this message]
2021-03-03 5:22 ` Dan Carpenter
2021-03-03 17:31 ` kernel test robot
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=20210302221911.6c1582e2@kant \
--to=stefanr@s5r6.in-berlin.de \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/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