public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: linux-kernel@vger•kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
	stable@vger•kernel.org, Richard Palethorpe <rpalethorpe@suse•com>,
	Kees Cook <keescook@chromium•org>,
	linux-can@vger•kernel.org, netdev@vger•kernel.org,
	security@kernel•org, wg@grandegger•com, mkl@pengutronix•de,
	davem@davemloft•net
Subject: [PATCH 5.4 11/41] slcan: Dont transmit uninitialized stack data in padding
Date: Sat, 11 Apr 2020 14:09:20 +0200	[thread overview]
Message-ID: <20200411115504.898395559@linuxfoundation.org> (raw)
In-Reply-To: <20200411115504.124035693@linuxfoundation.org>

From: Richard Palethorpe <rpalethorpe@suse•com>

[ Upstream commit b9258a2cece4ec1f020715fe3554bc2e360f6264 ]

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: a1044e36e457 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
---
 drivers/net/can/slcan.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -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':
@@ -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++) {



      parent reply	other threads:[~2020-04-11 12:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200411115504.124035693@linuxfoundation.org>
2020-04-11 12:09 ` [PATCH 5.4 01/41] net: phy: realtek: fix handling of RTL8105e-integrated PHY Greg Kroah-Hartman
2020-04-11 12:09 ` [PATCH 5.4 03/41] ipv6: dont auto-add link-local address to lag ports Greg Kroah-Hartman
2020-04-11 12:09 ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200411115504.898395559@linuxfoundation.org \
    --to=gregkh@linuxfoundation$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=keescook@chromium$(echo .)org \
    --cc=linux-can@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=mkl@pengutronix$(echo .)de \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=rpalethorpe@suse$(echo .)com \
    --cc=security@kernel$(echo .)org \
    --cc=stable@vger$(echo .)kernel.org \
    --cc=wg@grandegger$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox