public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH v4.19] tools: perf: Fix build error in v4.19.y
Date: Mon, 9 Nov 2020 12:44:51 +0100	[thread overview]
Message-ID: <20201109114451.GE1769924@kroah.com> (raw)
In-Reply-To: <20201108003124.100732-1-linux@roeck-us.net>

On Sat, Nov 07, 2020 at 04:31:24PM -0800, Guenter Roeck wrote:
> perf may fail to build in v4.19.y with the following error.
> 
> util/evsel.c: In function ‘perf_evsel__exit’:
> util/util.h:25:28: error:
> 	passing argument 1 of ‘free’ discards ‘const’ qualifier from pointer target type
> 
> This is observed (at least) with gcc v6.5.0. The underlying problem is
> the following statement.
> 	zfree(&evsel->pmu_name);
> evsel->pmu_name is decared 'const *'. zfree in turn is defined as
> 	#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
> and thus passes the const * to free(). The problem is not seen
> in the upstream kernel since zfree() has been rewritten there.
> 
> The problem has been introduced into v4.19.y with the backport of upstream
> commit d4953f7ef1a2 (perf parse-events: Fix 3 use after frees found with
> clang ASAN).
> 
> One possible fix of this problem would be to not declare pmu_name
> as const. This patch chooses to typecast the parameter of zfree()
> to void *, following the guidance from the upstream kernel which
> does the same since commit 7f7c536f23e6a ("tools lib: Adopt
> zalloc()/zfree() from tools/perf")
> 
> Fixes: a0100a363098 ("perf parse-events: Fix 3 use after frees found with clang ASAN")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> This patch only applies to v4.19.y and has no upstream equivalent.
> 
>  tools/perf/util/util.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index dc58254a2b69..8c01b2cfdb1a 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -22,7 +22,7 @@ static inline void *zalloc(size_t size)
>  	return calloc(1, size);
>  }
>  
> -#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
> +#define zfree(ptr) ({ free((void *)*ptr); *ptr = NULL; })
>  
>  struct dirent;
>  struct nsinfo;
> -- 
> 2.17.1
> 

Now queued up, thanks.

greg k-h

      reply	other threads:[~2020-11-09 11:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-08  0:31 [PATCH v4.19] tools: perf: Fix build error in v4.19.y Guenter Roeck
2020-11-09 11:44 ` Greg Kroah-Hartman [this message]

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=20201109114451.GE1769924@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --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