From: Paolo Abeni <pabeni@redhat.com>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org,
"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Jason Wang" <jasowang@redhat.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Yuri Benditovich" <yuri.benditovich@daynix.com>,
"Akihiko Odaki" <akihiko.odaki@daynix.com>,
"Jonathan Corbet" <corbet@lwn.net>,
kvm@vger.kernel.org
Subject: Re: [PATCH v5 net-next 4/9] vhost-net: allow configuring extended features
Date: Mon, 23 Jun 2025 12:58:36 +0200 [thread overview]
Message-ID: <61d10c9b-4f1b-46f6-9a52-1de9aa193a7b@redhat.com> (raw)
In-Reply-To: <20250622160221.GH71935@horms.kernel.org>
On 6/22/25 6:02 PM, Simon Horman wrote:
> On Fri, Jun 20, 2025 at 07:39:48PM +0200, Paolo Abeni wrote:
>> Use the extended feature type for 'acked_features' and implement
>> two new ioctls operation allowing the user-space to set/query an
>> unbounded amount of features.
>>
>> The actual number of processed features is limited by VIRTIO_FEATURES_MAX
>> and attempts to set features above such limit fail with
>> EOPNOTSUPP.
>>
>> Note that: the legacy ioctls implicitly truncate the negotiated
>> features to the lower 64 bits range and the 'acked_backend_features'
>> field don't need conversion, as the only negotiated feature there
>> is in the low 64 bit range.
>>
>> Acked-by: Jason Wang <jasowang@redhat.com>
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> ...
>
>> + case VHOST_GET_FEATURES_ARRAY:
>> + if (get_user(count, featurep))
>> + return -EFAULT;
>> +
>> + /* Copy the net features, up to the user-provided buffer size */
>> + argp += sizeof(u64);
>> + copied = min(count, VIRTIO_FEATURES_DWORDS);
>> + if (copy_to_user(argp, vhost_net_features,
>> + copied * sizeof(u64)))
>> + return -EFAULT;
>> +
>> + /* Zero the trailing space provided by user-space, if any */
>> + if (clear_user(argp, (count - copied) * sizeof(u64)))
>
> Hi Paolo,
>
> Smatch warns to "check for integer overflow 'count'" on the line above.
>
> Perhaps it is wrong. Or my analyais is. But it seems to me that an overflow
> could occur if count is very large, say such that (count - copied) is more
> than 2^64 / 8. As then (count - copied) * sizeof(u64) would overflow 64
> bits.
>
> By the same reasoning this could overflow 32 bits on systems where an
> unsigned long, type type of the 2nd parameter of clear_user, is 32 bits.
I think you and smatch are right. I'll use size_mul() in the next
iteration. I'll wait a little more before posting it to possibly allow
for more reviews.
Thanks,
Paolo
next prev parent reply other threads:[~2025-06-23 10:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 17:39 [PATCH v5 net-next 0/9] virtio: introduce GSO over UDP tunnel Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 1/9] scripts/kernel_doc.py: properly handle VIRTIO_DECLARE_FEATURES Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 2/9] virtio: introduce extended features Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 3/9] virtio_pci_modern: allow configuring " Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 4/9] vhost-net: " Paolo Abeni
2025-06-22 16:02 ` Simon Horman
2025-06-23 10:58 ` Paolo Abeni [this message]
2025-06-24 14:40 ` Dan Carpenter
2025-06-20 17:39 ` [PATCH v5 net-next 5/9] virtio_net: add supports for extended offloads Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 6/9] net: implement virtio helpers to handle UDP GSO tunneling Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 7/9] virtio_net: enable gso over UDP tunnel support Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 8/9] tun: " Paolo Abeni
2025-06-20 17:39 ` [PATCH v5 net-next 9/9] vhost/net: " Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=61d10c9b-4f1b-46f6-9a52-1de9aa193a7b@redhat.com \
--to=pabeni@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=horms@kernel.org \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).