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=1796387376; b=3YGE/98l2J9+s8Jmf+u/t3tSX6LeCK2t6IkFf/1uYfD32NWeV4DcGAsXLUiPLhdfF1Gj knnzTz2BpJf+uvCKitWyv9Yq42+NcjqCpu+PgtFunmQ01Nkqlnx9VV27hoMV9jiiIXvTq gXx5ASw5baj3K42kubDHW6ez7WLyKZGXbACj1figE1gwdn68WJQsJm3O3WF4n+74nStM5 vRL3aDev5AQu/28U+k1hmFOt/Da6k9YCQEP6OdvBpr8pjsiMBf5xzuCXGqNvgF6Xz6eN+ wd6dNia86VaoIoiE4mA6rOetaB65m5Xli0wxOMcVDdw1bGJXgu7I/8pz6U+BAzJYlQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387376; 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=m46JEwtsEQduu6kQh3nmpWUkcBhLpVHZHrOMJiLIpx8=; b=Xs4R8oU5RBp2x9n+/nzJ1ZS9tiwLX0RzouUAtCtkMXhmIGrk+rq1c/C3xRjLENKhFINe Vm8EFvPjR0+8hr+j8kUxZ/tJAYiZlNWY6pIFkbWTOdwuDU+6OdhdnTeyR5fi5YWxjoAyj YlJ4nbkdjPOcvrpb21QA3jeqzlX1sibGyDXFQRN0qStVXxHqtIphYkX99cWXlqkZDYPtE k9AKjlnxPK1v6JUHmI8d7sN4ToutaWEwFImWmjFfl8vd+JDUhz7p5gyCnPGDyyYmQTGcw 44NEC/L9GIwTZKcqtE2iSd/Gwu4D30d4+Qh3LoVlWfa1i/M+g9iDlyAAsHrGg7ftIsg== 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=M9IL+G4w; 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 8C6D3606A322; Fri, 4 Dec 2026 12:29: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=M9IL+G4w Received: by smtp.kernel.org (Postfix) with ESMTPSA id C57AB1F000CE; Fri, 4 Dec 2026 12:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387376; bh=m46JEwtsEQduu6kQh3nmpWUkcBhLpVHZHrOMJiLIpx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M9IL+G4wOI9yt2BRJXzHutVZQSpwHNFjSNkXYI4V9LTypLqwp25GPMZePqsTXiQ+R ZhOF6Q4X8EwN4RiyTTlYyWZk3jWsiuHXNTtqNqLfjhkmaT/lGfEwJpdf9TBJqkVJbw PXgOWB0v7+ip2iI2YENWeJPJlG6Fs14r8wZb98ts= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Paulo Alcantara , David Howells , Namjae Jeon , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , Sasha Levin Subject: [PATCH 6.1 0218/1059] smb: client: reclaim credits for decrypted reads with no matching mid Date: Fri, 4 Dec 2026 18:55:49 +0900 Message-ID: <20261204100649.918875696@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara [ Upstream commit 78f73985846465a25a7bd1d89904053661f3ca92 ] When a decrypted SMB2 READ response carries a MessageId that matches no outstanding request, both the inline receive_encrypted_read() and the offloaded smb2_decrypt_offload() paths drop the frame without accounting the credits the server granted in it. The plaintext unknown-frame path in cifs_demultiplex_thread() already reclaims them with smb2_add_credits_from_hdr(), so encrypted reads leak credits that the plaintext path would not. This also happens for legitimate frames - e.g. a reply that arrives after the client has timed out and dropped the mid - so over a long-lived connection the client's credit count drifts down and can eventually starve it of the ability to issue requests. The frame is AEAD-authenticated, so the granted credits in the decrypted header come from the real server and are safe to apply. Reclaim the credits from the decrypted header before dropping the frame, and export smb2_add_credits_from_hdr() so the SMB2 receive paths can use it. Fixes: c42a6abe3012 ("CIFS: Add capability to decrypt big read responses") Fixes: 35cf94a39728 ("smb3: allow parallelizing decryption of reads") Signed-off-by: Paulo Alcantara Reviewed-by: David Howells Cc: Namjae Jeon Cc: Ronnie Sahlberg Cc: Shyam Prasad N Cc: Tom Talpey Cc: Bharath SM Cc: stable@vger.kernel.org [ sashal: Context lines in the cifsproto.h prototype hunk were adjusted, since the older tree still uses extern prototypes, while the logic changes match the original. ] Signed-off-by: Sasha Levin --- fs/smb/client/cifsproto.h | 1 + fs/smb/client/connect.c | 3 +-- fs/smb/client/smb2ops.c | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 8cfa504e6bd83..7f462ba39a93d 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -160,6 +160,7 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, bool mark_smb_session); extern int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session); +void smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server); extern int checkSMB(char *buf, unsigned int len, struct TCP_Server_Info *srvr); extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *); extern bool backup_cred(struct cifs_sb_info *); diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 7895f0f4831e6..df8634228cbad 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -1163,8 +1163,7 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) return 0; } -static void -smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) +void smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) { struct smb2_hdr *shdr = (struct smb2_hdr *)buffer; int scredits, in_flight; diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 17a44992667c2..20a166e1a5b52 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5113,9 +5113,10 @@ static void smb2_decrypt_offload(struct work_struct *work) dw->server->lstrp = jiffies; mid = smb2_find_dequeue_mid(dw->server, dw->buf); - if (mid == NULL) + if (mid == NULL) { cifs_dbg(FYI, "mid not found\n"); - else { + smb2_add_credits_from_hdr(dw->buf, dw->server); + } else { mid->decrypted = true; rc = handle_read_data(dw->server, mid, dw->buf, dw->server->vals->read_rsp_size, @@ -5245,6 +5246,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, *mid = smb2_find_mid(server, buf); if (*mid == NULL) { cifs_dbg(FYI, "mid not found\n"); + smb2_add_credits_from_hdr(buf, server); rc = -1; } else { cifs_dbg(FYI, "mid found\n"); -- 2.53.0