Skip to content

Commit adfc80d

Browse files
author
Paul Walmsley
committed
prctl: rename branch landing pad implementation functions to be more explicit
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>
1 parent ac4e61c commit adfc80d

3 files changed

Lines changed: 19 additions & 18 deletions

File tree

arch/riscv/kernel/usercfi.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ int arch_lock_shadow_stack_status(struct task_struct *task,
457457
return 0;
458458
}
459459

460-
int arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *status)
460+
int arch_prctl_get_branch_landing_pad_state(struct task_struct *t,
461+
unsigned long __user *state)
461462
{
462463
unsigned long fcfi_status = 0;
463464

@@ -467,10 +468,10 @@ int arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *sta
467468
/* indirect branch tracking is enabled on the task or not */
468469
fcfi_status |= (is_indir_lp_enabled(t) ? PR_INDIR_BR_LP_ENABLE : 0);
469470

470-
return copy_to_user(status, &fcfi_status, sizeof(fcfi_status)) ? -EFAULT : 0;
471+
return copy_to_user(state, &fcfi_status, sizeof(fcfi_status)) ? -EFAULT : 0;
471472
}
472473

473-
int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status)
474+
int arch_prctl_set_branch_landing_pad_state(struct task_struct *t, unsigned long state)
474475
{
475476
bool enable_indir_lp = false;
476477

@@ -482,24 +483,23 @@ int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status)
482483
return -EINVAL;
483484

484485
/* Reject unknown flags */
485-
if (status & ~PR_INDIR_BR_LP_ENABLE)
486+
if (state & ~PR_INDIR_BR_LP_ENABLE)
486487
return -EINVAL;
487488

488-
enable_indir_lp = (status & PR_INDIR_BR_LP_ENABLE);
489+
enable_indir_lp = (state & PR_INDIR_BR_LP_ENABLE);
489490
set_indir_lp_status(t, enable_indir_lp);
490491

491492
return 0;
492493
}
493494

494-
int arch_lock_indir_br_lp_status(struct task_struct *task,
495-
unsigned long arg)
495+
int arch_prctl_lock_branch_landing_pad_state(struct task_struct *task)
496496
{
497497
/*
498498
* If indirect branch tracking is not supported or not enabled on task,
499499
* nothing to lock here
500500
*/
501501
if (!is_user_lpad_enabled() ||
502-
!is_indir_lp_enabled(task) || arg != 0)
502+
!is_indir_lp_enabled(task))
503503
return -EINVAL;
504504

505505
set_indir_lp_lock(task, true);

include/linux/cpu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ static inline bool cpu_attack_vector_mitigated(enum cpu_attack_vectors v)
229229
#define smt_mitigations SMT_MITIGATIONS_OFF
230230
#endif
231231

232-
int arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *status);
233-
int arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status);
234-
int arch_lock_indir_br_lp_status(struct task_struct *t, unsigned long status);
232+
int arch_prctl_get_branch_landing_pad_state(struct task_struct *t, unsigned long __user *state);
233+
int arch_prctl_set_branch_landing_pad_state(struct task_struct *t, unsigned long state);
234+
int arch_prctl_lock_branch_landing_pad_state(struct task_struct *t);
235235

236236
#endif /* _LINUX_CPU_H_ */

kernel/sys.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,17 +2388,18 @@ int __weak arch_lock_shadow_stack_status(struct task_struct *t, unsigned long st
23882388
return -EINVAL;
23892389
}
23902390

2391-
int __weak arch_get_indir_br_lp_status(struct task_struct *t, unsigned long __user *status)
2391+
int __weak arch_prctl_get_branch_landing_pad_state(struct task_struct *t,
2392+
unsigned long __user *state)
23922393
{
23932394
return -EINVAL;
23942395
}
23952396

2396-
int __weak arch_set_indir_br_lp_status(struct task_struct *t, unsigned long status)
2397+
int __weak arch_prctl_set_branch_landing_pad_state(struct task_struct *t, unsigned long state)
23972398
{
23982399
return -EINVAL;
23992400
}
24002401

2401-
int __weak arch_lock_indir_br_lp_status(struct task_struct *t, unsigned long status)
2402+
int __weak arch_prctl_lock_branch_landing_pad_state(struct task_struct *t)
24022403
{
24032404
return -EINVAL;
24042405
}
@@ -2891,17 +2892,17 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
28912892
case PR_GET_INDIR_BR_LP_STATUS:
28922893
if (arg3 || arg4 || arg5)
28932894
return -EINVAL;
2894-
error = arch_get_indir_br_lp_status(me, (unsigned long __user *)arg2);
2895+
error = arch_prctl_get_branch_landing_pad_state(me, (unsigned long __user *)arg2);
28952896
break;
28962897
case PR_SET_INDIR_BR_LP_STATUS:
28972898
if (arg3 || arg4 || arg5)
28982899
return -EINVAL;
2899-
error = arch_set_indir_br_lp_status(me, arg2);
2900+
error = arch_prctl_set_branch_landing_pad_state(me, arg2);
29002901
break;
29012902
case PR_LOCK_INDIR_BR_LP_STATUS:
2902-
if (arg3 || arg4 || arg5)
2903+
if (arg2 || arg3 || arg4 || arg5)
29032904
return -EINVAL;
2904-
error = arch_lock_indir_br_lp_status(me, arg2);
2905+
error = arch_prctl_lock_branch_landing_pad_state(me);
29052906
break;
29062907
default:
29072908
trace_task_prctl_unknown(option, arg2, arg3, arg4, arg5);

0 commit comments

Comments
 (0)