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
606606 free_extent_map(em);
607607
608608 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);
610610 if (!cb->compressed_folios) {
611611 ret = BLK_STS_RESOURCE;
612612 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
35083508 ASSERT(folio_test_locked(folio));
35093509 xa_lock_irq(&folio->mapping->i_pages);
35103510 if (!folio_test_dirty(folio))
3511− __xa_clear_mark(&folio->mapping->i_pages,
3512− folio_index(folio), PAGECACHE_TAG_DIRTY);
3511+ __xa_clear_mark(&folio->mapping->i_pages, folio->index,
3512+ PAGECACHE_TAG_DIRTY);
35133513 xa_unlock_irq(&folio->mapping->i_pages);
35143514 }
35153515
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
298298 */
299299 static inline int __pure num_extent_folios(const struct extent_buffer *eb)
300300 {
301+ if (!eb->folios[0])
302+ return 0;
301303 if (folio_order(eb->folios[0]))
302304 return 1;
303305 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
15411541 u64 extent_gen;
15421542 int ret;
15431543
1544− if (unlikely(!extent_root)) {
1545− btrfs_err(fs_info, "no valid extent root for scrub");
1544+ if (unlikely(!extent_root || !csum_root)) {
1545+ btrfs_err(fs_info, "no valid extent or csum root for scrub");
15461546 return -EUCLEAN;
15471547 }
15481548 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
733733 return has_metadata_uuid ? sb->metadata_uuid : sb->fsid;
734734 }
735735
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− */
745−static 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;
773−out:
774− kfree(path_buf);
775− path_put(&path);
776− return is_good;
777−}
778−
779−static 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);
806−out:
807− kfree(path_buf);
808− path_put(&path);
809− return ret;
810−}
811−
812736 static bool is_same_device(struct btrfs_device *device, const char *new_path)
813737 {
814738 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
15131437 bool new_device_added = false;
15141438 struct btrfs_device *device = NULL;
15151439 struct file *bdev_file;
1516− char *canonical_path = NULL;
15171440 u64 bytenr;
15181441 dev_t devt;
15191442 int ret;
15201443
15211444 lockdep_assert_held(&uuid_mutex);
15221445
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− }
15331446 /*
15341447 * Avoid an exclusive open here, as the systemd-udev may initiate the
15351448 * 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
15741487 goto free_disk_super;
15751488 }
15761489
1577− device = device_list_add(canonical_path ? : path, disk_super,
1578− &new_device_added);
1490+ device = device_list_add(path, disk_super, &new_device_added);
15791491 if (!IS_ERR(device) && new_device_added)
15801492 btrfs_free_stale_devices(device->devt, device);
15811493
@@ -1584,7 +1496,6 @@ free_disk_super: · 2 unmodified lines
15841496
15851497 error_bdev_put:
15861498 fput(bdev_file);
1587− kfree(canonical_path);
15881499
15891500 return device;
15901501 }
include/trace/events/btrfs.h+1−1
@@ -1928,7 +1928,7 @@ DECLARE_EVENT_CLASS(btrfs__prelim_ref, · 1927 unmodified lines
19281928 TP_PROTO(const struct btrfs_fs_info *fs_info,
19291929 const struct prelim_ref *oldref,
19301930 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),
19321932
19331933 TP_STRUCT__entry_btrfs(
19341934 __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