]> git.baikalelectronics.ru Git - kernel.git/commit
nfc: nci: Potential off by one in ->pipes[] array
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 3 Apr 2019 07:13:51 +0000 (10:13 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sat, 6 Apr 2019 22:05:07 +0000 (15:05 -0700)
commit25e53b4817b6e2a27f205c12bf3c6fb5edd80ade
tree808896ceb6b2639bf7d00c8d086000b13abefabd
parent1f596720b2eb3ca57da88e555f775b2494c33a29
nfc: nci: Potential off by one in ->pipes[] array

This is similar to commit 2bf9751450d8 ("NFC: Fix the number of pipes")
where we changed NFC_HCI_MAX_PIPES from 127 to 128.

As the comment next to the define explains, the pipe identifier is 7
bits long.  The highest possible pipe is 127, but the number of possible
pipes is 128.  As the code is now, then there is potential for an
out of bounds array access:

    net/nfc/nci/hci.c:297 nci_hci_cmd_received() warn: array off by one?
    'ndev->hci_dev->pipes[pipe]' '0-127 == 127'

Fixes: 843d93602c1c ("NFC: nci: Add HCI over NCI protocol support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/nfc/nci_core.h