Skip to content

Commit 5e87ddb

Browse files
Norbert Slusarekmarckleinebudde
authored andcommitted
can: bcm: fix infoleak in struct bcm_msg_head
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: ffd980f ("[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 <[email protected]> Signed-off-by: Norbert Slusarek <[email protected]> Acked-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 8d0caed commit 5e87ddb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/can/bcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer)
406406
if (!op->count && (op->flags & TX_COUNTEVT)) {
407407

408408
/* create notification to user */
409+
memset(&msg_head, 0, sizeof(msg_head));
409410
msg_head.opcode = TX_EXPIRED;
410411
msg_head.flags = op->flags;
411412
msg_head.count = op->count;
@@ -443,6 +444,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data)
443444
/* this element is not throttled anymore */
444445
data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV);
445446

447+
memset(&head, 0, sizeof(head));
446448
head.opcode = RX_CHANGED;
447449
head.flags = op->flags;
448450
head.count = op->count;
@@ -564,6 +566,7 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
564566
}
565567

566568
/* create notification to user */
569+
memset(&msg_head, 0, sizeof(msg_head));
567570
msg_head.opcode = RX_TIMEOUT;
568571
msg_head.flags = op->flags;
569572
msg_head.count = op->count;

0 commit comments

Comments
 (0)