fs/fuse kio: set NULL to stat->kio_stat in failure case

Submitted by Pavel Butsykin on July 4, 2019, 9:29 a.m.

Details

Message ID 20190704092941.24418-1-pbutsykin@virtuozzo.com
State New
Series "fs/fuse kio: set NULL to stat->kio_stat in failure case"
Headers show

Commit Message

Pavel Butsykin July 4, 2019, 9:29 a.m.
At the beginning of the initialization, 'stat' struct may contain garbage, so
if pcs_fuse_stat_init() fails before stat->kio_stat field is initialized, there
may be garbage in stat->kio_stat, which can lead to a crash due to an invalid
address access.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 fs/fuse/kio/pcs/fuse_stat.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/fuse_stat.c b/fs/fuse/kio/pcs/fuse_stat.c
index 580f655e7567..8bef965f8037 100644
--- a/fs/fuse/kio/pcs/fuse_stat.c
+++ b/fs/fuse/kio/pcs/fuse_stat.c
@@ -842,6 +842,7 @@  void pcs_fuse_stat_init(struct pcs_fuse_stat *stat)
 fail2:
 	pcs_fuse_io_stat_free(&stat->io);
 fail1:
+	stat->kio_stat = NULL;
 	mutex_unlock(&fuse_mutex);
 }