FAILED: patch "[PATCH] smb: client: delete compound mids on send failure before" failed to apply to 6.6-stable tree
Subsystems (5)
[email protected]
maintainerThe patch below does not apply to the 6.6-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 <[email protected]>.
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.6.y
git checkout FETCH_HEAD
git cherry-pick -x 8f6f8a48399f82f4a83f7b9f25b9707e0062a4f9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092927-uproar-implement-c4b4@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8f6f8a48399f82f4a83f7b9f25b9707e0062a4f9 Mon Sep 17 00:00:00 2001
From: Adarsh Das <[email protected]>
Date: Sat, 19 Sep 2026 16:27:32 +0530
Subject: [PATCH] smb: client: delete compound mids on send failure before
unlock
When sending a compound request fails, smb_send_rqst() kicks off a reconnect. compound_send_recv() still has those mids on pending_mid_q, but it unlocks the server without removing them first.
During reconnect, cifs_abort_connection() walks pending_mid_q and runs each mid callback. With no response yet, those callbacks return credits and drop in_flight. Then compound_send_recv()'s send-error path returns the same credits again. in_flight ends up decremented twice and smb2_add_credits() WARNs.
syzbot hits this during SMB2_negotiate when the socket send fails.
cifs_call_async() already calls delete_mid() before unlock on send failure. Do the same for compound chains and set cancelled_mid[] so the
out: path does not delete them again.
fs/smb/client/transport.c +4 -0
@@ -965,6 +965,10 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,if (rc <0 ) {revert_current_mid (server, num_rqst); server->sequence_number -=2 ; +for (i =0 ; i < num_rqst; i++) { +delete_mid (server, mid[i]); + cancelled_mid[i] = true; + } }cifs_server_unlock (server);
Sasha Levin
maintainerPATCH 1/3 cifs: Remove the RFC1002 header from smb_hdr
From: David Howells <[email protected]>
[ Upstream commit 83bfbd0bb9025f98fa62b44f93bd67466773d1db ]
Remove the RFC1002 header from struct smb_hdr as used for SMB-1.0. This simplifies the SMB-1.0 code by simplifying a lot of places that have to add or subtract 4 to work around the fact that the RFC1002 header isn't really part of the message and the base for various offsets within the message is from the base of the smb_hdr, not the RFC1002 header.
Further, clean up a bunch of places that require an extra kvec struct specifically pointing to the RFC1002 header, such that kvec[0].iov_base must be exactly 4 bytes before kvec[1].iov_base.
This allows the header preamble size stuff to be removed too.
The size of the request and response message are then handed around either directly or by summing the size of all the iov_len members in the kvec array for which we have a count.
Also, this simplifies and cleans up the common transmission and receive paths for SMB1 and SMB2/3 as there no longer needs to be special handling casing for SMB1 messages as the RFC1002 header is now generated on the fly for SMB1 as it is for SMB2/3.
Dependency backport for Linux 6.12:
Retain only the compound_send_recv() local MID array rename from midQ to mid. Drop the RFC1002/SMB1 refactor: this stable tree still keeps the SMB1 transport code in transport.c and struct smb_hdr in cifspdu.h, and the target fix does not require any changes to framing or message lengths.
To allow 8f6f8a48399f82f4a83f7b9f25b9707e0062a4f9 ("smb: client: delete compound mids on send failure before unlock") to apply and compile unchanged, also give the existing delete_mid() its explicit server argument and update all callers. Use ses->server in cifs_setup_request(), matching the server used by allocate_mid(). Retain the stable mid_lock, MID_DELETED flag, server pointer, and kref release implementation.
No functions are added, and the target's send-failure fix remains a separate patch. The upstream subject and author are preserved.
Upstream description follows:
Remove the RFC1002 header from struct smb_hdr as used for SMB-1.0. This simplifies the SMB-1.0 code by simplifying a lot of places that have to add or subtract 4 to work around the fact that the RFC1002 header isn't really part of the message and the base for various offsets within the message is from the base of the smb_hdr, not the RFC1002 header.
Further, clean up a bunch of places that require an extra kvec struct specifically pointing to the RFC1002 header, such that kvec[0].iov_base must be exactly 4 bytes before kvec[1].iov_base.
This allows the header preamble size stuff to be removed too.
The size of the request and response message are then handed around either directly or by summing the size of all the iov_len members in the kvec array for which we have a count.
Also, this simplifies and cleans up the common transmission and receive paths for SMB1 and SMB2/3 as there no longer needs to be special handling casing for SMB1 messages as the RFC1002 header is now generated on the fly for SMB1 as it is for SMB2/3.
[ sashal: Reduced backport -- upstream 83bfbd0bb9025 touches 19 file(s), this
backport carries 3. Not backported here:
fs/smb/client/cifs_debug.c
fs/smb/client/cifs_debug.h
fs/smb/client/cifsencrypt.c
fs/smb/client/cifsglob.h
fs/smb/client/cifspdu.h
fs/smb/client/cifssmb.c
fs/smb/client/cifstransport.c
fs/smb/client/connect.c
... and 9 more
This note is generated from the file lists only; see the resolution record for the reasoning. ]
Stable-dep-of: 8f6f8a48399f ("smb: client: delete compound mids on send failure before unlock")
--- fs/smb/client/cifsproto.h | 2 +- fs/smb/client/smb2transport.c | 2 +- fs/smb/client/transport.c | 74 +++++++++++++++++------------------ 3 files changed, 39 insertions(+), 39 deletions(-)
fs/smb/client/cifsproto.h +1 -1
@@ -83,7 +83,7 @@ extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx, int add_treename);extern char *build_wildcard_path_from_dentry (struct dentry *direntry);char *cifs_build_devname (char *nodename,const char *prepath); -extern void delete_mid (struct mid_q_entry *mid); +extern void delete_mid (struct TCP_Server_Info *server,struct mid_q_entry *mid);void __release_mid (struct kref *refcount);extern void cifs_wake_up_task (struct mid_q_entry *mid); extern int cifs_handle_standard(struct TCP_Server_Info *server,
fs/smb/client/smb2transport.c +1 -1
@@ -915,7 +915,7 @@ smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server, rc =smb2_sign_rqst (rqst, server);if (rc) {revert_current_mid_from_hdr (server, shdr); -delete_mid (mid); +delete_mid (server, mid);return ERR_PTR (rc); }
fs/smb/client/transport.c +37 -37
212 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 cifs: Fix specification of function pointers
From: David Howells <[email protected]>
[ Upstream commit 6a86a4cc281a5cfceda7af60ea6fa506b3db7430 ]
Change the mid_receive_t, mid_callback_t and mid_handle_t function pointers to have the pointer marker in the typedef.
Stable-dep-of: 8f6f8a48399f ("smb: client: delete compound mids on send failure before unlock")
--- fs/smb/client/cifsglob.h | 12 ++++++------ fs/smb/client/cifsproto.h | 8 ++++---- fs/smb/client/transport.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-)
fs/smb/client/cifsglob.h +6 -6
@@ -1659,7 +1659,7 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,* Returns zero on a successful receive, or an error. The receive state in * the TCP_Server_Info will also be updated. */ -typedef int (mid_receive_t )(struct TCP_Server_Info *server, +typedef int (*mid_receive_t )(struct TCP_Server_Info *server,struct mid_q_entry *mid);/*
@@ -1670,13 +1670,13 @@ typedef int (mid_receive_t)(struct TCP_Server_Info *server,* - it will be called by cifsd, with no locks held * - the mid will be removed from any lists */ -typedef void (mid_callback_t )(struct mid_q_entry *mid); +typedef void (*mid_callback_t )(struct mid_q_entry *mid);/* * This is the protopyte for mid handle function. This is called once the mid * has been recognized after decryption of the message. */ -typedef int (mid_handle_t )(struct TCP_Server_Info *server, +typedef int (*mid_handle_t )(struct TCP_Server_Info *server,struct mid_q_entry *mid);/* one of these for every pending CIFS request to the server */
@@ -1694,9 +1694,9 @@ struct mid_q_entry {unsigned long when_sent;/* time when smb send finished */ unsigned long when_received;/* when demux complete (taken off wire) */ #endif -mid_receive_t *receive;/* call receive callback */ -mid_callback_t *callback;/* call completion callback */ -mid_handle_t *handle;/* call handle mid callback */ +mid_receive_t receive;/* call receive callback */ +mid_callback_t callback;/* call completion callback */ +mid_handle_t handle;/* call handle mid callback */ void *callback_data;/* general purpose pointer for callback */ struct task_struct *creator;void *resp_buf;/* pointer to received SMB header */
fs/smb/client/cifsproto.h +4 -4
@@ -96,10 +96,10 @@ extern int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs);extern bool cifs_match_ipaddr (struct sockaddr *srcaddr,struct sockaddr *rhs);extern int cifs_discard_remaining_data (struct TCP_Server_Info *server);extern int cifs_call_async (struct TCP_Server_Info *server, -struct smb_rqst *rqst, -mid_receive_t *receive,mid_callback_t *callback, -mid_handle_t *handle,void *cbdata,const int flags, -const struct cifs_credits *exist_credits); +struct smb_rqst *rqst, +mid_receive_t receive,mid_callback_t callback, +mid_handle_t handle,void *cbdata,const int flags, +const struct cifs_credits *exist_credits);extern struct TCP_Server_Info *cifs_pick_channel (struct cifs_ses *ses); extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, struct TCP_Server_Info *server,
fs/smb/client/transport.c +2 -2
@@ -789,8 +789,8 @@ cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)*/ int cifs_call_async (struct TCP_Server_Info *server,struct smb_rqst *rqst, -mid_receive_t *receive,mid_callback_t *callback, -mid_handle_t *handle,void *cbdata,const int flags, +mid_receive_t receive,mid_callback_t callback, +mid_handle_t handle,void *cbdata,const int flags,const struct cifs_credits *exist_credits) {int rc;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 smb: client: delete compound mids on send failure before unlock
In reply to Sasha LevinFrom: Adarsh Das <[email protected]>
[ Upstream commit 8f6f8a48399f82f4a83f7b9f25b9707e0062a4f9 ]
When sending a compound request fails, smb_send_rqst() kicks off a reconnect. compound_send_recv() still has those mids on pending_mid_q, but it unlocks the server without removing them first.
During reconnect, cifs_abort_connection() walks pending_mid_q and runs each mid callback. With no response yet, those callbacks return credits and drop in_flight. Then compound_send_recv()'s send-error path returns the same credits again. in_flight ends up decremented twice and smb2_add_credits() WARNs.
syzbot hits this during SMB2_negotiate when the socket send fails.
cifs_call_async() already calls delete_mid() before unlock on send failure. Do the same for compound chains and set cancelled_mid[] so the
out: path does not delete them again.
--- fs/smb/client/transport.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/smb/client/transport.c +4 -0
@@ -1180,6 +1180,10 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,if (rc <0 ) {revert_current_mid (server, num_rqst); server->sequence_number -=2 ; +for (i =0 ; i < num_rqst; i++) { +delete_mid (server, mid[i]); + cancelled_mid[i] = true; + } }cifs_server_unlock (server);
Signature · 1 line
2.53.0