Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Pedro Falcato <pfalcato@suse.de>, Xiang Mei <xmei5@asu.edu>
Cc: Kees Cook <kees@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, linux-hardening@vger.kernel.org,
	Uladzislau Rezki <urezki@gmail.com>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	"H . Peter Anvin" <hpa@zytor.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Jennifer Miller <jmill@asu.edu>, Tiffany Bao <tbao@asu.edu>,
	Ruoyu Wang <fishw@asu.edu>, Adam Doupe <doupe@asu.edu>,
	Kyle Zeng <zengyhkyle@asu.edu>,
	Yan Shoshitaishvili <yans@asu.edu>
Subject: Re: [PATCH v2] mm/vmalloc: widen guard region to defeat ENTER-based stack pivot
Date: Tue, 30 Jun 2026 08:15:18 -0700	[thread overview]
Message-ID: <bddb2695-1b64-469d-be6d-e668fae18d84@intel.com> (raw)
In-Reply-To: <akPT82jDvPwlaNuo@pedro-suse.lan>

On 6/30/26 07:40, Pedro Falcato wrote:
>>> To even be considered, this series needs to be refactored properly.
>>> Making this VMAP_GUARD_PAGES a separate patch is the bare minimum.
>>>
>> Good suggestion, I will do it in v3:
>>
>>     1/3 - introduce VMAP_GUARD_PAGES
>>     2/3 - mark percpu vmap areas VM_NO_GUARD
> I would suggest you create a VMAP_STACK flag and condition these guard regions
> bsaed on that. Otherwise it's a bit arbitrary as to what callers get 0x11 guard
> pages, and which don't.
> 
> (you can find the concrete stack allocation functions in kernel/fork.c)

The real question here is whether VMAP_STACK is a good idea or whether
__get_vm_area_node() should grow functionality to manipulate guard gaps
and then just have the stack allocation code use it directly.

I, personally, despise code like this:

static inline size_t get_vm_area_size(const struct vm_struct *area)
{
        if (!(area->flags & VM_NO_GUARD))
                /* return actual size without guard page */
                return area->size - PAGE_SIZE;
        else
                return area->size;

}

I'd *much* rather it be something more like:

static inline size_t get_vm_area_size(const struct vm_struct *area)
{
	return area->size - area->gap;
}

for example.

Looking at every use of VM_NO_GUARD, I think the kernel just gets
simpler if it goes away. It's only referenced in 6 sites:

 1. __get_vm_area_node() - Munge gap argument into 'area'
 2. get_vm_area_size() can be replaced as I showed above
 3. kasan_mem_notifier() - just pass a gap=0 to __get_vm_area_node()
 4. kasan_alloc_module_shadow() - just pass a gap=0
 5. check_sparse_vm_area() - check area->gap instead
 6. Just remove VM_NO_GUARD checks. No flag means no munging the flag.



  reply	other threads:[~2026-06-30 15:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 21:47 [PATCH v2] mm/vmalloc: widen guard region to defeat ENTER-based stack pivot Xiang Mei
2026-06-29 22:29 ` Dave Hansen
2026-06-29 23:28   ` Xiang Mei
2026-06-29 23:37     ` Dave Hansen
2026-06-30  1:22       ` Xiang Mei
2026-06-30 14:01         ` Dave Hansen
2026-06-30 14:58           ` Pedro Falcato
2026-06-30 22:02           ` Xiang Mei
2026-06-30 22:05             ` Dave Hansen
2026-06-30 22:13               ` H. Peter Anvin
2026-06-30 22:47                 ` Xiang Mei
2026-06-30 23:40                   ` Dave Hansen
2026-06-30 23:48                     ` Xiang Mei
2026-06-30 14:40     ` Pedro Falcato
2026-06-30 15:15       ` Dave Hansen [this message]
2026-06-30 21:54         ` Dave Hansen
2026-06-30 21:41       ` Xiang Mei

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=bddb2695-1b64-469d-be6d-e668fae18d84@intel.com \
    --to=dave.hansen@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=doupe@asu.edu \
    --cc=fishw@asu.edu \
    --cc=gustavoars@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jmill@asu.edu \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=tbao@asu.edu \
    --cc=tglx@kernel.org \
    --cc=urezki@gmail.com \
    --cc=x86@kernel.org \
    --cc=xmei5@asu.edu \
    --cc=yans@asu.edu \
    --cc=zengyhkyle@asu.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox