Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'fs_for_v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull ext2, udf, and isofs updates from Jan Kara:

- conversion of ext2 to the new mount API

- small folio conversion work for ext2

- a fix of an unexpected return value in udf in inode_getblk()

- a fix of handling of corrupted directory in isofs

* tag 'fs_for_v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
udf: Fix inode_getblk() return value
ext2: Make ext2_params_spec static
ext2: create ext2_msg_fc for use during parsing
ext2: convert to the new mount API
ext2: Remove reference to bh->b_page
isofs: fix KMSAN uninit-value bug in do_isofs_readdir()

+334 -260
+1
fs/ext2/ext2.h
··· 368 368 #define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */ 369 369 #define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */ 370 370 #define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */ 371 + #define EXT2_MOUNT_ERRORS_MASK 0x000070 371 372 #define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */ 372 373 #define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */ 373 374 #define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */
+330 -259
fs/ext2/super.c
··· 23 23 #include <linux/slab.h> 24 24 #include <linux/init.h> 25 25 #include <linux/blkdev.h> 26 - #include <linux/parser.h> 26 + #include <linux/fs_context.h> 27 + #include <linux/fs_parser.h> 27 28 #include <linux/random.h> 28 29 #include <linux/buffer_head.h> 29 30 #include <linux/exportfs.h> ··· 41 40 #include "acl.h" 42 41 43 42 static void ext2_write_super(struct super_block *sb); 44 - static int ext2_remount (struct super_block * sb, int * flags, char * data); 45 43 static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf); 46 44 static int ext2_sync_fs(struct super_block *sb, int wait); 47 45 static int ext2_freeze(struct super_block *sb); ··· 79 79 "error: remounting filesystem read-only"); 80 80 sb->s_flags |= SB_RDONLY; 81 81 } 82 + } 83 + 84 + static void ext2_msg_fc(struct fs_context *fc, const char *prefix, 85 + const char *fmt, ...) 86 + { 87 + struct va_format vaf; 88 + va_list args; 89 + const char *s_id; 90 + 91 + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { 92 + s_id = fc->root->d_sb->s_id; 93 + } else { 94 + /* get last path component of source */ 95 + s_id = strrchr(fc->source, '/'); 96 + if (s_id) 97 + s_id++; 98 + else 99 + s_id = fc->source; 100 + } 101 + va_start(args, fmt); 102 + 103 + vaf.fmt = fmt; 104 + vaf.va = &args; 105 + 106 + printk("%sEXT2-fs (%s): %pV\n", prefix, s_id, &vaf); 107 + 108 + va_end(args); 82 109 } 83 110 84 111 void ext2_msg(struct super_block *sb, const char *prefix, ··· 373 346 .freeze_fs = ext2_freeze, 374 347 .unfreeze_fs = ext2_unfreeze, 375 348 .statfs = ext2_statfs, 376 - .remount_fs = ext2_remount, 377 349 .show_options = ext2_show_options, 378 350 #ifdef CONFIG_QUOTA 379 351 .quota_read = ext2_quota_read, ··· 428 402 .get_parent = ext2_get_parent, 429 403 }; 430 404 431 - static unsigned long get_sb_block(void **data) 432 - { 433 - unsigned long sb_block; 434 - char *options = (char *) *data; 405 + enum { 406 + Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, Opt_resgid, Opt_resuid, 407 + Opt_sb, Opt_errors, Opt_nouid32, Opt_debug, Opt_oldalloc, Opt_orlov, 408 + Opt_nobh, Opt_user_xattr, Opt_acl, Opt_xip, Opt_dax, Opt_ignore, 409 + Opt_quota, Opt_usrquota, Opt_grpquota, Opt_reservation, 410 + }; 435 411 436 - if (!options || strncmp(options, "sb=", 3) != 0) 437 - return 1; /* Default location */ 438 - options += 3; 439 - sb_block = simple_strtoul(options, &options, 0); 440 - if (*options && *options != ',') { 441 - printk("EXT2-fs: Invalid sb specification: %s\n", 442 - (char *) *data); 443 - return 1; 444 - } 445 - if (*options == ',') 446 - options++; 447 - *data = (void *) options; 448 - return sb_block; 412 + static const struct constant_table ext2_param_errors[] = { 413 + {"continue", EXT2_MOUNT_ERRORS_CONT}, 414 + {"panic", EXT2_MOUNT_ERRORS_PANIC}, 415 + {"remount-ro", EXT2_MOUNT_ERRORS_RO}, 416 + {} 417 + }; 418 + 419 + static const struct fs_parameter_spec ext2_param_spec[] = { 420 + fsparam_flag ("bsddf", Opt_bsd_df), 421 + fsparam_flag ("minixdf", Opt_minix_df), 422 + fsparam_flag ("grpid", Opt_grpid), 423 + fsparam_flag ("bsdgroups", Opt_grpid), 424 + fsparam_flag ("nogrpid", Opt_nogrpid), 425 + fsparam_flag ("sysvgroups", Opt_nogrpid), 426 + fsparam_gid ("resgid", Opt_resgid), 427 + fsparam_uid ("resuid", Opt_resuid), 428 + fsparam_u32 ("sb", Opt_sb), 429 + fsparam_enum ("errors", Opt_errors, ext2_param_errors), 430 + fsparam_flag ("nouid32", Opt_nouid32), 431 + fsparam_flag ("debug", Opt_debug), 432 + fsparam_flag ("oldalloc", Opt_oldalloc), 433 + fsparam_flag ("orlov", Opt_orlov), 434 + fsparam_flag ("nobh", Opt_nobh), 435 + fsparam_flag_no ("user_xattr", Opt_user_xattr), 436 + fsparam_flag_no ("acl", Opt_acl), 437 + fsparam_flag ("xip", Opt_xip), 438 + fsparam_flag ("dax", Opt_dax), 439 + fsparam_flag ("grpquota", Opt_grpquota), 440 + fsparam_flag ("noquota", Opt_ignore), 441 + fsparam_flag ("quota", Opt_quota), 442 + fsparam_flag ("usrquota", Opt_usrquota), 443 + fsparam_flag_no ("reservation", Opt_reservation), 444 + {} 445 + }; 446 + 447 + #define EXT2_SPEC_s_resuid (1 << 0) 448 + #define EXT2_SPEC_s_resgid (1 << 1) 449 + 450 + struct ext2_fs_context { 451 + unsigned long vals_s_flags; /* Bits to set in s_flags */ 452 + unsigned long mask_s_flags; /* Bits changed in s_flags */ 453 + unsigned int vals_s_mount_opt; 454 + unsigned int mask_s_mount_opt; 455 + kuid_t s_resuid; 456 + kgid_t s_resgid; 457 + unsigned long s_sb_block; 458 + unsigned int spec; 459 + 460 + }; 461 + 462 + static inline void ctx_set_mount_opt(struct ext2_fs_context *ctx, 463 + unsigned long flag) 464 + { 465 + ctx->mask_s_mount_opt |= flag; 466 + ctx->vals_s_mount_opt |= flag; 449 467 } 450 468 451 - enum { 452 - Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, 453 - Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, 454 - Opt_err_ro, Opt_nouid32, Opt_debug, 455 - Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr, 456 - Opt_acl, Opt_noacl, Opt_xip, Opt_dax, Opt_ignore, Opt_err, Opt_quota, 457 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation 458 - }; 459 - 460 - static const match_table_t tokens = { 461 - {Opt_bsd_df, "bsddf"}, 462 - {Opt_minix_df, "minixdf"}, 463 - {Opt_grpid, "grpid"}, 464 - {Opt_grpid, "bsdgroups"}, 465 - {Opt_nogrpid, "nogrpid"}, 466 - {Opt_nogrpid, "sysvgroups"}, 467 - {Opt_resgid, "resgid=%u"}, 468 - {Opt_resuid, "resuid=%u"}, 469 - {Opt_sb, "sb=%u"}, 470 - {Opt_err_cont, "errors=continue"}, 471 - {Opt_err_panic, "errors=panic"}, 472 - {Opt_err_ro, "errors=remount-ro"}, 473 - {Opt_nouid32, "nouid32"}, 474 - {Opt_debug, "debug"}, 475 - {Opt_oldalloc, "oldalloc"}, 476 - {Opt_orlov, "orlov"}, 477 - {Opt_nobh, "nobh"}, 478 - {Opt_user_xattr, "user_xattr"}, 479 - {Opt_nouser_xattr, "nouser_xattr"}, 480 - {Opt_acl, "acl"}, 481 - {Opt_noacl, "noacl"}, 482 - {Opt_xip, "xip"}, 483 - {Opt_dax, "dax"}, 484 - {Opt_grpquota, "grpquota"}, 485 - {Opt_ignore, "noquota"}, 486 - {Opt_quota, "quota"}, 487 - {Opt_usrquota, "usrquota"}, 488 - {Opt_reservation, "reservation"}, 489 - {Opt_noreservation, "noreservation"}, 490 - {Opt_err, NULL} 491 - }; 492 - 493 - static int parse_options(char *options, struct super_block *sb, 494 - struct ext2_mount_options *opts) 469 + static inline void ctx_clear_mount_opt(struct ext2_fs_context *ctx, 470 + unsigned long flag) 495 471 { 496 - char *p; 497 - substring_t args[MAX_OPT_ARGS]; 498 - int option; 499 - kuid_t uid; 500 - kgid_t gid; 472 + ctx->mask_s_mount_opt |= flag; 473 + ctx->vals_s_mount_opt &= ~flag; 474 + } 501 475 502 - if (!options) 503 - return 1; 476 + static inline unsigned long 477 + ctx_test_mount_opt(struct ext2_fs_context *ctx, unsigned long flag) 478 + { 479 + return (ctx->vals_s_mount_opt & flag); 480 + } 504 481 505 - while ((p = strsep (&options, ",")) != NULL) { 506 - int token; 507 - if (!*p) 508 - continue; 482 + static inline bool 483 + ctx_parsed_mount_opt(struct ext2_fs_context *ctx, unsigned long flag) 484 + { 485 + return (ctx->mask_s_mount_opt & flag); 486 + } 509 487 510 - token = match_token(p, tokens, args); 511 - switch (token) { 512 - case Opt_bsd_df: 513 - clear_opt (opts->s_mount_opt, MINIX_DF); 514 - break; 515 - case Opt_minix_df: 516 - set_opt (opts->s_mount_opt, MINIX_DF); 517 - break; 518 - case Opt_grpid: 519 - set_opt (opts->s_mount_opt, GRPID); 520 - break; 521 - case Opt_nogrpid: 522 - clear_opt (opts->s_mount_opt, GRPID); 523 - break; 524 - case Opt_resuid: 525 - if (match_int(&args[0], &option)) 526 - return 0; 527 - uid = make_kuid(current_user_ns(), option); 528 - if (!uid_valid(uid)) { 529 - ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option); 530 - return 0; 488 + static void ext2_free_fc(struct fs_context *fc) 489 + { 490 + kfree(fc->fs_private); 491 + } 531 492 532 - } 533 - opts->s_resuid = uid; 534 - break; 535 - case Opt_resgid: 536 - if (match_int(&args[0], &option)) 537 - return 0; 538 - gid = make_kgid(current_user_ns(), option); 539 - if (!gid_valid(gid)) { 540 - ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option); 541 - return 0; 542 - } 543 - opts->s_resgid = gid; 544 - break; 545 - case Opt_sb: 546 - /* handled by get_sb_block() instead of here */ 547 - /* *sb_block = match_int(&args[0]); */ 548 - break; 549 - case Opt_err_panic: 550 - clear_opt (opts->s_mount_opt, ERRORS_CONT); 551 - clear_opt (opts->s_mount_opt, ERRORS_RO); 552 - set_opt (opts->s_mount_opt, ERRORS_PANIC); 553 - break; 554 - case Opt_err_ro: 555 - clear_opt (opts->s_mount_opt, ERRORS_CONT); 556 - clear_opt (opts->s_mount_opt, ERRORS_PANIC); 557 - set_opt (opts->s_mount_opt, ERRORS_RO); 558 - break; 559 - case Opt_err_cont: 560 - clear_opt (opts->s_mount_opt, ERRORS_RO); 561 - clear_opt (opts->s_mount_opt, ERRORS_PANIC); 562 - set_opt (opts->s_mount_opt, ERRORS_CONT); 563 - break; 564 - case Opt_nouid32: 565 - set_opt (opts->s_mount_opt, NO_UID32); 566 - break; 567 - case Opt_debug: 568 - set_opt (opts->s_mount_opt, DEBUG); 569 - break; 570 - case Opt_oldalloc: 571 - set_opt (opts->s_mount_opt, OLDALLOC); 572 - break; 573 - case Opt_orlov: 574 - clear_opt (opts->s_mount_opt, OLDALLOC); 575 - break; 576 - case Opt_nobh: 577 - ext2_msg(sb, KERN_INFO, 578 - "nobh option not supported"); 579 - break; 493 + static int ext2_parse_param(struct fs_context *fc, struct fs_parameter *param) 494 + { 495 + struct ext2_fs_context *ctx = fc->fs_private; 496 + int opt; 497 + struct fs_parse_result result; 498 + 499 + opt = fs_parse(fc, ext2_param_spec, param, &result); 500 + if (opt < 0) 501 + return opt; 502 + 503 + switch (opt) { 504 + case Opt_bsd_df: 505 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_MINIX_DF); 506 + break; 507 + case Opt_minix_df: 508 + ctx_set_mount_opt(ctx, EXT2_MOUNT_MINIX_DF); 509 + break; 510 + case Opt_grpid: 511 + ctx_set_mount_opt(ctx, EXT2_MOUNT_GRPID); 512 + break; 513 + case Opt_nogrpid: 514 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_GRPID); 515 + break; 516 + case Opt_resuid: 517 + ctx->s_resuid = result.uid; 518 + ctx->spec |= EXT2_SPEC_s_resuid; 519 + break; 520 + case Opt_resgid: 521 + ctx->s_resgid = result.gid; 522 + ctx->spec |= EXT2_SPEC_s_resgid; 523 + break; 524 + case Opt_sb: 525 + /* Note that this is silently ignored on remount */ 526 + ctx->s_sb_block = result.uint_32; 527 + break; 528 + case Opt_errors: 529 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_ERRORS_MASK); 530 + ctx_set_mount_opt(ctx, result.uint_32); 531 + break; 532 + case Opt_nouid32: 533 + ctx_set_mount_opt(ctx, EXT2_MOUNT_NO_UID32); 534 + break; 535 + case Opt_debug: 536 + ctx_set_mount_opt(ctx, EXT2_MOUNT_DEBUG); 537 + break; 538 + case Opt_oldalloc: 539 + ctx_set_mount_opt(ctx, EXT2_MOUNT_OLDALLOC); 540 + break; 541 + case Opt_orlov: 542 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_OLDALLOC); 543 + break; 544 + case Opt_nobh: 545 + ext2_msg_fc(fc, KERN_INFO, "nobh option not supported\n"); 546 + break; 580 547 #ifdef CONFIG_EXT2_FS_XATTR 581 - case Opt_user_xattr: 582 - set_opt (opts->s_mount_opt, XATTR_USER); 583 - break; 584 - case Opt_nouser_xattr: 585 - clear_opt (opts->s_mount_opt, XATTR_USER); 586 - break; 548 + case Opt_user_xattr: 549 + if (!result.negated) 550 + ctx_set_mount_opt(ctx, EXT2_MOUNT_XATTR_USER); 551 + else 552 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_XATTR_USER); 553 + break; 587 554 #else 588 - case Opt_user_xattr: 589 - case Opt_nouser_xattr: 590 - ext2_msg(sb, KERN_INFO, "(no)user_xattr options" 591 - "not supported"); 592 - break; 555 + case Opt_user_xattr: 556 + ext2_msg_fc(fc, KERN_INFO, "(no)user_xattr options not supported"); 557 + break; 593 558 #endif 594 559 #ifdef CONFIG_EXT2_FS_POSIX_ACL 595 - case Opt_acl: 596 - set_opt(opts->s_mount_opt, POSIX_ACL); 597 - break; 598 - case Opt_noacl: 599 - clear_opt(opts->s_mount_opt, POSIX_ACL); 600 - break; 560 + case Opt_acl: 561 + if (!result.negated) 562 + ctx_set_mount_opt(ctx, EXT2_MOUNT_POSIX_ACL); 563 + else 564 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_POSIX_ACL); 565 + break; 601 566 #else 602 - case Opt_acl: 603 - case Opt_noacl: 604 - ext2_msg(sb, KERN_INFO, 605 - "(no)acl options not supported"); 606 - break; 567 + case Opt_acl: 568 + ext2_msg_fc(fc, KERN_INFO, "(no)acl options not supported"); 569 + break; 607 570 #endif 608 - case Opt_xip: 609 - ext2_msg(sb, KERN_INFO, "use dax instead of xip"); 610 - set_opt(opts->s_mount_opt, XIP); 611 - fallthrough; 612 - case Opt_dax: 571 + case Opt_xip: 572 + ext2_msg_fc(fc, KERN_INFO, "use dax instead of xip"); 573 + ctx_set_mount_opt(ctx, EXT2_MOUNT_XIP); 574 + fallthrough; 575 + case Opt_dax: 613 576 #ifdef CONFIG_FS_DAX 614 - ext2_msg(sb, KERN_WARNING, 615 - "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); 616 - set_opt(opts->s_mount_opt, DAX); 577 + ext2_msg_fc(fc, KERN_WARNING, 578 + "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); 579 + ctx_set_mount_opt(ctx, EXT2_MOUNT_DAX); 617 580 #else 618 - ext2_msg(sb, KERN_INFO, "dax option not supported"); 581 + ext2_msg_fc(fc, KERN_INFO, "dax option not supported"); 619 582 #endif 620 - break; 583 + break; 621 584 622 585 #if defined(CONFIG_QUOTA) 623 - case Opt_quota: 624 - case Opt_usrquota: 625 - set_opt(opts->s_mount_opt, USRQUOTA); 626 - break; 586 + case Opt_quota: 587 + case Opt_usrquota: 588 + ctx_set_mount_opt(ctx, EXT2_MOUNT_USRQUOTA); 589 + break; 627 590 628 - case Opt_grpquota: 629 - set_opt(opts->s_mount_opt, GRPQUOTA); 630 - break; 591 + case Opt_grpquota: 592 + ctx_set_mount_opt(ctx, EXT2_MOUNT_GRPQUOTA); 593 + break; 631 594 #else 632 - case Opt_quota: 633 - case Opt_usrquota: 634 - case Opt_grpquota: 635 - ext2_msg(sb, KERN_INFO, 636 - "quota operations not supported"); 637 - break; 595 + case Opt_quota: 596 + case Opt_usrquota: 597 + case Opt_grpquota: 598 + ext2_msg_fc(fc, KERN_INFO, "quota operations not supported"); 599 + break; 638 600 #endif 639 - 640 - case Opt_reservation: 641 - set_opt(opts->s_mount_opt, RESERVATION); 642 - ext2_msg(sb, KERN_INFO, "reservations ON"); 643 - break; 644 - case Opt_noreservation: 645 - clear_opt(opts->s_mount_opt, RESERVATION); 646 - ext2_msg(sb, KERN_INFO, "reservations OFF"); 647 - break; 648 - case Opt_ignore: 649 - break; 650 - default: 651 - return 0; 601 + case Opt_reservation: 602 + if (!result.negated) { 603 + ctx_set_mount_opt(ctx, EXT2_MOUNT_RESERVATION); 604 + ext2_msg_fc(fc, KERN_INFO, "reservations ON"); 605 + } else { 606 + ctx_clear_mount_opt(ctx, EXT2_MOUNT_RESERVATION); 607 + ext2_msg_fc(fc, KERN_INFO, "reservations OFF"); 652 608 } 609 + break; 610 + case Opt_ignore: 611 + break; 612 + default: 613 + return -EINVAL; 653 614 } 654 - return 1; 615 + return 0; 655 616 } 656 617 657 618 static int ext2_setup_super (struct super_block * sb, ··· 814 801 return ext2_group_first_block_no(sb, bg) + ext2_bg_has_super(sb, bg); 815 802 } 816 803 817 - static int ext2_fill_super(struct super_block *sb, void *data, int silent) 804 + /* 805 + * Set all mount options either from defaults on disk, or from parsed 806 + * options. Parsed/specified options override on-disk defaults. 807 + */ 808 + static void ext2_set_options(struct fs_context *fc, struct ext2_sb_info *sbi) 818 809 { 810 + struct ext2_fs_context *ctx = fc->fs_private; 811 + struct ext2_super_block *es = sbi->s_es; 812 + unsigned long def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 813 + 814 + /* Copy parsed mount options to sbi */ 815 + sbi->s_mount_opt = ctx->vals_s_mount_opt; 816 + 817 + /* Use in-superblock defaults only if not specified during parsing */ 818 + if (!ctx_parsed_mount_opt(ctx, EXT2_MOUNT_DEBUG) && 819 + def_mount_opts & EXT2_DEFM_DEBUG) 820 + set_opt(sbi->s_mount_opt, DEBUG); 821 + 822 + if (!ctx_parsed_mount_opt(ctx, EXT2_MOUNT_GRPID) && 823 + def_mount_opts & EXT2_DEFM_BSDGROUPS) 824 + set_opt(sbi->s_mount_opt, GRPID); 825 + 826 + if (!ctx_parsed_mount_opt(ctx, EXT2_MOUNT_NO_UID32) && 827 + def_mount_opts & EXT2_DEFM_UID16) 828 + set_opt(sbi->s_mount_opt, NO_UID32); 829 + 830 + #ifdef CONFIG_EXT2_FS_XATTR 831 + if (!ctx_parsed_mount_opt(ctx, EXT2_MOUNT_XATTR_USER) && 832 + def_mount_opts & EXT2_DEFM_XATTR_USER) 833 + set_opt(sbi->s_mount_opt, XATTR_USER); 834 + #endif 835 + #ifdef CONFIG_EXT2_FS_POSIX_ACL 836 + if (!ctx_parsed_mount_opt(ctx, EXT2_MOUNT_POSIX_ACL) && 837 + def_mount_opts & EXT2_DEFM_ACL) 838 + set_opt(sbi->s_mount_opt, POSIX_ACL); 839 + #endif 840 + 841 + if (!ctx_parsed_mount_opt(ctx, EXT2_MOUNT_ERRORS_MASK)) { 842 + if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC) 843 + set_opt(sbi->s_mount_opt, ERRORS_PANIC); 844 + else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE) 845 + set_opt(sbi->s_mount_opt, ERRORS_CONT); 846 + else 847 + set_opt(sbi->s_mount_opt, ERRORS_RO); 848 + } 849 + 850 + if (ctx->spec & EXT2_SPEC_s_resuid) 851 + sbi->s_resuid = ctx->s_resuid; 852 + else 853 + sbi->s_resuid = make_kuid(&init_user_ns, 854 + le16_to_cpu(es->s_def_resuid)); 855 + 856 + if (ctx->spec & EXT2_SPEC_s_resgid) 857 + sbi->s_resgid = ctx->s_resgid; 858 + else 859 + sbi->s_resgid = make_kgid(&init_user_ns, 860 + le16_to_cpu(es->s_def_resgid)); 861 + } 862 + 863 + static int ext2_fill_super(struct super_block *sb, struct fs_context *fc) 864 + { 865 + struct ext2_fs_context *ctx = fc->fs_private; 866 + int silent = fc->sb_flags & SB_SILENT; 819 867 struct buffer_head * bh; 820 868 struct ext2_sb_info * sbi; 821 869 struct ext2_super_block * es; 822 870 struct inode *root; 823 871 unsigned long block; 824 - unsigned long sb_block = get_sb_block(&data); 872 + unsigned long sb_block = ctx->s_sb_block; 825 873 unsigned long logic_sb_block; 826 874 unsigned long offset = 0; 827 - unsigned long def_mount_opts; 828 875 long ret = -ENOMEM; 829 876 int blocksize = BLOCK_SIZE; 830 877 int db_count; 831 878 int i, j; 832 879 __le32 features; 833 880 int err; 834 - struct ext2_mount_options opts; 835 881 836 882 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 837 883 if (!sbi) ··· 949 877 if (sb->s_magic != EXT2_SUPER_MAGIC) 950 878 goto cantfind_ext2; 951 879 952 - opts.s_mount_opt = 0; 953 - /* Set defaults before we parse the mount options */ 954 - def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 955 - if (def_mount_opts & EXT2_DEFM_DEBUG) 956 - set_opt(opts.s_mount_opt, DEBUG); 957 - if (def_mount_opts & EXT2_DEFM_BSDGROUPS) 958 - set_opt(opts.s_mount_opt, GRPID); 959 - if (def_mount_opts & EXT2_DEFM_UID16) 960 - set_opt(opts.s_mount_opt, NO_UID32); 961 - #ifdef CONFIG_EXT2_FS_XATTR 962 - if (def_mount_opts & EXT2_DEFM_XATTR_USER) 963 - set_opt(opts.s_mount_opt, XATTR_USER); 964 - #endif 965 - #ifdef CONFIG_EXT2_FS_POSIX_ACL 966 - if (def_mount_opts & EXT2_DEFM_ACL) 967 - set_opt(opts.s_mount_opt, POSIX_ACL); 968 - #endif 969 - 970 - if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC) 971 - set_opt(opts.s_mount_opt, ERRORS_PANIC); 972 - else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE) 973 - set_opt(opts.s_mount_opt, ERRORS_CONT); 974 - else 975 - set_opt(opts.s_mount_opt, ERRORS_RO); 976 - 977 - opts.s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid)); 978 - opts.s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid)); 979 - 980 - set_opt(opts.s_mount_opt, RESERVATION); 981 - 982 - if (!parse_options((char *) data, sb, &opts)) 983 - goto failed_mount; 984 - 985 - sbi->s_mount_opt = opts.s_mount_opt; 986 - sbi->s_resuid = opts.s_resuid; 987 - sbi->s_resgid = opts.s_resgid; 880 + ext2_set_options(fc, sbi); 988 881 989 882 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | 990 883 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); ··· 1361 1324 ext2_sync_fs(sb, 1); 1362 1325 } 1363 1326 1364 - static int ext2_remount (struct super_block * sb, int * flags, char * data) 1327 + static int ext2_reconfigure(struct fs_context *fc) 1365 1328 { 1329 + struct ext2_fs_context *ctx = fc->fs_private; 1330 + struct super_block *sb = fc->root->d_sb; 1366 1331 struct ext2_sb_info * sbi = EXT2_SB(sb); 1367 1332 struct ext2_super_block * es; 1368 1333 struct ext2_mount_options new_opts; 1334 + int flags = fc->sb_flags; 1369 1335 int err; 1370 1336 1371 1337 sync_filesystem(sb); 1372 1338 1373 - spin_lock(&sbi->s_lock); 1374 - new_opts.s_mount_opt = sbi->s_mount_opt; 1375 - new_opts.s_resuid = sbi->s_resuid; 1376 - new_opts.s_resgid = sbi->s_resgid; 1377 - spin_unlock(&sbi->s_lock); 1378 - 1379 - if (!parse_options(data, sb, &new_opts)) 1380 - return -EINVAL; 1339 + new_opts.s_mount_opt = ctx->vals_s_mount_opt; 1340 + new_opts.s_resuid = ctx->s_resuid; 1341 + new_opts.s_resgid = ctx->s_resgid; 1381 1342 1382 1343 spin_lock(&sbi->s_lock); 1383 1344 es = sbi->s_es; ··· 1384 1349 "dax flag with busy inodes while remounting"); 1385 1350 new_opts.s_mount_opt ^= EXT2_MOUNT_DAX; 1386 1351 } 1387 - if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb)) 1352 + if ((bool)(flags & SB_RDONLY) == sb_rdonly(sb)) 1388 1353 goto out_set; 1389 - if (*flags & SB_RDONLY) { 1354 + if (flags & SB_RDONLY) { 1390 1355 if (le16_to_cpu(es->s_state) & EXT2_VALID_FS || 1391 1356 !(sbi->s_mount_state & EXT2_VALID_FS)) 1392 1357 goto out_set; ··· 1505 1470 return 0; 1506 1471 } 1507 1472 1508 - static struct dentry *ext2_mount(struct file_system_type *fs_type, 1509 - int flags, const char *dev_name, void *data) 1473 + static int ext2_get_tree(struct fs_context *fc) 1510 1474 { 1511 - return mount_bdev(fs_type, flags, dev_name, data, ext2_fill_super); 1475 + return get_tree_bdev(fc, ext2_fill_super); 1512 1476 } 1513 1477 1514 1478 #ifdef CONFIG_QUOTA ··· 1590 1556 } 1591 1557 lock_buffer(bh); 1592 1558 memcpy(bh->b_data+offset, data, tocopy); 1593 - flush_dcache_page(bh->b_page); 1559 + flush_dcache_folio(bh->b_folio); 1594 1560 set_buffer_uptodate(bh); 1595 1561 mark_buffer_dirty(bh); 1596 1562 unlock_buffer(bh); ··· 1658 1624 1659 1625 #endif 1660 1626 1627 + static const struct fs_context_operations ext2_context_ops = { 1628 + .parse_param = ext2_parse_param, 1629 + .get_tree = ext2_get_tree, 1630 + .reconfigure = ext2_reconfigure, 1631 + .free = ext2_free_fc, 1632 + }; 1633 + 1634 + static int ext2_init_fs_context(struct fs_context *fc) 1635 + { 1636 + struct ext2_fs_context *ctx; 1637 + 1638 + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 1639 + if (!ctx) 1640 + return -ENOMEM; 1641 + 1642 + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { 1643 + struct super_block *sb = fc->root->d_sb; 1644 + struct ext2_sb_info *sbi = EXT2_SB(sb); 1645 + 1646 + spin_lock(&sbi->s_lock); 1647 + ctx->vals_s_mount_opt = sbi->s_mount_opt; 1648 + ctx->vals_s_flags = sb->s_flags; 1649 + ctx->s_resuid = sbi->s_resuid; 1650 + ctx->s_resgid = sbi->s_resgid; 1651 + spin_unlock(&sbi->s_lock); 1652 + } else { 1653 + ctx->s_sb_block = 1; 1654 + ctx_set_mount_opt(ctx, EXT2_MOUNT_RESERVATION); 1655 + } 1656 + 1657 + fc->fs_private = ctx; 1658 + fc->ops = &ext2_context_ops; 1659 + 1660 + return 0; 1661 + } 1662 + 1661 1663 static struct file_system_type ext2_fs_type = { 1662 1664 .owner = THIS_MODULE, 1663 1665 .name = "ext2", 1664 - .mount = ext2_mount, 1665 1666 .kill_sb = kill_block_super, 1666 1667 .fs_flags = FS_REQUIRES_DEV, 1668 + .init_fs_context = ext2_init_fs_context, 1669 + .parameters = ext2_param_spec, 1667 1670 }; 1668 1671 MODULE_ALIAS_FS("ext2"); 1669 1672
+2 -1
fs/isofs/dir.c
··· 147 147 de = tmpde; 148 148 } 149 149 /* Basic sanity check, whether name doesn't exceed dir entry */ 150 - if (de_len < de->name_len[0] + 150 + if (de_len < sizeof(struct iso_directory_record) || 151 + de_len < de->name_len[0] + 151 152 sizeof(struct iso_directory_record)) { 152 153 printk(KERN_NOTICE "iso9660: Corrupted directory entry" 153 154 " in block %lu of inode %lu\n", block,
+1
fs/udf/inode.c
··· 810 810 } 811 811 map->oflags = UDF_BLK_MAPPED; 812 812 map->pblk = udf_get_lb_pblock(inode->i_sb, &eloc, offset); 813 + ret = 0; 813 814 goto out_free; 814 815 } 815 816