Re: CVE-2024-40938: landlock: Fix d_parent walk

From: Mickaël Salaün
Date: Mon Jul 15 2024 - 06:38:34 EST


Hello,

AFAIK, commit 88da52ccd66e ("landlock: Fix d_parent walk") doesn't fix a
security issue but an unexpected case. The triggered WARN_ON_ONCE() is
just a canary, and this case was correctly handled with defensive
programming and didn't allow to bypass the security policy nor to harm
the kernel. However, this fix should indeed be backported.

Could you please Cc me for future CVE related to my changes or to
Landlock? For kernel CVEs, I think it would be good to Cc at least
maintainers, reviewers, authors, and committers for the related commits.

Regards,
Mickaël

On Fri, Jul 12, 2024 at 02:27:36PM +0200, Greg Kroah-Hartman wrote:
> Description
> ===========
>
> In the Linux kernel, the following vulnerability has been resolved:
>
> landlock: Fix d_parent walk
>
> The WARN_ON_ONCE() in collect_domain_accesses() can be triggered when
> trying to link a root mount point. This cannot work in practice because
> this directory is mounted, but the VFS check is done after the call to
> security_path_link().
>
> Do not use source directory's d_parent when the source directory is the
> mount point.
>
> [mic: Fix commit message]
>
> The Linux kernel CVE team has assigned CVE-2024-40938 to this issue.
>
>
> Affected and fixed versions
> ===========================
>
> Issue introduced in 5.19 with commit b91c3e4ea756 and fixed in 6.1.95 with commit b6e5e6964358
> Issue introduced in 5.19 with commit b91c3e4ea756 and fixed in 6.6.35 with commit cc30d05b34f9
> Issue introduced in 5.19 with commit b91c3e4ea756 and fixed in 6.9.6 with commit c7618c7b0b8c
> Issue introduced in 5.19 with commit b91c3e4ea756 and fixed in 6.10-rc2 with commit 88da52ccd66e
>
> 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-2024-40938
> 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:
> security/landlock/fs.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/b6e5e696435832b33e40775f060ef5c95f4fda1f
> https://git.kernel.org/stable/c/cc30d05b34f9a087a6928d09b131f7b491e9ab11
> https://git.kernel.org/stable/c/c7618c7b0b8c45bcef34410cc1d1e953eb17f8f6
> https://git.kernel.org/stable/c/88da52ccd66e65f2e63a6c35c9dff55d448ef4dc