[PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting

Linus Torvalds torvalds at linux-foundation.org
Sun Dec 27 18:40:36 EST 2020


On Sun, Dec 27, 2020 at 3:12 PM Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> Ok, your fix for that folded in, and here's yet another version.

Still not good.

I don't know what happened, but the change of

-       vm_fault_t ret = 0;
+       vm_fault_t ret;

is very very wrong. The next user is

+       if (!(vma->vm_flags & VM_SHARED))
+               ret = check_stable_address_space(vma->vm_mm);
+       if (ret)
+               return ret;

so now 'ret' will potentially be used uninitialized (although this is
the kind of thing that a compiler might almost accidentally end up
fixing - with a single dominating assignment, I could imagine the
compiler moving the test to that assignment and thus "fixing" the code
without really even meaning to).

I think Kirill was intending to move the "if (ret)" up into the path
that sets it, IOW something like

+       if (!(vma->vm_flags & VM_SHARED)) {
+               ret = check_stable_address_space(vma->vm_mm);
+               if (ret)
+                       return ret;
+       }

instead. But that patch as-is is broken.

Kirill?

                 Linus



More information about the linux-arm-kernel mailing list