Skip to content

Commit 86674a9

Browse files
HarryMorrisStefan Schmidt
authored andcommitted
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 <data.length> bytes over the SPI even though only <len> 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 <[email protected]> Signed-off-by: Harry Morris <[email protected]> Tested-by: Harry Morris <[email protected]> Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 8fd4bc8 commit 86674a9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/net/ieee802154/ca8210.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,13 +2493,14 @@ static ssize_t ca8210_test_int_user_write(
24932493
struct ca8210_priv *priv = filp->private_data;
24942494
u8 command[CA8210_SPI_BUF_SIZE];
24952495

2496-
if (len > CA8210_SPI_BUF_SIZE) {
2496+
memset(command, SPI_IDLE, 6);
2497+
if (len > CA8210_SPI_BUF_SIZE || len < 2) {
24972498
dev_warn(
24982499
&priv->spi->dev,
2499-
"userspace requested erroneously long write (%zu)\n",
2500+
"userspace requested erroneous write length (%zu)\n",
25002501
len
25012502
);
2502-
return -EMSGSIZE;
2503+
return -EBADE;
25032504
}
25042505

25052506
ret = copy_from_user(command, in_buf, len);
@@ -2511,6 +2512,13 @@ static ssize_t ca8210_test_int_user_write(
25112512
);
25122513
return -EIO;
25132514
}
2515+
if (len != command[1] + 2) {
2516+
dev_err(
2517+
&priv->spi->dev,
2518+
"write len does not match packet length field\n"
2519+
);
2520+
return -EBADE;
2521+
}
25142522

25152523
ret = ca8210_test_check_upstream(command, priv->spi);
25162524
if (ret == 0) {

0 commit comments

Comments
 (0)