From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pavel Machek <pavel@denx.de>
Cc: alexander.shishkin@linux.intel.com, security@kernel.org,
sasha.levin@oracle.com, gregkh@linuxfoundation.org,
kernel list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
trivial@kernel.org
Subject: Re: stm class: Prevent user-controllable allocations
Date: Tue, 7 May 2019 15:50:27 +0300 [thread overview]
Message-ID: <20190507125027.GV2239@kadam> (raw)
In-Reply-To: <20190507124113.GA659@amd>
On Tue, May 07, 2019 at 02:41:13PM +0200, Pavel Machek wrote:
>
> It seems to me that we still allow overflow if count == ~0. We'll then
> allocate 0 bytes but copy ~0 bytes. That does not sound healthy.
>
> Fixes: f08b18266c7116e2ec6885dd53a928f580060a71
>
> Signed-off-by: Pavel Machek <pavel@denx.de>
>
> diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
> index c7ba8ac..8846fca 100644
> --- a/drivers/hwtracing/stm/core.c
> +++ b/drivers/hwtracing/stm/core.c
> @@ -631,7 +631,7 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,
> char *kbuf;
> int err;
>
> - if (count + 1 > PAGE_SIZE)
> + if (count > PAGE_SIZE - 1)
> count = PAGE_SIZE - 1;
The "count" variable should all be checked in vfs_write(). count + off
is checked in rw_verify_area() and count is capped at MAX_RW_COUNT.
#define MAX_RW_COUNT (INT_MAX & PAGE_MASK)
regards,
dan carpenter
next prev parent reply other threads:[~2019-05-07 12:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-07 12:41 stm class: Prevent user-controllable allocations Pavel Machek
2019-05-07 12:50 ` Dan Carpenter [this message]
2019-05-07 15:11 ` Pavel Machek
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=20190507125027.GV2239@kadam \
--to=dan.carpenter@oracle.com \
--cc=akpm@osdl.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@denx.de \
--cc=sasha.levin@oracle.com \
--cc=security@kernel.org \
--cc=trivial@kernel.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