[RFC PATCH v2 0/2] ext4: Fix the conflict between modifying the superblock in user mode and kernel mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tune2fs does not recognize writes to filesystems in another namespace. Two
simultaneous write operations on a block will lead to file system
inconsistency, because there is no lock protection between userland and
kernelland.

The operation is as follows:
first terminal                                      second terminal
mkfs.ext4 /dev/sdb;
mount /dev/sdb /test-sdb;
dd if=/dev/zero of=/test-sdb/test1 bs=1M count=100;
                                                    unshare -m;
umount;
gdb tune2fs;
b io_channel_write_byte
r -e remount-ro /dev/sdb
c(Write a byte of old data into the cache)
                                                    exit;
(gdb finish)
tune2fs -l /dev/sdb;
tune2fs 1.46.4 (18-Aug-2021)
tune2fs: Superblock checksum does not match superblock while trying to
open /dev/sdb
Couldn't find valid filesystem superblock. 

Link: https://lore.kernel.org/linux-ext4/29f6134f-ba0a-d601-0a5a-ad2b5e9bbf1d@xxxxxxxxxx/

After discussing with Tytso, I decided to use ioctl to solve the above
problems. These patches are an example I wrote to complete the modification
of the s_errors variable in the super block.

Finally, if you have any good ideas, welcome to communicate with me by
email.

Diff V2 vs V1:
1) Modify symbols of comment.
Link: https://lore.kernel.org/oe-kbuild-all/202308030412.jMcaYq0E-lkp@xxxxxxxxx/
2) Add static symbols to functions.
Link: https://lore.kernel.org/oe-kbuild-all/202308021801.ieUVR2xl-lkp@xxxxxxxxx/

zhanchengbin (2):
  ext4: ioctl adds a framework for modifying superblock parameters
  ext4: ioctl add EXT4_IOC_SUPERBLOCK_KEY_S_ERRORS

 fs/ext4/ext4.h            |  12 +++
 fs/ext4/ioctl.c           | 149 ++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/ext4.h |  28 +++++++
 3 files changed, 189 insertions(+)

-- 
2.31.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux