[X][B][D][E][F][U][SRU][CVE-2020-11494][PATCH 1/1] slcan: Don't transmit uninitialized stack data in padding

Po-Hsu Lin po-hsu.lin at canonical.com
Wed Apr 8 08:58:24 UTC 2020

From: Richard Palethorpe <rpalethorpe at suse.com>


struct can_frame contains some padding which is not explicitly zeroed in
slc_bump. This uninitialized data will then be transmitted if the stack
initialization hardening feature is not enabled (CONFIG_INIT_STACK_ALL).

This commit just zeroes the whole struct including the padding.

Signed-off-by: Richard Palethorpe <rpalethorpe at suse.com>
Fixes: a1044e36e457 ("can: add slcan driver for serial/USB-serial CAN adapters")
Reviewed-by: Kees Cook <keescook at chromium.org>
Cc: linux-can at vger.kernel.org
Cc: netdev at vger.kernel.org
Cc: security at kernel.org
Cc: wg at grandegger.com
Cc: mkl at pengutronix.de
Cc: davem at davemloft.net
Acked-by: Marc Kleine-Budde <mkl at pengutronix.de>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit b9258a2cece4ec1f020715fe3554bc2e360f6264)
Signed-off-by: Po-Hsu Lin <po-hsu.lin at canonical.com>
 drivers/net/can/slcan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index cc4a0c4..b8694b5 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -147,7 +147,7 @@ static void slc_bump(struct slcan *sl)
 	u32 tmpid;
 	char *cmd = sl->rbuff;
-	cf.can_id = 0;
+	memset(&cf, 0, sizeof(cf));
 	switch (*cmd) {
 	case 'r':
@@ -186,8 +186,6 @@ static void slc_bump(struct slcan *sl)
-	*(u64 *) (&cf.data) = 0; /* clear payload */
 	/* RTR frames may have a dlc > 0 but they never have any data bytes */
 	if (!(cf.can_id & CAN_RTR_FLAG)) {
 		for (i = 0; i < cf.can_dlc; i++) {

More information about the kernel-team mailing list