Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3831963pxv; Mon, 28 Jun 2021 14:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMmdv1FaYuJhlzh2RgfSX58dInmGy/7bZHG5cZLbmF3HcgigJuMX0VbqucD9t+o4LOpYGt X-Received: by 2002:a6b:b491:: with SMTP id d139mr1156693iof.40.1624914427812; Mon, 28 Jun 2021 14:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624914427; cv=none; d=google.com; s=arc-20160816; b=BRXF/+6B1AM2XdqiJ7gPs9dgi2/cRp5F2jK0izXe/K8Wh4emGIeoEUwJTpAKYxFlVm LZF+8MixjhIL9AWeDInEnnJBCwB881fmcLWo8t1NnDVPSDoqsnM/CO8GOs9y8MnW0XqV XOYGZdmaunIqdqxfvTc6WjmLo4dyN66eAblRImhy8/07TqKe+iUuA6Vte/Juu5fvQ78k uob2hVUTH2ZiP91djIqq6cpAvG+72XmmYf5jlS9kFgFI+M6SLMLubGuG8lC5q8zVGSnE oJVNIRSdtxdKMfREv+erbfcax9wwcWRvGs91NimKnYnqPW28US9FlJv6X7MIAsUP1Ys1 bwhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pl16XQV+dOsYA3FoRSDwjVdMxWEKDMjKyb1/wC+zNIk=; b=J3ejz/pCd80eXQgqT5kGlqZZaiZVDl3oEaZuccrISYWqgrXpFYCy1PNCCm69odVjlX yPPPMZSwutJTZVEjSLpyLdCITaifSyt1lMAPsGOeIE1tQ4T1Mrqq1/DuGbFi2CiOPNjL 01pT3/41IZMEtmTa8bfg5Fp48dBVpY9cRvFtDWseEzpFrcnpabVLhS89atkx5k4D7g0c 045mF8Ae4LwfnqCBLvkwbHdjIdjZSql/EJNCoIhvhzpZAn5FzwmPR2mIYgearudfBOj3 hBJ/m7kayIsbU89fx0mTn18i+T0t5471Wa8cgx7YRR6BMN57u9vov2T37iC4FRSs8c4k BUng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fESEnCgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si18308361ild.74.2021.06.28.14.06.54; Mon, 28 Jun 2021 14:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fESEnCgl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236103AbhF1PLn (ORCPT + 99 others); Mon, 28 Jun 2021 11:11:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:54504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235576AbhF1OvH (ORCPT ); Mon, 28 Jun 2021 10:51:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7237961CB8; Mon, 28 Jun 2021 14:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891028; bh=LMluAgVmoP3/7m5lVRKMgPgZgdEGwdM9G99ODqOPB1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fESEnCgl/LsziaR1M7LttwyAOCvyyLHi7LI/Pk8zDdM+wdkK1WjZ3pOTilUXC1M32 AvYne/XWNj24CAqJMZOn/MKfPGnojzdnqx8lTNYM0JdBaZSZBSiYrucElh9zyxCTKG MD+WAYjfPkDsr6X32MqTakKcUI4dAkPSb832b5ilwQ+ha3lOOWGPXwYowJytCWBS59 /9fgYnlVLmO/puP9zwTt6+Ecv+yX/Xyf+I0LD6GdyLE2lDaR68fiK6OZ74ki6C2mEA QlNPov+JDFM7Exy66uH2IxEpcGT7q66Vp4QupD7oFvIQfjFh3ogkS0sZEcd5M4npsp oUm2xYJZk7OKg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Norbert Slusarek , Oliver Hartkopp , Marc Kleine-Budde , Greg Kroah-Hartman Subject: [PATCH 4.14 43/88] can: bcm: fix infoleak in struct bcm_msg_head Date: Mon, 28 Jun 2021 10:35:43 -0400 Message-Id: <20210628143628.33342-44-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Norbert Slusarek commit 5e87ddbe3942e27e939bdc02deb8579b0cbd8ecc upstream. On 64-bit systems, struct bcm_msg_head has an added padding of 4 bytes between struct members count and ival1. Even though all struct members are initialized, the 4-byte hole will contain data from the kernel stack. This patch zeroes out struct bcm_msg_head before usage, preventing infoleaks to userspace. Fixes: ffd980f976e7 ("[CAN]: Add broadcast manager (bcm) protocol") Link: https://lore.kernel.org/r/trinity-7c1b2e82-e34f-4885-8060-2cd7a13769ce-1623532166177@3c-app-gmx-bs52 Cc: linux-stable Signed-off-by: Norbert Slusarek Acked-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/bcm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/can/bcm.c b/net/can/bcm.c index 12d851c4604d..f691afcc5b8b 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -406,6 +406,7 @@ static void bcm_tx_timeout_tsklet(unsigned long data) if (!op->count && (op->flags & TX_COUNTEVT)) { /* create notification to user */ + memset(&msg_head, 0, sizeof(msg_head)); msg_head.opcode = TX_EXPIRED; msg_head.flags = op->flags; msg_head.count = op->count; @@ -453,6 +454,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data) /* this element is not throttled anymore */ data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV); + memset(&head, 0, sizeof(head)); head.opcode = RX_CHANGED; head.flags = op->flags; head.count = op->count; @@ -567,6 +569,7 @@ static void bcm_rx_timeout_tsklet(unsigned long data) struct bcm_msg_head msg_head; /* create notification to user */ + memset(&msg_head, 0, sizeof(msg_head)); msg_head.opcode = RX_TIMEOUT; msg_head.flags = op->flags; msg_head.count = op->count; -- 2.30.2