On Thu, Nov 5, 2020 at 7:16 AM Kevin Sheldrake <Kevin.Sheldrake@xxxxxxxxxxxxx> wrote: > > Resent due to some failure at my end. Apologies if it arrives twice. > > From 63e34d4106b4dd767f9bfce951f8a35f14b52072 Mon Sep 17 00:00:00 2001 > From: Kevin Sheldrake <kevin.sheldrake@xxxxxxxxxxxxx> > Date: Thu, 5 Nov 2020 12:18:53 +0000 > Subject: [PATCH] Update perf ring buffer to prevent corruption from > bpf_perf_output_event() > > The bpf_perf_output_event() helper takes a sample size parameter of u64, but > the underlying perf ring buffer uses a u16 internally. This 64KB maximum size > has to also accommodate a variable sized header. Failure to observe this > restriction can result in corruption of the perf ring buffer as samples > overlap. > > Track the sample size and return -E2BIG if too big to fit into the u16 > size parameter. > > Signed-off-by: Kevin Sheldrake <kevin.sheldrake@xxxxxxxxxxxxx> > --- LGTM. Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > include/linux/perf_event.h | 2 +- > kernel/events/core.c | 40 ++++++++++++++++++++++++++-------------- > 2 files changed, 27 insertions(+), 15 deletions(-) > [...]