[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/9] tools/virtiofsd/passthrough_ll: Fix double close()
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 5/9] tools/virtiofsd/passthrough_ll: Fix double close() |
Date: |
Wed, 25 Mar 2020 13:16:28 +0000 |
From: Philippe Mathieu-Daudé <address@hidden>
On success, the fdopendir() call closes fd. Later on the error
path we try to close an already-closed fd. This can lead to
use-after-free. Fix by only closing the fd if the fdopendir()
call failed.
Cc: address@hidden
Fixes: b39bce121b (add dirp_map to hide lo_dirp pointers)
Reported-by: Coverity (CID 1421933 USE_AFTER_FREE)
Suggested-by: Peter Maydell <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/passthrough_ll.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 4f259aac70..4c35c95b25 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -1520,8 +1520,7 @@ out_err:
if (d) {
if (d->dp) {
closedir(d->dp);
- }
- if (fd != -1) {
+ } else if (fd != -1) {
close(fd);
}
free(d);
--
2.25.1
- [PULL 0/9] migration queue, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 2/9] xbzrle: update xbzrle doc, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 1/9] hmp-cmd: fix a missing_break warning, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 3/9] tests/migration: Reduce autoconverge initial bandwidth, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 4/9] hmp/vnc: Fix info vnc list leak, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 5/9] tools/virtiofsd/passthrough_ll: Fix double close(),
Dr. David Alan Gilbert (git) <=
- [PULL 6/9] vl.c: fix migration failure for 3.1 and older machine types, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 7/9] migration/colo: fix use after free of local_err, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 9/9] migration: use "" instead of (null) for tls-authz, Dr. David Alan Gilbert (git), 2020/03/25
- [PULL 8/9] migration/ram: fix use after free of local_err, Dr. David Alan Gilbert (git), 2020/03/25
- Re: [PULL 0/9] migration queue, Peter Maydell, 2020/03/26