From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0559192D97 for ; Wed, 13 Aug 2025 13:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755091941; cv=none; b=o4UK61rrVRpdGai6joatI73BelP7ZeiD4r+j++9ypVHb9DY6Mq92cKF3ZghX23JQyx0vZgQM1u3QFNHagM6mfyzGVyWejjcwSQMwTd07J7yod+Tj2CatpZBrmSKbyf2N+2a4yGmqZUKDdx76793BKqw0jH3X/f2LRH9gVNUKkLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755091941; c=relaxed/simple; bh=wsOobTfT6VyMSKBaXMDuQzU6EsoJJ7eiNC2rBfB2Ly8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oVQPUafiie9J8Z69BxAAd3FCZdFDoX7dBg0FutzlHu1jTpejwKCOQ4pA+SaKzVxaFQcnwdhEOL9o0OHdU03Lxq1OyzCeV7vmF2OyK46/IqP6hdzuQxbH4tuhHvoQWHQYY25TCBb5DWt7Pgh9IWkco8wzimSRP6b1ugZM5MqpZe0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hsVv6K/F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hsVv6K/F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 991F1C4CEEB; Wed, 13 Aug 2025 13:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755091941; bh=wsOobTfT6VyMSKBaXMDuQzU6EsoJJ7eiNC2rBfB2Ly8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hsVv6K/FvWkkANpYKNhFb83rG5Uc04WIwO9dXjmc1dceGGQ7R3tFXvwW1qhmLRW9y Sy2u7lD5WYR11kbUqR7qRljnleEjTaX7XRlPNSivc3i0CZtvVYHtEI/tVnGMOTb2sU iDw2NLcovSQpMcHoFttoLjBUnknUB/RqJxvF97Gj6TDZnsIn001zCQcwd8fD0fTRhS oS6InTFIml8CPHDekPy4mjHN0k8bRbyETj1jb8QAx/DriTrjZR/uv1W9aUOEUjVsin vmYgArV9UYZV4p3/SbwcPy3Yam8pW/4IcDFARuO4KvwkSWYTcnbWofjsJilCKLac8O Io86SeeH9FxYg== From: Sasha Levin To: stable@vger.kernel.org Cc: Thorsten Blum , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 5.15.y] smb: server: Fix extension string in ksmbd_extract_shortname() Date: Wed, 13 Aug 2025 09:32:18 -0400 Message-Id: <20250813133218.2035014-1-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <2025081211-chirping-aversion-8b66@gregkh> References: <2025081211-chirping-aversion-8b66@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Thorsten Blum [ Upstream commit 8e7d178d06e8937454b6d2f2811fa6a15656a214 ] In ksmbd_extract_shortname(), strscpy() is incorrectly called with the length of the source string (excluding the NUL terminator) rather than the size of the destination buffer. This results in "__" being copied to 'extension' rather than "___" (two underscores instead of three). Use the destination buffer size instead to ensure that the string "___" (three underscores) is copied correctly. Cc: stable@vger.kernel.org Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Signed-off-by: Thorsten Blum Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/ksmbd/smb_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ksmbd/smb_common.c b/fs/ksmbd/smb_common.c index e90a1e8c1951..0438a634f4c2 100644 --- a/fs/ksmbd/smb_common.c +++ b/fs/ksmbd/smb_common.c @@ -508,7 +508,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname, p = strrchr(longname, '.'); if (p == longname) { /*name starts with a dot*/ - strscpy(extension, "___", strlen("___")); + strscpy(extension, "___", sizeof(extension)); } else { if (p) { p++; -- 2.39.5