From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>,
peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, kan.liang@linux.intel.com,
adrian.hunter@intel.com, jserv@ccns.ncku.edu.tw,
chuang@cs.nycu.edu.tw, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] perf ftrace: Fix undefined behavior in cmp_profile_data()
Date: Mon, 9 Dec 2024 17:26:50 -0300 [thread overview]
Message-ID: <Z1dSimfbQ5FO7sjU@x1> (raw)
In-Reply-To: <CAM9d7cgL-1rET97eVU2qpz5-V5XqeCX1N92wTwR5y2sp_4sjog@mail.gmail.com>
On Mon, Dec 09, 2024 at 09:02:24AM -0800, Namhyung Kim wrote:
> Hello,
>
> On Mon, Dec 9, 2024 at 5:42 AM Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
> >
> > The comparison function cmp_profile_data() violates the C standard's
> > requirements for qsort() comparison functions, which mandate symmetry
> > and transitivity:
> >
> > * Symmetry: If x < y, then y > x.
> > * Transitivity: If x < y and y < z, then x < z.
> >
> > When v1 and v2 are equal, the function incorrectly returns 1, breaking
> > symmetry and transitivity. This causes undefined behavior, which can
> > lead to memory corruption in certain versions of glibc [1].
> >
> > Fix the issue by returning 0 when v1 and v2 are equal, ensuring
> > compliance with the C standard and preventing undefined behavior.
> >
> > Link: https://www.qualys.com/2024/01/30/qsort.txt [1]
> > Fixes: 0f223813edd0 ("perf ftrace: Add 'profile' command")
> > Fixes: 74ae366c37b7 ("perf ftrace profile: Add -s/--sort option")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
>
> Reviewed-by: Namhyung Kim <namhyung@kernel.org>
I'm assuming you'll pick this for perf-tools, ok?
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
- Arnaldo
next prev parent reply other threads:[~2024-12-09 20:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 13:42 [PATCH] perf ftrace: Fix undefined behavior in cmp_profile_data() Kuan-Wei Chiu
2024-12-09 17:02 ` Namhyung Kim
2024-12-09 20:26 ` Arnaldo Carvalho de Melo [this message]
2024-12-09 21:48 ` Namhyung Kim
2024-12-11 17:23 ` Namhyung Kim
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=Z1dSimfbQ5FO7sjU@x1 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=chuang@cs.nycu.edu.tw \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=jserv@ccns.ncku.edu.tw \
--cc=kan.liang@linux.intel.com \
--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=stable@vger.kernel.org \
--cc=visitorckw@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 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.