From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: stable@vger.kernel.org, Eugeni Dodonov <eugeni.dodonov@intel.com>
Subject: Re: [PATCH] drm/i915: prevent division by zero when asking for chipset power
Date: Thu, 10 Nov 2011 13:21:38 +0000 [thread overview]
Message-ID: <e39f63$2kdj3o@fmsmga002.fm.intel.com> (raw)
In-Reply-To: <1320929486-6800-1-git-send-email-eugeni.dodonov@intel.com>
On Thu, 10 Nov 2011 10:51:26 -0200, Eugeni Dodonov <eugeni.dodonov@intel.com> wrote:
> This prevents an in-kernel division by zero which happens when we are
> asking for i915_chipset_val too quickly, or within a race condition
> between the power monitoring thread and userspace accesses via debugfs.
>
> The issue can be reproduced easily via the following command:
> while ``; do cat /sys/kernel/debug/dri/0/i915_emon_status; done
>
> This is particularly dangerous because it can be triggered by
> a non-privileged user by just reading the debugfs entry.
>
> This issue was also found independently by Konstantin Belousov
> <kostikbel@gmail.com>, who proposed a similar patch.
>
> Reported-by: Konstantin Belousov <kostikbel@gmail.com>
> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> Acked-by: Keith Packard <keithp@keithp.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Just spotted a typo...
> ---
> drivers/gpu/drm/i915/i915_dma.c | 10 ++++++++++
> drivers/gpu/drm/i915/i915_drv.h | 1 +
> 2 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 8a3942c..de199e7 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1453,6 +1453,14 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv)
>
> diff1 = now - dev_priv->last_time1;
>
> + /* Prevent division-by-zero if we are asking too fast.
> + * Also, we don't get interesting results in we are polling
s/in/if/
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
next prev parent reply other threads:[~2011-11-10 13:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 12:51 [PATCH] drm/i915: prevent division by zero when asking for chipset power Eugeni Dodonov
2011-11-10 13:21 ` Chris Wilson [this message]
2011-11-10 15:55 ` Eugeni Dodonov
2011-11-11 15:36 ` Jesse Barnes
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='e39f63$2kdj3o@fmsmga002.fm.intel.com' \
--to=chris@chris-wilson.co.uk \
--cc=eugeni.dodonov@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=stable@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