]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
prctl: rename branch landing pad implementation functions to be more explicit
authorPaul Walmsley <pjw@kernel.org>
Sun, 5 Apr 2026 00:40:58 +0000 (18:40 -0600)
committerPaul Walmsley <pjw@kernel.org>
Sun, 5 Apr 2026 00:40:58 +0000 (18:40 -0600)
Per Linus' comments about the unreadability of abbreviations such as
"indir_br_lp", rename the three prctl() implementation functions to be more
explicit.  This involves renaming "indir_br_lp_status" in the function
names to "branch_landing_pad_state".

While here, add _prctl_ into the function names, following the
speculation control prctl implementation functions.

Link: https://lore.kernel.org/linux-riscv/CAHk-=whhSLGZAx3N5jJpb4GLFDqH_QvS07D+6BnkPWmCEzTAgw@mail.gmail.com/
Cc: Deepak Gupta <debug@rivosinc.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/usercfi.c
include/linux/cpu.h
kernel/sys.c

index 9052171c1a8cc4dcca092b3fa4ae90fae043e854..04ab1eb8df297b18725a063efbd3fd98ffeeba5d 100644 (file)
@@ -457,7 +457,8 @@ int arch_lock_shadow_stack_status(struct task_struct *task,
        return 0;
 }
 
-int arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *status)
+int arch_prctl_get_branch_landing_pad_state(struct task_struct *t,
+                                           unsigned long __user *state)
 {
        unsigned long fcfi_status = 0;
 
@@ -467,10 +468,10 @@ int arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *sta
        /* indirect branch tracking is enabled on the task or not */
        fcfi_status |= (is_indir_lp_enabled(t) ? PR_INDIR_BR_LP_ENABLE : 0);
 
-       return copy_to_user(status, &fcfi_status, sizeof(fcfi_status)) ? -EFAULT : 0;
+       return copy_to_user(state, &fcfi_status, sizeof(fcfi_status)) ? -EFAULT : 0;
 }
 
-int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status)
+int arch_prctl_set_branch_landing_pad_state(struct task_struct *t, unsigned long state)
 {
        bool enable_indir_lp = false;
 
@@ -482,24 +483,23 @@ int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status)
                return -EINVAL;
 
        /* Reject unknown flags */
-       if (status & ~PR_INDIR_BR_LP_ENABLE)
+       if (state & ~PR_INDIR_BR_LP_ENABLE)
                return -EINVAL;
 
-       enable_indir_lp = (status & PR_INDIR_BR_LP_ENABLE);
+       enable_indir_lp = (state & PR_INDIR_BR_LP_ENABLE);
        set_indir_lp_status(t, enable_indir_lp);
 
        return 0;
 }
 
-int arch_lock_indir_br_lp_status(struct task_struct *task,
-                                unsigned long arg)
+int arch_prctl_lock_branch_landing_pad_state(struct task_struct *task)
 {
        /*
         * If indirect branch tracking is not supported or not enabled on task,
         * nothing to lock here
         */
        if (!is_user_lpad_enabled() ||
-           !is_indir_lp_enabled(task) || arg != 0)
+           !is_indir_lp_enabled(task))
                return -EINVAL;
 
        set_indir_lp_lock(task, true);
index 8239cd95a00533fd81e8cba8700b0b9b86a82168..9b6b0d87fdb05628dd067084c3423c47a3bcfdfb 100644 (file)
@@ -229,8 +229,8 @@ static inline bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v)
 #define smt_mitigations SMT_MITIGATIONS_OFF
 #endif
 
-int arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *status);
-int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status);
-int arch_lock_indir_br_lp_status(struct task_struct *t, unsigned long status);
+int arch_prctl_get_branch_landing_pad_state(struct task_struct *t, unsigned long __user *state);
+int arch_prctl_set_branch_landing_pad_state(struct task_struct *t, unsigned long state);
+int arch_prctl_lock_branch_landing_pad_state(struct task_struct *t);
 
 #endif /* _LINUX_CPU_H_ */
index c86eba9aa7e9df81b8c980084fb0ec34e41f20bf..a5e0c187bbbf3d38fa85fc36be8a406e2780a44a 100644 (file)
@@ -2388,17 +2388,18 @@ int __weak arch_lock_shadow_stack_status(struct task_struct *t, unsigned long st
        return -EINVAL;
 }
 
-int __weak arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *status)
+int __weak arch_prctl_get_branch_landing_pad_state(struct task_struct *t,
+                                                  unsigned long __user *state)
 {
        return -EINVAL;
 }
 
-int __weak arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status)
+int __weak arch_prctl_set_branch_landing_pad_state(struct task_struct *t, unsigned long state)
 {
        return -EINVAL;
 }
 
-int __weak arch_lock_indir_br_lp_status(struct task_struct *t, unsigned long status)
+int __weak arch_prctl_lock_branch_landing_pad_state(struct task_struct *t)
 {
        return -EINVAL;
 }
@@ -2891,17 +2892,17 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
        case PR_GET_INDIR_BR_LP_STATUS:
                if (arg3 || arg4 || arg5)
                        return -EINVAL;
-               error = arch_get_indir_br_lp_status(me, (unsigned long __user *)arg2);
+               error = arch_prctl_get_branch_landing_pad_state(me, (unsigned long __user *)arg2);
                break;
        case PR_SET_INDIR_BR_LP_STATUS:
                if (arg3 || arg4 || arg5)
                        return -EINVAL;
-               error = arch_set_indir_br_lp_status(me, arg2);
+               error = arch_prctl_set_branch_landing_pad_state(me, arg2);
                break;
        case PR_LOCK_INDIR_BR_LP_STATUS:
-               if (arg3 || arg4 || arg5)
+               if (arg2 || arg3 || arg4 || arg5)
                        return -EINVAL;
-               error = arch_lock_indir_br_lp_status(me, arg2);
+               error = arch_prctl_lock_branch_landing_pad_state(me);
                break;
        default:
                trace_task_prctl_unknown(option, arg2, arg3, arg4, arg5);