drivers/misc/open-dice: don't touch VM_MAYSHARE
authorDavid Hildenbrand <david@redhat.com>
Mon, 2 Jan 2023 16:08:56 +0000 (17:08 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 19 Jan 2023 01:12:57 +0000 (17:12 -0800)
commit997931ce02b72f15c40e742ee035ce5643ba574f
tree1e144b743cb0dcceabb92be8662b668372541ebf
parentb6b7a8faf05c709cd9f63d3b7d9c66bd91bc3b0d
drivers/misc/open-dice: don't touch VM_MAYSHARE

A MAP_SHARED mapping always has VM_MAYSHARE set, and writable
(VM_MAYWRITE) MAP_SHARED mappings have VM_SHARED set as well.  To identify
a MAP_SHARED mapping, it's sufficient to look at VM_MAYSHARE.

We cannot have VM_MAYSHARE|VM_WRITE mappings without having VM_SHARED set.
Consequently, current code will never actually end up clearing
VM_MAYSHARE and that code is confusing, because nobody is supposed to mess
with VM_MAYWRITE.

Let's clean it up and restructure the code. No functional change intended.

Link: https://lkml.kernel.org/r/20230102160856.500584-4-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/misc/open-dice.c