linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Marc Reisner <reisner.marc@gmail.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>,
	Paul Moore <paul@paul-moore.com>,
	akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org,
	omosnace@redhat.com, peterz@infradead.org,
	selinux@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Subject: Re: [PATCH v3 3/4] selinux: use vma_is_initial_stack() and vma_is_initial_heap()
Date: Thu, 8 Aug 2024 14:00:09 -0400	[thread overview]
Message-ID: <zk5ffj6otbixbnppw4shxgz4tjulagm7du457gzi4qg7zrtdkk@e7mbwyzhdtrx> (raw)
In-Reply-To: <ZrTeT8_pzD8fH-_P@marcreisner.com>

* Marc Reisner <reisner.marc@gmail.com> [240808 11:03]:
> On Thu, Aug 08, 2024 at 09:12:59PM +0800, Kefeng Wang wrote:
> >
> > OK,revert patch is sent, but I am also curious about it.
> >
> > https://lore.kernel.org/all/20240808130909.1027860-1-wangkefeng.wang@huawei.com/
> 
> I am also curious. It seems like the "real" fix would be in mmap - my
> understanding is that it should not intersect with heap, even when heap
> is empty (start_brk == brk).
> 
> It looks like start_brk is fixed in place when the ELF is
> loaded in fs/binfmt_elf.c:load_elf_binary (line 1288).
> 
>         if ((current->flags & PF_RANDOMIZE) && (snapshot_randomize_va_space > 1)) {
>                 /*
>                  * For architectures with ELF randomization, when executing
>                  * a loader directly (i.e. no interpreter listed in ELF
>                  * headers), move the brk area out of the mmap region
>                  * (since it grows up, and may collide early with the stack
>                  * growing down), and into the unused ELF_ET_DYN_BASE region.
>                  */
>                 if (IS_ENABLED(CONFIG_ARCH_HAS_ELF_RANDOMIZE) &&
>                     elf_ex->e_type == ET_DYN && !interpreter) {
>                         mm->brk = mm->start_brk = ELF_ET_DYN_BASE;
>                 } else {
>                         /* Otherwise leave a gap between .bss and brk. */
>                         mm->brk = mm->start_brk = mm->brk + PAGE_SIZE;
>                 }
> 
>                 mm->brk = mm->start_brk = arch_randomize_brk(mm);
> #ifdef compat_brk_randomized
>                 current->brk_randomized = 1;
> #endif
>         }


Have a look at the mmapstress 3 test in ltp [1].  The tests pokes holes
and mmaps into those holes throughout the brk range.

[1]. https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/mem/mmapstress/mmapstress03.c


  parent reply	other threads:[~2024-08-08 18:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28  5:00 [PATCH v3 0/4] mm: convert to vma_is_initial_heap/stack() Kefeng Wang
2023-07-28  5:00 ` [PATCH v3 1/4] mm: factor out VMA stack and heap checks Kefeng Wang
2023-07-28  5:00 ` [PATCH v3 2/4] drm/amdkfd: use vma_is_initial_stack() and vma_is_initial_heap() Kefeng Wang
2023-07-28  5:00 ` [PATCH v3 3/4] selinux: " Kefeng Wang
     [not found]   ` <CAEjxPJ5ZuBGVDah0f3g0-7t2v1uSXTmp_cTT3g_MSP3J9QtoeA@mail.gmail.com>
     [not found]     ` <CAHC9VhR_Tzbs=fE+D6VrP1boe7O_uHPu9yd7kfVppnB2vtPLOA@mail.gmail.com>
     [not found]       ` <CAEjxPJ6iFRZUetSvMgZvq_327U_JZ_w9s=gFccKgJhfCt8bqNg@mail.gmail.com>
     [not found]         ` <CAHC9VhRB1uVVWFUgnMZ1iwCD_A0mEX2Xhn79qTxuNKTzisWULg@mail.gmail.com>
2023-12-06 14:22           ` Ondrej Mosnacek
2023-12-06 20:47             ` Paul Moore
2023-12-07  4:50               ` Kefeng Wang
2023-12-07  8:37                 ` Ondrej Mosnacek
2023-12-07  9:23                   ` Kefeng Wang
     [not found]                     ` <ZrPmoLKJEf1wiFmM@marcreisner.com>
     [not found]                       ` <CAHC9VhSWVdiuK+VtbjV6yJiCp=2+6Bji_86mSkj1eeRL4g_Jfg@mail.gmail.com>
     [not found]                         ` <7fb19e0a-118d-46a1-8d1b-ab71c545d7ed@huawei.com>
     [not found]                           ` <0806d149-905c-49b2-930f-5d6d0f8890c9@huawei.com>
     [not found]                             ` <CAEjxPJ5S9sz4PaRMVLyP6PWdLCG_bBxj7nw53EhU5+L1TM7kFg@mail.gmail.com>
     [not found]                               ` <4d2e1d4f-659a-428f-a167-faaaa4eca18a@huawei.com>
     [not found]                                 ` <ZrTeT8_pzD8fH-_P@marcreisner.com>
2024-08-08 18:00                                   ` Liam R. Howlett [this message]
2024-08-08 19:35                                     ` Marc Reisner
2024-08-08 20:40                                       ` Paul Moore
2023-07-28  5:00 ` [PATCH v3 4/4] perf/core: " Kefeng Wang
2023-07-31 13:47 ` [PATCH v3 0/4] mm: convert to vma_is_initial_heap/stack() Peter Zijlstra

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=zk5ffj6otbixbnppw4shxgz4tjulagm7du457gzi4qg7zrtdkk@e7mbwyzhdtrx \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=peterz@infradead.org \
    --cc=reisner.marc@gmail.com \
    --cc=selinux@vger.kernel.org \
    --cc=vbabka@suse.cz \
    --cc=wangkefeng.wang@huawei.com \
    /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