Hi Dong, kernel test robot noticed the following build warnings: url: https://github.com/intel-lab-lkp/linux/commits/Dong-Chenchen/net-netfilter-Fix-use-after-free-in-get_info/20241022-165936 base: net/main patch link: https://lore.kernel.org/r/20241022085753.2069639-1-dongchenchen2%40huawei.com patch subject: [PATCH net] net: netfilter: Fix use-after-free in get_info() config: x86_64-randconfig-161-20241023 (https://download.01.org/0day-ci/archive/20241024/202410240020.Cqi2d68p-lkp@xxxxxxxxx/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) 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@xxxxxxxxx> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> | Closes: https://lore.kernel.org/r/202410240020.Cqi2d68p-lkp@xxxxxxxxx/ smatch warnings: net/netfilter/x_tables.c:1280 xt_find_table_lock() warn: passing zero to 'ERR_PTR' vim +/ERR_PTR +1280 net/netfilter/x_tables.c 03d13b6868a261 Florian Westphal 2017-12-08 1234 /* Find table by name, grabs mutex & ref. Returns ERR_PTR on error. */ 76108cea065cda Jan Engelhardt 2008-10-08 1235 struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af, 76108cea065cda Jan Engelhardt 2008-10-08 1236 const char *name) 2e4e6a17af35be Harald Welte 2006-01-12 1237 { 1d610d4d31a8ed Florian Westphal 2021-04-01 1238 struct xt_pernet *xt_net = net_generic(net, xt_pernet_id); fdacd57c79b79a Florian Westphal 2021-08-03 1239 struct module *owner = NULL; fdacd57c79b79a Florian Westphal 2021-08-03 1240 struct xt_template *tmpl; fdacd57c79b79a Florian Westphal 2021-08-03 1241 struct xt_table *t; f4f502d5a8ea29 Dong Chenchen 2024-10-22 1242 int err = -ENOENT; 2e4e6a17af35be Harald Welte 2006-01-12 1243 7926dbfa4bc14e Pablo Neira Ayuso 2014-07-31 1244 mutex_lock(&xt[af].mutex); 1d610d4d31a8ed Florian Westphal 2021-04-01 1245 list_for_each_entry(t, &xt_net->tables[af], list) 2e4e6a17af35be Harald Welte 2006-01-12 1246 if (strcmp(t->name, name) == 0 && try_module_get(t->me)) 2e4e6a17af35be Harald Welte 2006-01-12 1247 return t; b9e69e12739718 Florian Westphal 2016-02-25 1248 fdacd57c79b79a Florian Westphal 2021-08-03 1249 /* Table doesn't exist in this netns, check larval list */ fdacd57c79b79a Florian Westphal 2021-08-03 1250 list_for_each_entry(tmpl, &xt_templates[af], list) { fdacd57c79b79a Florian Westphal 2021-08-03 1251 if (strcmp(tmpl->name, name)) b9e69e12739718 Florian Westphal 2016-02-25 1252 continue; fdacd57c79b79a Florian Westphal 2021-08-03 1253 if (!try_module_get(tmpl->me)) 03d13b6868a261 Florian Westphal 2017-12-08 1254 goto out; fdacd57c79b79a Florian Westphal 2021-08-03 1255 fdacd57c79b79a Florian Westphal 2021-08-03 1256 owner = tmpl->me; fdacd57c79b79a Florian Westphal 2021-08-03 1257 b9e69e12739718 Florian Westphal 2016-02-25 1258 mutex_unlock(&xt[af].mutex); fdacd57c79b79a Florian Westphal 2021-08-03 1259 err = tmpl->table_init(net); 03d13b6868a261 Florian Westphal 2017-12-08 1260 if (err < 0) { fdacd57c79b79a Florian Westphal 2021-08-03 1261 module_put(owner); 03d13b6868a261 Florian Westphal 2017-12-08 1262 return ERR_PTR(err); b9e69e12739718 Florian Westphal 2016-02-25 1263 } b9e69e12739718 Florian Westphal 2016-02-25 1264 b9e69e12739718 Florian Westphal 2016-02-25 1265 mutex_lock(&xt[af].mutex); b9e69e12739718 Florian Westphal 2016-02-25 1266 break; b9e69e12739718 Florian Westphal 2016-02-25 1267 } b9e69e12739718 Florian Westphal 2016-02-25 1268 f4f502d5a8ea29 Dong Chenchen 2024-10-22 1269 if (err < 0) f4f502d5a8ea29 Dong Chenchen 2024-10-22 1270 goto out; f4f502d5a8ea29 Dong Chenchen 2024-10-22 1271 b9e69e12739718 Florian Westphal 2016-02-25 1272 /* and once again: */ 1d610d4d31a8ed Florian Westphal 2021-04-01 1273 list_for_each_entry(t, &xt_net->tables[af], list) b9e69e12739718 Florian Westphal 2016-02-25 1274 if (strcmp(t->name, name) == 0) b9e69e12739718 Florian Westphal 2016-02-25 1275 return t; ret it zero here, but if we fail to find the name then we should set ret = -ENOENT; b9e69e12739718 Florian Westphal 2016-02-25 1276 fdacd57c79b79a Florian Westphal 2021-08-03 1277 module_put(owner); b9e69e12739718 Florian Westphal 2016-02-25 1278 out: 9e19bb6d7a0959 Ingo Molnar 2006-03-25 1279 mutex_unlock(&xt[af].mutex); f4f502d5a8ea29 Dong Chenchen 2024-10-22 @1280 return ERR_PTR(err); 2e4e6a17af35be Harald Welte 2006-01-12 1281 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki