linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: Fix incorrect calculation of object size by sizeof
@ 2023-06-19  8:20 Li Dong
  2023-06-20 19:19 ` Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Li Dong @ 2023-06-19  8:20 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Sean Christopherson,
	open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM
  Cc: opensource.kernel, lidong

What we need to calculate is the size of the object, not the size of the
pointer.

Signed-off-by: Li Dong <lidong@vivo.com>
---
 tools/perf/util/scripting-engines/trace-event-python.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 59063ec98619..25fcd6630a4d 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -771,12 +771,12 @@ static void set_regs_in_dict(PyObject *dict,
 	int size = __sw_hweight64(attr->sample_regs_intr) * 28;
 	char *bf = malloc(size);
 
-	regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf));
+	regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, size);
 
 	pydict_set_item_string_decref(dict, "iregs",
 			_PyUnicode_FromString(bf));
 
-	regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, sizeof(bf));
+	regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, size);
 
 	pydict_set_item_string_decref(dict, "uregs",
 			_PyUnicode_FromString(bf));
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools: Fix incorrect calculation of object size by sizeof
  2023-06-19  8:20 [PATCH] tools: Fix incorrect calculation of object size by sizeof Li Dong
@ 2023-06-20 19:19 ` Namhyung Kim
       [not found]   ` <CA+JHD93f_c8OJf4Kg68C_Xo=_rcO669G0QJ_mjL78upLmUwfoA@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2023-06-20 19:19 UTC (permalink / raw)
  To: Li Dong
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Sean Christopherson,
	open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM, opensource.kernel

Hello,

On Mon, Jun 19, 2023 at 1:21 AM Li Dong <lidong@vivo.com> wrote:
>
> What we need to calculate is the size of the object, not the size of the
> pointer.
>
> Signed-off-by: Li Dong <lidong@vivo.com>

Since this problem was introduced in the current dev cycle and not in the
mainline yet, I think we can skip the Fixes tag.

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/scripting-engines/trace-event-python.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index 59063ec98619..25fcd6630a4d 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -771,12 +771,12 @@ static void set_regs_in_dict(PyObject *dict,
>         int size = __sw_hweight64(attr->sample_regs_intr) * 28;
>         char *bf = malloc(size);
>
> -       regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf));
> +       regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, size);
>
>         pydict_set_item_string_decref(dict, "iregs",
>                         _PyUnicode_FromString(bf));
>
> -       regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, sizeof(bf));
> +       regs_map(&sample->user_regs, attr->sample_regs_user, arch, bf, size);
>
>         pydict_set_item_string_decref(dict, "uregs",
>                         _PyUnicode_FromString(bf));
> --
> 2.31.1.windows.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools: Fix incorrect calculation of object size by sizeof
       [not found]   ` <CA+JHD93f_c8OJf4Kg68C_Xo=_rcO669G0QJ_mjL78upLmUwfoA@mail.gmail.com>
@ 2023-06-20 22:42     ` Namhyung Kim
  2023-06-21 17:26       ` Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2023-06-20 22:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Li Dong, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Sean Christopherson,
	open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM, opensource.kernel

Hi Arnaldo,

On Tue, Jun 20, 2023 at 3:06 PM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
>
>
> On Tue, Jun 20, 2023, 3:19 PM Namhyung Kim <namhyung@kernel.org> wrote:
>>
>> Hello,
>>
>> On Mon, Jun 19, 2023 at 1:21 AM Li Dong <lidong@vivo.com> wrote:
>> >
>> > What we need to calculate is the size of the object, not the size of the
>> > pointer.
>> >
>> > Signed-off-by: Li Dong <lidong@vivo.com>
>>
>> Since this problem was introduced in the current dev cycle and not in the
>> mainline yet, I think we can skip the Fixes tag.
>>
>> Acked-by: Namhyung Kim <namhyung@kernel.org>
>
>
> I think we should have it anyway, if not for the stable guys to pick it up, for documentation sake :-)

Ok, I'll add that.  Thanks for the reply while on your vacation. :)

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools: Fix incorrect calculation of object size by sizeof
  2023-06-20 22:42     ` Namhyung Kim
@ 2023-06-21 17:26       ` Namhyung Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2023-06-21 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Li Dong, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Sean Christopherson,
	open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM, opensource.kernel

On Tue, Jun 20, 2023 at 3:42 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Arnaldo,
>
> On Tue, Jun 20, 2023 at 3:06 PM Arnaldo Carvalho de Melo
> <arnaldo.melo@gmail.com> wrote:
> >
> >
> >
> > On Tue, Jun 20, 2023, 3:19 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >>
> >> Hello,
> >>
> >> On Mon, Jun 19, 2023 at 1:21 AM Li Dong <lidong@vivo.com> wrote:
> >> >
> >> > What we need to calculate is the size of the object, not the size of the
> >> > pointer.
> >> >
> >> > Signed-off-by: Li Dong <lidong@vivo.com>
> >>
> >> Since this problem was introduced in the current dev cycle and not in the
> >> mainline yet, I think we can skip the Fixes tag.
> >>
> >> Acked-by: Namhyung Kim <namhyung@kernel.org>
> >
> >
> > I think we should have it anyway, if not for the stable guys to pick it up, for documentation sake :-)
>
> Ok, I'll add that.  Thanks for the reply while on your vacation. :)

Applied to perf-tools-next with the below tag, thanks!

Fixed: 51cfe7a3e87e ("perf python: Avoid 2 leak sanitizer issues")

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-21 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19  8:20 [PATCH] tools: Fix incorrect calculation of object size by sizeof Li Dong
2023-06-20 19:19 ` Namhyung Kim
     [not found]   ` <CA+JHD93f_c8OJf4Kg68C_Xo=_rcO669G0QJ_mjL78upLmUwfoA@mail.gmail.com>
2023-06-20 22:42     ` Namhyung Kim
2023-06-21 17:26       ` Namhyung Kim

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).