mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] omfs: reject unsupported nonzero size changes
@ 2026-11-04 11:45 Hungyu Lin
  0 siblings, 0 replies; only message in thread
From: Hungyu Lin @ 2026-11-04 11:45 UTC (permalink / raw)
  To: me; +Cc: linux-karma-devel, linux-fsdevel, linux-kernel, stable, Hungyu Lin

omfs_shrink_inode() only implements truncation to zero and returns -EIO
for a nonzero i_size. However, omfs_setattr() updates i_size and the page
cache before calling omfs_truncate(), which discards that error.

As a result, ftruncate() on an empty file to 16384 bytes succeeds, but
reading the extended file fails with EIO. Shrinking to a nonzero size
also leaves the old extents in place, so a later extension can expose
data that should have been discarded.

Reject size changes with a nonzero target before changing i_size or the
page cache. Keep truncation to zero and requests that leave the size
unchanged working.

Fixes: 8f09e98768c1 ("omfs: add file routines")
Cc: stable@vger.kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 fs/omfs/file.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index 79a413f1dc0..a4bf45d73bc 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -353,6 +353,9 @@ static int omfs_setattr(const struct mnt_idmap *idmap,
 		error = inode_newsize_ok(inode, attr->ia_size);
 		if (error)
 			return error;
+		/* Only truncation to zero is implemented. */
+		if (attr->ia_size)
+			return -EOPNOTSUPP;
 		truncate_setsize(inode, attr->ia_size);
 		omfs_truncate(inode);
 	}

base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-04 11:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 11:45 [PATCH] omfs: reject unsupported nonzero size changes Hungyu Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®