[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <135f7b3f-cd54-40bb-9ea8-cee8b06bb16c@lucifer.local>
Date: Wed, 23 Oct 2024 17:35:32 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Jann Horn <jannh@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"Liam R . Howlett" <Liam.Howlett@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Xu <peterx@...hat.com>
Subject: Re: [PATCH hotfix 6.12 3/8] mm: refactor map_deny_write_exec()
On Tue, Oct 22, 2024 at 11:15:18PM +0200, Jann Horn wrote:
> On Tue, Oct 22, 2024 at 10:41 PM Lorenzo Stoakes
> <lorenzo.stoakes@...cle.com> wrote:
> > Refactor the map_deny_write_exec() to not unnecessarily require a VMA
> > parameter but rather to accept VMA flags parameters, which allows us to use
> > this function early in mmap_region() in a subsequent commit.
> >
> > While we're here, we refactor the function to be more readable and add some
> > additional documentation.
> >
> > Reported-by: Jann Horn <jannh@...gle.com>
> > Fixes: deb0f6562884 ("mm/mmap: undo ->mmap() when arch_validate_flags() fails")
> > Cc: stable <stable@...nel.org>
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
>
> Reviewed-by: Jann Horn <jannh@...gle.com>
Thanks!
>
> [..]
> > -static inline bool map_deny_write_exec(struct vm_area_struct *vma, unsigned long vm_flags)
> > +static inline bool map_deny_write_exec(unsigned long old, unsigned long new)
> > {
> > + /* If MDWE is disabled, we have nothing to deny. */
> > if (!test_bit(MMF_HAS_MDWE, ¤t->mm->flags))
> > return false;
> >
> > - if ((vm_flags & VM_EXEC) && (vm_flags & VM_WRITE))
> > + /* If the new VMA is not executable, we have nothing to deny. */
> > + if (!(new & VM_EXEC))
> > + return false;
> > +
> > + /* Under MDWE we absolutely do not accept writably executable... */
> > + if (new & VM_WRITE)
> > return true;
> >
> > - if (!(vma->vm_flags & VM_EXEC) && (vm_flags & VM_EXEC))
> > + /* ...nor newly executable VMAs. */
>
> nit: maybe clarify this as "nor existing VMAs newly becoming
> executable" or something like that
Ack
>
>
> > + if (!(old & VM_EXEC))
> > return true;
> >
> > return false;
Powered by blists - more mailing lists