]> git.hungrycats.org Git - linux/commitdiff
smb: client: do not pass a NULL buf to is_oplock_break()
authorZikang Gao <2715417602@qq.com>
Mon, 2 Nov 2026 22:14:57 +0000 (17:14 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:13 +0000 (12:06 -0500)
[ 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 <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
[ sashal: Adjusted context to retain the existing one-argument mid_execute_callback() and release_mid() calls. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/client/connect.c
fs/smb/client/smb2ops.c

index 3089b469b80183e2871a0201736e3d027afd2f61..2cbbbf0c93b8099984e78b25bbc1eb2484567f6f 100644 (file)
@@ -1400,12 +1400,14 @@ next_pdu:
                                        mid_execute_callback(mids[i]);
 
                                release_mid(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(&mid_count));
                                cifs_dump_mem("Received Data is: ", bufs[i],
index f47f0f9ca781bb15baeda472b5c49f4a7af52efb..7cf6419df037d1d6137e429703f14f3da6f824c4 100644 (file)
@@ -5381,6 +5381,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");
+               rc = -1;
        } else {
                cifs_dbg(FYI, "mid found\n");
                (*mid)->decrypted = true;