History

Merge tag 'for-6.15-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba: - revert device path canonicalization, this does not work as intended with namespaces and is not reliable in all setups - fix crash in scrub when checksum tree is not valid, e.g. when mounted with rescue=ignoredatacsums - fix crash when tracepoint btrfs_prelim_ref_insert is enabled - other minor fixups: - open code folio_index(), meant to be used in MM code - use matching type for sizeof in compression allocation * tag 'for-6.15-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: open code folio_index() in btree_clear_folio_dirty_tag() Revert "btrfs: canonicalize the device path before adding it" btrfs: avoid NULL pointer dereference if no valid csum tree btrfs: handle empty eb->folios in num_extent_folios() btrfs: correct the order of prelim_ref arguments in btrfs__prelim_ref btrfs: compression: adjust cb->compressed_folios allocation type

Linus Torvalds committed 1 year ago

Commit 0d8d44d2 parents cccd033 38e54106 files · +9 −96Browse files

Unified · Split

6 files
  1. fs/btrfs/compression.c +1 −1
  2. fs/btrfs/extent_io.c +2 −2
  3. fs/btrfs/extent_io.h +2 −0
  4. fs/btrfs/scrub.c +2 −2
  5. fs/btrfs/volumes.c +1 −90
  6. include/trace/events/btrfs.h +1 −1
fs/btrfs/compression.c+1−1
@@ -606,7 +606,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio) · 605 unmodified lines
606 free_extent_map(em);606 free_extent_map(em);
607 607
608 cb->nr_folios = DIV_ROUND_UP(compressed_len, PAGE_SIZE);608 cb->nr_folios = DIV_ROUND_UP(compressed_len, PAGE_SIZE);
609 cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct page *), GFP_NOFS);609 cb->compressed_folios = kcalloc(cb->nr_folios, sizeof(struct folio *), GFP_NOFS);
610 if (!cb->compressed_folios) {610 if (!cb->compressed_folios) {
611 ret = BLK_STS_RESOURCE;611 ret = BLK_STS_RESOURCE;
612 goto out_free_bio;612 goto out_free_bio;
fs/btrfs/extent_io.c+2−2
@@ -3508,8 +3508,8 @@ static void btree_clear_folio_dirty_tag(struct folio *folio) · 3507 unmodified lines
3508 ASSERT(folio_test_locked(folio));3508 ASSERT(folio_test_locked(folio));
3509 xa_lock_irq(&folio->mapping->i_pages);3509 xa_lock_irq(&folio->mapping->i_pages);
3510 if (!folio_test_dirty(folio))3510 if (!folio_test_dirty(folio))
3511 __xa_clear_mark(&folio->mapping->i_pages,3511 __xa_clear_mark(&folio->mapping->i_pages, folio->index,
3512 folio_index(folio), PAGECACHE_TAG_DIRTY);3512 PAGECACHE_TAG_DIRTY);
3513 xa_unlock_irq(&folio->mapping->i_pages);3513 xa_unlock_irq(&folio->mapping->i_pages);
3514}3514}
3515 3515
fs/btrfs/extent_io.h+2−0
@@ -298,6 +298,8 @@ static inline int __pure num_extent_pages(const struct extent_buffer *eb) · 297 unmodified lines
298 */298 */
299static inline int __pure num_extent_folios(const struct extent_buffer *eb)299static inline int __pure num_extent_folios(const struct extent_buffer *eb)
300{300{
301 if (!eb->folios[0])
302 return 0;
301 if (folio_order(eb->folios[0]))303 if (folio_order(eb->folios[0]))
302 return 1;304 return 1;
303 return num_extent_pages(eb);305 return num_extent_pages(eb);
fs/btrfs/scrub.c+2−2
@@ -1541,8 +1541,8 @@ static int scrub_find_fill_first_stripe(struct btrfs_block_group *bg, · 1540 unmodified lines
1541 u64 extent_gen;1541 u64 extent_gen;
1542 int ret;1542 int ret;
1543 1543
1544 if (unlikely(!extent_root)) {1544 if (unlikely(!extent_root || !csum_root)) {
1545 btrfs_err(fs_info, "no valid extent root for scrub");1545 btrfs_err(fs_info, "no valid extent or csum root for scrub");
1546 return -EUCLEAN;1546 return -EUCLEAN;
1547 }1547 }
1548 memset(stripe->sectors, 0, sizeof(struct scrub_sector_verification) *1548 memset(stripe->sectors, 0, sizeof(struct scrub_sector_verification) *
fs/btrfs/volumes.c+1−90
@@ -733,82 +733,6 @@ const u8 *btrfs_sb_fsid_ptr(const struct btrfs_super_block *sb) · 732 unmodified lines
733 return has_metadata_uuid ? sb->metadata_uuid : sb->fsid;733 return has_metadata_uuid ? sb->metadata_uuid : sb->fsid;
734}734}
735 735
736/*
737 * We can have very weird soft links passed in.
738 * One example is "/proc/self/fd/<fd>", which can be a soft link to
739 * a block device.
740 *
741 * But it's never a good idea to use those weird names.
742 * Here we check if the path (not following symlinks) is a good one inside
743 * "/dev/".
744 */
745static bool is_good_dev_path(const char *dev_path)
746{
747 struct path path = { .mnt = NULL, .dentry = NULL };
748 char *path_buf = NULL;
749 char *resolved_path;
750 bool is_good = false;
751 int ret;
752
753 if (!dev_path)
754 goto out;
755
756 path_buf = kmalloc(PATH_MAX, GFP_KERNEL);
757 if (!path_buf)
758 goto out;
759
760 /*
761 * Do not follow soft link, just check if the original path is inside
762 * "/dev/".
763 */
764 ret = kern_path(dev_path, 0, &path);
765 if (ret)
766 goto out;
767 resolved_path = d_path(&path, path_buf, PATH_MAX);
768 if (IS_ERR(resolved_path))
769 goto out;
770 if (strncmp(resolved_path, "/dev/", strlen("/dev/")))
771 goto out;
772 is_good = true;
773out:
774 kfree(path_buf);
775 path_put(&path);
776 return is_good;
777}
778
779static int get_canonical_dev_path(const char *dev_path, char *canonical)
780{
781 struct path path = { .mnt = NULL, .dentry = NULL };
782 char *path_buf = NULL;
783 char *resolved_path;
784 int ret;
785
786 if (!dev_path) {
787 ret = -EINVAL;
788 goto out;
789 }
790
791 path_buf = kmalloc(PATH_MAX, GFP_KERNEL);
792 if (!path_buf) {
793 ret = -ENOMEM;
794 goto out;
795 }
796
797 ret = kern_path(dev_path, LOOKUP_FOLLOW, &path);
798 if (ret)
799 goto out;
800 resolved_path = d_path(&path, path_buf, PATH_MAX);
801 if (IS_ERR(resolved_path)) {
802 ret = PTR_ERR(resolved_path);
803 goto out;
804 }
805 ret = strscpy(canonical, resolved_path, PATH_MAX);
806out:
807 kfree(path_buf);
808 path_put(&path);
809 return ret;
810}
811
812static bool is_same_device(struct btrfs_device *device, const char *new_path)736static bool is_same_device(struct btrfs_device *device, const char *new_path)
813{737{
814 struct path old = { .mnt = NULL, .dentry = NULL };738 struct path old = { .mnt = NULL, .dentry = NULL };
@@ -1513,23 +1437,12 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, · 698 unmodified lines
1513 bool new_device_added = false;1437 bool new_device_added = false;
1514 struct btrfs_device *device = NULL;1438 struct btrfs_device *device = NULL;
1515 struct file *bdev_file;1439 struct file *bdev_file;
1516 char *canonical_path = NULL;
1517 u64 bytenr;1440 u64 bytenr;
1518 dev_t devt;1441 dev_t devt;
1519 int ret;1442 int ret;
1520 1443
1521 lockdep_assert_held(&uuid_mutex);1444 lockdep_assert_held(&uuid_mutex);
1522 1445
1523 if (!is_good_dev_path(path)) {
1524 canonical_path = kmalloc(PATH_MAX, GFP_KERNEL);
1525 if (canonical_path) {
1526 ret = get_canonical_dev_path(path, canonical_path);
1527 if (ret < 0) {
1528 kfree(canonical_path);
1529 canonical_path = NULL;
1530 }
1531 }
1532 }
1533 /*1446 /*
1534 * Avoid an exclusive open here, as the systemd-udev may initiate the1447 * Avoid an exclusive open here, as the systemd-udev may initiate the
1535 * device scan which may race with the user's mount or mkfs command,1448 * device scan which may race with the user's mount or mkfs command,
@@ -1574,8 +1487,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, · 38 unmodified lines
1574 goto free_disk_super;1487 goto free_disk_super;
1575 }1488 }
1576 1489
1577 device = device_list_add(canonical_path ? : path, disk_super,1490 device = device_list_add(path, disk_super, &new_device_added);
1578 &new_device_added);
1579 if (!IS_ERR(device) && new_device_added)1491 if (!IS_ERR(device) && new_device_added)
1580 btrfs_free_stale_devices(device->devt, device);1492 btrfs_free_stale_devices(device->devt, device);
1581 1493
@@ -1584,7 +1496,6 @@ free_disk_super: · 2 unmodified lines
1584 1496
1585error_bdev_put:1497error_bdev_put:
1586 fput(bdev_file);1498 fput(bdev_file);
1587 kfree(canonical_path);
1588 1499
1589 return device;1500 return device;
1590}1501}
include/trace/events/btrfs.h+1−1
@@ -1928,7 +1928,7 @@ DECLARE_EVENT_CLASS(btrfs__prelim_ref, · 1927 unmodified lines
1928 TP_PROTO(const struct btrfs_fs_info *fs_info,1928 TP_PROTO(const struct btrfs_fs_info *fs_info,
1929 const struct prelim_ref *oldref,1929 const struct prelim_ref *oldref,
1930 const struct prelim_ref *newref, u64 tree_size),1930 const struct prelim_ref *newref, u64 tree_size),
1931 TP_ARGS(fs_info, newref, oldref, tree_size),1931 TP_ARGS(fs_info, oldref, newref, tree_size),
1932 1932
1933 TP_STRUCT__entry_btrfs(1933 TP_STRUCT__entry_btrfs(
1934 __field( u64, root_id )1934 __field( u64, root_id )

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t