Eric W. Biederman f9d87929d4 ucount: Make get_ucount a safe get_user replacement
When the ucount code was refactored to create get_ucount it was missed
that some of the contexts in which a rlimit is kept elevated can be
the only reference to the user/ucount in the system.

Ordinary ucount references exist in places that also have a reference
to the user namspace, but in POSIX message queues, the SysV shm code,
and the SIGPENDING code there is no independent user namespace
reference.

Inspection of the the user_namespace show no instance of circular
references between struct ucounts and the user_namespace.  So
hold a reference from struct ucount to i's user_namespace to
resolve this problem.

Link: https://lore.kernel.org/lkml/YZV7Z+yXbsx9p3JN@fixkernel.com/
Reported-by: Qian Cai <quic_qiancai@quicinc.com>
Reported-by: Mathias Krause <minipli@grsecurity.net>
Tested-by: Mathias Krause <minipli@grsecurity.net>
Reviewed-by: Mathias Krause <minipli@grsecurity.net>
Reviewed-by: Alexey Gladkov <legion@kernel.org>
Fixes: d64696905554 ("Reimplement RLIMIT_SIGPENDING on top of ucounts")
Fixes: 6e52a9f0532f ("Reimplement RLIMIT_MSGQUEUE on top of ucounts")
Fixes: d7c9e99aee48 ("Reimplement RLIMIT_MEMLOCK on top of ucounts")
Cc: stable@vger.kernel.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2022-01-26 18:34:11 -06:00
..
2022-01-16 15:53:00 +02:00
2021-12-01 00:06:43 +01:00
2022-01-12 16:26:58 -08:00
2021-12-02 17:25:21 +09:00
2022-01-22 08:33:37 +02:00
2022-01-11 09:51:26 -08:00
2022-01-16 10:08:13 +02:00
2022-01-23 06:20:44 +02:00
\n
2021-11-06 16:43:20 -07:00
2022-01-11 13:08:21 -08:00
2021-11-01 21:17:39 -07:00
2022-01-11 13:08:21 -08:00
2021-08-11 13:11:12 -07:00
2021-09-08 15:32:35 -07:00
2021-11-09 10:02:51 -08:00
2021-06-18 11:43:08 +02:00
2022-01-16 10:08:13 +02:00
2021-09-08 15:32:34 -07:00
2021-05-07 00:26:33 -07:00
2022-01-20 08:52:55 +02:00
2021-10-14 13:29:18 +02:00
2022-01-08 12:43:57 -06:00
2022-01-22 08:33:37 +02:00
2021-05-07 00:26:34 -07:00