[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <41a290a5-19ef-40e7-ad21-f3f552f58845@daynix.com>
Date: Fri, 20 Jun 2025 14:59:24 +0900
From: Akihiko Odaki <akihiko.odaki@...nix.com>
To: Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org
Cc: Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Jason Wang <jasowang@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, "Michael S. Tsirkin" <mst@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Eugenio Pérez
<eperezma@...hat.com>, Yuri Benditovich <yuri.benditovich@...nix.com>
Subject: Re: [PATCH v4 net-next 3/8] vhost-net: allow configuring extended
features
On 2025/06/20 5:13, Paolo Abeni wrote:
> On 6/19/25 5:00 PM, Akihiko Odaki wrote:
>> On 2025/06/18 1:12, Paolo Abeni wrote:
>>> +
>>> + /* 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
Powered by blists - more mailing lists