]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/CVE-2016-9914-9pfs-add-cleanup-operation-in-FileOperations.patch
import stable-4 build files
[pve-qemu.git] / debian / patches / extra / CVE-2016-9914-9pfs-add-cleanup-operation-in-FileOperations.patch
CommitLineData
95259824
WB
1From f2ef9ae2a512fca1df0d56c226adc24ddf002b8b Mon Sep 17 00:00:00 2001
2From: Li Qiang <liq3ea@gmail.com>
3Date: Wed, 23 Nov 2016 13:53:34 +0100
4Subject: [PATCH 07/12] 9pfs: add cleanup operation in FileOperations
5
6Currently, the backend of VirtFS doesn't have a cleanup
7function. This will lead resource leak issues if the backed
8driver allocates resources. This patch addresses this issue.
9
10Signed-off-by: Li Qiang <liq3ea@gmail.com>
11Reviewed-by: Greg Kurz <groug@kaod.org>
12Signed-off-by: Greg Kurz <groug@kaod.org>
13---
14 fsdev/file-op-9p.h | 1 +
15 hw/9pfs/9p.c | 6 ++++++
16 2 files changed, 7 insertions(+)
17
18diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
19index 6db9fea..a56dc84 100644
20--- a/fsdev/file-op-9p.h
21+++ b/fsdev/file-op-9p.h
22@@ -100,6 +100,7 @@ struct FileOperations
23 {
24 int (*parse_opts)(QemuOpts *, struct FsDriverEntry *);
25 int (*init)(struct FsContext *);
26+ void (*cleanup)(struct FsContext *);
27 int (*lstat)(FsContext *, V9fsPath *, struct stat *);
28 ssize_t (*readlink)(FsContext *, V9fsPath *, char *, size_t);
29 int (*chmod)(FsContext *, V9fsPath *, FsCred *);
30diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
31index ced7b4c..f2a90d4 100644
32--- a/hw/9pfs/9p.c
33+++ b/hw/9pfs/9p.c
34@@ -3490,6 +3490,9 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
35 rc = 0;
36 out:
37 if (rc) {
38+ if (s->ops->cleanup && s->ctx.private) {
39+ s->ops->cleanup(&s->ctx);
40+ }
41 g_free(s->tag);
42 g_free(s->ctx.fs_root);
43 v9fs_path_free(&path);
44@@ -3499,6 +3502,9 @@ out:
45
46 void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
47 {
48+ if (s->ops->cleanup) {
49+ s->ops->cleanup(&s->ctx);
50+ }
51 g_free(s->tag);
52 g_free(s->ctx.fs_root);
53 }
54--
552.1.4
56