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=1796381434; b=D5wv4qV5VVeaSDvLvI1/gqvWOakflqPTtR1/98S9OFTzKHWqfsg811n9GpVspt03UeDI B6LcliUCPAzvM8KNVwKRCf2L3N+MOZqix4fCqVcN8ypaiARbPqamd7+xC4Gxqau1DnAzG TKfTh5Yq22+wvVyaCAcCG8AcB1jFpVKERiXiViAI1hvh1smXzQRr2gc5UDowkTX1mXgQY p9XMGSa+xOZL9j45nzZgfVXdScOA1q3TRZAJrnuwpbrl84Ba5XaFd5oqQaD8zHL63AA96 CAQGPMGub7276TigOOuRka1Bj0bLV+IGCYKvA4fmEFHbhbiTLwOqSUz2Z834BGM6N/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381434; 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=yoxwgQAqhPNRUbooEpXQcn8wu0PN+fQX7Sw0bWlsuzk=; b=QWrAE8YF0bo7ewrMwuyeLuzi4S3t79IbAoZAuEZLn5oIou5fvtX+zKYjI/kL1Dd8gjdt CS5h6KYgA/wZLZmspb2woWpma1Ngpt2nva/iVd2ROufohixQ9n86X5BufvCAZLVF4ZN7G BpjumxGi9/olb6la+zKqN+ojUStUI5CTbb76cLkDjoo6CSZe8RljvpqH1HYWugLgrKd/P CYhhgY/OPWEntYKY+HpKYTxygQw+nAp9otQVY2F5eWhoe5HVzFWSZfRYmTUoIm9asx7O1 svqp4gy2YzSaG8lv8hsnxSHdfyI6SQHa1/Mn5HirP4EVs8+BJQStPc4bQOF8cVOJ65Q== 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=1j2Z55+6; 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 384DF606A33C; Fri, 4 Dec 2026 10:50:34 +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=1j2Z55+6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A77901F000C2; Fri, 4 Dec 2026 10:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381434; bh=yoxwgQAqhPNRUbooEpXQcn8wu0PN+fQX7Sw0bWlsuzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1j2Z55+6mqVjzfKl3UC1CiFGV1msVVYUi268iKXmpBfc12i2uyFVGxtQN5+lKR/dU 5av9cPnsU+f9VN21gwgtOgvlfCDZhTI+3MlN7Je6mqaGyleO9PDd8G3xZVobus3VrW gxogoPyFZCF8NdKkyGI8Kk4Ge8X51ivqv0wzQtvE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kaixuan Li , Suyuan Wang , Paulo Alcantara Subject: [PATCH 7.3 662/742] smb: client: dont use read data that failed signature verification Date: Fri, 4 Dec 2026 19:08:46 +0900 Message-ID: <20261204100652.661618368@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: Suyuan Wang commit a1a0ef3ba8e802060bfc2b0ebf131a2cf98c3b71 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/smb2pdu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -4800,6 +4800,8 @@ smb2_readv_callback(struct TCP_Server_In 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); @@ -4879,9 +4881,8 @@ do_retry: __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