All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: cphealy@gmail.com, dri-devel@lists.freedesktop.org,
	linux+etnaviv@armlinux.org.uk
Subject: Re: [PATCH 09/10] drm/etnaviv: validate readback register address
Date: Mon, 30 Jan 2017 11:58:32 +0100	[thread overview]
Message-ID: <1485773912.21479.6.camel@pengutronix.de> (raw)
In-Reply-To: <20161209112131.3924-10-christian.gmeiner@gmail.com>

Am Freitag, den 09.12.2016, 12:21 +0100 schrieb Christian Gmeiner:
> Reading some registers end in a system crash ala:
> 
>   Unhandled fault: external abort on non-linefetch (0x1028) at 0xfe641000
>   Internal error: : 1028 [#1] PREEMPT ARM
> 
> Avoid those by register validation.

Avoiding crashes is one thing, but I believe this needs to go further
and avoid reads from any register that isn't a performance counter. This
probably isn't a big hole, but we want to avoid leaking the GPU state to
userspace.

Regards,
Lucas

> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index 08f9b3d..4383c0d 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -277,6 +277,27 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
>  	return 0;
>  }
>  
> +static int readback_reg_valid(unsigned reg)
> +{
> +	/*
> +	 * 0x000..0x200:     ok
> +	 * 0x200..0x400:     crash
> +	 * 0x400..0x800:     ok
> +	 * 0x800..0xa00:     crash
> +	 * 0xa00..0xc00:     crash
> +	 * 0xc00..0xe00:     crash
> +	 * 0xe00..0x1000:    crash
> +	 * everything above: crash
> +	 */
> +	if (reg >= 0x200 && reg < 400)
> +		return 0;
> +
> +	if (reg >= 0x800)
> +		return 0;
> +
> +	return 1;
> +}
> +
>  static int submit_readback(struct etnaviv_gem_submit *submit,
>  		struct etnaviv_cmdbuf *cmdbuf,
>  		const struct drm_etnaviv_gem_submit_readback *readbacks,
> @@ -303,6 +324,11 @@ static int submit_readback(struct etnaviv_gem_submit *submit,
>  			return -EINVAL;
>  		}
>  
> +		if (!readback_reg_valid(r->reg)) {
> +			DRM_ERROR("invalid readback reg (would cause crash)");
> +			return -EINVAL;
> +		}
> +
>  		cmdbuf->readbacks[i].bo_vma = etnaviv_gem_vmap(&bo->obj->base);
>  		cmdbuf->readbacks[i].offset = r->readback_offset;
>  		cmdbuf->readbacks[i].reg = r->reg;


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-01-30 10:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-09 11:21 [PATCH 00/10] drm/etnaviv: add readout support Christian Gmeiner
2016-12-09 11:21 ` [PATCH 01/10] drm/etnaviv: add uapi for register read feature Christian Gmeiner
2017-01-30 10:50   ` Lucas Stach
2017-01-30 20:18   ` Thierry Reding
2017-01-30 23:45     ` Russell King - ARM Linux
2017-01-31  7:40       ` Daniel Vetter
2016-12-09 11:21 ` [PATCH 02/10] drm/etnaviv: add internal representation of readback Christian Gmeiner
2016-12-09 11:21 ` [PATCH 03/10] drm/etnaviv: rework error handling Christian Gmeiner
2016-12-09 11:21 ` [PATCH 04/10] drm/etnaviv: extend etnaviv_gpu_cmdbuf_new(..) with nr_readbacks Christian Gmeiner
2016-12-09 11:21 ` [PATCH 05/10] drm/etnaviv: copy readbacks from userspace Christian Gmeiner
2016-12-09 11:21 ` [PATCH 06/10] drm/etnaviv: store readback data in struct etnaviv_event Christian Gmeiner
2016-12-09 11:21 ` [PATCH 07/10] drm/etnaviv: process readbacks in interrupt handler Christian Gmeiner
2016-12-09 11:21 ` [PATCH 08/10] drm/etnaviv: make it possible to reconfigure perf counter Christian Gmeiner
2016-12-09 15:48   ` Wladimir J. van der Laan
2016-12-09 17:56     ` Christian Gmeiner
2017-01-30 11:01   ` Lucas Stach
2017-01-30 23:40     ` Russell King - ARM Linux
2016-12-09 11:21 ` [PATCH 09/10] drm/etnaviv: validate readback register address Christian Gmeiner
2017-01-30 10:58   ` Lucas Stach [this message]
2017-01-30 23:38     ` Russell King - ARM Linux
2016-12-09 11:21 ` [PATCH 10/10] drm/etnaviv: add readout param Christian Gmeiner

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=1485773912.21479.6.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=christian.gmeiner@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux+etnaviv@armlinux.org.uk \
    /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.