From: kernel test robot <lkp@intel.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: oe-kbuild-all@lists.linux.dev, ntfs3@lists.linux.dev
Subject: [paragon-software-group-ntfs3:master 11/13] fs/ntfs3/super.c:1473:40: sparse: sparse: incorrect type in initializer (different base types)
Date: Thu, 18 Apr 2024 11:26:35 +0800 [thread overview]
Message-ID: <202404181111.Wz8a1qX6-lkp@intel.com> (raw)
tree: https://github.com/Paragon-Software-Group/linux-ntfs3.git master
head: 21b6b5bc6774720b8298d9e362bec01a53ec693b
commit: ad4d82df0d44e558d23aba1954040e9b531796c4 [11/13] fs/ntfs3: Optimize to store sorted attribute definition table
config: parisc-randconfig-r133-20240418 (https://download.01.org/0day-ci/archive/20240418/202404181111.Wz8a1qX6-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240418/202404181111.Wz8a1qX6-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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404181111.Wz8a1qX6-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
fs/ntfs3/super.c:465:23: sparse: sparse: unknown escape sequence: '%'
>> fs/ntfs3/super.c:1473:40: sparse: sparse: incorrect type in initializer (different base types) @@ expected restricted __le16 const [usertype] *src @@ got unsigned short [usertype] *upcase @@
fs/ntfs3/super.c:1473:40: sparse: expected restricted __le16 const [usertype] *src
fs/ntfs3/super.c:1473:40: sparse: got unsigned short [usertype] *upcase
vim +1473 fs/ntfs3/super.c
1339
1340 /* Check bitmap boundary. */
1341 tt = sbi->used.bitmap.nbits;
1342 if (inode->i_size < bitmap_size(tt)) {
1343 ntfs_err(sb, "$Bitmap is corrupted.");
1344 err = -EINVAL;
1345 goto put_inode_out;
1346 }
1347
1348 err = wnd_init(&sbi->used.bitmap, sb, tt);
1349 if (err) {
1350 ntfs_err(sb, "Failed to initialize $Bitmap (%d).", err);
1351 goto put_inode_out;
1352 }
1353
1354 iput(inode);
1355
1356 /* Compute the MFT zone. */
1357 err = ntfs_refresh_zone(sbi);
1358 if (err) {
1359 ntfs_err(sb, "Failed to initialize MFT zone (%d).", err);
1360 goto out;
1361 }
1362
1363 /* Load $BadClus. */
1364 ref.low = cpu_to_le32(MFT_REC_BADCLUST);
1365 ref.seq = cpu_to_le16(MFT_REC_BADCLUST);
1366 inode = ntfs_iget5(sb, &ref, &NAME_BADCLUS);
1367 if (IS_ERR(inode)) {
1368 err = PTR_ERR(inode);
1369 ntfs_err(sb, "Failed to load $BadClus (%d).", err);
1370 goto out;
1371 }
1372
1373 ni = ntfs_i(inode);
1374 bad_len = bad_frags = 0;
1375 for (i = 0; run_get_entry(&ni->file.run, i, &vcn, &lcn, &len); i++) {
1376 if (lcn == SPARSE_LCN)
1377 continue;
1378
1379 bad_len += len;
1380 bad_frags += 1;
1381 if (ro)
1382 continue;
1383
1384 if (wnd_set_used_safe(&sbi->used.bitmap, lcn, len, &tt) || tt) {
1385 /* Bad blocks marked as free in bitmap. */
1386 ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
1387 }
1388 }
1389 if (bad_len) {
1390 /*
1391 * Notice about bad blocks.
1392 * In normal cases these blocks are marked as used in bitmap.
1393 * And we never allocate space in it.
1394 */
1395 ntfs_notice(sb,
1396 "Volume contains %zu bad blocks in %zu fragments.",
1397 bad_len, bad_frags);
1398 }
1399 iput(inode);
1400
1401 /* Load $AttrDef. */
1402 ref.low = cpu_to_le32(MFT_REC_ATTR);
1403 ref.seq = cpu_to_le16(MFT_REC_ATTR);
1404 inode = ntfs_iget5(sb, &ref, &NAME_ATTRDEF);
1405 if (IS_ERR(inode)) {
1406 err = PTR_ERR(inode);
1407 ntfs_err(sb, "Failed to load $AttrDef (%d)", err);
1408 goto out;
1409 }
1410
1411 /*
1412 * Typical $AttrDef contains up to 20 entries.
1413 * Check for extremely large/small size.
1414 */
1415 if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY) ||
1416 inode->i_size > 100 * sizeof(struct ATTR_DEF_ENTRY)) {
1417 ntfs_err(sb, "Looks like $AttrDef is corrupted (size=%llu).",
1418 inode->i_size);
1419 err = -EINVAL;
1420 goto put_inode_out;
1421 }
1422
1423 {
1424 u32 bytes = inode->i_size;
1425 struct ATTR_DEF_ENTRY *def_table = kmalloc(bytes, GFP_KERNEL);
1426 if (!def_table) {
1427 err = -ENOMEM;
1428 goto put_inode_out;
1429 }
1430
1431 /* Read the entire file. */
1432 err = inode_read_data(inode, def_table, bytes);
1433 if (err) {
1434 ntfs_err(sb, "Failed to read $AttrDef (%d).", err);
1435 } else {
1436 /* Check content and store sorted array. */
1437 err = ntfs_check_attr_def(sbi, def_table, bytes);
1438 if (err)
1439 ntfs_err(sb, "$AttrDef is corrupted.");
1440 }
1441
1442 kfree(def_table);
1443 if (err)
1444 goto put_inode_out;
1445 }
1446 iput(inode);
1447
1448 /* Load $UpCase. */
1449 ref.low = cpu_to_le32(MFT_REC_UPCASE);
1450 ref.seq = cpu_to_le16(MFT_REC_UPCASE);
1451 inode = ntfs_iget5(sb, &ref, &NAME_UPCASE);
1452 if (IS_ERR(inode)) {
1453 err = PTR_ERR(inode);
1454 ntfs_err(sb, "Failed to load $UpCase (%d).", err);
1455 goto out;
1456 }
1457
1458 if (inode->i_size != 0x10000 * sizeof(short)) {
1459 err = -EINVAL;
1460 ntfs_err(sb, "$UpCase is corrupted.");
1461 goto put_inode_out;
1462 }
1463
1464 /* Read the entire file. */
1465 err = inode_read_data(inode, sbi->upcase, 0x10000 * sizeof(short));
1466 if (err) {
1467 ntfs_err(sb, "Failed to read $UpCase (%d).", err);
1468 goto put_inode_out;
1469 }
1470
1471 #ifdef __BIG_ENDIAN
1472 {
> 1473 const __le16 *src = sbi->upcase;
1474 u16 *dst = sbi->upcase;
1475
1476 for (i = 0; i < 0x10000; i++)
1477 *dst++ = le16_to_cpu(*src++);
1478 }
1479 #endif
1480
1481 shared = ntfs_set_shared(sbi->upcase, 0x10000 * sizeof(short));
1482 if (shared && sbi->upcase != shared) {
1483 kvfree(sbi->upcase);
1484 sbi->upcase = shared;
1485 }
1486
1487 iput(inode);
1488
1489 if (is_ntfs3(sbi)) {
1490 /* Load $Secure. */
1491 err = ntfs_security_init(sbi);
1492 if (err) {
1493 ntfs_err(sb, "Failed to initialize $Secure (%d).", err);
1494 goto out;
1495 }
1496
1497 /* Load $Extend. */
1498 err = ntfs_extend_init(sbi);
1499 if (err) {
1500 ntfs_warn(sb, "Failed to initialize $Extend.");
1501 goto load_root;
1502 }
1503
1504 /* Load $Extend/$Reparse. */
1505 err = ntfs_reparse_init(sbi);
1506 if (err) {
1507 ntfs_warn(sb, "Failed to initialize $Extend/$Reparse.");
1508 goto load_root;
1509 }
1510
1511 /* Load $Extend/$ObjId. */
1512 err = ntfs_objid_init(sbi);
1513 if (err) {
1514 ntfs_warn(sb, "Failed to initialize $Extend/$ObjId.");
1515 goto load_root;
1516 }
1517 }
1518
1519 load_root:
1520 /* Load root. */
1521 ref.low = cpu_to_le32(MFT_REC_ROOT);
1522 ref.seq = cpu_to_le16(MFT_REC_ROOT);
1523 inode = ntfs_iget5(sb, &ref, &NAME_ROOT);
1524 if (IS_ERR(inode)) {
1525 err = PTR_ERR(inode);
1526 ntfs_err(sb, "Failed to load root (%d).", err);
1527 goto out;
1528 }
1529
1530 /*
1531 * Final check. Looks like this case should never occurs.
1532 */
1533 if (!inode->i_op) {
1534 err = -EINVAL;
1535 ntfs_err(sb, "Failed to load root (%d).", err);
1536 goto put_inode_out;
1537 }
1538
1539 sb->s_root = d_make_root(inode);
1540 if (!sb->s_root) {
1541 err = -ENOMEM;
1542 goto put_inode_out;
1543 }
1544
1545 if (boot2) {
1546 /*
1547 * Alternative boot is ok but primary is not ok.
1548 * Volume is recognized as NTFS. Update primary boot.
1549 */
1550 struct buffer_head *bh0 = sb_getblk(sb, 0);
1551 if (bh0) {
1552 if (buffer_locked(bh0))
1553 __wait_on_buffer(bh0);
1554
1555 lock_buffer(bh0);
1556 memcpy(bh0->b_data, boot2, sizeof(*boot2));
1557 set_buffer_uptodate(bh0);
1558 mark_buffer_dirty(bh0);
1559 unlock_buffer(bh0);
1560 if (!sync_dirty_buffer(bh0))
1561 ntfs_warn(sb, "primary boot is updated");
1562 put_bh(bh0);
1563 }
1564
1565 kfree(boot2);
1566 }
1567
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2024-04-18 3:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202404181111.Wz8a1qX6-lkp@intel.com \
--to=lkp@intel.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=ntfs3@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox