Skip to contentSkip to conversation

net/qrtr/qrtr.c:857:20-24: ERROR: invalid reference to the index variable of the iterator on line 848 (fwd)

PATCH In review Julia Lawall 2 participants 2 messages May 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 6887/8703 net/qrtr/qrtr.c:857:20-24: ERROR: invalid reference to the index variable of the iterator on line 848 (fwd)

Hello,

Please check whether the break on line 851 is guaranteed to be taken. If not, on line 857, node may point to an invalid object.

julia

---------- Forwarded message ----------
Date: Tue, 19 May 2020 08:08:44 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: lkp(a)intel.com, Julia Lawall <[email protected]>
Subject: [linux-next:master 6887/8703] net/qrtr/qrtr.c:857:20-24: ERROR: invalid
reference to the index variable of the iterator on line 848

CC: kbuild-all(a)lists.01.org
TO: Manivannan Sadhasivam <[email protected]>
CC: Bjorn Andersson <[email protected]>

Hi Manivannan,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   e098d7762d602be640c53565ceca342f81e55ad2
commit: e42671084361302141a09284fde9bbc14fdd16bf [6887/8703] net: qrtr: Do not depend on ARCH_QCOM
config: nds32-randconfig-c003-20200519 (attached as .config)

:::::: branch date: 7 days ago
:::::: commit date: 11 days ago

If you fix the issue, kindly add following tag as appropriate

coccinelle warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

net/qrtr/qrtr.c:857:20-24: ERROR: invalid reference to the index variable of the iterator on line 848

# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=e42671084361302141a09284fde9bbc14fdd16bf
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout e42671084361302141a09284fde9bbc14fdd16bf
vim +857 net/qrtr/qrtr.c

bdabad3e363d825 Courtney Cavin  2016-05-06  839
bdabad3e363d825 Courtney Cavin  2016-05-06  840  /* Queue packet for broadcast. */
e7044482c8ac508 Bjorn Andersson 2017-10-10  841  static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb,
e7044482c8ac508 Bjorn Andersson 2017-10-10  842  			      int type, struct sockaddr_qrtr *from,
e7044482c8ac508 Bjorn Andersson 2017-10-10  843  			      struct sockaddr_qrtr *to)
bdabad3e363d825 Courtney Cavin  2016-05-06  844  {
bdabad3e363d825 Courtney Cavin  2016-05-06  845  	struct sk_buff *skbn;
bdabad3e363d825 Courtney Cavin  2016-05-06  846
bdabad3e363d825 Courtney Cavin  2016-05-06  847  	mutex_lock(&qrtr_node_lock);
bdabad3e363d825 Courtney Cavin  2016-05-06 @848  	list_for_each_entry(node, &qrtr_all_nodes, item) {
bdabad3e363d825 Courtney Cavin  2016-05-06  849  		skbn = skb_clone(skb, GFP_KERNEL);
bdabad3e363d825 Courtney Cavin  2016-05-06  850  		if (!skbn)
bdabad3e363d825 Courtney Cavin  2016-05-06  851  			break;
bdabad3e363d825 Courtney Cavin  2016-05-06  852  		skb_set_owner_w(skbn, skb->sk);
e7044482c8ac508 Bjorn Andersson 2017-10-10  853  		qrtr_node_enqueue(node, skbn, type, from, to);
bdabad3e363d825 Courtney Cavin  2016-05-06  854  	}
bdabad3e363d825 Courtney Cavin  2016-05-06  855  	mutex_unlock(&qrtr_node_lock);
bdabad3e363d825 Courtney Cavin  2016-05-06  856
e7044482c8ac508 Bjorn Andersson 2017-10-10 @857  	qrtr_local_enqueue(node, skb, type, from, to);
bdabad3e363d825 Courtney Cavin  2016-05-06  858
bdabad3e363d825 Courtney Cavin  2016-05-06  859  	return 0;
bdabad3e363d825 Courtney Cavin  2016-05-06  860  }
bdabad3e363d825 Courtney Cavin  2016-05-06  861

:::::: The code at line 857 was first introduced by commit
:::::: e7044482c8ac5081f4775063995647787d5082a4 net: qrtr: Pass source and destination to enqueue functions

:::::: TO: Bjorn Andersson <[email protected]> :::::: CC: David S. Miller <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#1 lore raw

Hi,

Quoted 5 lines · Julia Lawall

Hello,

Please check whether the break on line 851 is guaranteed to be taken. If not, on line 857, node may point to an invalid object.

This will get fixed by: https://lkml.org/lkml/2020/5/19/838

Sorry for not CCing you. I thought git send-email will add you to CC since you're in Reported-by tag but it doesn't :/

Thanks,
Mani

Quoted 73 lines

julia

---------- Forwarded message ----------
Date: Tue, 19 May 2020 08:08:44 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: lkp(a)intel.com, Julia Lawall <[email protected]>
Subject: [linux-next:master 6887/8703] net/qrtr/qrtr.c:857:20-24: ERROR: invalid
reference to the index variable of the iterator on line 848

CC: kbuild-all(a)lists.01.org
TO: Manivannan Sadhasivam <[email protected]>
CC: Bjorn Andersson <[email protected]>

Hi Manivannan,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   e098d7762d602be640c53565ceca342f81e55ad2
commit: e42671084361302141a09284fde9bbc14fdd16bf [6887/8703] net: qrtr: Do not depend on ARCH_QCOM
config: nds32-randconfig-c003-20200519 (attached as .config)

:::::: branch date: 7 days ago
:::::: commit date: 11 days ago

If you fix the issue, kindly add following tag as appropriate

coccinelle warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

net/qrtr/qrtr.c:857:20-24: ERROR: invalid reference to the index variable of the iterator on line 848

# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=e42671084361302141a09284fde9bbc14fdd16bf
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout e42671084361302141a09284fde9bbc14fdd16bf
vim +857 net/qrtr/qrtr.c

bdabad3e363d825 Courtney Cavin  2016-05-06  839
bdabad3e363d825 Courtney Cavin  2016-05-06  840  /* Queue packet for broadcast. */
e7044482c8ac508 Bjorn Andersson 2017-10-10  841  static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb,
e7044482c8ac508 Bjorn Andersson 2017-10-10  842  			      int type, struct sockaddr_qrtr *from,
e7044482c8ac508 Bjorn Andersson 2017-10-10  843  			      struct sockaddr_qrtr *to)
bdabad3e363d825 Courtney Cavin  2016-05-06  844  {
bdabad3e363d825 Courtney Cavin  2016-05-06  845  	struct sk_buff *skbn;
bdabad3e363d825 Courtney Cavin  2016-05-06  846
bdabad3e363d825 Courtney Cavin  2016-05-06  847  	mutex_lock(&qrtr_node_lock);
bdabad3e363d825 Courtney Cavin  2016-05-06 @848  	list_for_each_entry(node, &qrtr_all_nodes, item) {
bdabad3e363d825 Courtney Cavin  2016-05-06  849  		skbn = skb_clone(skb, GFP_KERNEL);
bdabad3e363d825 Courtney Cavin  2016-05-06  850  		if (!skbn)
bdabad3e363d825 Courtney Cavin  2016-05-06  851  			break;
bdabad3e363d825 Courtney Cavin  2016-05-06  852  		skb_set_owner_w(skbn, skb->sk);
e7044482c8ac508 Bjorn Andersson 2017-10-10  853  		qrtr_node_enqueue(node, skbn, type, from, to);
bdabad3e363d825 Courtney Cavin  2016-05-06  854  	}
bdabad3e363d825 Courtney Cavin  2016-05-06  855  	mutex_unlock(&qrtr_node_lock);
bdabad3e363d825 Courtney Cavin  2016-05-06  856
e7044482c8ac508 Bjorn Andersson 2017-10-10 @857  	qrtr_local_enqueue(node, skb, type, from, to);
bdabad3e363d825 Courtney Cavin  2016-05-06  858
bdabad3e363d825 Courtney Cavin  2016-05-06  859  	return 0;
bdabad3e363d825 Courtney Cavin  2016-05-06  860  }
bdabad3e363d825 Courtney Cavin  2016-05-06  861

:::::: The code at line 857 was first introduced by commit
:::::: e7044482c8ac5081f4775063995647787d5082a4 net: qrtr: Pass source and destination to enqueue functions

:::::: TO: Bjorn Andersson <[email protected]> :::::: CC: David S. Miller <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org