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=1796381443; b=qXBza1l90bNeJFQWkqSDMKSnEIROSHscXOz7RYXReCrcMBcUJLAagELLGIO66sehKhMz yf7M17cfNAgKAg/2x6QWV/hYrWweL35YoLUSMvsF+XaHn3ZgR1lkaqIAXcwv7fcXxcJCw XgYf9LToPxCyDw0iLDlmVuyAGWRE1qDkJAJJJ3jyCTZrVRnmenxYvdIYRvAN66PGp7oiL q8uXo+0QdyVDCIoxlQlyjncw+/H/Xcbf70Tu8SdfC0VMEiQX2EhgoDMfupbCHb/Bn9E+G sZmqLf/+VnodHf4iiH7dluRLeeOneFQ9gnfdFfs5Si77C78wHc+HftwmuIG38+0Ngkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381443; 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=L+kn2GUsLEP3pQHgAv+zhhEQUEuH3QuSyMBNTMbRSHo=; b=jlJiGmgd3ULOVcLNYANMkXbDE+Mj5gNB8RA0lRkRXkS27m2fmf1DpFpkb8ozKODfYVxe jr8shhAt+t9KkEpFzHbAIJTYxLCiQ1UM7o4xdyqECpWZKudsKU66MDPBe2jGZSHXCxWLp bAtHakhKyExGHD85oZBFu+p4esYAzGhwFeQaoHic5YvhFCJ3mc2bjOkeD899IpUCkTVMz 4oUOcGYsdKz86P3OlnWzHqbluMSlPfcua+w/Xp+VNqnSgBPV6xN/KgpBrc0wnbi5KRK5x Mc0ap/VmBOQ4YSRC8DmPNfExmeDk4RwBCuop7vm22anq6o9b7bpIkrkukiaI7B0gK2A== 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=H6Bb+CAk; 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 51131606A32C; Fri, 4 Dec 2026 10:50:43 +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=H6Bb+CAk Received: by smtp.kernel.org (Postfix) with ESMTPSA id C09B31F000C2; Fri, 4 Dec 2026 10:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381443; bh=L+kn2GUsLEP3pQHgAv+zhhEQUEuH3QuSyMBNTMbRSHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=H6Bb+CAkYjFgmpHwq13GnIrYQP0ykEr5HC5trTlcuFiH/g7kEATpJoPnsxMwaCeoL vMkIiz1v6972iB7r1MIP8exDKTZFixWk7DXzZkyun2wK8o3t8QHlkX+OmO07q8eC5k fKMtAbxsWVYoShGQj0yOz8t7EarpHufyQjWrftM0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, koraynilay , Namjae Jeon , Paulo Alcantara Subject: [PATCH 7.3 666/742] smb: client: fix negative timestamps being read from smb Date: Fri, 4 Dec 2026 19:08:50 +0900 Message-ID: <20261204100652.762927696@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: patches@lists.linux.dev 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 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 @@ -133,8 +133,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;