slcan: Don't transmit uninitialized stack data in padding
[ 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: a1044e36e4
("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>
This commit is contained in:
parent
2a63744e67
commit
f7dd0134a1
1 changed files with 1 additions and 3 deletions
|
@ -147,7 +147,7 @@ static void slc_bump(struct slcan *sl)
|
||||||
u32 tmpid;
|
u32 tmpid;
|
||||||
char *cmd = sl->rbuff;
|
char *cmd = sl->rbuff;
|
||||||
|
|
||||||
cf.can_id = 0;
|
memset(&cf, 0, sizeof(cf));
|
||||||
|
|
||||||
switch (*cmd) {
|
switch (*cmd) {
|
||||||
case 'r':
|
case 'r':
|
||||||
|
@ -186,8 +186,6 @@ static void slc_bump(struct slcan *sl)
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
*(u64 *) (&cf.data) = 0; /* clear payload */
|
|
||||||
|
|
||||||
/* RTR frames may have a dlc > 0 but they never have any data bytes */
|
/* RTR frames may have a dlc > 0 but they never have any data bytes */
|
||||||
if (!(cf.can_id & CAN_RTR_FLAG)) {
|
if (!(cf.can_id & CAN_RTR_FLAG)) {
|
||||||
for (i = 0; i < cf.can_dlc; i++) {
|
for (i = 0; i < cf.can_dlc; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue