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=1795051958; b=gNea/KbzvzXtcyEfQxVciN+psyuovusbrO6yFf576IcZjKCy6BJ9mA9pkbksnXO2xEoX WmAfmLLZ5PV3tQgpUDM9ZjczrPYoLciSchzz7r/JpnryOSdwrQnzMcbfUuygu5tNtVblc zkzeOyJdMp4DlwABc4sTFnJ83OdlwWPHH3uFsy6jnOhlg2D/jgwAxZfLMvYAKUz1GiAb9 4FCxONQccm+eV53p6fbYsvaT2kBLypyGjnUAu+TyrtkL3e5GjlmmfcqleqgFZZsGKNQ0Z /lsDlhqKD124YicUlVRY5SKAt86mq/xkFSJOnBXzL8WJyGguTleNAVYu/kDV4txBQ5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795051958; 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=mmpOiELadD7A2TQMFg3DtnlpTxCGRp1G7MuSJBAgnyU=; b=IuYc1nMT/F1BdALHOTvXhGjKlvwbdehMdaEvFoFi6zML1xQ3gM2KUlQRjIMM5bbi8MWF yY7lpMxjjxhS5379GVlfWJlq8sCLea0jGGb0wMoPhxiw+tQ9C53F/d8Sbpq/OfQwu64ea Mk0nyJLHjwRZ8LvXIJsHLj/peUQMThDuDAIVDy2U3fwqE2DMrTgdIPVIwHwScUi+Rf3OC I++QkLSWqf+plsk1BQCHJevGWeLDZmpx49FYO6Jz8JhEWXILY7/e1MreA1Ogl5FuYQXjB KjzAdDoGJ+XJAexa/FPDKISd7OfTvFlRA/SatIE624jP5wlc+VGzLiHi1743CAkLHlg== 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=giZy7zwA; 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 4C909606A331; Thu, 19 Nov 2026 01:32:37 +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=giZy7zwA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 076021F000C4; Thu, 19 Nov 2026 01:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795051957; bh=mmpOiELadD7A2TQMFg3DtnlpTxCGRp1G7MuSJBAgnyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=giZy7zwA62XAwh7AB36ZAvbeU4aNTtIDbNzumuX+G30jzryiogtr3jKhBrJYjHbMG 2gEnVd3VZkoWmLlh8R0fA0LufA1y9xn3lvea+7BRGBLKVqNsI2CGpjJN9jypl8oNTx pnp4NbkpQS4g8BuF6G/fKcdAnX+sXZsbvsmAdzhk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zikang Gao <2715417602@qq.com>, David Howells , Paulo Alcantara , Sasha Levin Subject: [PATCH 5.15 0392/2214] smb: client: do not pass a NULL buf to is_oplock_break() Date: Wed, 18 Nov 2026 15:34:28 +0100 Message-ID: <20261118150026.350210470@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zikang Gao <2715417602@qq.com> [ Upstream commit 2225ab306575e424b3dad2ee1be2521c89249d15 ] receive_encrypted_read() sets *num_mids = 1 and never writes the caller's bufs[]. Offload returns -1 with *num_mids = 0, so the demultiplex thread skips the frame. The inline decrypt path returns 0 even when smb2_find_mid() fails. cifs_demultiplex_thread() then treats mids[i] == NULL as an oplock break and calls is_oplock_break(bufs[i], server) with bufs[i] still NULL. smb2_is_valid_oplock_break() reads hdr.Command at offset 12 and oopses. A large encrypted READ whose MessageId does not match is enough to panic cifsd. Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 100 Comm: cifsd RIP: smb2_is_valid_oplock_break+0xc8/0x2270 [cifs] cifs_demultiplex_thread Kernel panic - not syncing: Fatal exception Return -1 when inline decrypt finds no mid, and skip is_oplock_break() plus the unknown-frame dump when bufs[i] is NULL. receive_encrypted_standard() already assigns bufs[*num_mids]. Fixes: c42a6abe3012 ("CIFS: Add capability to decrypt big read responses") Assisted-by: LLM Signed-off-by: Zikang Gao <2715417602@qq.com> Reviewed-by: David Howells Signed-off-by: Paulo Alcantara Cc: stable@vger.kernel.org [ sashal: Added braces around the existing single-statement missing-MID branch. ] Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 4 +++- fs/cifs/smb2ops.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index a91d3f6ae5be6..98a3e25c107db 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1089,12 +1089,14 @@ cifs_demultiplex_thread(void *p) mids[i]->callback(mids[i]); cifs_mid_q_entry_release(mids[i]); - } else if (server->ops->is_oplock_break && + } else if (bufs[i] && server->ops->is_oplock_break && server->ops->is_oplock_break(bufs[i], server)) { smb2_add_credits_from_hdr(bufs[i], server); cifs_dbg(FYI, "Received oplock break\n"); } else { + if (!bufs[i]) + continue; cifs_server_dbg(VFS, "No task to wake, unknown frame received! NumMids %d\n", atomic_read(&midCount)); cifs_dump_mem("Received Data is: ", bufs[i], diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 781fe599dda7e..348168c9b7617 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -5208,9 +5208,10 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, goto free_pages; *mid = smb2_find_mid(server, buf); - if (*mid == NULL) + if (*mid == NULL) { cifs_dbg(FYI, "mid not found\n"); - else { + rc = -1; + } else { cifs_dbg(FYI, "mid found\n"); (*mid)->decrypted = true; rc = handle_read_data(server, *mid, buf, -- 2.53.0