Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2304263imm; Thu, 7 Jun 2018 08:28:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLvphkMWdqgMHSgWzXshix4jYGUav6d75cYOE3v481fQOJQDAeJ13h+M22M3mzI19hGhIfZ X-Received: by 2002:a17:902:380c:: with SMTP id l12-v6mr2544131plc.19.1528385339170; Thu, 07 Jun 2018 08:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528385339; cv=none; d=google.com; s=arc-20160816; b=xrKyZUeWxzJ/4xXxgfAx16+bEGx88FNPmuuxWFuwsVrfPnVBq4LqMiHA7cejRmfm05 GIws/31W4W4UZ17nhP1p3CFZ94xaaX2hEluDcJy8n1sjn+GBnGupkXlSDcIq1sanWUTi WHNZMcUUNFl5wkZFfnkoQOQQu+GKTqcva8voqWTh+O1WxtiTcde/xfJh2ny44L0jbZ/k yZmc/3qFpN0/h31bAnSq0Xi+p1ma4Dlvhd8k2Gpz+pScwaVDB/QoIDeoSwAfpUXBU4f8 F4aH0WPITbpM/U8O64Blc4nVdSXHo603e4KXc+a1hwavEVVdFVVythX55iSJ360p6Y0e 6uFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dsa6ThT7gJQj3Ut/gWAzUKn6yLlkNfnBJLsuPvCngig=; b=EX6GfqHH7n6CYcwaS15W+zUO9bBNYDVzOpBys1f3Iuxf6/+qV0yEF8cVynLV7kPVC0 JTlD/W3xfjtj7m5nZ+62WE7PgUi++N+VYvYGWedudVvYZIAo9LhZoGHFkOqUWmDYr5wx cllG8v1AsBo+LP1dABoC5EE/ERftGFbRtsToYnjlL3YfrRHczmnqAGJ/4EGhrI1lyKwb 2Uuhyvajx8Y2HZL0twU5m5HnvXEZiVgWAhxo9loA3+Q6tqYbeERFsaNKqm+jOOZ0NdDI eDAxeslhmjpug/kbGRhKbIwoev2SC8plToJGPxFrxkZghyd2vMU4puCByo6aTSd6AIpK Ub4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sOgQKHIB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26-v6si13420737pfd.253.2018.06.07.08.28.45; Thu, 07 Jun 2018 08:28:59 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sOgQKHIB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753777AbeFGP1a (ORCPT + 99 others); Thu, 7 Jun 2018 11:27:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60214 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933409AbeFGO51 (ORCPT ); Thu, 7 Jun 2018 10:57:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dsa6ThT7gJQj3Ut/gWAzUKn6yLlkNfnBJLsuPvCngig=; b=sOgQKHIBw/iveujMEslcvBZ8W NB/53bpDMlpuIeBlqLkYv/sm0tdyNz+1e5Ew0WwddUtGhwqJeo7h5QEASuSgvV+y+nK0J+wxz4TYi G/6UKnE8tDk/Eglhj/V5TpstkR69Rt4GTJT1aMEABqgyy5vGO/fN9UBupCHZpstcbZ7ZLDJQZKs/U 3IM67p/B+4YQDTDDr4oX3FlNpGu/F6PQ6782NyiaPbwzMP+GA0mpjsAKP7+LJyd8cW+selugppQMs 6xteMiMa5qXeRlVwpv14OXFvR4hjh8kbIUvFywS1P/GLsPrPTUPjDPfsMpkqybeQhzhHvb0BM7Mh/ aHyYbr35w==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQwLt-0005tx-9b; Thu, 07 Jun 2018 14:57:25 +0000 From: Matthew Wilcox To: Kees Cook Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH 4/6] Convert vhost to struct_size Date: Thu, 7 Jun 2018 07:57:18 -0700 Message-Id: <20180607145720.22590-5-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180607145720.22590-1-willy@infradead.org> References: <20180607145720.22590-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox Signed-off-by: Matthew Wilcox --- drivers/vhost/vhost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 895eaa25807c..f9bce818da11 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1286,7 +1286,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) return -EOPNOTSUPP; if (mem.nregions > max_mem_regions) return -E2BIG; - newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL); + newmem = kvzalloc(struct_size(newmem, regions, mem.nregions), + GFP_KERNEL); if (!newmem) return -ENOMEM; -- 2.17.0