From 7b7db479f03eb34f7a4b2a74a179c7405ed5c3df Mon Sep 17 00:00:00 2001 From: vasilito Date: Sat, 11 Jul 2026 08:06:32 +0300 Subject: [PATCH] FIX: AddrSpace dup handles must NOT be POSITIONED AddrSpace handles from dup(b'empty') and dup(b'exclusive') use the write syscall for mmap commands, not seekable I/O. The kwriteoff handler returns the mapped address (not bytes written), which sys_write would incorrectly add to the file offset when POSITIONED is set. This corrupted the offset, causing the next write to fail with EINVAL (offset_word skip exhausted the buffer). Only mmap-min-addr needs POSITIONED for actual read/write. --- src/scheme/proc.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index dd9adbb528..fb76068cdb 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -1247,7 +1247,8 @@ impl KernelScheme for ProcScheme { _ => return Err(Error::new(EINVAL)), }; - handle(Handle { context, kind }, true) + let positioned = !matches!(kind, ContextHandle::AddrSpace { .. }); + handle(Handle { context, kind }, positioned) } _ => return Err(Error::new(EINVAL)), },