From 8fd4bc8a15b218165c45f44eba1b33a3c7181dfb Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 1 Mar 2018 14:40:19 +0000 Subject: ieee802154: remove unused variable 'val' Variable 'val' is not being initialized and is later being logically or'd with DAR_PHY_CTRL4_PROMISCUOUS. Considering this variable is never being read anyway we may as well remove val altogether. Cleans up error detected by cppcheck: drivers/net/ieee802154/mcr20a.c:732: (error) Uninitialized variable: val Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver") Signed-off-by: Colin Ian King Signed-off-by: Stefan Schmidt --- drivers/net/ieee802154/mcr20a.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c index d9eb22a52551..55a22c761808 100644 --- a/drivers/net/ieee802154/mcr20a.c +++ b/drivers/net/ieee802154/mcr20a.c @@ -723,13 +723,11 @@ mcr20a_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on) struct mcr20a_local *lp = hw->priv; int ret; u8 rx_frame_filter_reg = 0x0; - u8 val; dev_dbg(printdev(lp), "%s(%d)\n", __func__, on); if (on) { /* All frame types accepted*/ - val |= DAR_PHY_CTRL4_PROMISCUOUS; rx_frame_filter_reg &= ~(IAR_RX_FRAME_FLT_FRM_VER); rx_frame_filter_reg |= (IAR_RX_FRAME_FLT_ACK_FT | IAR_RX_FRAME_FLT_NS_FT); -- cgit v1.2.3 From 86674a97f5055f4c7f406563408096e8cf9364ff Mon Sep 17 00:00:00 2001 From: Harry Morris Date: Wed, 28 Mar 2018 11:54:27 +0100 Subject: ieee802154: ca8210: fix uninitialised data read In ca8210_test_int_user_write() a user can request the transfer of a frame with a length field (command.length) that is longer than the actual buffer provided (len). In this scenario the driver will copy the buffer contents into the uninitialised command[] buffer, then transfer bytes over the SPI even though only bytes had been populated, potentially leaking sensitive kernel memory. Also the first 6 bytes of the command buffer must be initialised in case a malformed, short packet is written and the uninitialised bytes are read in ca8210_test_check_upstream. Reported-by: Domen Puncer Kugler Signed-off-by: Harry Morris Tested-by: Harry Morris Signed-off-by: Stefan Schmidt --- drivers/net/ieee802154/ca8210.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 377af43b81b3..58299fb666ed 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -2493,13 +2493,14 @@ static ssize_t ca8210_test_int_user_write( struct ca8210_priv *priv = filp->private_data; u8 command[CA8210_SPI_BUF_SIZE]; - if (len > CA8210_SPI_BUF_SIZE) { + memset(command, SPI_IDLE, 6); + if (len > CA8210_SPI_BUF_SIZE || len < 2) { dev_warn( &priv->spi->dev, - "userspace requested erroneously long write (%zu)\n", + "userspace requested erroneous write length (%zu)\n", len ); - return -EMSGSIZE; + return -EBADE; } ret = copy_from_user(command, in_buf, len); @@ -2511,6 +2512,13 @@ static ssize_t ca8210_test_int_user_write( ); return -EIO; } + if (len != command[1] + 2) { + dev_err( + &priv->spi->dev, + "write len does not match packet length field\n" + ); + return -EBADE; + } ret = ca8210_test_check_upstream(command, priv->spi); if (ret == 0) { -- cgit v1.2.3