public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: "Martin Liška" <mliska@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [HSA, PATCH] Allocate memory for shadow arg (PR hsa/70337)
Date: Mon, 21 Mar 2016 19:06:00 -0000	[thread overview]
Message-ID: <20160321182325.GD3435@virgil.suse.cz> (raw)
In-Reply-To: <56EFEDD5.8010508@suse.cz>

Hi,

On Mon, Mar 21, 2016 at 01:49:25PM +0100, Martin Liska wrote:
> Hello.
> 
> Following patch fixes an invalid write in HSA plug-in.
> I've been running bootstrap and regression tests on x86-linux-gnu.
> 
> Ready after it finishes?
> Thanks,
> Martin

> From 2674ceb5fddeaeb26ff87d26a43bddaf40060ea2 Mon Sep 17 00:00:00 2001
> From: marxin <mliska@suse.cz>
> Date: Mon, 21 Mar 2016 13:34:04 +0100
> Subject: [PATCH] Allocate memory for shadow arg (PR hsa/70337)
> 
> libgomp/ChangeLog:
> 
> 2016-03-21  Martin Liska  <mliska@suse.cz>
> 
> 	PR hsa/70337
> 	* plugin/plugin-hsa.c (create_single_kernel_dispatch): Allocate
> 	memory for hsa_kernel_runtime * argument.
> ---
>  libgomp/plugin/plugin-hsa.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
> index d888493..36b3cf4 100644
> --- a/libgomp/plugin/plugin-hsa.c
> +++ b/libgomp/plugin/plugin-hsa.c
> @@ -884,9 +884,10 @@ create_single_kernel_dispatch (struct kernel_info *kernel,
>    shadow->private_segment_size = kernel->private_segment_size;
>    shadow->group_segment_size = kernel->group_segment_size;
>  
> -  status
> -    = hsa_memory_allocate (agent->kernarg_region, kernel->kernarg_segment_size,
> -			   &shadow->kernarg_address);
> +  size_t kernarg_size = kernel->kernarg_segment_size
> +    + sizeof (struct hsa_kernel_runtime *);

This is strange.  The pointer to the shadow data structure is, from
the HSA perspective, a normal kernel argument and therefore should
already be included in the kernel->kernarg_segment_size.  Have you
checked that the values are indeed off?

Martin


> +  status = hsa_memory_allocate (agent->kernarg_region, kernarg_size,
> +				&shadow->kernarg_address);
>    if (status != HSA_STATUS_SUCCESS)
>      hsa_fatal ("Could not allocate memory for HSA kernel arguments", status);
>  
> -- 
> 2.7.1
> 

  reply	other threads:[~2016-03-21 18:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 13:05 Martin Liška
2016-03-21 19:06 ` Martin Jambor [this message]
2016-03-21 20:58   ` Martin Liška
2016-03-22 16:51     ` Martin Jambor

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=20160321182325.GD3435@virgil.suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).