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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 May 2019 17:41:27 +0000 (19:41 +0200)
commit322a57551d0655fc4198d4b131ad77dd171af769
tree2aaa0cfe666028810bd50f947ad5060238b1a6b7
parentf5e60565e6bd9a54fa17d62bc397890a70d1d1d2
nfc: nci: Potential off by one in ->pipes[] array

[ Upstream commit 6491d698396fd5da4941980a35ca7c162a672016 ]

This is similar to commit e285d5bfb7e9 ("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: 11f54f228643 ("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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
include/net/nfc/nci_core.h