Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4812290img; Tue, 26 Mar 2019 17:58:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNvu+VrwhGgVoDaiUB2oQ/7mP6MUqvGddK18Om7YYuad5Jo2LpKKi3swT03nzl5DfqLQy+ X-Received: by 2002:a17:902:e684:: with SMTP id cn4mr11147828plb.71.1553648338510; Tue, 26 Mar 2019 17:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553648338; cv=none; d=google.com; s=arc-20160816; b=JFafal6akQ1JqRe0w0mjyM5CzR5mMcYWMRUCH0NiW0YYRSxXS+S1YADegDZLo1RxQt eBRKD2GjKihIgZHrSW1LF0EALfh/begFCl5/Q78LGyC9Tx1pdZ6CMQ174W+2/L1st0GK orI5s7c/Jl5ExMPEvhQ25TqG7SyiM1BvGp0F8MJ7A3rwudM5D+UZNpgxKDjvgS8oSn8z LgTm6XT/Mh/sY6tGX+AuePSQaIHhVtsd5j5VEmdPR188LuDbKZSlVq/nu1UO5rhj8jn3 pkadLC+imXq/jkG5cKzXca8SFJzJ/mpnIM0S99I5fSPTnl4+OoWDU667PtoyggFU7fHY 1hlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=A9mw3YqoaCKpOM09oY8exgctLd5NEjv3YH6a6QF+6us=; b=0J+0rbxECVZe++KBKrC32c2o5aKwr6FnYhrmbyW1RNZmCfKwmkDLgdXlG9hrsd6TCa xNCmwkcEGDbQDNyrNMqhQTL0UfX7R4ACHdzAFckBEsGYrRJ2PoQXdOZzO1t+I1jDIRK6 3Y9KQmzOz+20/ELS93v6urmqBAPXu7XyjxC7Aupv0eWBCcel7AlsHii+FEsHXEbPKr/5 cxNsfvEqHBEJprHUArVKFAiyNAhSIETVZFQI1thgDv5x+GT65ar516cIQI4EXttwH51s inBFpxZhnLUup9QFWMVAhbV4rPNAWj8RkUzEWXOcpOhOXu46e6AiZ+dXpwlrvas7wISS U0YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e1h8ErLq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si16542093pgv.396.2019.03.26.17.58.43; Tue, 26 Mar 2019 17:58:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e1h8ErLq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732277AbfC0A4a (ORCPT + 99 others); Tue, 26 Mar 2019 20:56:30 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:43359 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfC0A43 (ORCPT ); Tue, 26 Mar 2019 20:56:29 -0400 Received: by mail-qk1-f194.google.com with SMTP id c20so8891721qkc.10 for ; Tue, 26 Mar 2019 17:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=A9mw3YqoaCKpOM09oY8exgctLd5NEjv3YH6a6QF+6us=; b=e1h8ErLq3CDYegPt5vXNcPOC6+WBOUrro9ITrUbB2okDZ+jCvVQJU5yCPZeGZekdtq rBXnS7nRDkE/wYDW2gGx5JxmDEo+0WWRyh7d668NysMsI2Tc8FKIGPTALgNs//V4Mstz 7jbmsdBEYS02jPSmQFm1ALTYbntv2Z/gq9bmtFxYXYXro94ozql+AoIYYAR8szZf1kxt AQx03evkBlo0TYhcsu3iHbdud6LiHdqJ8ZVvzK/vIW+SS4SYMy0xZq8RpKkAX+C9Bf8w 1iOJGv2fRh67mYGo2iOxvymUYI4RzJdPYk9vHqX8CnBHPPRMjprpWpHaOsf1RQwVen+k zTUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=A9mw3YqoaCKpOM09oY8exgctLd5NEjv3YH6a6QF+6us=; b=EX92oq+HfjFKvmLpTTI++RusuqjtcMY7rfiqotbn65ebCEnzy5XqcjCO/BOpKPHsP+ s/Iv/gaG2Z+oLhRmbGf+ObFI/4aw4e7cswTo0do/5JOO/xvt8GBsr7fomG/Xs/edilJ1 lSbUgCIQddx9SmP6RIiS+hPlR8H3yf6xLyhJdIeCV+DIfUMru8SGTnaEiHvZGf+TWbQH 0siSgZMP42xbOTB1Yhzu7/n/Ng+8o3kFdlgBgTyCAXZoIH5Vn3YEzOfZW32rOrtmwA4N rOde8ch4EyaY6rdSBelknvLs3mXwrawhDibTpYUP2Uw8NPNcAufGQ0bIXTtfltiOAu5X DNmg== X-Gm-Message-State: APjAAAVbgKPs/PiKx9p7BFESq8dmyqWByx0mSHZVESL4CTDrVQ2+SA/Z HvldJxxwaQjnCmxK+lMNz5U4j3i0 X-Received: by 2002:ae9:e313:: with SMTP id v19mr25888259qkf.153.1553648188939; Tue, 26 Mar 2019 17:56:28 -0700 (PDT) Received: from gravicappa.gravicappa.info (pool-72-74-132-209.bstnma.fios.verizon.net. [72.74.132.209]) by smtp.gmail.com with ESMTPSA id e4sm1533229qkg.6.2019.03.26.17.56.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 17:56:28 -0700 (PDT) From: Vitaly Mayatskikh To: Stefan Hajnoczi Cc: Michal Hocko , linux-kernel@vger.kernel.org Subject: [PATCH] vhost: zero vhost_vsock memory on allocation Date: Tue, 26 Mar 2019 20:56:14 -0400 Message-Id: <1553648174-24913-1-git-send-email-v.mayatskih@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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