From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Namjae Jeon <linkinjeon@kernel.org>,
Steve French <smfrench@gmail.com>, Tom Talpey <tom@talpey.com>,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
Stefan Metzmacher <metze@samba.org>,
Steve French <stfrench@microsoft.com>
Subject: [PATCH 6.19 12/49] smb: server: fix last send credit problem causing disconnects
Date: Fri, 13 Feb 2026 14:47:31 +0100 [thread overview]
Message-ID: <20260213134709.176447405@linuxfoundation.org> (raw)
In-Reply-To: <20260213134708.713126210@linuxfoundation.org>
6.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <metze@samba.org>
commit 8cf2bbac6281434065f5f3aeab19c9c08ff755a2 upstream.
When we are about to use the last send credit that was
granted to us by the peer, we need to wait until
we are ourself able to grant at least one credit
to the peer. Otherwise it might not be possible
for the peer to grant more credits.
The following sections in MS-SMBD are related to this:
3.1.5.1 Sending Upper Layer Messages
...
If Connection.SendCredits is 1 and the CreditsGranted field of the
message is 0, stop processing.
...
3.1.5.9 Managing Credits Prior to Sending
...
If Connection.ReceiveCredits is zero, or if Connection.SendCredits is
one and the Connection.SendQueue is not empty, the sender MUST allocate
and post at least one receive of size Connection.MaxReceiveSize and MUST
increment Connection.ReceiveCredits by the number allocated and posted.
If no receives are posted, the processing MUST return a value of zero to
indicate to the caller that no Send message can be currently performed.
...
This problem was found by running this on Windows 2025
against ksmbd with required smb signing:
'frametest.exe -r 4k -t 20 -n 2000' after
'frametest.exe -w 4k -t 20 -n 2000'.
Link: https://lore.kernel.org/linux-cifs/b58fa352-2386-4145-b42e-9b4b1d484e17@samba.org/
Cc: <stable@vger.kernel.org> # 6.18.x
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/server/transport_rdma.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -1033,6 +1033,15 @@ static void smb_direct_post_recv_credits
atomic_add(credits, &sc->recv_io.credits.available);
+ /*
+ * If the last send credit is waiting for credits
+ * it can grant we need to wake it up
+ */
+ if (credits &&
+ atomic_read(&sc->send_io.bcredits.count) == 0 &&
+ atomic_read(&sc->send_io.credits.count) == 0)
+ wake_up(&sc->send_io.credits.wait_queue);
+
if (credits)
queue_work(sc->workqueue, &sc->idle.immediate_work);
}
@@ -1306,6 +1315,7 @@ static int calc_rw_credits(struct smbdir
static int smb_direct_create_header(struct smbdirect_socket *sc,
int size, int remaining_data_length,
+ int new_credits,
struct smbdirect_send_io **sendmsg_out)
{
struct smbdirect_socket_parameters *sp = &sc->parameters;
@@ -1321,7 +1331,7 @@ static int smb_direct_create_header(stru
/* Fill in the packet header */
packet = (struct smbdirect_data_transfer *)sendmsg->packet;
packet->credits_requested = cpu_to_le16(sp->send_credit_target);
- packet->credits_granted = cpu_to_le16(manage_credits_prior_sending(sc));
+ packet->credits_granted = cpu_to_le16(new_credits);
packet->flags = 0;
if (manage_keep_alive_before_sending(sc))
@@ -1459,6 +1469,7 @@ static int smb_direct_post_send_data(str
int data_length;
struct scatterlist sg[SMBDIRECT_SEND_IO_MAX_SGE - 1];
struct smbdirect_send_batch _send_ctx;
+ int new_credits;
if (!send_ctx) {
smb_direct_send_ctx_init(&_send_ctx, false, 0);
@@ -1477,12 +1488,29 @@ static int smb_direct_post_send_data(str
if (ret)
goto credit_failed;
+ new_credits = manage_credits_prior_sending(sc);
+ if (new_credits == 0 &&
+ atomic_read(&sc->send_io.credits.count) == 0 &&
+ atomic_read(&sc->recv_io.credits.count) == 0) {
+ queue_work(sc->workqueue, &sc->recv_io.posted.refill_work);
+ ret = wait_event_interruptible(sc->send_io.credits.wait_queue,
+ atomic_read(&sc->send_io.credits.count) >= 1 ||
+ atomic_read(&sc->recv_io.credits.available) >= 1 ||
+ sc->status != SMBDIRECT_SOCKET_CONNECTED);
+ if (sc->status != SMBDIRECT_SOCKET_CONNECTED)
+ ret = -ENOTCONN;
+ if (ret < 0)
+ goto credit_failed;
+
+ new_credits = manage_credits_prior_sending(sc);
+ }
+
data_length = 0;
for (i = 0; i < niov; i++)
data_length += iov[i].iov_len;
ret = smb_direct_create_header(sc, data_length, remaining_data_length,
- &msg);
+ new_credits, &msg);
if (ret)
goto header_failed;
next prev parent reply other threads:[~2026-02-13 13:49 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 13:47 [PATCH 6.19 00/49] 6.19.1-rc1 review Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 01/49] io_uring/io-wq: add exit-on-idle state Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 02/49] io_uring: allow io-wq workers to exit when unused Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 03/49] smb: client: split cached_fid bitfields to avoid shared-byte RMW races Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 04/49] ksmbd: fix infinite loop caused by next_smb2_rcv_hdr_off reset in error paths Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 05/49] ksmbd: add chann_lock to protect ksmbd_chann_list xarray Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 06/49] smb: server: fix leak of active_num_conn in ksmbd_tcp_new_connection() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 07/49] smb: smbdirect: introduce smbdirect_socket.recv_io.credits.available Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 08/49] smb: smbdirect: introduce smbdirect_socket.send_io.bcredits.* Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 09/49] smb: server: make use of smbdirect_socket.recv_io.credits.available Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 10/49] smb: server: let recv_done() queue a refill when the peer is low on credits Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 11/49] smb: server: make use of smbdirect_socket.send_io.bcredits Greg Kroah-Hartman
2026-02-13 13:47 ` Greg Kroah-Hartman [this message]
2026-02-13 13:47 ` [PATCH 6.19 13/49] smb: server: let send_done handle a completion without IB_SEND_SIGNALED Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 14/49] smb: client: make use of smbdirect_socket.recv_io.credits.available Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 15/49] smb: client: let recv_done() queue a refill when the peer is low on credits Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 16/49] smb: client: let smbd_post_send() make use of request->wr Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 17/49] smb: client: remove pointless sc->recv_io.credits.count rollback Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 18/49] smb: client: remove pointless sc->send_io.pending handling in smbd_post_send_iter() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 19/49] smb: client: port and use the wait_for_credits logic used by server Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 20/49] smb: client: split out smbd_ib_post_send() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 21/49] smb: client: introduce and use smbd_{alloc, free}_send_io() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 22/49] smb: client: use smbdirect_send_batch processing Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 23/49] smb: client: make use of smbdirect_socket.send_io.bcredits Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 24/49] smb: client: fix last send credit problem causing disconnects Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 25/49] smb: client: let smbd_post_send_negotiate_req() use smbd_post_send() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 26/49] smb: client: let send_done handle a completion without IB_SEND_SIGNALED Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 27/49] driver core: enforce device_lock for driver_match_device() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 28/49] Bluetooth: btusb: Add USB ID 7392:e611 for Edimax EW-7611UXB Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 29/49] ALSA: hda/conexant: Add quirk for HP ZBook Studio G4 Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 30/49] crypto: iaa - Fix out-of-bounds index in find_empty_iaa_compression_mode Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 31/49] crypto: octeontx - Fix length check to avoid truncation in ucode_load_store Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 32/49] crypto: omap - Allocate OMAP_CRYPTO_FORCE_COPY scatterlists correctly Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 33/49] crypto: virtio - Add spinlock protection with virtqueue notification Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 34/49] crypto: virtio - Remove duplicated virtqueue_kick in virtio_crypto_skcipher_crypt_req Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 35/49] nilfs2: Fix potential block overflow that cause system hang Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 36/49] hfs: ensure sb->s_fs_info is always cleaned up Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 37/49] wifi: rtw88: Fix alignment fault in rtw_core_enable_beacon() Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 38/49] scsi: qla2xxx: Validate sp before freeing associated memory Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 39/49] scsi: qla2xxx: Allow recovery for tape devices Greg Kroah-Hartman
2026-02-13 13:47 ` [PATCH 6.19 40/49] scsi: qla2xxx: Delay module unload while fabric scan in progress Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 41/49] scsi: qla2xxx: Free sp in error path to fix system crash Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 42/49] scsi: qla2xxx: Query FW again before proceeding with login Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 43/49] sched/mmcid: Dont assume CID is CPU owned on mode switch Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 44/49] bus: fsl-mc: fix use-after-free in driver_override_show() Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 45/49] erofs: fix UAF issue for file-backed mounts w/ directio option Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 46/49] xfs: fix UAF in xchk_btree_check_block_owner Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 47/49] drm/exynos: vidi: use ctx->lock to protect struct vidi_context member variables related to memory alloc/free Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 48/49] PCI: endpoint: Avoid creating sub-groups asynchronously Greg Kroah-Hartman
2026-02-13 13:48 ` [PATCH 6.19 49/49] wifi: rtl8xxxu: fix slab-out-of-bounds in rtl8xxxu_sta_add Greg Kroah-Hartman
2026-02-13 14:48 ` [PATCH 6.19 00/49] 6.19.1-rc1 review Achill Gilgenast
2026-02-13 15:35 ` Greg Kroah-Hartman
2026-02-13 15:36 ` Greg Kroah-Hartman
2026-02-13 15:57 ` Greg Kroah-Hartman
2026-02-13 16:26 ` Peter Schneider
2026-02-13 16:37 ` Greg Kroah-Hartman
2026-02-13 16:41 ` Konstantin Ryabitsev
2026-02-13 16:45 ` Peter Schneider
2026-02-13 17:53 ` Achill Gilgenast
2026-02-13 16:33 ` Peter Schneider
2026-02-13 17:37 ` Justin Forbes
2026-02-13 21:25 ` Florian Fainelli
2026-02-13 22:20 ` Jon Hunter
2026-02-14 0:49 ` Takeshi Ogasawara
2026-02-14 5:49 ` Luna Jernberg
2026-02-14 10:30 ` Ron Economos
2026-02-14 16:02 ` Brett A C Sheffield
2026-02-15 2:36 ` Miguel Ojeda
2026-02-15 10:59 ` Dileep malepu
2026-02-16 14:33 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260213134709.176447405@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=metze@samba.org \
--cc=patches@lists.linux.dev \
--cc=samba-technical@lists.samba.org \
--cc=smfrench@gmail.com \
--cc=stable@vger.kernel.org \
--cc=stfrench@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox