Skip to content

Commit

Permalink
slcan: Don't transmit uninitialized stack data in padding
Browse files Browse the repository at this point in the history
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@suse.com>
Fixes: a1044e3 ("can: add slcan driver for serial/USB-serial CAN adapters")
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: linux-can@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: security@kernel.org
Cc: wg@grandegger.com
Cc: mkl@pengutronix.de
Cc: davem@davemloft.net
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Richard Palethorpe authored and davem330 committed Apr 1, 2020
1 parent b1f4c20 commit b9258a2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/can/slcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,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':
Expand Down Expand Up @@ -187,8 +187,6 @@ static void slc_bump(struct slcan *sl)
else
return;

*(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++) {
Expand Down

0 comments on commit b9258a2

Please sign in to comment.