From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A64BC33C9E for ; Wed, 29 Jan 2020 02:26:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F93620720 for ; Wed, 29 Jan 2020 02:26:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b="v3D3VFE3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbgA2C0R (ORCPT ); Tue, 28 Jan 2020 21:26:17 -0500 Received: from gateway32.websitewelcome.com ([192.185.145.187]:18871 "EHLO gateway32.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbgA2C0R (ORCPT ); Tue, 28 Jan 2020 21:26:17 -0500 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway32.websitewelcome.com (Postfix) with ESMTP id D5DF52D7C7 for ; Tue, 28 Jan 2020 20:26:15 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id wd3Xi8zq5kjvMwd3Xi8Qhr; Tue, 28 Jan 2020 20:26:15 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Type:MIME-Version:Message-ID:Subject: Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QMzuKYE0RHG5OPt7NV4kpzyK5o/dAwzIOEetmHlnOnw=; b=v3D3VFE3zz6AeFC0/5HZKayxOo +Eq3lZJ6psSFnEUmdEIn4OFZ+doeH2TuvmypckmrpzZ5FpxpVRDDidFoBBz6UFCuDD/tGN0AfgEFC D+VKu7nt8i4m+iFCac0CViCKdRBPyRqWFOCujXY2w27S9fBBFvTcL5wkNkRmd2Y6NYAUfcQkTj5j6 0N4dYFChEtURA0QesFJavmZ5hGfRF2m6wd6MENDbyYpGCNv+ZO11t4k1t2lq7dLu/aggpy1ZoNBet obBFzvdzCAkr/Q2xFRg0S1EOwVSQP/3bhUkdL/en4RGslJJDykE6bK/podZnGrDoZDB7ZtuwiHCqR N5+q33yg==; Received: from cablelink-189-218-116-241.hosts.intercable.net ([189.218.116.241]:38272 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1iwd3W-001A4g-KI; Tue, 28 Jan 2020 20:26:14 -0600 Date: Tue, 28 Jan 2020 20:26:13 -0600 From: "Gustavo A. R. Silva" To: Clemens Ladisch , Arnd Bergmann , Greg Kroah-Hartman , "Gustavo A. R. Silva" Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] char: hpet: Fix out-of-bounds read bug Message-ID: <20200129022613.GA24281@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.218.116.241 X-Source-L: No X-Exim-ID: 1iwd3W-001A4g-KI X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cablelink-189-218-116-241.hosts.intercable.net (embeddedor) [189.218.116.241]:38272 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 4 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, there is an out-of-bounds read on array hpetp->hp_dev in the following for loop: 870 for (i = 0; i < hdp->hd_nirqs; i++) 871 hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i]; This is due to the recent change from one-element array to flexible-array member in struct hpets: 104 struct hpets { ... 113 struct hpet_dev hp_dev[]; 114 }; This change affected the total size of the dynamic memory allocation, decreasing it by one time the size of struct hpet_dev. Fix this by adjusting the allocation size when calling struct_size(). Fixes: 987f028b8637c ("char: hpet: Use flexible-array member") Signed-off-by: Gustavo A. R. Silva --- Here to fix what I break. :p Sorry... drivers/char/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index aed2c45f7968..ed3b7dab678d 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -855,7 +855,7 @@ int hpet_alloc(struct hpet_data *hdp) return 0; } - hpetp = kzalloc(struct_size(hpetp, hp_dev, hdp->hd_nirqs - 1), + hpetp = kzalloc(struct_size(hpetp, hp_dev, hdp->hd_nirqs), GFP_KERNEL); if (!hpetp) -- 2.23.0