Jann Horn a56a15432a userns: move user access out of the mutex
commit 5820f140edef111a9ea2ef414ab2428b8cb805b1 upstream.

The old code would hold the userns_state_mutex indefinitely if
memdup_user_nul stalled due to e.g. a userfault region. Prevent that by
moving the memdup_user_nul in front of the mutex_lock().

Note: This changes the error precedence of invalid buf/count/*ppos vs
map already written / capabilities missing.

Fixes: 22d917d80e84 ("userns: Rework the user_namespace adding uid/gid...")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Acked-by: Christian Brauner <christian@brauner.io>
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-09 20:01:24 +02:00
..
2018-05-30 07:50:51 +02:00
2017-09-02 07:07:53 +02:00
2016-04-04 09:46:47 -04:00
2018-08-03 07:55:12 +02:00
2017-05-20 14:28:40 +02:00
2017-07-05 14:40:24 +02:00
2018-08-03 07:55:24 +02:00
2018-05-09 09:50:20 +02:00
2016-09-22 20:00:36 -05:00