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=1796382756; b=fL0IRXgpkkZu1ZmzgVhclFxXKCK591RqBF2rRADXk1O7/cd73j8/tFoOqxM1KyXGXmPp Te1//59RauQNhWRKKhpqBbbkPSNGmnvq9NyN4DnT50bDoDXm40MFYQRQ9kWnW+wk8Ak7c mp4r9taUkU7N2twXpY14TWgdKDl/Fx2x1w+/sjbmkpkaiOBZV/WFeYOFLzTb3r0yfTk7f +Xv4BdI3QBe7sjiKfY09MQOmkRTPzPjJEaqYhaH76zEsfNHOpZx+MvqsVN6bkoNFxUV+U sfaZFW6dE2+A9+vzVLx4rlNEwCXHKrRecjR5lRPylVmFw9FwCSnR0p2szGo3lQDfNxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382756; 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=opoC7fKouya3ncpbawFDhb0/YWPYlQhKdQh/4WcWCsk=; b=3PTL4Qf9vV4fE2sKMQhi6IQ9eK2oE1JWglv28LmqUBmJUdkMHp21XTM9zxoCeXHvQelA ZeIwBYFBw/qxby/ze/gI2Qe3bjjv75zS6LNYlYrfSTJvYvzJhHr1RcwkxXm6mn7VknRRA NzL6F5usQrC5TPaPSz61X3vNc7MAZQcmLkWjW50jDsO66/RyaWbSdEdTBvFYJgha8ymEs Ct7Tdtiy5O1pOn2VxnrBra1qEbUiBi9n7WX4xqS2uO/8HA+PR4R/J6EJmvONghWa9Uey+ NQTDNjoA180/DIYUAyRyItrBi/FeGAk5lTDRnd5EpWmjqWU9jpvgjaibA3enWO7CNJg== 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=zXHpvFHW; 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 249EC606A32F; Fri, 4 Dec 2026 11:12:36 +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=zXHpvFHW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EDC91F000C2; Fri, 4 Dec 2026 11:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382755; bh=opoC7fKouya3ncpbawFDhb0/YWPYlQhKdQh/4WcWCsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zXHpvFHWWA6aKkcHT+luJg4afX+ru8p4mT/bEQS8Td9SiLBeX9xq3d4FYjdF3TFkn VUuZpXa6ZR1tzUkGS9cAw/05jqnxQY8Vlp4++QORP+BDt9rmiyjopvUbhWUbtHhfe7 5z/rFj20bWD311mPpwZBT2Owvx/Ryj9CZosa12xw= 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.18 582/703] smb: client: fix negative timestamps being read from smb Date: Fri, 4 Dec 2026 19:08:01 +0900 Message-ID: <20261204100643.237771410@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -950,8 +950,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;