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]
Message-ID: <961f9533-1e0c-416c-b6b0-d46b97127de2@intel.com>
Date: Wed, 29 May 2024 09:41:22 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Byungchul Park <byungchul@...com>
Cc: "Huang, Ying" <ying.huang@...el.com>, linux-kernel@...r.kernel.org,
 linux-mm@...ck.org, kernel_team@...ynix.com, akpm@...ux-foundation.org,
 vernhao@...cent.com, mgorman@...hsingularity.net, hughd@...gle.com,
 willy@...radead.org, david@...hat.com, peterz@...radead.org,
 luto@...nel.org, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com, rjgolo@...il.com
Subject: Re: [PATCH v10 00/12] LUF(Lazy Unmap Flush) reducing tlb numbers over
 90%

On 5/28/24 22:00, Byungchul Park wrote:
> All the code updating ptes already performs TLB flush needed in a safe
> way if it's inevitable e.g. munmap.  LUF which controls when to flush in
> a higer level than arch code, just leaves stale ro tlb entries that are
> currently supposed to be in use.  Could you give a scenario that you are
> concering?

Let's go back this scenario:

 	fd = open("/some/file", O_RDONLY);
 	ptr1 = mmap(-1, size, PROT_READ, ..., fd, ...);
 	foo1 = *ptr1;

There's a read-only PTE at 'ptr1'.  Right?  The page being pointed to is
eligible for LUF via the try_to_unmap() paths.  In other words, the page
might be reclaimed at any time.  If it is reclaimed, the PTE will be
cleared.

Then, the user might do:

	munmap(ptr1, PAGE_SIZE);

Which will _eventually_ wind up in the zap_pte_range() loop.  But that
loop will only see pte_none().  It doesn't do _anything_ to the 'struct
mmu_gather'.

The munmap() then lands in tlb_flush_mmu_tlbonly() where it looks at the
'struct mmu_gather':

        if (!(tlb->freed_tables || tlb->cleared_ptes ||
	      tlb->cleared_pmds || tlb->cleared_puds ||
	      tlb->cleared_p4ds))
                return;

But since there were no cleared PTEs (or anything else) during the
unmap, this just returns and doesn't flush the TLB.

We now have an address space with a stale TLB entry at 'ptr1' and not
even a VMA there.  There's nothing to stop a new VMA from going in,
installing a *new* PTE, but getting data from the stale TLB entry that
still hasn't been flushed.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ