lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sat, 18 Mar 2023 11:36:03 +0800 From: Zhiqiang Liu <liuzhiqiang26@...wei.com> To: Ext4 Developers List <linux-ext4@...r.kernel.org> CC: "Theodore Y. Ts'o" <tytso@....edu>, <adilger@...mcloud.com>, Jan Kara <jack@...e.cz>, linfeilong <linfeilong@...wei.com>, wuguanghao <wuguanghao3@...wei.com>, zhanchengbin <zhanchengbin1@...wei.com>, <libaokun1@...wei.com> Subject: [PATCH] tune2fs: check whether dev is mounted or in use before setting From: Zhiqiang Liu <liuzhiqiang26@...wei.com> tune2fs is used to adjust various tunable filesystem pars, which may conflict with kernel operations. So we should check whether device is mounted or in use at the begin similar to e2fsck and mke2fs. Of course, we can ignore this check if -f is set. Reported-by: Baokun Li <libaokun1@...wei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com> Signed-off-by: zhanchengbin <zhanchengbin1@...wei.com> --- misc/tune2fs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 458f7cf6..b667e1f4 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -3327,6 +3327,22 @@ retry_open: goto closefs; } + if (open_flag & EXT2_FLAG_RW) { + if (mount_flags & EXT2_MF_MOUNTED) { + fprintf(stderr, _("Warning! %s is mounted.\n"), device_name); + if (!f_flag) { + rc = 1; + goto closefs; + } + } else if (mount_flags & EXT2_MF_BUSY) { + fprintf(stderr, _("Warning! %s is in use by the system.\n"), + device_name); + if (!f_flag) { + rc = 1; + goto closefs; + } + } + } #ifdef NO_RECOVERY /* Warn if file system needs recovery and it is opened for writing. */ if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) && -- 2.33.0
Powered by blists - more mailing lists