cdc37ca3d0
The VhostUserMsg struct binary representation must match the vhost-user protocol specification since this struct is read from and written to the socket. The VhostUserMsg.request union contains enum fields. Enum binary representation is implementation-defined according to the C standard and it is unportable to make assumptions about the representation: 6.7.2.2 Enumeration specifiers ... Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration. Additionally, librte_vhost relies on the enum type being unsigned when validating untrusted inputs: if (ret <= 0 || msg.request.master >= VHOST_USER_MAX) { If msg.request.master is signed then negative values pass this check! Even if we assume gcc on x86_64 (SysV amd64 ABI) and don't care about portability, the actual enum constants still affect the final type. For example, if we add a negative constant then its type changes to signed int: typedef enum VhostUserRequest { ... VHOST_USER_INVALID = -1, }; This is very fragile and it's unlikely that anyone changing the code would remember this. A security hole can be introduced accidentally. This patch switches VhostUserMsg.request fields to uint32_t to avoid the portability and potential security issues. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> |
||
---|---|---|
.. | ||
librte_acl | ||
librte_bbdev | ||
librte_bitratestats | ||
librte_cfgfile | ||
librte_cmdline | ||
librte_compat | ||
librte_cryptodev | ||
librte_distributor | ||
librte_eal | ||
librte_efd | ||
librte_ether | ||
librte_eventdev | ||
librte_flow_classify | ||
librte_gro | ||
librte_gso | ||
librte_hash | ||
librte_ip_frag | ||
librte_jobstats | ||
librte_kni | ||
librte_kvargs | ||
librte_latencystats | ||
librte_lpm | ||
librte_mbuf | ||
librte_member | ||
librte_mempool | ||
librte_meter | ||
librte_metrics | ||
librte_net | ||
librte_pci | ||
librte_pdump | ||
librte_pipeline | ||
librte_port | ||
librte_power | ||
librte_rawdev | ||
librte_reorder | ||
librte_ring | ||
librte_sched | ||
librte_security | ||
librte_table | ||
librte_timer | ||
librte_vhost | ||
Makefile | ||
meson.build |