Re: [PATCH 1/2] ksmbd: fix negative timestamps being saved to disk
From: Namjae Jeon
Date: Thu Nov 12 2026 - 19:01:10 EST
On Fri, Nov 13, 2026 at 3:27 AM Ian Bridges <icb@xxxxxxxxxxxx> wrote:
>
> Hi,
>
> On Thu, Nov 12, 2026 at 12:16:36PM +0100, koraynilay wrote:
> > When setting a timestamp before epoch 0, ksmbd converts it from NT
> > format to Unix format without normalizing it, leading to the nanoseconds
> > field to be saved (on-disk too) as a negative number, which leads to a
> > garbled stat command output and a reported +4 seconds in the timestamp.
>
> I tested this with the ksmbd code from ksmbd-for-next. Before the
> patch, setting an access or write time before 1970 with a fraction of
> a second stored the wrong time on disk. The stored time was about four
> seconds late, stat showed garbage for the fraction, and a query over
> SMB returned the wrong time too. With the patch, the time on disk and
> the time returned over SMB match the time that was set. Times after
> 1970, and whole seconds before it, behave as before. smbtorture gives
> the same results as without the patch, and KASAN reports nothing.
>
> Reviewed-by: Ian Bridges <icb@xxxxxxxxxxxx>
> Tested-by: Ian Bridges <icb@xxxxxxxxxxxx>
Applied it to #ksmbd-for-next.
Thanks!