kernel_samsung_a53x/kernel/events
Adrian Hunter 785481cfc0 perf: Prevent passing zero nr_pages to rb_alloc_aux()
[ Upstream commit dbc48c8f41c208082cfa95e973560134489e3309 ]

nr_pages is unsigned long but gets passed to rb_alloc_aux() as an int,
and is stored as an int.

Only power-of-2 values are accepted, so if nr_pages is a 64_bit value, it
will be passed to rb_alloc_aux() as zero.

That is not ideal because:
 1. the value is incorrect
 2. rb_alloc_aux() is at risk of misbehaving, although it manages to
 return -ENOMEM in that case, it is a result of passing zero to get_order()
 even though the get_order() result is documented to be undefined in that
 case.

Fix by simply validating the maximum supported value in the first place.
Use -ENOMEM error code for consistency with the current error code that
is returned in that case.

Fixes: 45bfb2e50471 ("perf: Add AUX area to ring buffer for raw data streams")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240624201101.60186-6-adrian.hunter@intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:20:08 +01:00
..
callchain.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
core.c perf: Prevent passing zero nr_pages to rb_alloc_aux() 2024-11-23 23:20:08 +01:00
hw_breakpoint.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
internal.h perf: Fix perf_aux_size() for greater-than 32-bit size 2024-11-23 23:20:08 +01:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ring_buffer.c perf/core: Add a new read format to get a number of lost samples 2024-11-18 12:11:45 +01:00
uprobes.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00