summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2017-03-05 15:03:22 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-18 19:18:38 +0800
commitda603aadd53a9a5ac18eaac09f61a5af74b9a52e (patch)
tree10b53cbf84789562805c5109848f8378c6f78b54 /include
parentb7e9ef5cf4d9562c3a1a15beee269a0b18f71976 (diff)
downloadlinux-stable-da603aadd53a9a5ac18eaac09f61a5af74b9a52e.tar.gz
linux-stable-da603aadd53a9a5ac18eaac09f61a5af74b9a52e.tar.bz2
linux-stable-da603aadd53a9a5ac18eaac09f61a5af74b9a52e.zip
ucount: Remove the atomicity from ucount->count
commit 040757f738e13caaa9c5078bca79aa97e11dde88 upstream. Always increment/decrement ucount->count under the ucounts_lock. The increments are there already and moving the decrements there means the locking logic of the code is simpler. This simplification in the locking logic fixes a race between put_ucounts and get_ucounts that could result in a use-after-free because the count could go zero then be found by get_ucounts and then be freed by put_ucounts. A bug presumably this one was found by a combination of syzkaller and KASAN. JongWhan Kim reported the syzkaller failure and Dmitry Vyukov spotted the race in the code. Fixes: f6b2db1a3e8d ("userns: Make the count of user namespaces per user") Reported-by: JongHwan Kim <zzoru007@gmail.com> Reported-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Andrei Vagin <avagin@gmail.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/user_namespace.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index eb209d4523f5..dc797739f164 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -65,7 +65,7 @@ struct ucounts {
struct hlist_node node;
struct user_namespace *ns;
kuid_t uid;
- atomic_t count;
+ int count;
atomic_t ucount[UCOUNT_COUNTS];
};