ext4: enforce the immutable flag on open files
authorTheodore Ts'o <tytso@mit.edu>
Mon, 10 Jun 2019 02:04:33 +0000 (22:04 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jul 2019 06:29:29 +0000 (08:29 +0200)
commitc9ea4620a37f544e46cead4e276b4f273141f08a
treef6e31c096f7a9bd11800d466c7cd20e62982a0a1
parent29171e82348cb0ce787120d42f0b94e8fba2bcae
ext4: enforce the immutable flag on open files

commit 02b016ca7f99229ae6227e7b2fc950c4e140d74a upstream.

According to the chattr man page, "a file with the 'i' attribute
cannot be modified..."  Historically, this was only enforced when the
file was opened, per the rest of the description, "... and the file
can not be opened in write mode".

There is general agreement that we should standardize all file systems
to prevent modifications even for files that were opened at the time
the immutable flag is set.  Eventually, a change to enforce this at
the VFS layer should be landing in mainline.  Until then, enforce this
at the ext4 level to prevent xfstests generic/553 from failing.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/file.c
fs/ext4/inode.c