From: Hungyu Lin <dennylin0707@gmail.com>
To: me@bobcopeland.com
Cc: linux-karma-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Hungyu Lin <dennylin0707@gmail.com>
Subject: [PATCH] omfs: reject unsupported nonzero size changes
Date: Wed, 4 Nov 2026 11:45:30 +0000 [thread overview]
Message-ID: <20261104114530.30536-1-dennylin0707@gmail.com> (raw)
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)
reply other threads:[~2026-11-04 11:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104114530.30536-1-dennylin0707@gmail.com \
--to=dennylin0707@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-karma-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=me@bobcopeland.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®