[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202506010920.TbxfWuYH-lkp@intel.com>
Date: Mon, 2 Jun 2025 09:52:34 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: oe-kbuild@...ts.linux.dev, Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
linux-kernel@...r.kernel.org, Paolo Abeni <pabeni@...hat.com>
Subject: net/netlabel/netlabel_kapi.c:1200 netlbl_conn_setattr() warn:
inconsistent returns 'rcu_read'.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4cb6c8af8591135ec000fbe4bb474139ceec595d
commit: 6e9f2df1c550ead7cecb3e450af1105735020c92 calipso: Don't call calipso functions for AF_INET sk.
date: 4 days ago
config: i386-randconfig-141-20250601 (https://download.01.org/0day-ci/archive/20250601/202506010920.TbxfWuYH-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
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@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
| Closes: https://lore.kernel.org/r/202506010920.TbxfWuYH-lkp@intel.com/
smatch warnings:
net/netlabel/netlabel_kapi.c:1200 netlbl_conn_setattr() warn: inconsistent returns 'rcu_read'.
vim +/rcu_read +1200 net/netlabel/netlabel_kapi.c
014ab19a69c325 Paul Moore 2008-10-10 1129 int netlbl_conn_setattr(struct sock *sk,
014ab19a69c325 Paul Moore 2008-10-10 1130 struct sockaddr *addr,
014ab19a69c325 Paul Moore 2008-10-10 1131 const struct netlbl_lsm_secattr *secattr)
014ab19a69c325 Paul Moore 2008-10-10 1132 {
014ab19a69c325 Paul Moore 2008-10-10 1133 int ret_val;
014ab19a69c325 Paul Moore 2008-10-10 1134 struct sockaddr_in *addr4;
ceba1832b1b2da Huw Davies 2016-06-27 1135 #if IS_ENABLED(CONFIG_IPV6)
ceba1832b1b2da Huw Davies 2016-06-27 1136 struct sockaddr_in6 *addr6;
ceba1832b1b2da Huw Davies 2016-06-27 1137 #endif
6a8b7f0c85f1f4 Paul Moore 2013-08-02 1138 struct netlbl_dommap_def *entry;
014ab19a69c325 Paul Moore 2008-10-10 1139
014ab19a69c325 Paul Moore 2008-10-10 1140 rcu_read_lock();
014ab19a69c325 Paul Moore 2008-10-10 1141 switch (addr->sa_family) {
014ab19a69c325 Paul Moore 2008-10-10 1142 case AF_INET:
014ab19a69c325 Paul Moore 2008-10-10 1143 addr4 = (struct sockaddr_in *)addr;
6a8b7f0c85f1f4 Paul Moore 2013-08-02 1144 entry = netlbl_domhsh_getentry_af4(secattr->domain,
014ab19a69c325 Paul Moore 2008-10-10 1145 addr4->sin_addr.s_addr);
6a8b7f0c85f1f4 Paul Moore 2013-08-02 1146 if (entry == NULL) {
014ab19a69c325 Paul Moore 2008-10-10 1147 ret_val = -ENOENT;
014ab19a69c325 Paul Moore 2008-10-10 1148 goto conn_setattr_return;
014ab19a69c325 Paul Moore 2008-10-10 1149 }
6a8b7f0c85f1f4 Paul Moore 2013-08-02 1150 switch (entry->type) {
014ab19a69c325 Paul Moore 2008-10-10 1151 case NETLBL_NLTYPE_CIPSOV4:
014ab19a69c325 Paul Moore 2008-10-10 1152 ret_val = cipso_v4_sock_setattr(sk,
8ec9897ec2e93a Davide Caratti 2024-05-10 1153 entry->cipso, secattr,
8ec9897ec2e93a Davide Caratti 2024-05-10 1154 netlbl_sk_lock_check(sk));
014ab19a69c325 Paul Moore 2008-10-10 1155 break;
014ab19a69c325 Paul Moore 2008-10-10 1156 case NETLBL_NLTYPE_UNLABELED:
014ab19a69c325 Paul Moore 2008-10-10 1157 /* just delete the protocols we support for right now
014ab19a69c325 Paul Moore 2008-10-10 1158 * but we could remove other protocols if needed */
ceba1832b1b2da Huw Davies 2016-06-27 1159 netlbl_sock_delattr(sk);
014ab19a69c325 Paul Moore 2008-10-10 1160 ret_val = 0;
014ab19a69c325 Paul Moore 2008-10-10 1161 break;
014ab19a69c325 Paul Moore 2008-10-10 1162 default:
014ab19a69c325 Paul Moore 2008-10-10 1163 ret_val = -ENOENT;
014ab19a69c325 Paul Moore 2008-10-10 1164 }
014ab19a69c325 Paul Moore 2008-10-10 1165 break;
dfd56b8b38fff3 Eric Dumazet 2011-12-10 1166 #if IS_ENABLED(CONFIG_IPV6)
014ab19a69c325 Paul Moore 2008-10-10 1167 case AF_INET6:
6e9f2df1c550ea Kuniyuki Iwashima 2025-05-22 1168 if (sk->sk_family != AF_INET6)
6e9f2df1c550ea Kuniyuki Iwashima 2025-05-22 1169 return -EAFNOSUPPORT;
Need to call conn_setattr_return() so goto conn_setattr_return.
6e9f2df1c550ea Kuniyuki Iwashima 2025-05-22 1170
ceba1832b1b2da Huw Davies 2016-06-27 1171 addr6 = (struct sockaddr_in6 *)addr;
ceba1832b1b2da Huw Davies 2016-06-27 1172 entry = netlbl_domhsh_getentry_af6(secattr->domain,
ceba1832b1b2da Huw Davies 2016-06-27 1173 &addr6->sin6_addr);
ceba1832b1b2da Huw Davies 2016-06-27 1174 if (entry == NULL) {
ceba1832b1b2da Huw Davies 2016-06-27 1175 ret_val = -ENOENT;
ceba1832b1b2da Huw Davies 2016-06-27 1176 goto conn_setattr_return;
ceba1832b1b2da Huw Davies 2016-06-27 1177 }
ceba1832b1b2da Huw Davies 2016-06-27 1178 switch (entry->type) {
ceba1832b1b2da Huw Davies 2016-06-27 1179 case NETLBL_NLTYPE_CALIPSO:
ceba1832b1b2da Huw Davies 2016-06-27 1180 ret_val = calipso_sock_setattr(sk,
ceba1832b1b2da Huw Davies 2016-06-27 1181 entry->calipso, secattr);
ceba1832b1b2da Huw Davies 2016-06-27 1182 break;
ceba1832b1b2da Huw Davies 2016-06-27 1183 case NETLBL_NLTYPE_UNLABELED:
ceba1832b1b2da Huw Davies 2016-06-27 1184 /* just delete the protocols we support for right now
ceba1832b1b2da Huw Davies 2016-06-27 1185 * but we could remove other protocols if needed */
ceba1832b1b2da Huw Davies 2016-06-27 1186 netlbl_sock_delattr(sk);
014ab19a69c325 Paul Moore 2008-10-10 1187 ret_val = 0;
014ab19a69c325 Paul Moore 2008-10-10 1188 break;
ceba1832b1b2da Huw Davies 2016-06-27 1189 default:
ceba1832b1b2da Huw Davies 2016-06-27 1190 ret_val = -ENOENT;
ceba1832b1b2da Huw Davies 2016-06-27 1191 }
ceba1832b1b2da Huw Davies 2016-06-27 1192 break;
014ab19a69c325 Paul Moore 2008-10-10 1193 #endif /* IPv6 */
014ab19a69c325 Paul Moore 2008-10-10 1194 default:
389fb800ac8be2 Paul Moore 2009-03-27 1195 ret_val = -EPROTONOSUPPORT;
014ab19a69c325 Paul Moore 2008-10-10 1196 }
014ab19a69c325 Paul Moore 2008-10-10 1197
014ab19a69c325 Paul Moore 2008-10-10 1198 conn_setattr_return:
014ab19a69c325 Paul Moore 2008-10-10 1199 rcu_read_unlock();
014ab19a69c325 Paul Moore 2008-10-10 @1200 return ret_val;
014ab19a69c325 Paul Moore 2008-10-10 1201 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists