提交 151a944a 编写于 作者: N Norbert Slusarek 提交者: Yang Yingliang

can: bcm: fix infoleak in struct bcm_msg_head

mainline inclusion
from mainline-v5.13-rc7
commit 5e87ddbe
category: bugfix
bugzilla: NA
CVE: CVE-2021-34693

--------------------------------

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: ffd980f9 ("[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 <stable@vger.kernel.org>
Signed-off-by: NNorbert Slusarek <nslusarek@gmx.net>
Acked-by: NOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 493ac0dc
...@@ -393,6 +393,7 @@ static void bcm_tx_timeout_tsklet(unsigned long data) ...@@ -393,6 +393,7 @@ static void bcm_tx_timeout_tsklet(unsigned long data)
if (!op->count && (op->flags & TX_COUNTEVT)) { if (!op->count && (op->flags & TX_COUNTEVT)) {
/* create notification to user */ /* create notification to user */
memset(&msg_head, 0, sizeof(msg_head));
msg_head.opcode = TX_EXPIRED; msg_head.opcode = TX_EXPIRED;
msg_head.flags = op->flags; msg_head.flags = op->flags;
msg_head.count = op->count; msg_head.count = op->count;
...@@ -440,6 +441,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data) ...@@ -440,6 +441,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data)
/* this element is not throttled anymore */ /* this element is not throttled anymore */
data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV); data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV);
memset(&head, 0, sizeof(head));
head.opcode = RX_CHANGED; head.opcode = RX_CHANGED;
head.flags = op->flags; head.flags = op->flags;
head.count = op->count; head.count = op->count;
...@@ -554,6 +556,7 @@ static void bcm_rx_timeout_tsklet(unsigned long data) ...@@ -554,6 +556,7 @@ static void bcm_rx_timeout_tsklet(unsigned long data)
struct bcm_msg_head msg_head; struct bcm_msg_head msg_head;
/* create notification to user */ /* create notification to user */
memset(&msg_head, 0, sizeof(msg_head));
msg_head.opcode = RX_TIMEOUT; msg_head.opcode = RX_TIMEOUT;
msg_head.flags = op->flags; msg_head.flags = op->flags;
msg_head.count = op->count; msg_head.count = op->count;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册