From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Zixuan Tan <tanzixuan.me@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/genelf: Switch deprecated openssl MD5_* functions to new EVP API
Date: Thu, 25 Aug 2022 17:17:12 -0300 [thread overview]
Message-ID: <YwfYyLE3ajSFVHGQ@kernel.org> (raw)
In-Reply-To: <CABwm_eTnARC1GwMD-JF176k8WXU1Z0+H190mvXn61yr369qt6g@mail.gmail.com>
Em Fri, Aug 26, 2022 at 01:00:58AM +0800, Zixuan Tan escreveu:
> Switch to the flavored EVP API like in test-libcrypto.c, and remove the
> bad gcc #pragma.
>
> Inspired-By: 5b245985a6de ("tools build: Switch to new openssl API for
> test-libcrypto")
How did you test the end result? Can you please describe step by step?
Also please consider adding a 'perf test' entry to make sure this
doesn't regress.
Thanks,
- Arnaldo
> Signed-off-by: Zixuan Tan <tanzixuan.me@gmail.com>
> ---
> tools/perf/util/genelf.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/util/genelf.c b/tools/perf/util/genelf.c
> index 953338b9e887..ed28a0dbcb7f 100644
> --- a/tools/perf/util/genelf.c
> +++ b/tools/perf/util/genelf.c
> @@ -30,10 +30,6 @@
>
> #define BUILD_ID_URANDOM /* different uuid for each run */
>
> -// FIXME, remove this and fix the deprecation warnings before its removed and
> -// We'll break for good here...
> -#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> -
> #ifdef HAVE_LIBCRYPTO_SUPPORT
>
> #define BUILD_ID_MD5
> @@ -45,6 +41,7 @@
> #endif
>
> #ifdef BUILD_ID_MD5
> +#include <openssl/evp.h>
> #include <openssl/md5.h>
> #endif
> #endif
> @@ -142,15 +139,20 @@ gen_build_id(struct buildid_note *note,
> static void
> gen_build_id(struct buildid_note *note, unsigned long load_addr,
> const void *code, size_t csize)
> {
> - MD5_CTX context;
> + EVP_MD_CTX *mdctx;
>
> if (sizeof(note->build_id) < 16)
> errx(1, "build_id too small for MD5");
>
> - MD5_Init(&context);
> - MD5_Update(&context, &load_addr, sizeof(load_addr));
> - MD5_Update(&context, code, csize);
> - MD5_Final((unsigned char *)note->build_id, &context);
> + mdctx = EVP_MD_CTX_new();
> + if (!mdctx)
> + errx(2, "failed to create EVP_MD_CTX");
> +
> + EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
> + EVP_DigestUpdate(mdctx, &load_addr, sizeof(load_addr));
> + EVP_DigestUpdate(mdctx, code, csize);
> + EVP_DigestFinal_ex(mdctx, (unsigned char *)note->build_id, NULL);
> + EVP_MD_CTX_free(mdctx);
> }
> #endif
>
> --
> 2.34.1
--
- Arnaldo
next prev parent reply other threads:[~2022-08-25 20:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 17:00 [PATCH] perf/genelf: Switch deprecated openssl MD5_* functions to new EVP API Zixuan Tan
2022-08-25 20:17 ` Arnaldo Carvalho de Melo [this message]
2022-08-26 17:21 ` Zixuan Tan
2022-08-26 18:32 ` Namhyung Kim
2022-09-06 9:40 ` Zixuan Tan
2022-09-06 12:33 ` Arnaldo Carvalho de Melo
2022-09-06 12:38 ` Arnaldo Carvalho de Melo
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=YwfYyLE3ajSFVHGQ@kernel.org \
--to=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tanzixuan.me@gmail.com \
/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 NNTP newsgroup(s).