struct kvm_x86_pmu_event_filter has a flexible array member, so annotate
it with the field that describes the amount of entries in such array.
Opportunistically replace the open-coded array size calculation with
flex_array_size() when copying the array portion of the struct from
userspace.
Signed-off-by: Carlos López <clopez@suse.de>
Link: https://patch.msgid.link/20260212140556.3883030-2-clopez@suse.de
Signed-off-by: Sean Christopherson <seanjc@google.com>
__u32 nr_excludes;
__u64 *includes;
__u64 *excludes;
- __u64 events[];
+ __u64 events[] __counted_by(nevents);
};
enum kvm_apicv_inhibit {
r = -EFAULT;
if (copy_from_user(filter->events, user_filter->events,
- sizeof(filter->events[0]) * filter->nevents))
+ flex_array_size(filter, events, filter->nevents)))
goto cleanup;
r = prepare_filter_lists(filter);