From patchwork Thu Jun 7 14:57:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10452549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 221B160234 for ; Thu, 7 Jun 2018 14:58:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1445F29608 for ; Thu, 7 Jun 2018 14:58:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08C7729621; Thu, 7 Jun 2018 14:58:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 438A629608 for ; Thu, 7 Jun 2018 14:58:25 +0000 (UTC) Received: (qmail 5887 invoked by uid 550); 7 Jun 2018 14:57:46 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 5526 invoked from network); 7 Jun 2018 14:57:39 -0000 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==; 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> X-Virus-Scanned: ClamAV using ClamSMTP 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;