From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9227A39657D for ; Thu, 9 Jul 2026 16:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783614994; cv=none; b=IJ5Yd1eJTNJxPu3erRXTo+Y+ApGSqewC+NHaFF2SEY6YftVDJBNjSKDZfoIUaBeTl/L5Yq5l/XN1G7KFsaiLrJ4SE33iot3EFyIDw+pQbcsNGTCc130nChYLqkA580T16qGqyN+wviO6TB8NTDqmDYyunnzh8jLekBoR0aCtc1k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783614994; c=relaxed/simple; bh=UsbaNrmIn63ARuAebfUPXUmtATO3t4qV3jGnIvUWHz0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cVVfA6ircYM4Bcd3BgInXznd8tNeK5zaAyhFJ+afFnXN25RRcnKderscDG46ARUB9rvt+wPTkbPy6h3raKYRvvO3pkJwp05d2NclakC38wd1WLdIKPdpkBBSvZihURhQF0iJ+YYLsfZY/65gAaJSo6pPkKi9yXp0Gj3epx8pFXU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rQ6zC61f; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rQ6zC61f" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so168015e9.0 for ; Thu, 09 Jul 2026 09:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783614991; x=1784219791; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=XpHK7z6dsHMMY8QknSXEZPqq3A8a/T0iO7+AZZEhDvk=; b=rQ6zC61fV7LeVAKVwVH9oG2GLeUbHYDTIP94zEfcNbV0ZSbLscsrapE+FtOAyokL49 vQD0VcRe3nfiSFMG/eWYbRk6DFMZK7ckZ62KWHUI0XTFxS2SxL7GMHh3jJKC1+6INCQ1 XUryu8rDCHgNOZk3sXemNeyh1+w0+sMHZZ4ribsblXP4LUroDqS3JLesSDL1voUZoUra 8NiAUIR5xVIW/aEajV0Hr21bQzErLNDqf0e7RTnTZ6kBQFJ3KAhpxTxHdghBNplMQny5 LX2k+HtUvgvIU0YRa8IaJEqKj7pkudn2gD3tl5nk3yhg8pN2r5dhXYuC9JkgCIUap6op eE6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783614991; x=1784219791; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XpHK7z6dsHMMY8QknSXEZPqq3A8a/T0iO7+AZZEhDvk=; b=EgpSJpZsaY/YGbBszAIfGFZzhSkgA/FY5020KWLp6iPS0bJqw1Ug9V36J05EE8tN2R mGiHOsM/jUFJ4AdpIjFW5XTlD5A9oSb9hPxbEL8k3qu//syp5czqm8iIBTVkZQebcQqt J0CfGuLn3DYYyYDCbB2YN7czl1VfiZnVqGDshhHw/jG2vlK/R6EIludQve6FNVzB7+HM zuhfVny/NVofa0nVrtGS57zx6CMLojSF/DX6pdiIgj8qm+oIgh2dfhqT+4IiYSw2pv/M SglKn7LjG0ks6/XTf4QXqIon2yFmaySjjlnnVpHCMrnkX4z0kDMkPN0WVDvfB9yRuPqV inhw== X-Forwarded-Encrypted: i=1; AHgh+RoS+qHSb0ZpGW6wFjgztuAf0wW9emLJWhmhlHUHwuVBcz7KsmhLnHd9kgT2EbDONLaqQc/S+arTXEguD+s=@vger.kernel.org X-Gm-Message-State: AOJu0Yyg85artrKk5AnLKVcnPdPswHOagcXJPxsfEXEUe8X5y8GK6bTv 1L43pdeGp9g6JQY5qjGsN6CfAxPKevZOD7HPfpkjOn81KcGOYnSFo2ubQ4ikfbpn X-Gm-Gg: AfdE7cnUb9cIPqVxJ0tZ+jWTrlxjuU2Svhr3BRggDdm+pIq2I4aUdO0cbntr2D0JwTm HTHrcUecUskgsN8dk2Dzb7OufN/ls9bDj9F3f0zAbU4in0/mSVEfsT0G4GIfKDJ683x7P7I5RTp iAUyJmePbWBfqtzFbAFjHIPHpljZ+WUo7vY1yXm5pZI0os/XGfftQddAcfbAncwZfglsBT9u4pu WlwbCA/vg4ONxM5YhoqtW36aI4YYpBwyWd9y+eMyg8sxauTpsd+2pMSJNmckWBhvfAuPTw/X+Lk PZfQ+qKe5mDjb/l68ECe4VnM209YOJJEcos+Jv0US31+tIf5OnMOMuxV/u+/ItJSwHwp+Qy0IAM WhhDCGG9YehO3vcnaB1isVLOd9TBgU7qovu/uC+dblm50k02YZSpkLWg9E08vgntUq//i07cEVB 4IT00/aj4XJVq35cUHqi1FSF2ikVfySRnwbpnKQxfDpcRuWA== X-Received: by 2002:a05:600c:310f:b0:493:d1e0:a4f1 with SMTP id 5b1f17b1804b1-493e6c05de0mr72385005e9.0.1783614990763; Thu, 09 Jul 2026 09:36:30 -0700 (PDT) Received: from pumpkin (host-92-21-50-228.as13285.net. [92.21.50.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493e5a5d174sm174062095e9.2.2026.07.09.09.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 09:36:30 -0700 (PDT) Date: Thu, 9 Jul 2026 17:36:28 +0100 From: David Laight To: raoxu 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 Message-ID: <20260709173628.22eeb7f7@pumpkin> In-Reply-To: <527C2DB5ABAE200F+20260707133017.1740557-1-raoxu@uniontech.com> References: <527C2DB5ABAE200F+20260707133017.1740557-1-raoxu@uniontech.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 7 Jul 2026 21:30:17 +0800 raoxu wrote: > From: Xu Rao > > 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 > --- > 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 > >