Re: [PATCH 3/6] perf: implement kprobe support to PERF_TYPE_PROBE

From: Peter Zijlstra
Date: Thu Nov 23 2017 - 05:06:32 EST


On Wed, Nov 15, 2017 at 09:23:36AM -0800, Song Liu wrote:
> +int perf_probe_init(struct perf_event *p_event)
> +{

> + __aligned_u64 aligned_probe_desc;
> +
> + /*
> + * attr.probe_desc may not be 64-bit aligned on 32-bit systems.
> + * Make an aligned copy of it to before u64_to_user_ptr().
> + */
> + memcpy(&aligned_probe_desc, &p_event->attr.probe_desc,
> + sizeof(__aligned_u64));
> +
> + if (copy_from_user(&pd, u64_to_user_ptr(aligned_probe_desc),
> + sizeof(struct probe_desc)))
> + return -EFAULT;

That doesn't seem to make any sense what so ever.. the alignment has no
effect on this usecase. Not to mention that the kernel variable should
very much already be aligned.