On Mon, Aug 15, 2022 at 10:27:53AM +0200, Vegard Nossum wrote:
Creating a new user namespace grants you the ability to reach a lot of code
(including loading certain kernel modules) that would otherwise be out of
reach of an attacker. We can reduce the attack surface and block exploits
by ensuring that user namespaces cannot trigger module (auto-)loading.
+ /*
+ * Disallow if we're in a user namespace and we don't have
+ * CAP_SYS_MODULE in the init namespace.
+ */
+ if (current_user_ns() != &init_user_ns &&
+ !capable(CAP_SYS_MODULE) &&
It's monday, so maybe I'm thinking wrongly - but I don't believe that you can
possible pass capable(CAP_SYS_MODULE) if current_user_ns() != &init_user_ns.
So I think you can drop the second check.