On 2025/06/20 5:13, Paolo Abeni wrote:
On 6/19/25 5:00 PM, Akihiko Odaki wrote:
quoted
On 2025/06/18 1:12, Paolo Abeni wrote:
quoted
+
+ /* Any feature specified by user-space above VIRTIO_FEATURES_MAX is
+ * not supported by definition.
+ */
+ for (; i < count; ++i) {
+ if (copy_from_user(&features, argp, sizeof(u64)))
get_user() is a simpler alternative.
That would require an explicit cast of 'argp' to a suitable pointer
type, which is IMHO uglier. I prefer sticking with copy_from_user().
Side note: there is a bug in this loop, as it lacks the needed increment
of the src pointer at every iteration.
A pointer casted to u64 __user * will make the pointer usage a bit simpler.
For example, initialize featurep as follows:
featurep = (u64 __user *)argp + 1; /* skipping count */
...and you can get the i-th element with:
get_user(features, featurep + i)
You don't need sizeof(u64) this way.
Regards,
Akihiko Odaki