From patchwork Thu Jun 7 14:57:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10452521 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 01A5460146 for ; Thu, 7 Jun 2018 14:57:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E655D2960B for ; Thu, 7 Jun 2018 14:57:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB2F529625; Thu, 7 Jun 2018 14:57:31 +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 852FA2960B for ; Thu, 7 Jun 2018 14:57:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69D6C6B0003; 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 5D7F96B000C; 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 3DCF06B02A6; 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-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id E90106B000C for ; Thu, 7 Jun 2018 10:57:27 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id z20-v6so3582242pgv.17 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=QKH8PoXeHU53llWIDaCCGPfS6h6juRwuJA6oGiO9+VA=; b=r4QC5zcg3D1BRCAC0Pn7ZhRi2zHaaGAUvjVgBZtW03mm2lvCZYo9Q4uT6oHQ8fOcbq qCezQD4igEuIiEOIgWaZ5Mz3CdYP4b2AgFHUXA8+hPSP81akksz9tTqAgEk+nqaBMfnD Jp0QNu2TAze8XwgEs+FOn2uqB+8IcHzO5tiHblRxRZQXkWH+KK020GgzpjUzWU4DTSGn BUR7sQzP8II/uzHE2MlFNWOiJmBQ6oMtY9GPFeqfefZQu2KpaFWAFGph9h4uvfqUM4IM Fie0dHFxUu53n/DoN19fjiJSPFch47GZ7FTImj0n4NNCz/9DH3oDc7wFytmXE6RMbTV2 eBmg== X-Gm-Message-State: APt69E0iKQkT8QBchRF93UcRyxorBdFyDajCOkYAh38mlEbEPsw4wDb6 iVG3Zxd+CnYpZ8DZdmxkkKQiuWOQWEIyhzaw3DehD8YQxPpMaLTD9iKKaUc5JpdiRdWGu49LKec NNt8jXeqhOPqNd0XT9V4ozf+EsF40p9wguTqXAz89hwQZF8r9tYf5JL+SCieEmWNRmw== X-Received: by 2002:a17:902:a416:: with SMTP id p22-v6mr2370007plq.228.1528383447660; Thu, 07 Jun 2018 07:57:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/qVJQswrw9m7GoEnoZSPldbWT02xYZLC4U//ldxY+EvWnnudoiHR7cGLt/sgmRYBNubkZ X-Received: by 2002:a17:902:a416:: with SMTP id p22-v6mr2369954plq.228.1528383446667; 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=IpVC4goADIB1TLaUa80HShS/BwDEYLIvVMkKmVq2UH1w6bHl9Uu+DGObNf08dKx7tN YrIwYy1V4+yol7dtfWQk2rAy3fYPq69Omsy799qWlbcjGBp3xmkQeQYHhBNNXq637oUe Mr1uqXu6681gf/fguDMwE0qeSEV9aYacVeFn/jbOY11bPKVeEuSamLlVEKcd82R/Q2Vs lZADetTASPybYcqXF7zzQJDXgfA+4OWiTqL/F8rjI/WDCrCuyix2UFZ6bROxnskx+/AN +ChUV91UvIXTT2iTebSqAapDL3hhS+Y+OIWccSYxB/XF712eMHwT7ArmFGUa75oeTXSX GQyg== 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=QKH8PoXeHU53llWIDaCCGPfS6h6juRwuJA6oGiO9+VA=; b=TWiO6j7nZEwIGPhd+KUvDvjm0CJCY0kgHf2oZy9KScR250HgS1niwoWfPYYnVQfDHT zUulyOYY9z86LbAflFPBc7DdTqUuVQuVEUnmt9OX+g2tBToh5FgIM634+Ltgty7PAl0M aIRopKCumg82+gwTc5QWPSCrlR0lG0LkOxjeV+Y1dtFY8GkpYzcpED35i+lqbLn2dsKc BZNZfYL9bg/Fhz9RN9+P1lrxmVrvKtfDPYarutdtO9EXmKcan9lmu3KuYpTTzk8jvRfd DlzkhtnfwEeLkJLI5iqic8yZR82BgDEjOSUalYg0AchOc5uiLOHZbYyrxHKPasQMElBr /ziQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=LH8PnK+E; 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 i33-v6si52978553pld.546.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=LH8PnK+E; 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=QKH8PoXeHU53llWIDaCCGPfS6h6juRwuJA6oGiO9+VA=; b=LH8PnK+EydDfWdvK5in24KG2F SuUT1u1HDEFK8ymlHYbPANavlfMfWjU2VWlPXmRY6Bk7/Ke64RPgBlcClGsiGosLcIMMl1FakL0ZG Ki7LMNPmy2J32O99iDB1QYjIeW2Q0XTv3cWJiFtRixwSKH8bsRwHvVBySDtDcMLO2SttcZQoPzsD7 AZ3NGwxxdt54q+GCkhLyJfuyo5h31P2yMLYY4ZWHrwfoWTbUGbmb68OOc08sSAXn+u3qr/akdwf5g KY5m6rfbYdWqaPGvTJy5MLk2qNcSwdZKkCo5T+WPSWFpgkSCGB4xxABSGdTPc1qjt8naECXcBwNsj 7hGc+uXeg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQwLs-0005ti-Cw; Thu, 07 Jun 2018 14:57:24 +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 1/6] Convert virtio_console to struct_size Date: Thu, 7 Jun 2018 07:57:15 -0700 Message-Id: <20180607145720.22590-2-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/char/virtio_console.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 21085515814f..4bf7c06c2343 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size * Allocate buffer and the sg list. The sg list array is allocated * directly after the port_buffer struct. */ - buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, - GFP_KERNEL); + buf = kmalloc(struct_size(buf, sg, pages), GFP_KERNEL); if (!buf) goto fail;