Commit 9e2f9d3
committed
erofs: handle overlapped pclusters out of crafted images properly
syzbot reported a task hang issue due to a deadlock case where it is
waiting for the folio lock of a cached folio that will be used for
cache I/Os.
After looking into the crafted fuzzed image, I found it's formed with
several overlapped big pclusters as below:
Ext: logical offset | length : physical offset | length
0: 0.. 16384 | 16384 : 151552.. 167936 | 16384
1: 16384.. 32768 | 16384 : 155648.. 172032 | 16384
2: 32768.. 49152 | 16384 : 537223168.. 537239552 | 16384
...
Here, extent 0/1 are physically overlapped although it's entirely
_impossible_ for normal filesystem images generated by mkfs.
First, managed folios containing compressed data will be marked as
up-to-date and then unlocked immediately (unlike in-place folios) when
compressed I/Os are complete. If physical blocks are not submitted in
the incremental order, there should be separate BIOs to avoid dependency
issues. However, the current code mis-arranges z_erofs_fill_bio_vec()
and BIO submission which causes unexpected BIO waits.
Second, managed folios will be connected to their own pclusters for
efficient inter-queries. However, this is somewhat hard to implement
easily if overlapped big pclusters exist. Again, these only appear in
fuzzed images so let's simply fall back to temporary short-lived pages
for correctness.
Additionally, it justifies that referenced managed folios cannot be
truncated for now and reverts part of commit 2080ca1 ("erofs: tidy
up `struct z_erofs_bvec`") for simplicity although it shouldn't be any
difference.
Reported-by: [email protected]
Reported-by: [email protected]
Reported-by: [email protected]
Tested-by: [email protected]
Closes: https://lore.kernel.org/r/[email protected]
Fixes: 8e6c8fa ("erofs: enable big pcluster feature")
Signed-off-by: Gao Xiang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]1 parent 3fc3e45 commit 9e2f9d3
1 file changed
+38
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1428 | 1428 | | |
1429 | 1429 | | |
1430 | 1430 | | |
| 1431 | + | |
1431 | 1432 | | |
1432 | 1433 | | |
1433 | 1434 | | |
| |||
1450 | 1451 | | |
1451 | 1452 | | |
1452 | 1453 | | |
1453 | | - | |
1454 | 1454 | | |
1455 | 1455 | | |
1456 | 1456 | | |
| |||
1468 | 1468 | | |
1469 | 1469 | | |
1470 | 1470 | | |
1471 | | - | |
| 1471 | + | |
1472 | 1472 | | |
1473 | 1473 | | |
1474 | 1474 | | |
| |||
1478 | 1478 | | |
1479 | 1479 | | |
1480 | 1480 | | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
1486 | 1488 | | |
1487 | | - | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
1488 | 1497 | | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | 1498 | | |
1497 | 1499 | | |
1498 | 1500 | | |
1499 | | - | |
| 1501 | + | |
1500 | 1502 | | |
1501 | | - | |
1502 | | - | |
| 1503 | + | |
| 1504 | + | |
1503 | 1505 | | |
1504 | 1506 | | |
1505 | 1507 | | |
1506 | 1508 | | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
| 1509 | + | |
| 1510 | + | |
1511 | 1511 | | |
1512 | 1512 | | |
1513 | 1513 | | |
1514 | | - | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
1515 | 1517 | | |
| 1518 | + | |
1516 | 1519 | | |
1517 | 1520 | | |
1518 | 1521 | | |
| |||
1647 | 1650 | | |
1648 | 1651 | | |
1649 | 1652 | | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
| 1653 | + | |
1654 | 1654 | | |
1655 | 1655 | | |
1656 | | - | |
| 1656 | + | |
1657 | 1657 | | |
1658 | 1658 | | |
1659 | 1659 | | |
| |||
1666 | 1666 | | |
1667 | 1667 | | |
1668 | 1668 | | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
1669 | 1678 | | |
1670 | 1679 | | |
1671 | 1680 | | |
| |||
1685 | 1694 | | |
1686 | 1695 | | |
1687 | 1696 | | |
1688 | | - | |
1689 | | - | |
1690 | | - | |
1691 | 1697 | | |
1692 | 1698 | | |
1693 | | - | |
1694 | | - | |
| 1699 | + | |
1695 | 1700 | | |
1696 | 1701 | | |
1697 | 1702 | | |
| |||
0 commit comments