diff --git a/kernel/events/core.c b/kernel/events/core.c index 969f865f9f1cdf5bea57e442cc637ad1570cea86..ee145bdee6edbb7588d02d1577b0d310c293dd74 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10125,6 +10125,9 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr, ret = -EINVAL; } + if (!attr->sample_max_stack) + attr->sample_max_stack = sysctl_perf_event_max_stack; + if (attr->sample_type & PERF_SAMPLE_REGS_INTR) ret = perf_reg_validate(attr->sample_regs_intr); out: @@ -10338,9 +10341,6 @@ SYSCALL_DEFINE5(perf_event_open, perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN)) return -EACCES; - if (!attr.sample_max_stack) - attr.sample_max_stack = sysctl_perf_event_max_stack; - /* * In cgroup mode, the pid argument is used to pass the fd * opened to the cgroup directory in cgroupfs. The cpu argument