From 383c40cdd226d9f8d6ccf681f8b01418138e298c Mon Sep 17 00:00:00 2001
From: Jun Nie <jun.nie@linaro.org>
Date: Wed, 14 Dec 2022 16:14:01 +0800
Subject: [PATCH] ext4: remove deprecated noacl/nouser_xattr options

These two options should have been removed since 3.5, but none notices it.
Recently, I and Darrick found this. Also, have some discussion for this[1][2][3].

So now, let's remove them.

Link: https://lore.kernel.org/linux-ext4/6258F7BB.8010104@fujitsu.com/T/#u[1]
Link: https://lore.kernel.org/linux-ext4/20220602110421.ymoug3rwfspmryqg@fedora/T/#t[2]
Link: https://lore.kernel.org/linux-ext4/08e2ca4c8f6344bdcd76d75b821116c6147fd57a.camel@kernel.org/T/#t[3]

This patch also fix below bug, that syzbot reports:

KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
CPU: 1 PID: 453 Comm: syz-executor.0 Not tainted 5.15.82-syzkaller #0
audit: type=1400 audit(1670986739.270:143): avc:  denied  { unmount } for  pid=453 comm="syz-executor.0" scontext=root:sysadm_r:sysadm_t tcontext=system_u:object_r:fs_t tclass=filesystem permissive=1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:ext4_xattr_set_entry+0x276a/0x3950
Call Trace:
 <TASK>
 ? __kmalloc+0x203/0x350
 ? ext4_xattr_block_set+0x328/0x3820
 ? ext4_expand_extra_isize_ea+0x1591/0x1f30
 ? generic_shutdown_super+0x69/0x2e0
 ? cleanup_mnt+0x45f/0x510
 ? ext4_xattr_ibody_set+0x380/0x380
 ? __kasan_kmalloc+0x9/0x10
 ? __kmalloc+0x203/0x350
 ? ext4_xattr_block_set+0x328/0x3820
 ext4_xattr_block_set+0x8f8/0x3820
 ? ext4_xattr_ibody_set+0x380/0x380
 ? ext4_get_inode_loc+0x1d0/0x1d0
 ? ext4_xattr_block_find+0x5b0/0x5b0
 ? ext4_xattr_inode_get+0x2a2/0x960
 ? ext4_xattr_block_find+0x113/0x5b0
 ? __kasan_check_write+0x14/0x20
 ext4_expand_extra_isize_ea+0x1591/0x1f30
 ? __kasan_check_read+0x11/0x20
 ? ext4_xattr_set+0x3e0/0x3e0
 ? ext4_reserve_inode_write+0x30d/0x3d0
 ? __kasan_check_write+0x14/0x20
 __ext4_expand_extra_isize+0x29e/0x3d0
 __ext4_mark_inode_dirty+0x4bf/0x7a0
 ? ext4_blocks_for_truncate+0x2d0/0x2d0
 ? __kasan_check_write+0x14/0x20
 ? ext4_journal_check_start+0x16b/0x230
 ? ext4_dirty_inode+0x8e/0x100
 ? __ext4_journal_start_sb+0x14c/0x2a0
 ext4_dirty_inode+0xbc/0x100
 ? __ext4_expand_extra_isize+0x3d0/0x3d0
 __mark_inode_dirty+0x1f9/0x9d0
 iput+0x155/0x7d0
 ? __kasan_check_write+0x14/0x20
 dentry_unlink_inode+0x349/0x430
 __dentry_kill+0x3e2/0x5d0
 shrink_dentry_list+0x379/0x4d0
 shrink_dcache_parent+0xcd/0x350
 ? d_set_mounted+0x230/0x230
 ? __kasan_check_write+0x14/0x20
 ? up_write+0xa1/0x190
 shrink_dcache_for_umount+0x7c/0x1a0
 generic_shutdown_super+0x69/0x2e0
 kill_block_super+0x80/0xe0
 deactivate_locked_super+0xb0/0x100
 deactivate_super+0xa5/0xd0
 cleanup_mnt+0x45f/0x510
 __cleanup_mnt+0x19/0x20
 task_work_run+0x147/0x1b0
 exit_to_user_mode_loop+0xfd/0x110
 syscall_exit_to_user_mode+0x79/0xc0
 do_syscall_64+0x50/0xd0
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Change-Id: I3e650886f8263002b55732847a1a0bb7c51ee6dd
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/1658977369-2478-1-git-send-email-xuyang2018.jy@fujitsu.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit 2d544ec923dbe5fbed64a7f43dccf527218380bc)
Reported-by: syzbot+2dacb8f015bf1420155f@syzkaller.appspotmail.com
Signed-off-by: Jun Nie <jun.nie@linaro.org>
---
 fs/ext4/super.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f98ea964a137..0c40025ec260 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1658,7 +1658,7 @@ enum {
 	Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
 	Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
 	Opt_nouid32, Opt_debug, Opt_removed,
-	Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
+	Opt_user_xattr, Opt_acl,
 	Opt_auto_da_alloc, Opt_noauto_da_alloc, Opt_noload,
 	Opt_commit, Opt_min_batch_time, Opt_max_batch_time, Opt_journal_dev,
 	Opt_journal_path, Opt_journal_checksum, Opt_journal_async_commit,
@@ -1702,9 +1702,7 @@ static const match_table_t tokens = {
 	{Opt_removed, "oldalloc"},
 	{Opt_removed, "orlov"},
 	{Opt_user_xattr, "user_xattr"},
-	{Opt_nouser_xattr, "nouser_xattr"},
 	{Opt_acl, "acl"},
-	{Opt_noacl, "noacl"},
 	{Opt_noload, "norecovery"},
 	{Opt_noload, "noload"},
 	{Opt_removed, "nobh"},
@@ -1971,13 +1969,10 @@ static const struct mount_opts {
 	{Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA,
 	 MOPT_NO_EXT2 | MOPT_DATAJ},
 	{Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET},
-	{Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR},
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
 	{Opt_acl, EXT4_MOUNT_POSIX_ACL, MOPT_SET},
-	{Opt_noacl, EXT4_MOUNT_POSIX_ACL, MOPT_CLEAR},
 #else
 	{Opt_acl, 0, MOPT_NOSUPPORT},
-	{Opt_noacl, 0, MOPT_NOSUPPORT},
 #endif
 	{Opt_nouid32, EXT4_MOUNT_NO_UID32, MOPT_SET},
 	{Opt_debug, EXT4_MOUNT_DEBUG, MOPT_SET},
@@ -2121,10 +2116,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
 		return clear_qf_name(sb, GRPQUOTA);
 #endif
 	switch (token) {
-	case Opt_noacl:
-	case Opt_nouser_xattr:
-		ext4_msg(sb, KERN_WARNING, deprecated_msg, opt, "3.5");
-		break;
 	case Opt_sb:
 		return 1;	/* handled by get_sb_block() */
 	case Opt_removed:
-- 
2.34.1

