Commit b8845cd4 authored by Will Deacon's avatar Will Deacon Committed by Isaac Manjarres
Browse files

FROMGIT: vhost/vsock: Avoid allocating arbitrarily-sized SKBs



vhost_vsock_alloc_skb() returns NULL for packets advertising a length
larger than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE in the packet header. However,
this is only checked once the SKB has been allocated and, if the length
in the packet header is zero, the SKB may not be freed immediately.

Hoist the size check before the SKB allocation so that an iovec larger
than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + the header size is rejected
outright. The subsequent check on the length field in the header can
then simply check that the allocated SKB is indeed large enough to hold
the packet.

Cc: <stable@vger.kernel.org>
Fixes: 71dc9ec9 ("virtio/vsock: replace virtio_vsock_pkt with sk_buff")
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
Message-Id: <20250717090116.11987-2-will@kernel.org>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
(cherry picked from commit c76f3c4364fe523cd2782269eab92529c86217aa
 git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

 vhost)
Bug: 421244320
Signed-off-by: default avatarWill Deacon <willdeacon@google.com>
Change-Id: Ie904fdc2790aadb12c9775e6ae3ca7a74fa0cc39
parent 45954b1a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment