lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260109024716.12047-1-chao@kernel.org>
Date: Fri,  9 Jan 2026 10:47:16 +0800
From: Chao Yu <chao@...nel.org>
To: jaegeuk@...nel.org
Cc: linux-f2fs-devel@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org,
	Chao Yu <chao@...nel.org>
Subject: [PATCH] f2fs: fix to prevent clearing immutable for large folio supported inode

Below testcase can change large folio supported inode from immutable
to mutable, it's not as expected, let's add a new check condition in
f2fs_setflags_common() to detect and reject it.

- dd if=/dev/zero of=/mnt/f2fs/test bs=32k count=4
- f2fs_io setflags immutable /mnt/f2fs/test
- echo 3 > /proc/sys/vm/drop_caches
 : to reload inode with large folio
- f2fs_io read 32 0 1 mmap 0 0 /mnt/f2fs/test
- f2fs_io clearflags immutable /mnt/f2fs/test

Signed-off-by: Chao Yu <chao@...nel.org>
---
 fs/f2fs/file.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ce291f152bc3..f7f9da0b215f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2155,6 +2155,12 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 		}
 	}
 
+	if ((iflags ^ masked_flags) & F2FS_IMMUTABLE_FL) {
+		if ((masked_flags & F2FS_IMMUTABLE_FL) &&
+			mapping_large_folio_support(inode->i_mapping))
+			return -EINVAL;
+	}
+
 	fi->i_flags = iflags | (fi->i_flags & ~mask);
 	f2fs_bug_on(F2FS_I_SB(inode), (fi->i_flags & F2FS_COMPR_FL) &&
 					(fi->i_flags & F2FS_NOCOMP_FL));
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ