From a446b92e9b03d793503071392bbb6d436116e956 Mon Sep 17 00:00:00 2001 From: Tian Tao Date: Wed, 11 Nov 2020 09:14:48 +0800 Subject: [PATCH] vhost_vdpa: switch to vmemdup_user() mainline inclusion from mainline-v5.11-rc1 commit 0ab4b8901a8edda4fd1c2aded36192566d89353f category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5WXCZ CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ab4b8901a8edda4fd1c2aded36192566d89353f ---------------------------------------------------------------------- Replace opencoded alloc and copy with vmemdup_user() Signed-off-by: Tian Tao Link: https://lore.kernel.org/r/1605057288-60400-1-git-send-email-tiantao6@hisilicon.com Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella Signed-off-by: Pengyuan Zhao --- drivers/vhost/vdpa.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 02ae9c4a571c..2e65e4dcf6de 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -248,14 +248,10 @@ static long vhost_vdpa_set_config(struct vhost_vdpa *v, return -EFAULT; if (vhost_vdpa_config_validate(v, &config)) return -EINVAL; - buf = kvzalloc(config.len, GFP_KERNEL); - if (!buf) - return -ENOMEM; - if (copy_from_user(buf, c->buf, config.len)) { - kvfree(buf); - return -EFAULT; - } + buf = vmemdup_user(c->buf, config.len); + if (IS_ERR(buf)) + return PTR_ERR(buf); ops->set_config(vdpa, config.off, buf, config.len); -- GitLab