lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202211050153.EzdXBoMu-lkp@intel.com>
Date:   Sat, 5 Nov 2022 14:12:13 +0300
From:   Dan Carpenter <error27@...il.com>
To:     oe-kbuild@...ts.linux.dev, Kees Cook <keescook@...omium.org>
Cc:     lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org, Jens Axboe <axboe@...nel.dk>
Subject: fs/pstore/zone.c:1421 register_pstore_zone() warn: inconsistent
 returns '&cxt->pstore_zone_info_lock'.

Hi Kees,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ee6050c8af96bba2f81e8b0793a1fc2f998fcd20
commit: d1faacbf67b1944f0e0c618dc581d929263f6fe9 Revert "mark pstore-blk as broken"
config: s390-randconfig-m031-20221104
compiler: s390-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <error27@...il.com>

smatch warnings:
fs/pstore/zone.c:1421 register_pstore_zone() warn: inconsistent returns '&cxt->pstore_zone_info_lock'.

vim +1421 fs/pstore/zone.c

d26c3321fe18dc WeiXiong Liao 2020-03-25  1341  	if (!info->read || !info->write) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1342  		pr_err("no valid general read/write interface\n");
d26c3321fe18dc WeiXiong Liao 2020-03-25  1343  		return -EINVAL;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1344  	}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1345  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1346  	mutex_lock(&cxt->pstore_zone_info_lock);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1347  	if (cxt->pstore_zone_info) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1348  		pr_warn("'%s' already loaded: ignoring '%s'\n",
d26c3321fe18dc WeiXiong Liao 2020-03-25  1349  				cxt->pstore_zone_info->name, info->name);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1350  		mutex_unlock(&cxt->pstore_zone_info_lock);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1351  		return -EBUSY;

This is a false positive.  Smatch can't see that
"&cxt->pstore_zone_info_lock" and "&pstore_zone_cxt.pstore_zone_info_lock"
are the same.  (Presumably they are.  I haven't looked at the context
outside this email).

d26c3321fe18dc WeiXiong Liao 2020-03-25  1352  	}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1353  	cxt->pstore_zone_info = info;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1354  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1355  	pr_debug("register %s with properties:\n", info->name);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1356  	pr_debug("\ttotal size : %ld Bytes\n", info->total_size);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1357  	pr_debug("\tkmsg size : %ld Bytes\n", info->kmsg_size);
0dc068265a1c59 WeiXiong Liao 2020-03-25  1358  	pr_debug("\tpmsg size : %ld Bytes\n", info->pmsg_size);
cc9c4d1b559716 WeiXiong Liao 2020-03-25  1359  	pr_debug("\tconsole size : %ld Bytes\n", info->console_size);
34327e9fd21341 WeiXiong Liao 2020-03-25  1360  	pr_debug("\tftrace size : %ld Bytes\n", info->ftrace_size);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1361  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1362  	err = psz_alloc_zones(cxt);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1363  	if (err) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1364  		pr_err("alloc zones failed\n");
d26c3321fe18dc WeiXiong Liao 2020-03-25  1365  		goto fail_out;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1366  	}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1367  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1368  	if (info->kmsg_size) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1369  		cxt->pstore.bufsize = cxt->kpszs[0]->buffer_size -
d26c3321fe18dc WeiXiong Liao 2020-03-25  1370  			sizeof(struct psz_kmsg_header);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1371  		cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1372  		if (!cxt->pstore.buf) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1373  			err = -ENOMEM;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1374  			goto fail_free;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1375  		}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1376  	}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1377  	cxt->pstore.data = cxt;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1378  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1379  	pr_info("registered %s as backend for", info->name);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1380  	cxt->pstore.max_reason = info->max_reason;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1381  	cxt->pstore.name = info->name;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1382  	if (info->kmsg_size) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1383  		cxt->pstore.flags |= PSTORE_FLAGS_DMESG;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1384  		pr_cont(" kmsg(%s",
d26c3321fe18dc WeiXiong Liao 2020-03-25  1385  			kmsg_dump_reason_str(cxt->pstore.max_reason));
d26c3321fe18dc WeiXiong Liao 2020-03-25  1386  		if (cxt->pstore_zone_info->panic_write)
d26c3321fe18dc WeiXiong Liao 2020-03-25  1387  			pr_cont(",panic_write");
d26c3321fe18dc WeiXiong Liao 2020-03-25  1388  		pr_cont(")");
d26c3321fe18dc WeiXiong Liao 2020-03-25  1389  	}
0dc068265a1c59 WeiXiong Liao 2020-03-25  1390  	if (info->pmsg_size) {
0dc068265a1c59 WeiXiong Liao 2020-03-25  1391  		cxt->pstore.flags |= PSTORE_FLAGS_PMSG;
0dc068265a1c59 WeiXiong Liao 2020-03-25  1392  		pr_cont(" pmsg");
0dc068265a1c59 WeiXiong Liao 2020-03-25  1393  	}
cc9c4d1b559716 WeiXiong Liao 2020-03-25  1394  	if (info->console_size) {
cc9c4d1b559716 WeiXiong Liao 2020-03-25  1395  		cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE;
cc9c4d1b559716 WeiXiong Liao 2020-03-25  1396  		pr_cont(" console");
cc9c4d1b559716 WeiXiong Liao 2020-03-25  1397  	}
34327e9fd21341 WeiXiong Liao 2020-03-25  1398  	if (info->ftrace_size) {
34327e9fd21341 WeiXiong Liao 2020-03-25  1399  		cxt->pstore.flags |= PSTORE_FLAGS_FTRACE;
34327e9fd21341 WeiXiong Liao 2020-03-25  1400  		pr_cont(" ftrace");
34327e9fd21341 WeiXiong Liao 2020-03-25  1401  	}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1402  	pr_cont("\n");
d26c3321fe18dc WeiXiong Liao 2020-03-25  1403  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1404  	err = pstore_register(&cxt->pstore);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1405  	if (err) {
d26c3321fe18dc WeiXiong Liao 2020-03-25  1406  		pr_err("registering with pstore failed\n");
d26c3321fe18dc WeiXiong Liao 2020-03-25  1407  		goto fail_free;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1408  	}
d26c3321fe18dc WeiXiong Liao 2020-03-25  1409  	mutex_unlock(&pstore_zone_cxt.pstore_zone_info_lock);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1410  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1411  	return 0;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1412  
d26c3321fe18dc WeiXiong Liao 2020-03-25  1413  fail_free:
d26c3321fe18dc WeiXiong Liao 2020-03-25  1414  	kfree(cxt->pstore.buf);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1415  	cxt->pstore.buf = NULL;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1416  	cxt->pstore.bufsize = 0;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1417  	psz_free_all_zones(cxt);
d26c3321fe18dc WeiXiong Liao 2020-03-25  1418  fail_out:
d26c3321fe18dc WeiXiong Liao 2020-03-25  1419  	pstore_zone_cxt.pstore_zone_info = NULL;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1420  	mutex_unlock(&pstore_zone_cxt.pstore_zone_info_lock);
d26c3321fe18dc WeiXiong Liao 2020-03-25 @1421  	return err;
d26c3321fe18dc WeiXiong Liao 2020-03-25  1422  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ