Skip to contentSkip to conversation

dlm: fix buffer overflow from negative len in dlm_search_rsb_tree

PATCH In review Joseph Qi 3 participants 10 messages May 17 – Jul 16 Distributed lock manager (DLM)

lore
Share & tools
lore

Joseph Qi

author
#0 lore raw

PATCH v2 1/1 dlm: fix buffer overflow from negative len in dlm_search_rsb_tree

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does not catch negative values. While the input 'len' can be negative and a negative int passed to memcpy() is implicitly converted to a large size_t, causing a stack buffer overflow on the key[] array.

Fix this by changing the 'len' parameter type from int to unsigned int. This ensures negative values from callers are implicitly converted to large unsigned values that are caught by the existing
len > DLM_RESNAME_MAXLEN check.

---
 fs/dlm/lock.c | 6 ++++--
 fs/dlm/lock.h | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)
fs/dlm/lock.c +4 -2
index c381e1028446..373abdb4354a 100644
@@ -622,12 +622,14 @@ static int get_rsb_struct(struct dlm_ls *ls, const void *name, int len,
 	return 0;
 }
 
-int dlm_search_rsb_tree(struct rhashtable *rhash, const void *name, int len,
-			struct dlm_rsb **r_ret)
+int dlm_search_rsb_tree(struct rhashtable *rhash, const void *name,
+			unsigned int len, struct dlm_rsb **r_ret)
 {
 	char key[DLM_RESNAME_MAXLEN] = {};
+
 	if (len > DLM_RESNAME_MAXLEN)
 		return -EINVAL;
+
 	memcpy(key, name, len);
 	*r_ret = rhashtable_lookup_fast(rhash, &key, dlm_rhash_rsb_params);
 	if (*r_ret)
fs/dlm/lock.h +2 -2
index b23d7b854ed4..c75975937331 100644
@@ -31,8 +31,8 @@ void resume_scan_timer(struct dlm_ls *ls);
 int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name,
 		      int len, unsigned int flags, int *r_nodeid, int *result);
 
-int dlm_search_rsb_tree(struct rhashtable *rhash, const void *name, int len,
-			struct dlm_rsb **r_ret);
+int dlm_search_rsb_tree(struct rhashtable *rhash, const void *name,
+			unsigned int len, struct dlm_rsb **r_ret);
 
 void dlm_recover_purge(struct dlm_ls *ls, const struct list_head *root_list);
 void dlm_purge_mstcpy_locks(struct dlm_rsb *r);
Signature · 1 line
2.39.3
maintainer
#1 lore raw

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

- Alex

maintainer
#3 lore raw

Hi,

Quoted 15 lines · Alexander Aring

Hi,

Quoted 10 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

Quoted 5 lines

This also addresses CVE-2026-43125 [0].

- Alex

[0] https://lore.kernel.org/linux-cve-announce/2026050619-CVE-2026-43125-c9f9@gregkh/

cc the right folks [email protected] as described in the kernel documentation.

There is another patch required for CVE-2026-43125 [0].

Joseph I think for v3 you should cc also [email protected] and mention this in your commit msg.

Thanks.

- Alex

[0] https://lore.kernel.org/gfs2/[email protected]/

#4 lore raw
Quoted 18 lines · Alexander Aring

Hi,

Quoted 15 lines · Alexander Aring

Hi,

Quoted 10 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

Quoted 7 lines
Quoted 5 lines

This also addresses CVE-2026-43125 [0].

- Alex

[0] https://lore.kernel.org/linux-cve-announce/2026050619-CVE-2026-43125-c9f9@gregkh/

cc the right folks [email protected] as described in the kernel documentation.

For what?

Quoted 4 lines

There is another patch required for CVE-2026-43125 [0].

Joseph I think for v3 you should cc also [email protected] and mention this in your commit msg.

Why doesn't this deserve a different CVE id when it lands in the public trees?

thanks,

greg k-h

maintainer
#5 lore raw

Hi,

Quoted 22 lines · Greg KH
Quoted 20 lines · Alexander Aring

Hi,

Quoted 17 lines · Alexander Aring

Hi,

Quoted 10 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

This also addresses CVE-2026-43125 [0].

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

- Alex

[0] https://lore.kernel.org/linux-cve-announce/2026050619-CVE-2026-43125-c9f9@gregkh/

cc the right folks [email protected] as described in the kernel documentation.

For what?

because

"If the CVE assignment team misses a specific fix that any user feels should have a CVE assigned to it, please email them at <[email protected]> and the team there will work with you on it." [0]

The initial fix did not resolve CVE-2026-43125, there are additional changes are required.

Quoted 8 lines
Quoted 4 lines

There is another patch required for CVE-2026-43125 [0].

Joseph I think for v3 you should cc also [email protected] and mention this in your commit msg.

Why doesn't this deserve a different CVE id when it lands in the public trees?

because the vulnerability described in CVE-2026-43125 is the same, I'm also not sure I cc "[email protected]" that the team there will work with me on it as the kernel doc told me. :)

thanks.

- Alex

[0] https://docs.kernel.org/process/cve.html

#6 lore raw
Quoted 34 lines · Alexander Aring

Hi,

Quoted 22 lines · Greg KH
Quoted 20 lines · Alexander Aring

Hi,

Quoted 17 lines · Alexander Aring

Hi,

Quoted 10 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

This also addresses CVE-2026-43125 [0].

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

- Alex

[0] https://lore.kernel.org/linux-cve-announce/2026050619-CVE-2026-43125-c9f9@gregkh/

cc the right folks [email protected] as described in the kernel documentation.

For what?

Quoted 8 lines

because

"If the CVE assignment team misses a specific fix that any user feels should have a CVE assigned to it, please email them at <[email protected]> and the team there will work with you on it." [0]

The initial fix did not resolve CVE-2026-43125, there are additional changes are required.

That CVE describes the specific issue that that patch fixes. If there are additional issues that this patch does not resolve, then it deserves a new CVE for the new fix, OR you should add the new sha1 to the old CVE entry.

Where is the new fix?

thanks,

greg k-h

author
#7 lore raw
In reply to Alexander Aring
Quoted 22 lines · Alexander Aring

Hi,

Quoted 19 lines · Alexander Aring

Hi,

Quoted 10 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

This also addresses CVE-2026-43125 [0].

- Alex

Quoted 9 lines
Quoted 1 line

[0] https://lore.kernel.org/linux-cve-announce/2026050619-CVE-2026-43125-c9f9@gregkh/

cc the right folks [email protected] as described in the kernel documentation.

There is another patch required for CVE-2026-43125 [0].

Joseph I think for v3 you should cc also [email protected] and mention this in your commit msg.

This is indeed found when I backport this CVE into our tree. But I think it is a different case so I just send to upstream first.

Thanks,
Joseph

maintainer
#8 lore raw

Hi,

Quoted 30 lines · Joseph Qi
Quoted 26 lines · Alexander Aring

Hi,

Quoted 15 lines · Alexander Aring

Hi,

Quoted 10 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

Quoted 5 lines

This also addresses CVE-2026-43125 [0].

- Alex

[0] https://lore.kernel.org/linux-cve-announce/2026050619-CVE-2026-43125-c9f9@gregkh/

cc the right folks [email protected] as described in the kernel documentation.

Quoted 9 lines
Quoted 5 lines

There is another patch required for CVE-2026-43125 [0].

Joseph I think for v3 you should cc also [email protected] and mention this in your commit msg.

This is indeed found when I backport this CVE into our tree. But I think it is a different case so I just send to upstream first.

In my opinion the first patch did not fix the vulnerability described in CVE-2026-43125, but with your additional changes it does. This means it is the same case.

A different case would be if -EINVAL is returned and we cannot recover from it (e.g., deadlock or something, but probably not a CVE). That is a different case, DLM is mostly currently running in a local environment, which is why I am not very worried about it. I have it on my list to check. I wrote once a scapy module [0] to create and feed DLM messages to discover such things; it might be a starting point.

- Alex

[0] https://github.com/alexaring/scapy/commits/dlm/

maintainer
#9 lore raw
In reply to Alexander Aring

Hi,

Quoted 9 lines · Alexander Aring

Hi,

Quoted 2 lines · Joseph Qi

commit 080e5563f878 only checks for len > DLM_RESNAME_MAXLEN, which does

check with checkpath, it reports an error regarding how this commit reference is done.

I fixed your commit message for this patch; checkpatch requires a very specific commit reference style here.
It's "commit 080e5563f878c ("dlm: validate length in dlm_search_rsb_tree")".

- Alex