linux-stable/kernel
Steven Rostedt (Google) 321dca2afd ring-buffer: Fix memory leak of free page
commit 17d8017581 upstream.

Reading the ring buffer does a swap of a sub-buffer within the ring buffer
with a empty sub-buffer. This allows the reader to have full access to the
content of the sub-buffer that was swapped out without having to worry
about contention with the writer.

The readers call ring_buffer_alloc_read_page() to allocate a page that
will be used to swap with the ring buffer. When the code is finished with
the reader page, it calls ring_buffer_free_read_page(). Instead of freeing
the page, it stores it as a spare. Then next call to
ring_buffer_alloc_read_page() will return this spare instead of calling
into the memory management system to allocate a new page.

Unfortunately, on freeing of the ring buffer, this spare page is not
freed, and causes a memory leak.

Link: https://lore.kernel.org/linux-trace-kernel/20231210221250.7b9cc83c@rorschach.local.home

Cc: stable@vger.kernel.org
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: 73a757e631 ("ring-buffer: Return reader page back into existing ring buffer")
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-20 15:32:38 +01:00
..
bpf bpf: Address KCSAN report on bpf_lru_list 2023-08-11 11:33:48 +02:00
cgroup cgroup: Remove duplicates in cgroup v1 tasks file 2023-10-25 11:13:30 +02:00
configs
debug kdb: Make memory allocations more robust 2021-03-03 18:22:36 +01:00
events perf/core: Fix potential NULL deref 2023-11-08 11:21:06 +01:00
gcov gcov: add support for checksum field 2023-01-18 09:26:35 +01:00
irq genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware 2023-11-28 16:45:45 +00:00
livepatch livepatch: fix race between fork and KLP transition 2022-10-26 13:16:57 +02:00
locking locking/ww_mutex/test: Fix potential workqueue corruption 2023-11-28 16:45:42 +00:00
power PM: hibernate: Clean up sync_read handling in snapshot_write_next() 2023-11-28 16:45:45 +00:00
printk printk: fix return value of printk.devkmsg __setup handler 2022-04-20 09:08:15 +02:00
rcu rcu: Suppress smp_processor_id() complaint in synchronize_rcu_expedited_wait() 2023-03-11 16:26:41 +01:00
sched sched/fair: Don't balance task to its current running CPU 2023-08-11 11:33:48 +02:00
time posix-timers: Ensure timer ID search-loop limit is valid 2023-08-11 11:33:48 +02:00
trace ring-buffer: Fix memory leak of free page 2023-12-20 15:32:38 +01:00
.gitignore
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
Makefile elfcore: fix building with clang 2021-02-10 09:12:08 +01:00
acct.c acct: fix potential integer overflow in encode_comp_t() 2023-01-18 09:26:30 +01:00
async.c treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
audit.c treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
audit.h audit: fix a net reference leak in audit_list_rules_send() 2020-06-20 10:25:10 +02:00
audit_fsnotify.c audit: fix potential double free on error path from fsnotify_add_inode_mark 2022-09-05 10:25:02 +02:00
audit_tree.c
audit_watch.c audit: don't WARN_ON_ONCE(!current->mm) in audit_exe_compare() 2023-11-28 16:45:44 +00:00
auditfilter.c audit: fix a net reference leak in audit_list_rules_send() 2020-06-20 10:25:10 +02:00
auditsc.c audit: fix possible soft lockup in __audit_inode_child() 2023-09-23 10:46:56 +02:00
backtracetest.c
bounds.c
capability.c
compat.c sched_getaffinity: don't assume 'cpumask_size()' is fully initialized 2023-04-05 11:14:19 +02:00
configs.c
context_tracking.c
cpu.c random: clear fast pool, crng, and batches in cpuhp bring up 2022-06-25 11:46:35 +02:00
cpu_pm.c kernel/cpu_pm: Fix uninitted local in cpu_pm 2020-06-20 10:25:19 +02:00
crash_core.c
crash_dump.c
cred.c cred: switch to using atomic_long_t 2023-12-20 15:32:35 +01:00
delayacct.c
dma.c
exec_domain.c
exit.c treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
extable.c kernel/extable.c: use address-of operator on section symbols 2023-06-09 10:22:53 +02:00
fork.c mm/hugetlb: initialize hugetlb_usage in mm_init 2021-09-22 11:45:32 +02:00
freezer.c
futex.c treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
groups.c
hung_task.c kernel: hung_task.c: disable on suspend 2019-04-20 09:15:05 +02:00
irq_work.c
jump_label.c
kallsyms.c kallsyms: Don't let kallsyms_lookup_size_offset() fail on retrieving the first symbol 2019-09-21 07:15:38 +02:00
kcmp.c
kcov.c
kexec.c
kexec_core.c kexec: fix a memory leak in crash_shrink_memory() 2023-08-11 11:33:34 +02:00
kexec_file.c kexec_file: drop weak attribute from arch_kexec_apply_relocations[_add] 2022-07-02 16:18:11 +02:00
kexec_internal.h
kmod.c kmod: make request_module() return an error when autoloading is disabled 2020-04-24 08:00:44 +02:00
kprobes.c x86/kprobes: Fix arch_check_optimized_kprobe check within optimized_kprobe range 2023-03-11 16:26:46 +01:00
ksysfs.c
kthread.c kthread: prevent deadlock when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync() 2021-07-11 12:48:13 +02:00
latencytop.c
memremap.c
module-internal.h
module.c modules: only allow symbol_get of EXPORT_SYMBOL_GPL modules 2023-09-23 10:46:52 +02:00
module_signing.c
notifier.c x86/mm: split vmalloc_sync_all() 2020-04-02 16:34:20 +02:00
nsproxy.c
padata.c crypto: pcrypt - Fix hungtask for PADATA_RESET 2023-11-28 16:45:43 +00:00
panic.c exit: Use READ_ONCE() for all oops/warn limit reads 2023-02-06 07:46:35 +01:00
params.c
pid.c
pid_namespace.c memcg: enable accounting for pids in nested pid namespaces 2021-09-22 11:45:32 +02:00
profile.c profiling: fix shift too large makes kernel panic 2022-08-25 11:11:24 +02:00
ptrace.c ptrace: Reimplement PTRACE_KILL by always sending SIGKILL 2022-06-14 16:53:43 +02:00
range.c
reboot.c reboot: fix overflow parsing reboot cpu number 2020-11-18 18:28:02 +01:00
relay.c kernel/relay.c: fix memleak on destroy relay channel 2020-08-26 10:29:54 +02:00
resource.c
seccomp.c seccomp: Invalidate seccomp mode to catch death failures 2022-02-16 12:44:52 +01:00
signal.c signal handling: don't use BUG_ON() for debugging 2022-07-21 20:42:47 +02:00
smp.c smp: Fix offline cpu check in flush_smp_call_function_queue() 2022-04-20 09:08:33 +02:00
smpboot.c kthread: Extract KTHREAD_IS_PER_CPU 2021-02-07 14:47:41 +01:00
smpboot.h
softirq.c
stacktrace.c
stop_machine.c
sys.c prlimit: do_prlimit needs to have a speculation check 2023-01-24 07:05:18 +01:00
sys_ni.c
sysctl.c proc: proc_skip_spaces() shouldn't think it is working on C strings 2022-12-08 11:16:33 +01:00
sysctl_binary.c
task_work.c
taskstats.c taskstats: fix data-race 2020-01-09 10:17:53 +01:00
test_kprobes.c
torture.c
tracepoint.c tracepoint: Do not fail unregistering a probe due to memory failure 2021-03-03 18:22:47 +01:00
tsacct.c taskstats: Cleanup the use of task->exit_code 2022-02-23 11:57:34 +01:00
ucount.c
uid16.c
umh.c usermodehelper: reset umask to default before executing user process 2020-10-14 09:51:10 +02:00
up.c smp: Fix smp_call_function_single_async prototype 2021-05-22 10:57:35 +02:00
user-return-notifier.c
user.c
user_namespace.c
utsname.c
utsname_sysctl.c
watchdog.c watchdog/softlockup: Enforce that timestamp is valid on boot 2020-02-28 16:36:05 +01:00
watchdog_hld.c watchdog/perf: more properly prevent false positives with turbo modes 2023-08-11 11:33:34 +02:00
workqueue.c workqueue: Override implicit ordered attribute in workqueue_apply_unbound_cpumask() 2023-10-25 11:13:30 +02:00
workqueue_internal.h