CVE-2026-64139: ksmbd: fix SID memory leak in set_posix_acl_entries_dacl() on overflow

Greg Kroah-Hartman <[email protected]>
Newsgroups org.kernel.vger.linux-cve-announce
Message-ID <2026071928-CVE-2026-64139-d9cb@gregkh>
From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ksmbd: fix SID memory leak in set_posix_acl_entries_dacl() on overflow

Commit 299f962c0b02 ("ksmbd: use check_add_overflow() to prevent u16
DACL size overflow") added check_add_overflow() guards that break out
of the ACE-building loops in set_posix_acl_entries_dacl() when the
accumulated DACL size would wrap past 65535.

However, each iteration allocates a struct smb_sid via kmalloc_obj()
at the top of the loop and relies on the kfree(sid) call at the end
of the loop body (the 'pass_same_sid' label in the first loop, and
the explicit kfree at the tail of the second loop) to release it.
The newly introduced 'break' statements bypass those kfree() calls,
leaking the sid buffer every time an overflow is detected.

A malicious or malformed file with enough POSIX ACL entries to trip
the overflow check will leak one or more struct smb_sid allocations
on every request that touches the file's DACL, providing a trivial
kernel memory exhaustion vector.

Free sid before breaking out of the loops to plug the leak.

The Linux kernel CVE team has assigned CVE-2026-64139 to this issue.


Affected and fixed versions
===========================

	Issue introduced in 6.6.136 with commit 8d5729350b236896f51379588d9a690b7fafb8db and fixed in 6.6.142 with commit 9d378e17c864da08c3a4df41dae92cfa6468b00a
	Issue introduced in 6.12.84 with commit e1955a94b6f17f4b058afa955a6f187eb3ed7615 and fixed in 6.12.92 with commit 519fb0a42ce5d7e46935577309fb282a5f2c6ea3
	Issue introduced in 6.18.25 with commit 5e7b8f3c539d69b2ed5f2408e2f75e68ce7eef43 and fixed in 6.18.34 with commit 0e198f09cb2a554c04de0fea4e790f1250a943ca
	Issue introduced in 7.0.2 with commit ef7902be3f215b6bf7babe4dc9dd9a7d57dad7a7 and fixed in 7.0.11 with commit eced48cb08f07393a5ea770fdd1026452883c3ad
	Issue introduced in 6.1.175 with commit 41e53a773db6342ac9a689ee5ba635c31744c9f0

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2026-64139
will be updated if fixes are backported, please check that for the most
up to date information about this issue.


Affected files
==============

The file(s) affected by this issue are:
	fs/smb/server/smbacl.c


Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/9d378e17c864da08c3a4df41dae92cfa6468b00a
	https://git.kernel.org/stable/c/519fb0a42ce5d7e46935577309fb282a5f2c6ea3
	https://git.kernel.org/stable/c/0e198f09cb2a554c04de0fea4e790f1250a943ca
	https://git.kernel.org/stable/c/eced48cb08f07393a5ea770fdd1026452883c3ad
	https://git.kernel.org/stable/c/af92ee994cc7f7e83a41c2025f32257a2f82a7ef
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.