Re: [RFC PATCH] mm: Fetch the dirty bit before we reset the pte

From: Aneesh Kumar K.V
Date: Thu Oct 08 2020 - 13:34:19 EST


On 10/8/20 10:32 PM, Linus Torvalds wrote:
On Thu, Oct 8, 2020 at 2:27 AM Aneesh Kumar K.V
<aneesh.kumar@xxxxxxxxxxxxx> wrote:

In copy_present_page, after we mark the pte non-writable, we should
check for previous dirty bit updates and make sure we don't lose the dirty
bit on reset.

No, we'll just remove that entirely.

Do you have a test-case that shows a problem? I have a patch that I
was going to delay until 5.10 because I didn't think it mattered in
practice..


Unfortunately, I don't have a test case. That was observed by code inspection while I was fixing syzkaller report.

The second part of this patch would be to add a sequence count
protection to fast-GUP pinning, so that GUP and fork() couldn't race,
but I haven't written that part.

Here's the first patch anyway. If you actually have a test-case where
this matters, I guess I need to apply it now..

Linus



-aneesh