linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost: zero vhost_vsock memory on allocation
@ 2019-03-27  0:56 Vitaly Mayatskikh
  2019-03-27  8:47 ` Michal Hocko
  2019-03-27 16:49 ` Stefan Hajnoczi
  0 siblings, 2 replies; 8+ messages in thread
From: Vitaly Mayatskikh @ 2019-03-27  0:56 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Michal Hocko, linux-kernel

This fixes OOPS when using under-initialized vhost_vsock object.

The code had a combo of kzalloc plus vmalloc as a fallback
initially, but it has been replaced by plain kvmalloc in
commit 6c5ab6511f71 ("mm: support __GFP_REPEAT in kvmalloc_node for >32kB")

OOPS is easy to reproduce with open/ioctl after trashing the RAM.

Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>
---
 drivers/vhost/vsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index bb5fc0e..9e7cb13 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -512,7 +512,7 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file)
 	/* This struct is large and allocation could fail, fall back to vmalloc
 	 * if there is no other way.
 	 */
-	vsock = kvmalloc(sizeof(*vsock), GFP_KERNEL | __GFP_RETRY_MAYFAIL);
+	vsock = kvzalloc(sizeof(*vsock), GFP_KERNEL | __GFP_RETRY_MAYFAIL);
 	if (!vsock)
 		return -ENOMEM;
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-04-05 10:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27  0:56 [PATCH] vhost: zero vhost_vsock memory on allocation Vitaly Mayatskikh
2019-03-27  8:47 ` Michal Hocko
2019-03-27 16:49 ` Stefan Hajnoczi
2019-03-27 17:08   ` Vitaly Mayatskih
2019-03-28 16:36     ` Stefan Hajnoczi
2019-03-28 17:08       ` Vitaly Mayatskih
2019-03-28 17:10         ` [PATCH] vhost/vsock: initialize vhost_vsock->hash Vitaly Mayatskikh
2019-04-05 10:24           ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).