From: Wenwen Wang <wang6495@umn.edu>
To: Wenwen Wang <wang6495@umn.edu>
Cc: Kangjie Lu <kjlu@umn.edu>,
alexander.shishkin@linux.intel.com,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] intel_th: Fix a missing-check bug
Date: Mon, 29 Oct 2018 13:39:49 -0500 [thread overview]
Message-ID: <CAAa=b7fnx01565vUuturXLefLjsfUwGpD8Zh1bZZnrkSQ=wWpg@mail.gmail.com> (raw)
In-Reply-To: <1539956812-11300-1-git-send-email-wang6495@umn.edu>
Hello,
Can anyone confirm this bug? Thanks!
Wenwen
On Fri, Oct 19, 2018 at 8:47 AM Wenwen Wang <wang6495@umn.edu> wrote:
>
> In msc_data_sz(), the 'valid_dw' field of the msc block descriptor 'bdesc'
> is firstly checked to see whether the descriptor has a valid data width. If
> yes, i.e., 'bdesc->valid_dw' is not 0, the data size of this descriptor
> will be returned. It is worth noting that the data size is calculated from
> 'bdesc->valid_dw'. The problem here is that 'bdesc' actually points to a
> consistent DMA region, which is allocated through dma_alloc_coherent() in
> msc_buffer_win_alloc(). Given that the device also has the permission to
> access this DMA region, it is possible that a malicious device controlled
> by an attacker can modify the 'valid_dw' field after the if statement but
> before the return statement in msc_data_sz(). Through this way, the device
> can bypass the check and supply unexpected data width.
>
> This patch copies the 'valid_dw' field to a local variable and then
> performs the check and the calculation on the local variable to avoid the
> above issue.
>
> Signed-off-by: Wenwen Wang <wang6495@umn.edu>
> ---
> drivers/hwtracing/intel_th/msu.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/intel_th/msu.h b/drivers/hwtracing/intel_th/msu.h
> index 9cc8ace..b7d846e 100644
> --- a/drivers/hwtracing/intel_th/msu.h
> +++ b/drivers/hwtracing/intel_th/msu.h
> @@ -79,10 +79,12 @@ struct msc_block_desc {
>
> static inline unsigned long msc_data_sz(struct msc_block_desc *bdesc)
> {
> - if (!bdesc->valid_dw)
> + u32 valid_dw = bdesc->valid_dw;
> +
> + if (!valid_dw)
> return 0;
>
> - return bdesc->valid_dw * 4 - MSC_BDESC;
> + return valid_dw * 4 - MSC_BDESC;
> }
>
> static inline bool msc_block_wrapped(struct msc_block_desc *bdesc)
> --
> 2.7.4
>
next prev parent reply other threads:[~2018-10-29 18:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-19 13:46 [PATCH] intel_th: Fix a missing-check bug Wenwen Wang
2018-10-29 18:39 ` Wenwen Wang [this message]
2018-10-30 11:15 ` Alexander Shishkin
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='CAAa=b7fnx01565vUuturXLefLjsfUwGpD8Zh1bZZnrkSQ=wWpg@mail.gmail.com' \
--to=wang6495@umn.edu \
--cc=alexander.shishkin@linux.intel.com \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).