[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f9d008bc-2416-8032-0005-35d7c6d87fc1@hartkopp.net>
Date: Sun, 13 Jun 2021 11:51:34 +0200
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Norbert Slusarek <nslusarek@....net>
Cc: mkl@...gutronix.de, davem@...emloft.net, kuba@...nel.org,
linux-can@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH] can: bcm: fix infoleak in struct bcm_msg_head
On 12.06.21 23:09, Norbert Slusarek wrote:
> From: Norbert Slusarek <nslusarek@....net>
> Date: Sat, 12 Jun 2021 22:18:54 +0200
> Subject: [PATCH] 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: ffd980f976e7 ("[CAN]: Add broadcast manager (bcm) protocol")
> Signed-off-by: Norbert Slusarek <nslusarek@....net>
Acked-by: Oliver Hartkopp <socketcan@...tkopp.net>
Thanks Norbert!
Yes, when this data structure was created in 2003 either 64 bit machines
were far away for me and infoleaks were not a hot topic like today.
Would be interesting to check where data structures are used in the
Linux UAPI that became an infoleak in the 32-to-64-bit compilation
transistion.
Thanks for the heads up!
Best regards,
Oliver
>
> ---
> net/can/bcm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index 909b9e684e04..b03062f84fe7 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
> @@ -402,6 +402,7 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer)
> 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;
> @@ -439,6 +440,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;
> @@ -560,6 +562,7 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
> }
>
> /* 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
>
Powered by blists - more mailing lists