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=1796384094; b=bu/3w/M50jNF1usQVB8HkIo2/lv6Wr572K5KyDGwGWRK1OIGOPSpSsd8sstRjH1aKriT b+8l1Cv4ZSzALZCs67mB+6spyBqS7FmCBbag93L0tgohw+VqZjQuDphKVyjN5pORLHnfR EYBlBVjOsB+Ne2LvdYAt7m+bDJEqHRkzscIM2WwnNFzMj1e5Ve8QvwdQUcAboO37djoN0 PpFzadLApSHft0R/Y/8sIBuR9lMvmbyqiglhxcrSUBnJU4/tgBdG2cAAl6aBnKuWLjCTn GodT7OkJfbMyi9YjXeH0Gs/2wrKhjawuoiKNrt0Plarl77pFsuzbRCyzyE+HCuPjGaw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384094; 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=YKNFjSZeGgdn4rKuCfmj/Bk34y5LR67Oe/0LUHiXT5A=; b=Ondc35Pgr+hZWDzFg5CBhME/6fkrjLB0Lac+59/qII4LEzFSIXFAFg+w6127qEW37VJB MiqFO2UBn6kgektmD6OKZfkJtDP0TAjYpEmB3RkY19gxYwMd+eNWoLHSuI72aXMtcpMHC QteVUQuYweuBk/cUQkxMVUGIIVQ4KQ3+/8/HmVl3+k65HwZYYAr/TYvSkROjnHrkP6DI+ JngcZpmGRnLv4Oi23uaSYlZS791cEwPo1nLSliYRGivGWgp2NbnOfxSosnooRGmN7wunx b7ABW8fSk7YJdviwzKzWX+A1DtxnP48w3XT9MGRMF+YzV30klLvsA15AsrhWMipcjqw== 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=pEcK1wwO; 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 384F6606A322; Fri, 4 Dec 2026 11:34:54 +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=pEcK1wwO Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8F001F000CE; Fri, 4 Dec 2026 11:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384094; bh=YKNFjSZeGgdn4rKuCfmj/Bk34y5LR67Oe/0LUHiXT5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pEcK1wwO8x0JGp1q3MdZN9YWBR3QyBuUdE8S6XxziWxO+GMLGQYn3k8gVcttUQsIM pzd6HuJkmthSW4GN6hrO8+xqPkDnz6QmlLZJuuPExb6ra/7Ip7NA03932DiuqwTSIY 0kD0nEm29vbgjium3wS2yj3oDSB8MxRgjtVH0XkM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, koraynilay , Namjae Jeon , Paulo Alcantara Subject: [PATCH 6.12 492/555] smb: client: fix negative timestamps being read from smb Date: Fri, 4 Dec 2026 19:08:55 +0900 Message-ID: <20261204100627.787256312@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: koraynilay commit 6a75ce0866bb1efe67947fc5536a476381d7a9d9 upstream. 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(). Fixes: 2ae83bf93882 ("[CIFS] Fix setting time before epoch (negative time values)") Cc: stable@vger.kernel.org Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.3 Signed-off-by: koraynilay Reviewed-by: Namjae Jeon Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/netmisc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/smb/client/netmisc.c +++ b/fs/smb/client/netmisc.c @@ -942,8 +942,7 @@ cifs_NTtimeToUnix(__le64 ntutc) if (t < 0) { abs_t = -t; ts.tv_nsec = (time64_t)(do_div(abs_t, 10000000) * 100); - ts.tv_nsec = -ts.tv_nsec; - ts.tv_sec = -abs_t; + set_normalized_timespec64(&ts, -abs_t, -ts.tv_nsec); } else { abs_t = t; ts.tv_nsec = (time64_t)do_div(abs_t, 10000000) * 100;