This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] ASAN: handle addressable params (PR sanitize/81040).
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 30 Jun 2017 11:30:59 +0200
- Subject: Re: [PATCH] ASAN: handle addressable params (PR sanitize/81040).
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7694C6B23B
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7694C6B23B
- References: <e1a133fa-9e3d-d043-0efd-c07fbc543c69@suse.cz> <20170619141340.GP2123@tucnak> <f380351e-51cb-43b5-3b88-3abf76f6aeda@suse.cz> <20170620093204.GF2123@tucnak> <ebab2c43-4fb6-0137-e292-4b6633e74b37@suse.cz> <20170629111737.GB2123@tucnak> <53a86396-fb7f-40c0-bd6a-334c377febf5@suse.cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jun 30, 2017 at 11:21:48AM +0200, Martin Liška wrote:
> @@ -858,6 +864,132 @@ sanitize_asan_mark_poison (void)
> }
> }
>
> +/* Rewrite all usages of tree OP which is a PARM_DECL with a VAR_DECL
> + that is it's DECL_VALUE_EXPR. */
> +
> +static tree
> +rewrite_usage_of_param (tree *op, int *walk_subtrees, void *)
> +{
> + if (TREE_CODE (*op) == PARM_DECL && DECL_HAS_VALUE_EXPR_P (*op))
> + {
> + *op = DECL_VALUE_EXPR (*op);
> + *walk_subtrees = 0;
> + }
If you are going to rely just on DECL_HAS_VALUE_EXPR_P here
> + for (tree arg = DECL_ARGUMENTS (current_function_decl);
> + arg; arg = DECL_CHAIN (arg))
> + {
I think you should gcc_assert here that !DECL_HAS_VALUE_EXPR_P (arg) here.
If that ever fails, another possibility would be to temporarily clear those
flags and remember it and then set it again after the walk_*. The question
would be what to do with arguments that already have DECL_VALUE_EXPR, are
addressable and you want to rewrite them.
> + if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (TREE_TYPE (arg)))
> + {
> + TREE_ADDRESSABLE (arg) = 0;
> + /* The parameter is no longer addressable. */
> + tree type = TREE_TYPE (arg);
> + has_any_addressable_param = true;
Otherwise LGTM.
Jakub