Re: [PATCH] ksmbd: fix named stream write and EOF handling
From: Namjae Jeon
Date: Thu Oct 08 2026 - 02:32:35 EST
On Wed, Oct 7, 2026 at 10:14 PM DaeMyung Kang <charsyam@xxxxxxxxx> wrote:
>
> An SMB WRITE to an existing named stream can silently discard data after
> its written range. ksmbd stores streams as xattr values, but the write
> path passes offset + count as the length of the replacement xattr even
> when the old stream is longer. Writing 26 bytes at offset 0 to a 60-byte
> stream reports 26 bytes written while discarding the remaining 34 bytes.
>
> Keep the existing xattr length when an in-place write ends before EOF.
> Reject writes that cross XATTR_SIZE_MAX rather than storing only the
> portion that fits while reporting the full requested count.
>
> Commit 4ea0bb8aaedf ("ksmbd: handle set/get info file for streamed file")
> intentionally skipped ordinary inode truncation for stream handles: an
> EOF SetInfo on an ADS had truncated the base file. That fixed the base
> file corruption but left stream EOF changes reporting success without
> resizing the stream. Handle these requests by resizing only the stream
> xattr; the base file size remains untouched. Zero-fill stream extensions.
> This is needed alongside the write fix: a short write's accidental
> truncation previously masked an ignored explicit EOF change. The stream
> resize helper returns xattr errors directly rather than using the
> base-file truncate path's EBADF conversion.
>
> Fixes: f44158485826 ("cifsd: add file operations")
> Fixes: 4ea0bb8aaedf ("ksmbd: handle set/get info file for streamed file")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: DaeMyung Kang <charsyam@xxxxxxxxx>
Applied it to #ksmbd-for-next.
Thanks!