Re: [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How does this differ from Greg's backports of this patches?

Sasha Levin <sashal@xxxxxxxxxx> writes:

> From: Richard Palethorpe <rpalethorpe@xxxxxxxx>
>
> [ 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@xxxxxxxx>
> Fixes: a1044e36e457 ("can: add slcan driver for serial/USB-serial CAN adapters")
> Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: linux-can@xxxxxxxxxxxxxxx
> Cc: netdev@xxxxxxxxxxxxxxx
> Cc: security@xxxxxxxxxx
> Cc: wg@xxxxxxxxxxxxxx
> Cc: mkl@xxxxxxxxxxxxxx
> Cc: davem@xxxxxxxxxxxxx
> Acked-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> ---
>  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 a3664281a33fc..4dfa459ef5c73 100644
> --- 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++) {



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux