mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paulo Alcantara <pc@manguebit.org>
To: koraynilay <koray.fra@gmail.com>, Namjae Jeon <linkinjeon@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Tom Talpey <tom@talpey.com>,
	ChenXiaoSong <chenxiaosong@chenxiaosong.com>,
	Hyunchul Lee <hyc.lee@gmail.com>,
	Ronnie Sahlberg <ronniesahlberg@gmail.com>,
	Shyam Prasad N <sprasad@microsoft.com>,
	Bharath SM <bharathsm@microsoft.com>,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org, koraynilay <koray.fra@gmail.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH 2/2] cifs: fix negative timestamps being read from smb
Date: Tue, 17 Nov 2026 19:01:33 -0300	[thread overview]
Message-ID: <aefc2a49baa1c3c1b153757612d2503a@manguebit.org> (raw)
In-Reply-To: <20261112111637.184045-2-koray.fra@gmail.com>

koraynilay <koray.fra@gmail.com> writes:

> When reading a timestamp before epoch 0, cifs converts it from NT format
> to Unix format without normalizing it, leading to the nanoseconds field
> to be used as a negative number, which leads to a garbled stat command
> output.
>
> This bug also violates a struct timespec64 invariant, as documented in
> the set_normalized_timespec64() kernel-doc:
> [...]
>  * Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC.
>  * For negative values only the tv_sec field is negative !
>  */
>
> Reproducer, with /tmp as the local filesystem folder exported as [test]
> in ksmbd.conf and /mnt as the smb folder mounted with mount -t cifs:
>
>   mount -t cifs //127.0.0.1/test /mnt -o username=user,password=pass
>   touch -d "1969-07-20 20:17:40.123456789" /tmp/test.txt
>   stat -c "Server local (/tmp):   %y" /tmp/test.txt
>   stat -c "CIFS client  (/mnt):   %y" /mnt/test.txt --cached=never
>   smbclient //127.0.0.1/test -U user%pass -c "allinfo test.txt"
>
> which prints (stat output is garbled because of negative value):
>
>   Server local (/tmp):   1969-07-20 20:17:40.123456789 +0000
>   CIFS client  (/mnt):   1969-07-20 20:17:41.()*+,--00 +0000
>   altname: TESTT~K6.TXT
>   [...]
>   access_time:    Sun Jul 20 20:17:40 1969 UTC
>   write_time:     Sun Jul 20 20:17:40 1969 UTC
>   [...]
>
> Fix this by using set_normalized_timespec64() in cifs_NTtimeToUnix().
> ...

Applied.

  parent reply	other threads:[~2026-11-17 22:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 11:16 [PATCH 1/2] ksmbd: fix negative timestamps being saved to disk koraynilay
2026-11-12 11:16 ` [PATCH 2/2] cifs: fix negative timestamps being read from smb koraynilay
2026-11-12 22:59   ` Namjae Jeon
2026-11-17 22:01   ` Paulo Alcantara [this message]
2026-11-12 18:27 ` [PATCH 1/2] ksmbd: fix negative timestamps being saved to disk Ian Bridges
2026-11-12 22:34   ` Namjae Jeon

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=aefc2a49baa1c3c1b153757612d2503a@manguebit.org \
    --to=pc@manguebit.org \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=hyc.lee@gmail.com \
    --cc=koray.fra@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=senozhatsky@chromium.org \
    --cc=sprasad@microsoft.com \
    --cc=stable@vger.kernel.org \
    --cc=tom@talpey.com \
    /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®