linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [linux-next:master 10943/11428] net/bluetooth/hci_event.c:3276 hci_conn_request_evt() warn: variable dereferenced before check 'hdev' (see line 3266)
@ 2023-10-11 17:26 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-10-11 17:26 UTC (permalink / raw)
  To: oe-kbuild, Arnd Bergmann
  Cc: lkp, oe-kbuild-all, Linux Memory Management List,
	Luiz Augusto von Dentz, Kees Cook

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   2933a1156742d8c47550493a77af8e2d81cf3c84
commit: b8ba8e65e84b99d58e278900b4261ef17a20eb27 [10943/11428] Bluetooth: avoid memcmp() out of bounds warning
config: i386-randconfig-141-20231011 (https://download.01.org/0day-ci/archive/20231012/202310120031.J3PSRP8D-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231012/202310120031.J3PSRP8D-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202310120031.J3PSRP8D-lkp@intel.com/

smatch warnings:
net/bluetooth/hci_event.c:3276 hci_conn_request_evt() warn: variable dereferenced before check 'hdev' (see line 3266)

vim +/hdev +3276 net/bluetooth/hci_event.c

3e54c5890c87a3 Luiz Augusto von Dentz 2021-12-01  3262  static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
3e54c5890c87a3 Luiz Augusto von Dentz 2021-12-01  3263  				 struct sk_buff *skb)
^1da177e4c3f41 Linus Torvalds         2005-04-16  3264  {
3e54c5890c87a3 Luiz Augusto von Dentz 2021-12-01  3265  	struct hci_ev_conn_request *ev = data;
a9de9248064bfc Marcel Holtmann        2007-10-20 @3266  	int mask = hdev->link_mode;
                                                                           ^^^^^^^^^^^^^^^
Dereference

70c464256310e1 Johan Hedberg          2014-07-09  3267  	struct inquiry_entry *ie;
70c464256310e1 Johan Hedberg          2014-07-09  3268  	struct hci_conn *conn;
20714bfef84d3e Frédéric Dalleau       2012-11-21  3269  	__u8 flags = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  3270  
3e54c5890c87a3 Luiz Augusto von Dentz 2021-12-01  3271  	bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type);
^1da177e4c3f41 Linus Torvalds         2005-04-16  3272  
d70e44fef8621a Lee, Chun-Yi           2023-10-01  3273  	/* Reject incoming connection from device with same BD ADDR against
d70e44fef8621a Lee, Chun-Yi           2023-10-01  3274  	 * CVE-2020-26555
d70e44fef8621a Lee, Chun-Yi           2023-10-01  3275  	 */
b8ba8e65e84b99 Arnd Bergmann          2023-10-09 @3276  	if (hdev && !bacmp(&hdev->bdaddr, &ev->bdaddr)) {
                                                                    ^^^^
Checked too late

d70e44fef8621a Lee, Chun-Yi           2023-10-01  3277  		bt_dev_dbg(hdev, "Reject connection with same BD_ADDR %pMR\n",
d70e44fef8621a Lee, Chun-Yi           2023-10-01  3278  			   &ev->bdaddr);
d70e44fef8621a Lee, Chun-Yi           2023-10-01  3279  		hci_reject_conn(hdev, &ev->bdaddr);
d70e44fef8621a Lee, Chun-Yi           2023-10-01  3280  		return;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-11 17:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11 17:26 [linux-next:master 10943/11428] net/bluetooth/hci_event.c:3276 hci_conn_request_evt() warn: variable dereferenced before check 'hdev' (see line 3266) Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox