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: 10452553 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 456B760146 for ; Thu, 7 Jun 2018 14:58:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3799D29621 for ; Thu, 7 Jun 2018 14:58:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C24A29628; Thu, 7 Jun 2018 14:58: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=-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 6952B29621 for ; Thu, 7 Jun 2018 14:58:33 +0000 (UTC) Received: (qmail 5932 invoked by uid 550); 7 Jun 2018 14:57:47 -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 5527 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=QKH8PoXeHU53llWIDaCCGPfS6h6juRwuJA6oGiO9+VA=; b=LH8PnK+EydDfWdvK5in24KG2F SuUT1u1HDEFK8ymlHYbPANavlfMfWjU2VWlPXmRY6Bk7/Ke64RPgBlcClGsiGosLcIMMl1FakL0ZG Ki7LMNPmy2J32O99iDB1QYjIeW2Q0XTv3cWJiFtRixwSKH8bsRwHvVBySDtDcMLO2SttcZQoPzsD7 AZ3NGwxxdt54q+GCkhLyJfuyo5h31P2yMLYY4ZWHrwfoWTbUGbmb68OOc08sSAXn+u3qr/akdwf5g KY5m6rfbYdWqaPGvTJy5MLk2qNcSwdZKkCo5T+WPSWFpgkSCGB4xxABSGdTPc1qjt8naECXcBwNsj 7hGc+uXeg==; 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-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;