yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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