Jacob Keller e4be66e5f3 vhost: use struct_size and size_add to compute flex array sizes
The vhost_get_avail_size and vhost_get_used_size functions compute the size
of structures with flexible array members with an additional 2 bytes if the
VIRTIO_RING_F_EVENT_IDX feature flag is set. Convert these functions to use
struct_size() and size_add() instead of coding the calculation by hand.

This ensures that the calculations will saturate at SIZE_MAX rather than
overflowing.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: kvm@vger.kernel.org
Message-Id: <20230227214127.3678392-1-jacob.e.keller@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2023-04-21 03:02:29 -04:00
..
2023-04-14 15:15:32 +02:00
2023-03-16 16:54:38 +09:00
2023-04-10 13:35:54 -07:00
2023-04-13 15:21:56 -07:00
2023-03-21 10:47:06 -07:00
2023-02-25 09:19:23 -08:00
2023-02-24 12:58:55 -08:00
2023-03-24 15:38:13 -07:00
2023-02-24 12:58:55 -08:00
2023-04-07 13:53:16 -07:00
2023-04-13 20:47:58 +02:00
2023-04-12 17:26:00 -07:00
2023-02-24 12:58:55 -08:00
2023-04-15 11:06:49 -07:00
2023-02-28 16:05:01 -08:00
2023-02-21 12:13:58 -08:00
2023-03-28 13:30:55 +02:00
2023-04-01 14:09:51 -07:00
2023-02-24 12:58:55 -08:00
2023-02-25 11:30:21 -08:00
2023-02-23 15:09:31 -08:00
2023-02-25 11:00:06 -08:00
2023-03-31 12:35:03 -07:00
2023-02-27 09:47:26 -08:00
2023-02-25 11:48:02 -08:00
2023-04-13 15:21:56 -07:00
2023-04-11 11:59:49 -07:00
2023-02-24 12:58:55 -08:00
2023-02-27 10:04:49 -08:00
2023-04-06 10:13:23 -07:00
2023-03-24 19:17:22 -07:00
2023-03-27 01:42:01 +01:00
2023-02-27 10:04:49 -08:00
2023-02-26 12:10:28 -08:00
2023-03-03 09:15:50 -08:00
2023-04-15 10:49:47 -07:00
2023-03-01 09:44:22 -08:00
2023-02-24 17:29:52 -08:00
2023-04-13 15:21:56 -07:00
2023-03-09 10:06:28 +01:00
2023-04-08 12:17:46 -07:00
2023-04-13 20:47:58 +02:00
2023-02-25 11:48:02 -08:00
2023-03-02 11:12:01 -08:00
2023-03-17 10:45:49 -07:00
2023-02-26 11:53:25 -08:00