yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-tools-virtiofsd-passthrough_ll-Fix-double-close.patch

77c23f
From 8ce8ccc2a22798a89bac06a37427c3a3cea91a62 Mon Sep 17 00:00:00 2001
77c23f
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
77c23f
Date: Tue, 5 May 2020 16:35:54 +0100
77c23f
Subject: [PATCH 3/9] tools/virtiofsd/passthrough_ll: Fix double close()
77c23f
MIME-Version: 1.0
77c23f
Content-Type: text/plain; charset=UTF-8
77c23f
Content-Transfer-Encoding: 8bit
77c23f
77c23f
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
77c23f
Message-id: <20200505163600.22956-2-dgilbert@redhat.com>
77c23f
Patchwork-id: 96269
77c23f
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 1/7] tools/virtiofsd/passthrough_ll: Fix double close()
77c23f
Bugzilla: 1817445
77c23f
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
77c23f
RH-Acked-by: Max Reitz <mreitz@redhat.com>
77c23f
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
77c23f
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
77c23f
77c23f
From: Philippe Mathieu-Daudé <philmd@redhat.com>
77c23f
77c23f
On success, the fdopendir() call closes fd. Later on the error
77c23f
path we try to close an already-closed fd. This can lead to
77c23f
use-after-free. Fix by only closing the fd if the fdopendir()
77c23f
call failed.
77c23f
77c23f
Cc: qemu-stable@nongnu.org
77c23f
Fixes: b39bce121b (add dirp_map to hide lo_dirp pointers)
77c23f
Reported-by: Coverity (CID 1421933 USE_AFTER_FREE)
77c23f
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
77c23f
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
77c23f
Message-Id: <20200321120654.7985-1-philmd@redhat.com>
77c23f
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
77c23f
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
77c23f
(cherry picked from commit e1cd92d95cd4f97b3464c4e08cd5b22bf5ca05cb)
77c23f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
77c23f
---
77c23f
 tools/virtiofsd/passthrough_ll.c | 3 +--
77c23f
 1 file changed, 1 insertion(+), 2 deletions(-)
77c23f
77c23f
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
77c23f
index 9cba3f1..50ff672 100644
77c23f
--- a/tools/virtiofsd/passthrough_ll.c
77c23f
+++ b/tools/virtiofsd/passthrough_ll.c
77c23f
@@ -1524,8 +1524,7 @@ out_err:
77c23f
     if (d) {
77c23f
         if (d->dp) {
77c23f
             closedir(d->dp);
77c23f
-        }
77c23f
-        if (fd != -1) {
77c23f
+        } else if (fd != -1) {
77c23f
             close(fd);
77c23f
         }
77c23f
         free(d);
77c23f
-- 
77c23f
1.8.3.1
77c23f