Commit b367318
loop: Avoid updating block size under exclusive owner
[ Upstream commit 7e49538 ]
Syzbot came up with a reproducer where a loop device block size is
changed underneath a mounted filesystem. This causes a mismatch between
the block device block size and the block size stored in the superblock
causing confusion in various places such as fs/buffer.c. The particular
issue triggered by syzbot was a warning in __getblk_slow() due to
requested buffer size not matching block device block size.
Fix the problem by getting exclusive hold of the loop device to change
its block size. This fails if somebody (such as filesystem) has already
an exclusive ownership of the block device and thus prevents modifying
the loop device under some exclusive owner which doesn't expect it.
Reported-by: syzbot+01ef7a8da81a975e1ccd@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Tested-by: syzbot+01ef7a8da81a975e1ccd@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20250711163202.19623-2-jack@suse.cz
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit ce8da5d13d8c2a7b30b2fb376a22e8eb1a70b8bb)1 parent 118ba78 commit b367318
1 file changed
Lines changed: 30 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1472 | 1472 | | |
1473 | 1473 | | |
1474 | 1474 | | |
1475 | | - | |
| 1475 | + | |
| 1476 | + | |
1476 | 1477 | | |
1477 | 1478 | | |
1478 | 1479 | | |
1479 | | - | |
1480 | | - | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
1481 | 1498 | | |
1482 | 1499 | | |
1483 | 1500 | | |
1484 | 1501 | | |
1485 | 1502 | | |
1486 | 1503 | | |
1487 | | - | |
| 1504 | + | |
1488 | 1505 | | |
1489 | 1506 | | |
1490 | 1507 | | |
| |||
1496 | 1513 | | |
1497 | 1514 | | |
1498 | 1515 | | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
1499 | 1521 | | |
1500 | 1522 | | |
1501 | 1523 | | |
| |||
1514 | 1536 | | |
1515 | 1537 | | |
1516 | 1538 | | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | 1539 | | |
1521 | 1540 | | |
1522 | 1541 | | |
| |||
1571 | 1590 | | |
1572 | 1591 | | |
1573 | 1592 | | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
1574 | 1597 | | |
1575 | 1598 | | |
1576 | | - | |
1577 | 1599 | | |
1578 | 1600 | | |
1579 | 1601 | | |
| |||
0 commit comments