[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPcyv4g94hK7j7hknSmtt11hgq+5N-Yf-fwLdS4VrARyqKwJLw@mail.gmail.com>
Date: Thu, 16 Jul 2020 08:53:30 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Eric Biggers <ebiggers@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux MM <linux-mm@...ck.org>, Ingo Molnar <mingo@...hat.com>,
Kees Cook <keescook@...omium.org>,
Matthew Wilcox <willy@...radead.org>,
Russell King <linux@....linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] /dev/mem: Add missing memory barriers for devmem_inode
On Wed, Jul 15, 2020 at 11:07 PM Eric Biggers <ebiggers@...nel.org> wrote:
>
> From: Eric Biggers <ebiggers@...gle.com>
>
> WRITE_ONCE() isn't the correct way to publish a pointer to a data
> structure, since it doesn't include a write memory barrier. Therefore
> other tasks may see that the pointer has been set but not see that the
> pointed-to memory has finished being initialized yet. Instead a
> primitive with "release" semantics is needed.
>
> Use smp_store_release() for this.
>
> The use of READ_ONCE() on the read side is still potentially correct if
> there's no control dependency, i.e. if all memory being "published" is
> transitively reachable via the pointer itself. But this pairing is
> somewhat confusing and error-prone. So just upgrade the read side to
> smp_load_acquire() so that it clearly pairs with smp_store_release().
>
> Cc: Dan Williams <dan.j.williams@...el.com>
> Cc: Arnd Bergmann <arnd@...db.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Matthew Wilcox <willy@...radead.org>
> Cc: Russell King <linux@....linux.org.uk>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Fixes: 3234ac664a87 ("/dev/mem: Revoke mappings when a driver claims the region")
> Signed-off-by: Eric Biggers <ebiggers@...gle.com>
Makes sense:
Acked-by: Dan Williams <dan.j.williams@...el.com>
Powered by blists - more mailing lists