From 78f0b2574a32e4ce982e0aede89358d10695c281 Mon Sep 17 00:00:00 2001 From: Salvatore Bonaccorso Date: Fri, 13 Sep 2019 06:11:19 +0200 Subject: [PATCH] vhost: make sure log_num < in_num (CVE-2019-14835) --- debian/changelog | 3 ++ .../all/vhost-make-sure-log_num-in_num.patch | 54 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 58 insertions(+) create mode 100644 debian/patches/bugfix/all/vhost-make-sure-log_num-in_num.patch diff --git a/debian/changelog b/debian/changelog index a4377e674..f76431682 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,9 @@ linux (4.19.67-2+deb10u1) UNRELEASED; urgency=medium * ALSA: usb-audio: Fix a stack buffer overflow bug in check_input_term (CVE-2019-15118) + [ Salvatore Bonaccorso ] + * vhost: make sure log_num < in_num (CVE-2019-14835) + -- Romain Perier Wed, 28 Aug 2019 13:28:09 +0200 linux (4.19.67-2) buster; urgency=medium diff --git a/debian/patches/bugfix/all/vhost-make-sure-log_num-in_num.patch b/debian/patches/bugfix/all/vhost-make-sure-log_num-in_num.patch new file mode 100644 index 000000000..5681e359a --- /dev/null +++ b/debian/patches/bugfix/all/vhost-make-sure-log_num-in_num.patch @@ -0,0 +1,54 @@ +From: yongduan +Date: Wed, 11 Sep 2019 17:44:24 +0800 +Subject: vhost: make sure log_num < in_num +Origin: https://git.kernel.org/linus/060423bfdee3f8bc6e2c1bac97de24d5415e2bc4 +Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2019-14835 + +The code assumes log_num < in_num everywhere, and that is true as long as +in_num is incremented by descriptor iov count, and log_num by 1. However +this breaks if there's a zero sized descriptor. + +As a result, if a malicious guest creates a vring desc with desc.len = 0, +it may cause the host kernel to crash by overflowing the log array. This +bug can be triggered during the VM migration. + +There's no need to log when desc.len = 0, so just don't increment log_num +in this case. + +Fixes: 3a4d5c94e959 ("vhost_net: a kernel-level virtio server") +Cc: stable@vger.kernel.org +Reviewed-by: Lidong Chen +Signed-off-by: ruippan +Signed-off-by: yongduan +Acked-by: Michael S. Tsirkin +Reviewed-by: Tyler Hicks +Signed-off-by: Michael S. Tsirkin +--- + drivers/vhost/vhost.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c +index 34ea219936e3..acabf20b069e 100644 +--- a/drivers/vhost/vhost.c ++++ b/drivers/vhost/vhost.c +@@ -2180,7 +2180,7 @@ static int get_indirect(struct vhost_virtqueue *vq, + /* If this is an input descriptor, increment that count. */ + if (access == VHOST_ACCESS_WO) { + *in_num += ret; +- if (unlikely(log)) { ++ if (unlikely(log && ret)) { + log[*log_num].addr = vhost64_to_cpu(vq, desc.addr); + log[*log_num].len = vhost32_to_cpu(vq, desc.len); + ++*log_num; +@@ -2321,7 +2321,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq, + /* If this is an input descriptor, + * increment that count. */ + *in_num += ret; +- if (unlikely(log)) { ++ if (unlikely(log && ret)) { + log[*log_num].addr = vhost64_to_cpu(vq, desc.addr); + log[*log_num].len = vhost32_to_cpu(vq, desc.len); + ++*log_num; +-- +2.23.0 + diff --git a/debian/patches/series b/debian/patches/series index 5c987a19b..7137208d9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -164,6 +164,7 @@ debian/ntfs-mark-it-as-broken.patch bugfix/all/netfilter-conntrack-use-consistent-ct-id-hash-calcul.patch bugfix/all/ALSA-usb-audio-Fix-an-OOB-bug-in-parse_audio_mixer_unit.patch bugfix/all/ALSA-usb-audio-Fix-a-stack-buffer-overflow-bug-in-check_input_term.patch +bugfix/all/vhost-make-sure-log_num-in_num.patch # Fix exported symbol versions bugfix/all/module-disable-matching-missing-version-crc.patch