On Wed, Aug 7, 2019 at 2:33 PM Daniel Xu <dxu@xxxxxxxxx> wrote: > > > On Tue, Aug 6, 2019, at 11:06 PM, Yonghong Song wrote: > [...] > > > +int perf_event_query_kprobe(struct perf_event *event, void __user *info) > > > +{ > > > + struct perf_event_query_kprobe __user *uquery = info; > > > + struct perf_event_query_kprobe query = {}; > > > + struct trace_event_call *call = event->tp_event; > > > + struct trace_kprobe *tk = (struct trace_kprobe *)call->data; > > > + u64 nmissed, nhit; > > > + > > > + if (!capable(CAP_SYS_ADMIN)) > > > + return -EPERM; > > > + if (copy_from_user(&query, uquery, sizeof(query))) > > > + return -EFAULT; > > > + if (query.size != sizeof(query)) > > > + return -EINVAL; > > > > Note that here we did not handle any backward or forward compatibility. > > > > I intended this to be reserved for future changes. Sort of like how new syscalls > will check for unknown flags. I can remove this if it's a problem. I think what Yonghong meant was that you should probably allow query.size > sizeof(query), but make sure that all the extra stuff is zeroed, similar to how it's done elsewhere (e.g., kernel/bpf/syscall.c).