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: 10452523 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 935F260234 for ; Thu, 7 Jun 2018 14:57:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83B972960B for ; Thu, 7 Jun 2018 14:57:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 787C329625; Thu, 7 Jun 2018 14:57:34 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 227932960B for ; Thu, 7 Jun 2018 14:57:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2F556B000C; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 826276B02A2; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5636A6B02A3; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 029776B0003 for ; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id x2-v6so5544941plv.0 for ; Thu, 07 Jun 2018 07:57:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=dsa6ThT7gJQj3Ut/gWAzUKn6yLlkNfnBJLsuPvCngig=; b=KZ7xJm/+6SyKUJtaEn2Be0hwSYshGckPWmWrAAbuHdAGPfUwaozaKkkFl9uHRbS2DS O+HcY8FNeTbxIaahBXhVzH5VcYM9h+j/JPyCiKEdqoxor/zhXrfU6rjy7ooAIK2/7GRF /u7hWpUN/odtueZH9RXnIBl9avyR2N4wKI++W40r3mOzXPtFccXMTgqUP9tLdwCrLdTk m9xS/mDpxy8VMkqLNCZO+GDgdDbZZSuoK9zbAH2p50cKdypPOAzy0HqJ9dB7AOQGFRLm L10aZbUcipmbUZHMf2+SSLuKdzjp3tXGomYgM0j9KV2/RsA0t/J7iU5bj9hn+W7Sh/B8 NGDg== X-Gm-Message-State: APt69E1iLaRXmp+CYoZCOCDyQCB1Ei1xr9wcc4Ju/JBxSfTGijrMtYgt o36FHR4rZp6xK17B20lB7K9KZ8I1wKfqPktuNkKWdTv7B+1Ox6VNyLqejySZRQMtuZCdMYoOx/Y R5NmYk82g7XN4/n3xfsYZdGsQHcMsZs64S0fAdli/1fVVc0jIKhRA2HPYSfvr9TEnvg== X-Received: by 2002:a63:583:: with SMTP id 125-v6mr1831168pgf.385.1528383447701; Thu, 07 Jun 2018 07:57:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIFlnTwKs6aLBaULEdG+oj7wxcjo5PJZS9cjBqlIKT//+t/MvijcODxyZCx97njfNT/iHCy X-Received: by 2002:a63:583:: with SMTP id 125-v6mr1831125pgf.385.1528383446674; Thu, 07 Jun 2018 07:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383446; cv=none; d=google.com; s=arc-20160816; b=AjbtCJM/GIsCH+cBpyj/BQTRKLcmd8GYK2+TdTaP783G0gsXT9vaInqMcDy9Nuvh2k VBzsQkMXkT4amL5EEYrBkGjIoIh26fEfJ4tT6TOM8rW4rKBaq4FidoJPadbi1MHaz3no rVm7kViBetzCW5LT0bA5INzfcHf/sIPKuqub6w2wWUnYYSnBQ93Max8R9Q8S1k1bCrLL rbtumxVPYDGT6t3HSPv82El6NEl9aW6V01+iOZIcjECs02ZXVAkn4Fh7JlmAf1ta8RjX 2kpcaDPWiK1LKgukESrzVHLvKsWfi8hYqcNOdhgS4eGPD7YdQpAEO9UjN3Zs6yKqnghb NsmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dsa6ThT7gJQj3Ut/gWAzUKn6yLlkNfnBJLsuPvCngig=; b=F9T8nSKQ0xSQ4soZSrRXWGQ/KMjlN1Nu/lweQhubsfNtDQxcCi60HwQTXx1krp58cU TGY/hJlMEfs8nMD1PGhFb8PcOIvX5MLDmGMYr9VJFTT1/HPpEfkn/qBMxXQyFkoc1vFM ZOHkm6uUWrL3ThJBMVa855CtPd9W84POy6PmFXqXr3ekcd/J419tLyT2fHTyx8V4Qd3z kIF0UPXb79qv/iLH1RckPvZXk95OXntB4/sE6+H05Kfws/Z++pKkqQ27g2rl4jjED04+ M7nncnT/zfjDqwS2NdyMIhzqtPrHxMYV3mHfPYwBDotwuri6MdLmmYk8sBopWkorNZuj lCAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=sOgQKHIB; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a29-v6si11260712pgn.423.2018.06.07.07.57.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jun 2018 07:57:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=sOgQKHIB; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;