All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lorenzo Stoakes" <ljs@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 04/13] mm: update generic_get_unmapped_area[_topdown]() to use vma_flags_t
Date: Sat, 11 Jul 2026 19:02:06 +0000	[thread overview]
Message-ID: <20260711190206.C5EA71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260711-b4-vma-flags-mm-v2-4-0fa2357d5431@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the x86-specific bottom-up mmap fallback path silently discards VMA flags, bypassing the shadow stack guard gap allocation.
--

--- Patch [4]: [PATCH v2 04/13] mm: update generic_get_unmapped_area[_topdown]() to use vma_flags_t ---
commit 00b351f4aaa23a000490d96bd47f04d6f2e0f5d1
Author: Lorenzo Stoakes <ljs@kernel.org>

mm: update generic_get_unmapped_area[_topdown]() to use vma_flags_t

This commit updates generic_get_unmapped_area() and
generic_get_unmapped_area_topdown() to accept vma_flags_t instead of
vm_flags_t. It also updates stack_guard_placement() to use the new type.
The architecture-specific wrappers are retained but use legacy_to_vma_flags()
for compatibility.

> diff --git a/mm/mmap.c b/mm/mmap.c
> index 4a88b2a233f7f..39d33f3a55c2e 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c

[ ... ]

> @@ -807,7 +807,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
>  			       unsigned long flags, vm_flags_t vm_flags)
>  {
>  	return generic_get_unmapped_area_topdown(filp, addr, len, pgoff, flags,
> -						 vm_flags);
> +						 legacy_to_vma_flags(vm_flags));

[Severity: High]
This isn't a bug introduced by this patch, but the x86-specific bottom-up mmap
fallback path silently discards VMA flags, bypassing the shadow stack guard
gap allocation.

Is it possible for an attacker to intentionally exhaust the top-down allocation
space (e.g., via high stack limits) to force the shadow stack allocation (using
the map_shadow_stack syscall) into the fallback bottom-up path in
arch_get_unmapped_area_topdown()?

In arch/x86/kernel/sys_x86_64.c, the fallback path looks like this:

bottomup:
	/*
	 * A failed mmap() very likely causes application failure,
	 * so fall back to the bottom-up function here. This scenario
	 * can happen with large stack limits and large mmap()
	 * allocations.
	 */
	return arch_get_unmapped_area(filp, addr0, len, pgoff, flags, 0);

By passing 0 for vm_flags, does this completely drop the VM_SHADOW_STACK flag
before the guard gap allocation logic checks for it?

Could this bypass allow shadow stacks to be allocated immediately adjacent to
other mappings, meaning if a shadow stack overflows, it corrupts adjacent data
instead of hitting a guard page?

>  }
>  #endif
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260711-b4-vma-flags-mm-v2-0-0fa2357d5431@kernel.org?part=4

  reply	other threads:[~2026-07-11 19:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11 18:44 [PATCH v2 00/13] mm: convert more vm_flags_t users to vma_flags_t Lorenzo Stoakes
2026-07-11 18:44 ` [PATCH v2 01/13] mm: introduce vma_flags_can_grow() and vma_can_grow() Lorenzo Stoakes
2026-07-11 18:44 ` [PATCH v2 02/13] mm/vma: update do_mmap() to use vma_flags_t Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 03/13] mm: convert __get_unmapped_area() " Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 04/13] mm: update generic_get_unmapped_area[_topdown]() " Lorenzo Stoakes
2026-07-11 19:02   ` sashiko-bot [this message]
2026-07-11 18:45 ` [PATCH v2 05/13] mm: prefer mm->def_vma_flags in mm logic Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 06/13] mm/vma: convert vm_pgprot_modify() to use vma_flags_t and rename Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 07/13] mm/vma: rename vma_get_page_prot to vma_flags_to_page_prot Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 08/13] mm: introduce vma_get_page_prot() and use it Lorenzo Stoakes
2026-07-11 21:02   ` sashiko-bot
2026-07-11 18:45 ` [PATCH v2 09/13] mm/vma: update create_init_stack_vma() to use vma_flags_t Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 10/13] mm/vma: convert miscellaneous uses of VMA flags in core mm Lorenzo Stoakes
2026-07-11 18:45 ` [PATCH v2 11/13] mm/mlock: convert mlock code to use vma_flags_t Lorenzo Stoakes
2026-07-11 19:12   ` sashiko-bot
2026-07-11 18:45 ` [PATCH v2 12/13] mm/mprotect: convert mprotect " Lorenzo Stoakes
2026-07-14  2:46   ` Zi Yan
2026-07-14  2:46     ` Zi Yan
2026-07-11 18:45 ` [PATCH v2 13/13] mm/mremap: convert mremap " Lorenzo Stoakes
2026-07-11 19:14   ` sashiko-bot
2026-07-13 17:36 ` ✗ Fi.CI.BUILD: failure for mm: convert more vm_flags_t users to vma_flags_t Patchwork
2026-07-14  2:25 ` [PATCH v2 00/13] " Andrew Morton
2026-07-14  2:25   ` Andrew Morton

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=20260711190206.C5EA71F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ljs@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.