]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
vhost_net: validate sock before trying to put its fd
authorJason Wang <jasowang@redhat.com>
Thu, 21 Jun 2018 05:11:31 +0000 (13:11 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Feb 2019 04:53:01 +0000 (04:53 +0000)
commitd4d0e8794afde659fb790a74cd672a064e1a6627
treefa2e85c9515e0d38978f0dae14821892760b4c2a
parent2f4b3c86fa7c092620d3c6b4628965662590fec2
vhost_net: validate sock before trying to put its fd

BugLink: http://bugs.launchpad.net/bugs/1811877
[ Upstream commit b8f1f65882f07913157c44673af7ec0b308d03eb ]

Sock will be NULL if we pass -1 to vhost_net_set_backend(), but when
we meet errors during ubuf allocation, the code does not check for
NULL before calling sockfd_put(), this will lead NULL
dereferencing. Fixing by checking sock pointer before.

Fixes: bab632d69ee4 ("vhost: vhost TX zero-copy support")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/vhost/net.c