From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381351; b=MSPd5RfLiJCfT6s5SmfAnq4RhU/doN5mqjhovbvM+NXnT1sXSNuEfYsPypj6CluLfCcj 0tXMcHJsbL9OtXRrwU6d/Tqww6YPkaIIAsciYplOaFUnjwf6sHAWkKzQLMg45Ta4RNu46 5xiGr5GI183KwJ+bJsvu8ryQofUHUU8/cRPpI6BkAoeYuqQezvRw+015+lMr5c9FOsx1b GQZiADisStHZgOob8+kR24NpgzeO7CN4cyTyoPmPJ9IgSaUGcwq0Ye2Fylw5LYnijrnQZ sI5CTJFPPOt8aD6/mkgtwy48GZXmG4xNjIvDq4mmV9v4WI28T4zKZgjAjNj0Xd8m1RQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381351; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=OEWVBpzWqVZQEj0orAJ4ZvGaD1EFHMEfgYoRgKPmAW0=; b=u4p7C88oU5w5TsqzGiHsiGkRQcSvPNmchk8fDTSaySaugBBxrGQy3VaDN+CYZ76SR1dk naOAz083ZeVkOfow5sQkltSLS4r6wgV4DGiPcjPmiOTr6mKNE2f+WRgBBlunMtIYk7OBs MuPSbCh456vLLix/8BuqRk37OubVdRSqq4HCBgleiJXuWfhNWNWjUSjgbIEt/xgUnnVWE KzRd4uyHcfpxNWfgvrVFNZ6gD+VJHxBTLLqsDD9/hT2CKESei7T1bGB0DcdkyDqA87Q3z 0xrmA/KxsAq7D6lxsE/wjNs/ey2D7EQg5AkW5UEoURlpfSgw30YS19KlkB3kTsk7dqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IqEpHG1V; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEFBA606A322; Fri, 4 Dec 2026 10:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IqEpHG1V Received: by smtp.kernel.org (Postfix) with ESMTPSA id 300AD1F000C2; Fri, 4 Dec 2026 10:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381351; bh=OEWVBpzWqVZQEj0orAJ4ZvGaD1EFHMEfgYoRgKPmAW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IqEpHG1V5I0PwSP9Q+u19m/peJrYXH1m1wnFsByQcn5527qvogJAo0h8cLI0g91rX /0J0lS7wZ27y2TuNW5ds4NwI5xQm5TE3E40gTV00mlnN44DFY6UMq1N/TTp6DZRsAZ +YbudEqeABQOWqTXewFugwB6KcmQZOVgM+w18GdY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , koraynilay , Namjae Jeon , Paulo Alcantara Subject: [PATCH 7.3 667/742] smb: client: fix times assignments in cifs_posix_to_fattr() Date: Fri, 4 Dec 2026 19:08:51 +0900 Message-ID: <20261204100652.788287223@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: koraynilay commit 8b456f136a76a29fee8d36934740cb7f7fb5c837 upstream. Currently cifs_posix_to_fattr() wrongly sets SMB's CreationTime to fattr->cf_ctime. Fix this by setting fattr->cf_createtime to SMB's CreationTime and fattr->cf_ctime to SMB's ChangeTime, matching the behaviour of __dir_info_to_fattr(). This patch also fixes a few related issues reported by sashiko on another patch (see Sashiko Link tag). Reproducers for these bugs, 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=ciao,password=c,posix Issue 1: ctime clobbered by CreationTime during readdir mkdir -p /mnt/dir touch /mnt/dir/file sleep 4 chmod 644 /mnt/dir/file stat -c "ctime and btime before readdir: %Z %W" /mnt/dir/file ls -lc /mnt/dir > /dev/null stat -c "ctime and btime after readdir: %Z %W" /mnt/dir/file stat -c "ctime and btime on disk: %Z %W" /tmp/dir/file output before the fix, notice how ctime is the same as btime after the readdir, while it's 4 seconds ahead (because of the sleep 4) before the readdir (on disk timestamps are not touched): ctime and btime before readdir: 1794842068 1794842064 ctime and btime after readdir: 1794842064 1794842064 ctime and btime on disk: 1794842068 1794842064 output after the fix: ctime and btime before readdir: 1794842908 1794842904 ctime and btime after readdir: 1794842908 1794842904 ctime and btime on disk: 1794842908 1794842904 Issue 2: btime and ptime wiped out by readdir [ no reproducer as it only happens after the linked patch series is applied, since it needs cifs_i->createtime = fattr->cf_createtime in cifs_fattr_to_inode() ] Issue 3: in-memory inode aliasing (flock bypass on hardlink via readdir) mkdir -p /mnt/dir1 /mnt/dir2 echo "test" > /mnt/dir1/h1 ln /mnt/dir1/h1 /mnt/dir2/h2 exec 3< /mnt/dir1/h1 flock -x -n 3 # get exclusive lock ls /mnt/dir2 > /dev/null exec 4< /mnt/dir2/h2 flock -x -n 4 if [ $? -eq 0 ];then echo "acquired: duplicate in-memory inode" else echo "blocked: same inode" fi output before the fix: acquired: duplicate in-memory inode output after the fix: blocked: same inode Fixes: 3d519bd1269f ("cifs: plumb smb2 POSIX dir enumeration") Cc: stable@vger.kernel.org Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20261115180343.576773-1-koray.fra%40gmail.com?part=10 Link: https://lore.kernel.org/all/20261115180343.576773-11-koray.fra@gmail.com/ Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.7 Signed-off-by: koraynilay Reviewed-by: Namjae Jeon Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/smb/client/readdir.c +++ b/fs/smb/client/readdir.c @@ -253,9 +253,10 @@ cifs_posix_to_fattr(struct cifs_fattr *f fattr->cf_bytes = le64_to_cpu(info->AllocationSize); fattr->cf_eof = le64_to_cpu(info->EndOfFile); + fattr->cf_createtime = le64_to_cpu(info->CreationTime); fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); - fattr->cf_ctime = cifs_NTtimeToUnix(info->CreationTime); + fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); fattr->cf_nlink = le32_to_cpu(info->HardLinks); fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes);