]> exis.tech > repos - linux.git/blobdiff - fs/ntfs/inode.c
Merge tag 'hwmon-for-v7.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groec...
[linux.git] / fs / ntfs / inode.c
index c2715521e5628657b547b9cc9e7d37fc8e6f0c3d..7381a18cfadd97738cd012cb43dfd768706b5ac5 100644 (file)
@@ -1191,6 +1191,15 @@ no_data_attr_special_case:
            !S_ISFIFO(vi->i_mode) && !S_ISSOCK(vi->i_mode) && !S_ISLNK(vi->i_mode))
                vi->i_flags |= S_IMMUTABLE;
 
+       /*
+        * System files such as $Bitmap and $MFT are maintained by the driver
+        * itself, and writing them from userspace corrupts the volume.
+        * Always make them immutable regardless of the sys_immutable option.
+        * Directories are skipped so the root and $Extend stay usable.
+        */
+       if (ni->mft_no < FILE_first_user && S_ISREG(vi->i_mode))
+               vi->i_flags |= S_IMMUTABLE;
+
        /*
         * The number of 512-byte blocks used on disk (for stat). This is in so
         * far inaccurate as it doesn't account for any named streams or other