* [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding [not found] <20200415113445.11881-1-sashal@kernel.org> @ 2020-04-15 11:33 ` Sasha Levin 2020-04-15 17:09 ` Eric W. Biederman 0 siblings, 1 reply; 4+ messages in thread From: Sasha Levin @ 2020-04-15 11:33 UTC (permalink / raw) To: linux-kernel, stable Cc: Richard Palethorpe, Kees Cook, linux-can, netdev, security, wg, mkl, davem, Sasha Levin 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: Sasha Levin <sashal@kernel.org> --- 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++) { -- 2.20.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding 2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding Sasha Levin @ 2020-04-15 17:09 ` Eric W. Biederman 2020-04-15 17:22 ` Greg KH 0 siblings, 1 reply; 4+ messages in thread From: Eric W. Biederman @ 2020-04-15 17:09 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Richard Palethorpe, Kees Cook, linux-can, netdev, security, wg, mkl, davem How does this differ from Greg's backports of this patches? Sasha Levin <sashal@kernel.org> writes: > 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: Sasha Levin <sashal@kernel.org> > --- > 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++) { ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding 2020-04-15 17:09 ` Eric W. Biederman @ 2020-04-15 17:22 ` Greg KH 2020-04-16 0:04 ` Sasha Levin 0 siblings, 1 reply; 4+ messages in thread From: Greg KH @ 2020-04-15 17:22 UTC (permalink / raw) To: Eric W. Biederman Cc: Sasha Levin, linux-kernel, stable, Richard Palethorpe, Kees Cook, linux-can, netdev, security, wg, mkl, davem On Wed, Apr 15, 2020 at 12:09:08PM -0500, Eric W. Biederman wrote: > > How does this differ from Greg's backports of this patches? His tool didn't catch that they are already in a merged tree, it's a few steps later that this happens :) greg k-h ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding 2020-04-15 17:22 ` Greg KH @ 2020-04-16 0:04 ` Sasha Levin 0 siblings, 0 replies; 4+ messages in thread From: Sasha Levin @ 2020-04-16 0:04 UTC (permalink / raw) To: Greg KH Cc: Eric W. Biederman, linux-kernel, stable, Richard Palethorpe, Kees Cook, linux-can, netdev, security, wg, mkl, davem On Wed, Apr 15, 2020 at 07:22:43PM +0200, Greg KH wrote: >On Wed, Apr 15, 2020 at 12:09:08PM -0500, Eric W. Biederman wrote: >> >> How does this differ from Greg's backports of this patches? > >His tool didn't catch that they are already in a merged tree, it's a few >steps later that this happens :) My process for doing these takes a day or two (or three) to build test, test, and send mails. Sometimes Greg beats me to it :) -- Thanks, Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-16 0:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200415113445.11881-1-sashal@kernel.org>
2020-04-15 11:33 ` [PATCH AUTOSEL 5.6 068/129] slcan: Don't transmit uninitialized stack data in padding Sasha Levin
2020-04-15 17:09 ` Eric W. Biederman
2020-04-15 17:22 ` Greg KH
2020-04-16 0:04 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox