missing MS_RDONLY check in fsync

From: Sanidhya Kashyap
Date: Mon Mar 23 2015 - 18:32:15 EST


Hello everyone,

We've been cross checking various file systems for the general
inconsistencies and we have a question about the check of MS_RDONLY
during fsync.

We know that the vfs layer does not check for MS_RDONLY for fsync and
this is confirmed by the ubifs where they have explicitly mentioned
about this (commit - 3b2f9a019e655f3407e4e69cdbaf8b75699b79a4 )

"""
if (c->ro_mount)
/*
* For some really strange reasons VFS does not filter out
* 'fsync()' for R/O mounted file-systems as per 2.6.39.
*/
"""

And there is a comment in include/linux/fs.h file (line: 1688) about
the MS_RDONLY flag: (commit - bbc1096ad8e9875a025bbcf012605da49129e8b8
):

""""
* Exception: MS_RDONLY is always applied to the entire file system.
*
* Unfortunately, it is possible to change a filesystems flags with it mounted
* with files in use. This means that all of the inodes will not have their
* i_flags updated. Hence, i_flags no longer inherit the superblock mount
* flags, so these have to be checked separately. -- rmk@xxxxxxxxxxxxxxxx */

"""

Looking at the above two comments, it is quite clear that the every
file system should independently check MS_RDONLY in fsync. Some file
systems such as ext3, ext4, ubifs, ocfs2 and f2fs do it whereas others
do not.

It would be great if anyone can let us know why is there no check for
every file system. Is there any particular reason for this?


Thanks,
Sanidhya
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/