lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 28 Nov 2018 09:57:35 +0000
From:   Will Deacon <will.deacon@....com>
To:     Nadav Amit <nadav.amit@...il.com>
Cc:     Rick Edgecombe <rick.p.edgecombe@...el.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Andy Lutomirski <luto@...nel.org>,
        linux-mm <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Kernel Hardening <kernel-hardening@...ts.openwall.com>,
        naveen.n.rao@...ux.vnet.ibm.com, anil.s.keshavamurthy@...el.com,
        David Miller <davem@...emloft.net>,
        Masami Hiramatsu <mhiramat@...nel.org>, rostedt@...dmis.org,
        mingo@...hat.com, ast@...nel.org, daniel@...earbox.net,
        jeyu@...nel.org, netdev@...r.kernel.org, ard.biesheuvel@...aro.org,
        jannh@...gle.com, kristen@...ux.intel.com, dave.hansen@...el.com,
        deneen.t.dock@...el.com
Subject: Re: [PATCH 0/2] Don’t leave executable
 TLB entries to freed pages

On Tue, Nov 27, 2018 at 05:21:08PM -0800, Nadav Amit wrote:
> > On Nov 27, 2018, at 5:06 PM, Nadav Amit <nadav.amit@...il.com> wrote:
> > 
> >> On Nov 27, 2018, at 4:07 PM, Rick Edgecombe <rick.p.edgecombe@...el.com> wrote:
> >> 
> >> Sometimes when memory is freed via the module subsystem, an executable
> >> permissioned TLB entry can remain to a freed page. If the page is re-used to
> >> back an address that will receive data from userspace, it can result in user
> >> data being mapped as executable in the kernel. The root of this behavior is
> >> vfree lazily flushing the TLB, but not lazily freeing the underlying pages. 
> >> 
> >> There are sort of three categories of this which show up across modules, bpf,
> >> kprobes and ftrace:
> >> 
> >> 1. When executable memory is touched and then immediatly freed
> >> 
> >>  This shows up in a couple error conditions in the module loader and BPF JIT
> >>  compiler.
> > 
> > Interesting!
> > 
> > Note that this may cause conflict with "x86: avoid W^X being broken during
> > modules loading”, which I recently submitted.
> 
> I actually have not looked on the vmalloc() code too much recent, but it
> seems … strange:
> 
>   void vm_unmap_aliases(void)
>   {       
> 
>   ...
>   	mutex_lock(&vmap_purge_lock);
>   	purge_fragmented_blocks_allcpus();
>   	if (!__purge_vmap_area_lazy(start, end) && flush)
>   		flush_tlb_kernel_range(start, end);
>   	mutex_unlock(&vmap_purge_lock);
>   }
> 
> Since __purge_vmap_area_lazy() releases the memory, it seems there is a time
> window between the release of the region and the TLB flush, in which the
> area can be allocated for another purpose. This can result in a
> (theoretical) correctness issue. No?

If __purge_vmap_area_lazy() returns false, then it hasn't freed the memory,
so we only invalidate the TLB if 'flush' is true in that case. If
__purge_vmap_area_lazy() returns true instead, then it takes care of the TLB
invalidation before the freeing.

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ