* [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes
@ 2026-11-20 20:00 Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error Alexander Aring
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Alexander Aring @ 2026-11-20 20:00 UTC (permalink / raw)
To: teigland; +Cc: aahringo, gfs2
Hi David,
This patch series contains mostly AI-assisted fixes and cleanups
across the DLM subsystem:
- Add missing length checks for oversized inner DLM messages,
this prevents potential buffer overruns or malformed packet
handling.
- Enforce RSB assignment before using LKBs, this ensures LKBs
cannot exist in lkbxa without an associated RSB set. It
resolves an issue with concurrent DLM user requests.
- Prevent DLM_ASSERT() on canceled pending requests, this fixes an
assertion failure triggered when a initial request is canceled and
recovery is triggered during this state.
- Fix lockspace node memory leak during release, this resolves a leak
involving delayed member removal during active lockspace releasing
members. Active releasing members will not run recovery so the delayed
cleanup of removed of members will never occur.
- Fixes a case where the reconnect mechanism gets stuck if a socket error
occurs while the socket send buffer is full. This was found by the
netdev-bot (sashik AI bot) [3]. I tested it with tcpkill again, and
everything still seems to run fine. To test this specific case, I used
netem to slow down networking so the socket buffer would fill up while
running tcpkill to trigger socket errors.
Ensuring that LKBs always have an RSB assigned should also reduce the
likelihood of subtle bugs elsewhere in the codebase where an RSB presence
check might be missing.
There is a pending sysfs fix [0] that conflicts with [1]. The fix for
[1] does not go through the dlm tree so [0] is delayed until [1] is
available.
- Alex
[0] https://lore.kernel.org/gfs2/20261019184849.24422-1-sanan.hasanou@gmail.com/
[1] https://lore.kernel.org/gfs2/20261027223847.652884-6-irogers@google.com/
[2] https://lore.kernel.org/gfs2/179090395863.434549.3668493667259120759@kernel.org/
changes since v2:
- add patch to fix the socket hang on send buffer limitation
- drop the Assisted-by tags
Alexander Aring (2):
dlm: fix socket hang on send buffer limitation with socket error
dlm: fix memory leak on active leaving member
Ameer Hamza (1):
dlm: don't set RSB_MASTER_UNCERTAIN on rsb with no master
Jérémy Jean (1):
dlm: reject wrapped messages with oversized inner lengths
Yogesh Gaur (1):
dlm: don't publish a lkb in ls_lkbxa before it has an rsb
fs/dlm/config.c | 9 +++++
fs/dlm/lock.c | 98 ++++++++++++++++++++++++++++++++---------------
fs/dlm/lowcomms.c | 47 ++++++++++++++++-------
fs/dlm/midcomms.c | 8 ++++
4 files changed, 118 insertions(+), 44 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error
2026-11-20 20:00 [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes Alexander Aring
@ 2026-11-20 20:00 ` Alexander Aring
2026-11-20 20:40 ` sashiko-bot
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 2/5] dlm: reject wrapped messages with oversized inner lengths Alexander Aring
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Alexander Aring @ 2026-11-20 20:00 UTC (permalink / raw)
To: teigland; +Cc: aahringo, gfs2
As Sashiko AI bot mentioned [0], a socket connection can get stuck when
the send buffer limitation is reached and a socket error simultaneously
occurs.
This issue can be reproduced with the following setup:
1. Set sk_sndbuf to SOCK_MIN_SNDBUF.
2. Slow down DLM connections using netem.
3. Use tcpkill to randomly send TCP resets to DLM connections.
I instrumented debug printouts to confirm that the sk_write_space()
notifier callbacks were being executed, using step 3 to trigger random
socket errors.
With these changes, I can no longer reproduce the hang.
Changes included:
- Removed sk_write_pending counting, as this should not be modified
at the socket application layer (or is at least unnecessary).
- Moved clearing the CF_SEND_PENDING bit—which allows re-queuing
swork (send worker for sendmsg())—to the sk_write_space() callback,
since this callback notifies us that the underlying socket is no longer
constrained by its send buffer.
- Handled the race condition between sendmsg() and evaluating
SOCK_NOSPACE after sendmsg(), where sk_write_space() could be called
in between, using CF_APP_LIMITED:
- In sk_write_space(), queue swork again if CF_APP_LIMITED is set.
- If CF_APP_LIMITED is not set, do nothing as send_to_sock() will handle
it, confirming the race occurred.
- Introduced new handling in lowcomms_error_report() when a socket error
occurs during send buffer limitation. If CF_APP_LIMITED is set, swork
will be re-queued, which will fail and trigger a reconnect.
- Added various comments explaining the interaction with CF_APP_LIMITED.
[0] https://lore.kernel.org/netdev/179090395863.434549.3668493667259120759@kernel.org/
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lowcomms.c | 47 +++++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 3929b164dc0d..6c972f1b412c 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -521,12 +521,20 @@ static void lowcomms_write_space(struct sock *sk)
sk_clear_nospace(sk);
- spin_lock_bh(&con->writequeue_lock);
- if (test_and_clear_bit(CF_APP_LIMITED, &con->flags))
- con->sock->sk->sk_write_pending--;
-
- lowcomms_queue_swork(con);
- spin_unlock_bh(&con->writequeue_lock);
+ if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) {
+ /* signal to send again by clearing
+ * CF_SEND_PENDING and queue swork.
+ */
+ spin_lock_bh(&con->writequeue_lock);
+ clear_bit(CF_SEND_PENDING, &con->flags);
+ lowcomms_queue_swork(con);
+ spin_unlock_bh(&con->writequeue_lock);
+ } else {
+ /* CF_APP_LIMITED is cleared, so send_to_sock() will
+ * simply reschedule work without hitting the
+ * CF_APP_LIMITED path.
+ */
+ }
}
static void lowcomms_state_change(struct sock *sk)
@@ -623,6 +631,20 @@ static void lowcomms_error_report(struct sock *sk)
break;
}
+ /* if waiting on sk_write_space() and an sk_err occurs, the callback
+ * won't fire. Clear CF_SEND_PENDING so resend tasks can re-queue
+ * swork, triggering a sendmsg() failure to initiate reconnection.
+ */
+ spin_lock_bh(&con->writequeue_lock);
+ clear_bit(CF_SEND_PENDING, &con->flags);
+ /* dlm_midcomms_unack_msg_resend() does not always
+ * trigger lowcomms_queue_swork() as it tries to
+ * avoid to put pending messages into the lowcomms
+ * sending buffer. Force it here again.
+ */
+ lowcomms_queue_swork(con);
+ spin_unlock_bh(&con->writequeue_lock);
+
dlm_midcomms_unack_msg_resend(con->nodeid);
listen_sock.sk_error_report(sk);
@@ -1391,22 +1413,19 @@ static int send_to_sock(struct connection *con)
spin_lock_bh(&con->writequeue_lock);
if (test_bit(SOCK_NOSPACE, &con->sock->flags) &&
!test_and_set_bit(CF_APP_LIMITED, &con->flags)) {
- /* Notify TCP that we're limited by the
- * application window size.
- */
- sk_set_nospace(con->sock->sk);
- con->sock->sk->sk_write_pending++;
-
- clear_bit(CF_SEND_PENDING, &con->flags);
spin_unlock_bh(&con->writequeue_lock);
release_sock(con->sock->sk);
- /* wait for write_space() event */
+ /* wait for sk_write_space() event */
return DLM_IO_END;
}
spin_unlock_bh(&con->writequeue_lock);
release_sock(con->sock->sk);
+ /* the sk_write_space() came in between sock_sendmsg()
+ * and check on SOCK_NOSPACE and the socket became
+ * writeable again so just resched swork.
+ */
return DLM_IO_RESCHED;
} else if (ret < 0) {
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 RESEND v7.4-rc3 2/5] dlm: reject wrapped messages with oversized inner lengths
2026-11-20 20:00 [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error Alexander Aring
@ 2026-11-20 20:00 ` Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 3/5] dlm: don't publish a lkb in ls_lkbxa before it has an rsb Alexander Aring
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2026-11-20 20:00 UTC (permalink / raw)
To: teigland; +Cc: aahringo, gfs2
From: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Reject DLM_OPTS packets whose wrapped inner message length exceeds the
bytes remaining inside the validated outer packet. This keeps malformed
wrapped RCOM replies from reaching downstream length-driven copies.
Fixes: 489d8e559c65 ("fs: dlm: add reliable connection if reconnect")
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Acked-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/midcomms.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index 045431524494..488a58f2c00b 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -652,6 +652,14 @@ static int dlm_opts_check_msglen(const union dlm_packet *p, uint16_t msglen,
return -1;
}
+ p = (const union dlm_packet *)((const unsigned char *)p->opts.o_opts +
+ le16_to_cpu(p->opts.o_optlen));
+ if (le16_to_cpu(p->header.h_length) > len) {
+ log_print("inner msg too large: %u > %d, will skip this message from node %d",
+ le16_to_cpu(p->header.h_length), len, nodeid);
+ return -1;
+ }
+
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 RESEND v7.4-rc3 3/5] dlm: don't publish a lkb in ls_lkbxa before it has an rsb
2026-11-20 20:00 [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 2/5] dlm: reject wrapped messages with oversized inner lengths Alexander Aring
@ 2026-11-20 20:00 ` Alexander Aring
2026-11-20 20:12 ` sashiko-bot
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 4/5] dlm: don't set RSB_MASTER_UNCERTAIN on rsb with no master Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 5/5] dlm: fix memory leak on active leaving member Alexander Aring
4 siblings, 1 reply; 8+ messages in thread
From: Alexander Aring @ 2026-11-20 20:00 UTC (permalink / raw)
To: teigland; +Cc: aahringo, gfs2
From: Yogesh Gaur <yogeshgaur.83@gmail.com>
_create_lkb() puts a new lkb into ls_lkbxa straight away, which is also
what assigns its lkb_id, but the lkb only gets an rsb later, when
request_lock(), receive_request(), dlm_recover_master_copy() or
dlm_debug_add_lkb() call attach_lkb(). In between, find_lkb() hands the
lkb out with lkb_resource still NULL, and its callers go straight for
the rsb:
r = lkb->lkb_resource;
hold_rsb(r);
lock_rsb(r);
For the userspace API the lkid is simply whatever was written to the
misc device, so a lkid can be aimed at a lkb that another thread is
still building, and hold_rsb() reads res_flags off NULL:
BUG: KASAN: null-ptr-deref in rsb_flag fs/dlm/dlm_internal.h:386 [inline]
BUG: KASAN: null-ptr-deref in hold_rsb fs/dlm/lock.c:334 [inline]
BUG: KASAN: null-ptr-deref in unlock_lock fs/dlm/lock.c:3333 [inline]
BUG: KASAN: null-ptr-deref in dlm_user_unlock+0x2ab/0x690 fs/dlm/lock.c:5956
Read of size 8 at addr 0000000000000050 by task syz.3.570/7893
rsb_flag fs/dlm/dlm_internal.h:386 [inline]
hold_rsb fs/dlm/lock.c:334 [inline]
unlock_lock fs/dlm/lock.c:3333 [inline]
dlm_user_unlock+0x2ab/0x690 fs/dlm/lock.c:5956
device_user_unlock+0x1ca/0x260 fs/dlm/user.c:321
Make it impossible for ls_lkbxa to hold a lkb without an rsb, rather
than filtering such lkbs in find_lkb() or reserving a NULL entry that
every walker would have to know about. create_lkb() no longer touches
ls_lkbxa; attach_lkb() sets lkb_resource and only then allocates the
lkb_id and stores the lkb, so the lkb becomes visible already attached.
dlm_debug_add_lkb() presets the id it wants and attach_lkb() allocates
exactly that one.
attach_lkb() can now fail, and each of its four callers releases the
lkb on the error path it already has for a failure just before the
attach. On failure attach_lkb() also clears lkb_id, so that
__put_lkb() cannot erase another lkb's entry when a requested id was
busy. All four callers hold the rsb lock, and nothing takes an rsb
lock under ls_lkbxa_lock, so taking it there adds no new lock ordering.
As a side effect an lkb has no lkb_id until it is attached, so
trace_dlm_lock_start() and the validate_lock_args() and
receive_rcom_lock_args() error messages report 0 for a new lock.
The unchecked r = lkb->lkb_resource goes back to the original DLM
import, but an untrusted lkid only became possible once the userspace
device interface was added, so that is the tag below.
Fixes: 597d0cae0f99 ("[DLM] dlm: user locks")
Reported-by: syzbot+da6dc573ce5e6624f505@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=da6dc573ce5e6624f505
Suggested-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Yogesh Gaur <yogeshgaur.83@gmail.com>
Acked-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lock.c | 90 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 62 insertions(+), 28 deletions(-)
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index c715e171bab7..3b3e15157f4c 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -1488,10 +1488,38 @@ void free_inactive_rsb(struct dlm_rsb *r)
/* Attaching/detaching lkb's from rsb's is for rsb reference counting.
The rsb must exist as long as any lkb's for it do. */
-static void attach_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb)
+/*
+ * An lkb is only put into ls_lkbxa here, once it has an rsb, so
+ * find_lkb() never returns an lkb without one. The lkb_id is assigned
+ * here too; dlm_debug_add_lkb() presets the one it wants.
+ */
+static int attach_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb)
{
+ struct dlm_ls *ls = r->res_ls;
+ struct xa_limit limit = XA_LIMIT(1, U32_MAX);
+ int rv;
+
+ if (lkb->lkb_id)
+ limit = XA_LIMIT(lkb->lkb_id, lkb->lkb_id);
+
hold_rsb(r);
lkb->lkb_resource = r;
+
+ write_lock_bh(&ls->ls_lkbxa_lock);
+ rv = xa_alloc(&ls->ls_lkbxa, &lkb->lkb_id, lkb, limit, GFP_ATOMIC);
+ write_unlock_bh(&ls->ls_lkbxa_lock);
+
+ if (rv < 0) {
+ log_error(ls, "%s xa error %d", __func__, rv);
+ /* the caller still holds its own rsb reference */
+ lkb->lkb_resource = NULL;
+ put_rsb(r);
+ /* don't let __put_lkb() erase another lkb's id */
+ lkb->lkb_id = 0;
+ return rv;
+ }
+
+ return 0;
}
static void detach_lkb(struct dlm_lkb *lkb)
@@ -1502,15 +1530,9 @@ static void detach_lkb(struct dlm_lkb *lkb)
}
}
-static int _create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret,
- unsigned long start, unsigned long end)
+static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
{
- struct xa_limit limit;
struct dlm_lkb *lkb;
- int rv;
-
- limit.max = end;
- limit.min = start;
lkb = dlm_allocate_lkb();
if (!lkb)
@@ -1525,25 +1547,10 @@ static int _create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret,
INIT_LIST_HEAD(&lkb->lkb_ownqueue);
INIT_LIST_HEAD(&lkb->lkb_rsb_lookup);
- write_lock_bh(&ls->ls_lkbxa_lock);
- rv = xa_alloc(&ls->ls_lkbxa, &lkb->lkb_id, lkb, limit, GFP_ATOMIC);
- write_unlock_bh(&ls->ls_lkbxa_lock);
-
- if (rv < 0) {
- log_error(ls, "create_lkb xa error %d", rv);
- dlm_free_lkb(lkb);
- return rv;
- }
-
*lkb_ret = lkb;
return 0;
}
-static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
-{
- return _create_lkb(ls, lkb_ret, 1, ULONG_MAX);
-}
-
static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret)
{
struct dlm_lkb *lkb;
@@ -3294,7 +3301,12 @@ static int request_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
lock_rsb(r);
- attach_lkb(r, lkb);
+ error = attach_lkb(r, lkb);
+ if (error) {
+ unlock_rsb(r);
+ put_rsb(r);
+ return error;
+ }
lkb->lkb_lksb->sb_lkid = lkb->lkb_id;
error = _request_lock(r, lkb);
@@ -4038,7 +4050,14 @@ static int receive_request(struct dlm_ls *ls, const struct dlm_message *ms)
}
}
- attach_lkb(r, lkb);
+ error = attach_lkb(r, lkb);
+ if (error) {
+ unlock_rsb(r);
+ put_rsb(r);
+ __put_lkb(ls, lkb);
+ goto fail;
+ }
+
error = do_request(r, lkb);
send_request_reply(r, lkb, error);
do_request_effects(r, lkb, error);
@@ -5642,7 +5661,12 @@ int dlm_recover_master_copy(struct dlm_ls *ls, const struct dlm_rcom *rc,
goto out_unlock;
}
- attach_lkb(r, lkb);
+ error = attach_lkb(r, lkb);
+ if (error) {
+ __put_lkb(ls, lkb);
+ goto out_unlock;
+ }
+
add_lkb(r, lkb, rl->rl_status);
ls->ls_recover_locks_in++;
@@ -6300,12 +6324,14 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
if (!lksb)
return -ENOMEM;
- error = _create_lkb(ls, &lkb, lkb_id, lkb_id + 1);
+ error = create_lkb(ls, &lkb);
if (error) {
kfree(lksb);
return error;
}
+ lkb->lkb_id = lkb_id;
+
dlm_set_dflags_val(lkb, lkb_dflags);
lkb->lkb_nodeid = lkb_nodeid;
lkb->lkb_lksb = lksb;
@@ -6321,7 +6347,15 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
}
lock_rsb(r);
- attach_lkb(r, lkb);
+ error = attach_lkb(r, lkb);
+ if (error) {
+ unlock_rsb(r);
+ put_rsb(r);
+ kfree(lksb);
+ __put_lkb(ls, lkb);
+ return error;
+ }
+
add_lkb(r, lkb, lkb_status);
unlock_rsb(r);
put_rsb(r);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 RESEND v7.4-rc3 4/5] dlm: don't set RSB_MASTER_UNCERTAIN on rsb with no master
2026-11-20 20:00 [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes Alexander Aring
` (2 preceding siblings ...)
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 3/5] dlm: don't publish a lkb in ls_lkbxa before it has an rsb Alexander Aring
@ 2026-11-20 20:00 ` Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 5/5] dlm: fix memory leak on active leaving member Alexander Aring
4 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2026-11-20 20:00 UTC (permalink / raw)
To: teigland; +Cc: aahringo, gfs2
From: Ameer Hamza <ameer.hamza@truenas.com>
When a local request reuses an inactive rsb, find_rsb_dir() sets
RSB_MASTER_UNCERTAIN if res_master_nodeid is not our nodeid. This also
matches an rsb that never got a master (res_master_nodeid 0, res_nodeid
-1). set_master() then trusts the "cached" master, copies res_nodeid -1
into lkb_nodeid and skips the lookup, and _request_lock() hits the
DLM_ASSERT(r->res_nodeid >= 0) in is_remote():
rsb: nodeid -1 master 0 dir 1 flags 200 first 1 rlc 0 name pr
Kernel panic - not syncing: DLM: Record message above and reboot.
Call Trace:
_request_lock.cold+0x3e/0x3e [dlm]
request_lock+0xcc/0x110 [dlm]
dlm_user_request+0x110/0x340 [dlm]
device_write+0x605/0x6d0 [dlm]
Such an rsb is left behind when a request is cancelled while its lookup
is still outstanding and the lockspace then recovers, e.g. because the
dir node died: dlm_recover_waiters_post() completes the cancelled lkb
instead of resending it, so no master is ever set. Once the rsb is
inactive, the next request for the name revives it and crashes as
above. If we became the dir node in that recovery, deactivate_rsb()
even keeps the rsb as a dir record, so it does not age out.
Before commit c04fecb4d9f7 ("dlm: use rsbtbl as resource directory")
the flag was only set when res_nodeid was > 0. Restore that and set the
flag only when a master is actually cached, so that set_master() does a
normal lookup (or becomes the master itself as dir node) for an rsb
that has none. res_first_lkid is still cleared, as the cancelled lkb
leaves a stale id behind.
Fixes: c04fecb4d9f7 ("dlm: use rsbtbl as resource directory")
Signed-off-by: Ameer Hamza <ameer.hamza@truenas.com>
Acked-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lock.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 3b3e15157f4c..934afc93464f 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -826,8 +826,12 @@ static int find_rsb_dir(struct dlm_ls *ls, const void *name, int len,
if (from_local && (r->res_master_nodeid != our_nodeid)) {
/* Because we have held no locks on this rsb,
- res_master_nodeid could have become stale. */
- rsb_set_flag(r, RSB_MASTER_UNCERTAIN);
+ * res_master_nodeid could have become stale. If no master
+ * was ever set, there is nothing to confirm and set_master()
+ * must resolve it as for a new rsb.
+ */
+ if (r->res_master_nodeid)
+ rsb_set_flag(r, RSB_MASTER_UNCERTAIN);
r->res_first_lkid = 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCHv2 RESEND v7.4-rc3 5/5] dlm: fix memory leak on active leaving member
2026-11-20 20:00 [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes Alexander Aring
` (3 preceding siblings ...)
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 4/5] dlm: don't set RSB_MASTER_UNCERTAIN on rsb with no master Alexander Aring
@ 2026-11-20 20:00 ` Alexander Aring
4 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2026-11-20 20:00 UTC (permalink / raw)
To: teigland; +Cc: aahringo, gfs2
When a node calls dlm_lockspace_release() locally, it does not
subsequently run recovery. Commit de7b4869b4ec ("dlm: add new configfs
entry release_recover for lockspace members") entry began tracking
leaving members to perform optional post processing, such as invoking
the slot callback. Because a locally leaving member does not execute
recovery, it never invokes dlm_config_nodes(), leaving the allocated
tracking entries uncleaned.
This issue was detected by kmemleak.
unreferenced object 0xffff88811d68bcc0 (size 32):
comm "dlm_controld", pid 406, jiffies 4294749992
hex dump (first 32 bytes):
03 00 00 00 00 00 00 00 08 bd 68 1d 81 88 ff ff ..........h.....
88 bc 68 1d 81 88 ff ff 00 00 00 00 00 00 00 00 ..h.............
backtrace (crc be1c20bb):
kmemleak_alloc+0x85/0xa0
__kmalloc_cache_noprof+0x2ac/0x380
drop_node+0x73/0x550
client_drop_item+0x83/0xe0
configfs_rmdir+0x735/0x910
vfs_rmdir+0x24a/0x820
filename_rmdir+0x3a3/0x4a0
__x64_sys_rmdir+0x42/0x60
x64_sys_call+0x1e8d/0x1fb0
do_syscall_64+0x87/0x490
entry_SYSCALL_64_after_hwframe+0x76/0x7e
A local node executing dlm_lockspace_release() does not require additional
recovery handling, such as invoking the slot callback. Fix this memory leak
by freeing the resources allocated in drop_node() when the lockspace
configfs entry is released.
Fixes: de7b4869b4ec ("dlm: add new configfs entry release_recover for lockspace members")
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/config.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 6ebc0fa9a2fa..5e41f795366c 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -533,9 +533,18 @@ static struct config_group *make_space(struct config_group *g, const char *name)
static void drop_space(struct config_group *g, struct config_item *i)
{
struct dlm_space *sp = config_item_to_space(i);
+ struct dlm_member_gone *mb_gone, *mb_safe;
/* assert list_empty(&sp->members) */
+ mutex_lock(&sp->members_lock);
+ list_for_each_entry_safe(mb_gone, mb_safe, &sp->members_gone, list) {
+ list_del(&mb_gone->list);
+ sp->members_gone_count--;
+ kfree(mb_gone);
+ }
+ mutex_unlock(&sp->members_lock);
+
configfs_remove_default_groups(&sp->group);
config_item_put(i);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCHv2 RESEND v7.4-rc3 3/5] dlm: don't publish a lkb in ls_lkbxa before it has an rsb
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 3/5] dlm: don't publish a lkb in ls_lkbxa before it has an rsb Alexander Aring
@ 2026-11-20 20:12 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-20 20:12 UTC (permalink / raw)
To: Alexander Aring, teigland; +Cc: gfs2
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dlm: __put_lkb() erases active ls_lkbxa entry on find_rsb()
failure
--
commit c68d5fa6b30984a97220ff35d349c3276a988660
Author: Yogesh Gaur <yogeshgaur.83@gmail.com>
dlm: don't publish a lkb in ls_lkbxa before it has an rsb
This commit moves the allocation of lkb_id and insertion of the lkb into
ls_lkbxa from create_lkb() to attach_lkb() so that find_lkb() never returns
an lkb with a NULL lkb_resource.
> diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
> index c715e171bab7e..3b3e15157f4c9 100644
> --- a/fs/dlm/lock.c
> +++ b/fs/dlm/lock.c
[ ... ]
> @@ -6300,12 +6324,14 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
> if (!lksb)
> return -ENOMEM;
>
> - error = _create_lkb(ls, &lkb, lkb_id, lkb_id + 1);
> + error = create_lkb(ls, &lkb);
> if (error) {
> kfree(lksb);
> return error;
> }
>
> + lkb->lkb_id = lkb_id;
> +
> dlm_set_dflags_val(lkb, lkb_dflags);
> lkb->lkb_nodeid = lkb_nodeid;
> lkb->lkb_lksb = lksb;
> @@ -6321,7 +6347,15 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
> }
[Severity: Medium]
Can setting lkb->lkb_id before find_rsb() cause __put_lkb() to erase an
existing lkb's entry in ls_lkbxa if find_rsb() fails?
attach_lkb() clears lkb->lkb_id on failure for that reason, but if
find_rsb() fails first (for example, with -EINVAL when len >
DLM_RESNAME_MAXLEN), dlm_debug_add_lkb() calls __put_lkb(ls, lkb) while
lkb->lkb_id still holds the caller-supplied id, and xa_erase() removes any
live lkb already occupying that id from ls_lkbxa. Setting lkb->lkb_id
right before attach_lkb() would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120200040.257152-1-aahringo@redhat.com?part=3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error Alexander Aring
@ 2026-11-20 20:40 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-20 20:40 UTC (permalink / raw)
To: Alexander Aring, teigland; +Cc: gfs2
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] dlm: missing CF_APP_LIMITED clear in lowcomms_error_report()
hangs send queue
- [High] dlm: unconditional swork queue in lowcomms_error_report()
breaks invariants
- [Medium] dlm: race in send_to_sock() sets CF_APP_LIMITED after socket
error
- [Low] dlm: missing Fixes trailer in commit message
--
commit 796bee147607d968d752eb2e6e9611c521fe108f
Author: Alexander Aring <aahringo@redhat.com>
> dlm: fix socket hang on send buffer limitation with socket error
>
> As Sashiko AI bot mentioned [0], a socket connection can get stuck when
> the send buffer limitation is reached and a socket error simultaneously
> occurs.
>
> This issue can be reproduced with the following setup:
> 1. Set sk_sndbuf to SOCK_MIN_SNDBUF.
> 2. Slow down DLM connections using netem.
> 3. Use tcpkill to randomly send TCP resets to DLM connections.
>
> I instrumented debug printouts to confirm that the sk_write_space()
> notifier callbacks were being executed, using step 3 to trigger random
> socket errors.
>
> With these changes, I can no longer reproduce the hang.
>
> Changes included:
> - Removed sk_write_pending counting, as this should not be modified
> at the socket application layer (or is at least unnecessary).
> - Moved clearing the CF_SEND_PENDING bit—which allows re-queuing
> swork (send worker for sendmsg())—to the sk_write_space() callback,
> since this callback notifies us that the underlying socket is no longer
> constrained by its send buffer.
> - Handled the race condition between sendmsg() and evaluating
> SOCK_NOSPACE after sendmsg(), where sk_write_space() could be called
> in between, using CF_APP_LIMITED:
> - In sk_write_space(), queue swork again if CF_APP_LIMITED is set.
> - If CF_APP_LIMITED is not set, do nothing as send_to_sock() will handle
> it, confirming the race occurred.
> - Introduced new handling in lowcomms_error_report() when a socket error
> occurs during send buffer limitation. If CF_APP_LIMITED is set, swork
> will be re-queued, which will fail and trigger a reconnect.
> - Added various comments explaining the interaction with CF_APP_LIMITED.
>
> [0] https://lore.kernel.org/netdev/179090395863.434549.3668493667259120759@kernel.org/
>
> Signed-off-by: Alexander Aring <aahringo@redhat.com>
[Severity: Low]
Should this bug fix include a Fixes: tag for the commit that gated
lowcomms_queue_swork() on CF_APP_LIMITED?
Fixes: dbb751ffab0b ("fs: dlm: parallelize lowcomms socket handling")
> diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
> index 3929b164dc0d4..6c972f1b412ca 100644
> --- a/fs/dlm/lowcomms.c
> +++ b/fs/dlm/lowcomms.c
[ ... ]
> @@ -623,6 +631,20 @@ static void lowcomms_error_report(struct sock *sk)
> break;
> }
>
> + /* if waiting on sk_write_space() and an sk_err occurs, the callback
> + * won't fire. Clear CF_SEND_PENDING so resend tasks can re-queue
> + * swork, triggering a sendmsg() failure to initiate reconnection.
> + */
> + spin_lock_bh(&con->writequeue_lock);
> + clear_bit(CF_SEND_PENDING, &con->flags);
> + /* dlm_midcomms_unack_msg_resend() does not always
> + * trigger lowcomms_queue_swork() as it tries to
> + * avoid to put pending messages into the lowcomms
> + * sending buffer. Force it here again.
> + */
> + lowcomms_queue_swork(con);
> + spin_unlock_bh(&con->writequeue_lock);
> +
> dlm_midcomms_unack_msg_resend(con->nodeid);
>
> listen_sock.sk_error_report(sk);
[Severity: High]
Does lowcomms_error_report() also need to clear CF_APP_LIMITED before
calling lowcomms_queue_swork(con)?
lowcomms_queue_swork() refuses to schedule con->swork while CF_APP_LIMITED
is set:
fs/dlm/lowcomms.c:lowcomms_queue_swork() {
if (!test_bit(CF_IO_STOP, &con->flags) &&
!test_bit(CF_APP_LIMITED, &con->flags) &&
!test_and_set_bit(CF_SEND_PENDING, &con->flags))
queue_work(io_workqueue, &con->swork);
}
When a socket error arrives while CF_APP_LIMITED is set, sk_write_space()
will not fire, so leaving CF_APP_LIMITED set here causes every
lowcomms_queue_swork(con) call to be a no-op and leaves the connection
permanently hung.
[Severity: High]
Should lowcomms_error_report() only clear CF_SEND_PENDING and queue
con->swork when test_and_clear_bit(CF_APP_LIMITED, &con->flags) succeeds,
matching lowcomms_write_space()?
Accepting a crossover connection in accept_from_sock() attaches the socket
to othercon (which has CF_IS_OTHERCON set) via add_sock(), installing
lowcomms_error_report() as sk_error_report. Because othercon is
receive-only, unconditionally queuing con->swork on a socket error
schedules process_send_sockets() on othercon, triggering
WARN_ON_ONCE(test_bit(CF_IS_OTHERCON, &con->flags)) and entering an
infinite reconnect loop calling dlm_connect(othercon) once othercon->sock
is closed.
On a primary connection where CF_APP_LIMITED is not set, unconditionally
clearing CF_SEND_PENDING also breaks swork serialization on the unbound
io_workqueue by allowing a second con->swork to be queued while
process_send_sockets() is already running.
> @@ -1391,22 +1413,19 @@ static int send_to_sock(struct connection *con)
> spin_lock_bh(&con->writequeue_lock);
> if (test_bit(SOCK_NOSPACE, &con->sock->flags) &&
> !test_and_set_bit(CF_APP_LIMITED, &con->flags)) {
> - /* Notify TCP that we're limited by the
> - * application window size.
> - */
> - sk_set_nospace(con->sock->sk);
> - con->sock->sk->sk_write_pending++;
> -
> - clear_bit(CF_SEND_PENDING, &con->flags);
> spin_unlock_bh(&con->writequeue_lock);
> release_sock(con->sock->sk);
>
> - /* wait for write_space() event */
> + /* wait for sk_write_space() event */
> return DLM_IO_END;
> }
> spin_unlock_bh(&con->writequeue_lock);
> release_sock(con->sock->sk);
>
> + /* the sk_write_space() came in between sock_sendmsg()
> + * and check on SOCK_NOSPACE and the socket became
> + * writeable again so just resched swork.
> + */
> return DLM_IO_RESCHED;
> } else if (ret < 0) {
> return ret;
[Severity: Medium]
Can send_to_sock() still set CF_APP_LIMITED and hang after a socket error
if the error arrives before lock_sock()?
kworker <softirq>
send_to_sock()
sock_sendmsg()
...
sk_set_nospace()
return -EAGAIN
tcp_v4_rcv() (TCP RST)
tcp_reset()
tcp_done_with_error()
lowcomms_error_report()
lock_sock(sk)
spin_lock_bh(&con->writequeue_lock)
test_bit(SOCK_NOSPACE, ...)
!test_and_set_bit(CF_APP_LIMITED, ...)
return DLM_IO_END <-- waits forever
Unlike lowcomms_write_space(), neither tcp_done_with_error() nor
lowcomms_error_report() clears SOCK_NOSPACE. When send_to_sock() then
checks SOCK_NOSPACE without checking sk->sk_err, it sets CF_APP_LIMITED
after lowcomms_error_report() has already finished and returns DLM_IO_END
on a dead socket that will never fire sk_write_space() or
sk_error_report() again. Checking !con->sock->sk->sk_err under lock_sock()
(or clearing SOCK_NOSPACE in lowcomms_error_report()) would avoid entering
CF_APP_LIMITED on an errored socket.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120200040.257152-1-aahringo@redhat.com?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-20 20:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 20:00 [PATCHv2 RESEND v7.4-rc3 0/5] dlm: various fixes Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 1/5] dlm: fix socket hang on send buffer limitation with socket error Alexander Aring
2026-11-20 20:40 ` sashiko-bot
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 2/5] dlm: reject wrapped messages with oversized inner lengths Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 3/5] dlm: don't publish a lkb in ls_lkbxa before it has an rsb Alexander Aring
2026-11-20 20:12 ` sashiko-bot
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 4/5] dlm: don't set RSB_MASTER_UNCERTAIN on rsb with no master Alexander Aring
2026-11-20 20:00 ` [PATCHv2 RESEND v7.4-rc3 5/5] dlm: fix memory leak on active leaving member Alexander Aring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.