[PATCH 04/10] ufs: do not inherit file flags from the parent directory

Ali Ahmet Memis <[email protected]> Sat, 1 Aug 2026 22:55:24 +0000
Newsgroups org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
ufs_new_inode() starts a new inode off with the parent directory's
on-disk flags:

	ufsi->i_flags = UFS_I(dir)->i_flags;

These are BSD chflags, and they have no inheritance semantics. FreeBSD's
ufs_makeinode() leaves di_flags at zero and only ever sets UF_OPAQUE, and
only for a whiteout. The line comes from the ext2 code fs/ufs/ialloc.c
was derived from, where the flags are Linux inode flags that do have an
inherited subset.

The result is that a file created on Linux inside a directory FreeBSD
marked with chflags schg or sappnd is written out carrying SF_IMMUTABLE
or SF_APPEND itself. Linux does not act on those bits, so nothing looks
wrong at the time, but back on FreeBSD the new file is immutable or
append-only and cannot be removed without lowering the securelevel.
Nothing asked for that.

Start new inodes with no flags set.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Ali Ahmet Memis <[email protected]>
---
 fs/ufs/ialloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 4c3c76c4e7ff..dc3eeb415876 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -293,7 +293,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
 	inode->i_blocks = 0;
 	inode->i_generation = 0;
 	simple_inode_init_ts(inode);
-	ufsi->i_flags = UFS_I(dir)->i_flags;
+	ufsi->i_flags = 0;
 	ufsi->i_extsize = 0;
 	memset(ufsi->i_extb, 0, sizeof(ufsi->i_extb));
 	ufsi->i_lastfrag = 0;
-- 
2.55.0