mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] omfs: reject writes starting beyond EOF
@ 2026-11-04 11:20 Hungyu Lin
  2026-11-04 14:32 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Hungyu Lin @ 2026-11-04 11:20 UTC (permalink / raw)
  To: me
  Cc: akpm, linux-karma-devel, linux-fsdevel, linux-kernel, stable, Hungyu Lin

OMFS does not initialize gaps between EOF and a buffered write. When the
requested block lies beyond the allocated extents, omfs_get_block() grows
the last extent and maps the write to the newly allocated block without
accounting for the skipped logical blocks.

A one-byte pwrite() at offset 8192 into an empty file returns success, as
does fsync(), but after remounting the byte is at offset 0 and offset 8192
reads as zero.

Reject writes starting beyond i_size before block_write_begin() can
allocate or map buffers. Overwrites, appends and writes crossing EOF
remain allowed. Gap initialization can be implemented separately.

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

diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index 79a413f1dc0..82c15756671 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -317,6 +317,10 @@ static int omfs_write_begin(const struct kiocb *iocb,
 {
 	int ret;
 
+	/* Initializing a gap between EOF and the write is not supported. */
+	if (pos > i_size_read(mapping->host))
+		return -EOPNOTSUPP;
+
 	ret = block_write_begin(mapping, pos, len, foliop, omfs_get_block);
 	if (unlikely(ret))
 		omfs_write_failed(mapping, pos + len);

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] omfs: reject writes starting beyond EOF
  2026-11-04 11:20 [PATCH] omfs: reject writes starting beyond EOF Hungyu Lin
@ 2026-11-04 14:32 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2026-11-04 14:32 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: me, akpm, linux-karma-devel, linux-fsdevel, linux-kernel, stable

On Wed, Nov 04, 2026 at 11:20:52AM +0000, Hungyu Lin wrote:
> OMFS does not initialize gaps between EOF and a buffered write. When the
> requested block lies beyond the allocated extents, omfs_get_block() grows
> the last extent and maps the write to the newly allocated block without
> accounting for the skipped logical blocks.
> 
> A one-byte pwrite() at offset 8192 into an empty file returns success, as
> does fsync(), but after remounting the byte is at offset 0 and offset 8192
> reads as zero.
> 
> Reject writes starting beyond i_size before block_write_begin() can
> allocate or map buffers. Overwrites, appends and writes crossing EOF
> remain allowed. Gap initialization can be implemented separately.

Why don't we just delete omfs?

          This is the proprietary file system used by the Rio Karma music
          player and ReplayTV DVR

Rio Karma and ReplayTV were both EOL in 2005.  Let's just delete this
filesystem.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-04 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 11:20 [PATCH] omfs: reject writes starting beyond EOF Hungyu Lin
2026-11-04 14:32 ` Matthew Wilcox

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®