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=1796221545; b=ANi+7+a3NK14Fe4GLGgZ9R+6JKt+cGSS37orjyID9G2a7yqXRNpTIF0LxZ48bcOxS01x 0p2Vvaa0ggf1ZwrQM+gHhvZmWKC4PaqLPPa/Zvp8Uw4JHYnGTzrVRF/0AiPMxlTQyLaWC 3HDaOaE4GZMb7Jzto9mgcWBLxKFNJyxQZWPWLacObcqsBgFzXBd4SNCWeSG84cEIPXcyG g3PPIcm3RTVeRgYysDnPp0ceSMQkgnSTWyHwfXIyo7UlbL2NRYStejPVfWn4fYXKDW/CZ CFt2lLa5NBxPjt1KtpkQ9qfnFUdous4pRa5THgVFq78zM9+5UMpMo/376sA/6m5prYA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221545; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=X0ck9TePeLLTvIeKAHGPEVE8cn/LQnCpv4/nthfiZlg=; b=IGbQa1Ic+MZYV/WOKNaAfyc+W8eG9+TuM2xlu1TyM+LHaQbxZ1fR3WY6CiJNDZDxllcL ARj7AzBxzgKR8fHZeilFypeOvcvHdk7VOTKxvmbGZOQroCRqTw0x3jxAhIDD18QhdREvr WvwBqE96hEsgyjbCW1C20+Rro3lemwUrYDNFRT8B3/2KNxCYIZMtq3HTDyKJfaTB7cB4L TWjHorjvFtySbzJa4XsRlyVtukzQXpd7yoasZzi3OgLapCblt+JzLcQkG10dnpqOxQ/vr bYvbk7w4Pf7NK2X0mt1NtajIZc7V5SVUAueRMTX9/RCXrwaxzlGmU1x0ZyPssza0evA== 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=uxactKn5; 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 4E576606A32F for ; Wed, 2 Dec 2026 14:25:45 +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=uxactKn5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D7921F0092F; Wed, 2 Dec 2026 14:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221545; bh=X0ck9TePeLLTvIeKAHGPEVE8cn/LQnCpv4/nthfiZlg=; h=Subject:To:Cc:From:Date; b=uxactKn5BoQn5vr/5G6O8QXUZ4R8eEtwTF28WvJFU8JV3nlFmk978rJM7UbgFxSQb Q+DGCscMaCDP0F6lwCektd3uRPYqcA5lVytA6MA/+AlICNdJw6LJERc2SBJyOZpIi3 dX4b7egwjZmrNRHg+1qYjorNomKj5D1Qcabaio6s= Subject: FAILED: patch "[PATCH] smb: client: don't use read data that failed signature" failed to apply to 6.18-stable tree To: stevewong@hust.edu.cn,kaixuan.li@ntu.edu.sg,pc@manguebit.org Cc: From: Date: Wed, 02 Dec 2026 14:55:20 +0100 Message-ID: <2026120220-throbbing-marbled-290c@gregkh> 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-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x a1a0ef3ba8e802060bfc2b0ebf131a2cf98c3b71 # git commit -s git send-email --to '' --in-reply-to '2026120220-throbbing-marbled-290c@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a1a0ef3ba8e802060bfc2b0ebf131a2cf98c3b71 Mon Sep 17 00:00:00 2001 From: Suyuan Wang Date: Thu, 19 Nov 2026 04:00:48 +0000 Subject: [PATCH] smb: client: don't use read data that failed signature verification When smb2_readv_callback() finds a bad signature, it sets the error in rdata->result but leaves rdata->got_bytes alone. Further down, a short read that reaches the remote EOF clears the error again: size_t trans = rdata->subreq.transferred + rdata->got_bytes; if (trans < rdata->subreq.len && rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) { rdata->result = 0; and got_bytes is then added to subreq.transferred. So the last part of a file, or all of a small one, is returned even though its signature is wrong. Clearing got_bytes is not enough on its own. If the read starts at or past the cached remote size, for example because the file has grown on the server since the size was last fetched, the check above still matches and the error turns into EOF, or into a zero-filled tail when NETFS_SREQ_CLEAR_TAIL is set. Clear got_bytes when the signature check fails, as the retry path in the same function already does, and only treat a short read as hitting the remote EOF when the read itself succeeded. That is what commit 1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read") describes: "clear the error if a short read occurred without error and the read-to file position is now at the remote inode size". Found with a static analysis tool and checked by hand. Fixes: 1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read") Cc: stable@vger.kernel.org Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Suyuan Wang Signed-off-by: Paulo Alcantara diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 2f05ba613f34..7b7d25364e20 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -4819,6 +4819,8 @@ smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid) rc); rdata->subreq.error = rc; rdata->result = rc; + /* the data can't be trusted, don't count it */ + rdata->got_bytes = 0; if (is_replayable_error(rc)) { trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_retry_needed); @@ -4898,9 +4900,8 @@ smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid) __set_bit(NETFS_SREQ_CLEAR_TAIL, &rdata->subreq.flags); } else { size_t trans = rdata->subreq.transferred + rdata->got_bytes; - if (trans < rdata->subreq.len && + if (!rdata->result && trans < rdata->subreq.len && rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) { - rdata->result = 0; if (rdata->subreq.start + trans >= i_size_read(inode)) __set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags); else