Thread (39 messages) 39 messages, 7 authors, 2025-06-24

Re: [PATCH v4 net-next 3/8] vhost-net: allow configuring extended features

From: Akihiko Odaki <hidden>
Date: 2025-06-20 05:59:28

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help