From: David Laight <david.laight.linux@gmail.com>
To: raoxu <raoxu@uniontech.com>
Cc: sfrench@samba.org, pc@manguebit.org, ronniesahlberg@gmail.com,
sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] smb: client: fix atime clamp check in read completion
Date: Thu, 9 Jul 2026 17:36:28 +0100 [thread overview]
Message-ID: <20260709173628.22eeb7f7@pumpkin> (raw)
In-Reply-To: <527C2DB5ABAE200F+20260707133017.1740557-1-raoxu@uniontech.com>
On Tue, 7 Jul 2026 21:30:17 +0800
raoxu <raoxu@uniontech.com> wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> cifs_rreq_done() updates the inode atime to current_time(inode) after a
> netfs read. It then preserves the CIFS rule that atime should not be
> older than mtime, because some applications break if atime is less than
> mtime. That rule only requires clamping when atime < mtime.
>
> The current check uses the raw non-zero result of timespec64_compare().
> It therefore takes the clamp path for both atime < mtime and
> atime > mtime. The latter is the normal case when reading an older file:
> the newly recorded atime is newer than the file mtime. The completion
> handler then immediately moves atime back to mtime, losing the access
> time that was just recorded. Userspace tools that rely on atime, such as
> stat, find -atime, backup tools or cold-data classifiers, can therefore
> see a recently read CIFS file as not recently accessed.
>
> This is easy to miss because the bug is silent: read I/O still succeeds,
> no error is reported, and many systems either do not check atime after
> reads or mount with policies such as relatime/noatime. It becomes
> visible when a CIFS file has an mtime older than the current time, the
> file is read, and the local inode atime is inspected before a later
> revalidation replaces the cached timestamps.
>
> Clamp only when atime is actually older than mtime. This matches the
> same atime/mtime rule used when applying CIFS inode attributes.
>
> Fixes: 69c3c023af25 ("cifs: Implement netfslib hooks")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
> ---
> fs/smb/client/file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
> index 58430ba51b10..62605928d2b8 100644
> --- a/fs/smb/client/file.c
> +++ b/fs/smb/client/file.c
> @@ -301,7 +301,7 @@ static void cifs_rreq_done(struct netfs_io_request *rreq)
> /* we do not want atime to be less than mtime, it broke some apps */
> atime = inode_set_atime_to_ts(inode, current_time(inode));
> mtime = inode_get_mtime(inode);
> - if (timespec64_compare(&atime, &mtime))
> + if (timespec64_compare(&atime, &mtime) < 0)
> inode_set_atime_to_ts(inode, inode_get_mtime(inode));
Should that be calling inode_get_mtime() again?
It seems to have the value cached.
David
> }
>
> --
> 2.50.1
>
>
next prev parent reply other threads:[~2026-07-09 16:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 13:30 [PATCH] smb: client: fix atime clamp check in read completion raoxu
2026-07-08 23:45 ` Steve French
2026-07-09 16:36 ` David Laight [this message]
2026-07-09 17:26 ` Steve French
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=20260709173628.22eeb7f7@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=bharathsm@microsoft.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=raoxu@uniontech.com \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.