kuap.c 663 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. #include <asm/kup.h>
  3. #include <asm/smp.h>
  4. struct static_key_false disable_kuap_key;
  5. EXPORT_SYMBOL(disable_kuap_key);
  6. void kuap_lock_all_ool(void)
  7. {
  8. kuap_lock_all();
  9. }
  10. EXPORT_SYMBOL(kuap_lock_all_ool);
  11. void kuap_unlock_all_ool(void)
  12. {
  13. kuap_unlock_all();
  14. }
  15. EXPORT_SYMBOL(kuap_unlock_all_ool);
  16. void setup_kuap(bool disabled)
  17. {
  18. if (!disabled) {
  19. kuap_lock_all_ool();
  20. init_mm.context.sr0 |= SR_KS;
  21. current->thread.sr0 |= SR_KS;
  22. }
  23. if (smp_processor_id() != boot_cpuid)
  24. return;
  25. if (disabled)
  26. static_branch_enable(&disable_kuap_key);
  27. else
  28. pr_info("Activating Kernel Userspace Access Protection\n");
  29. }