Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions arch/riscv/include/asm/usercfi.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ void set_active_shstk(struct task_struct *task, unsigned long shstk_addr);
bool is_shstk_enabled(struct task_struct *task);
bool is_shstk_locked(struct task_struct *task);
bool is_shstk_allocated(struct task_struct *task);
void set_shstk_lock(struct task_struct *task);
void set_shstk_lock(struct task_struct *task, bool lock);
void set_shstk_status(struct task_struct *task, bool enable);
unsigned long get_active_shstk(struct task_struct *task);
int restore_user_shstk(struct task_struct *tsk, unsigned long shstk_ptr);
int save_user_shstk(struct task_struct *tsk, unsigned long *saved_shstk_ptr);
bool is_indir_lp_enabled(struct task_struct *task);
bool is_indir_lp_locked(struct task_struct *task);
void set_indir_lp_status(struct task_struct *task, bool enable);
void set_indir_lp_lock(struct task_struct *task);
void set_indir_lp_lock(struct task_struct *task, bool lock);

#define PR_SHADOW_STACK_SUPPORTED_STATUS_MASK (PR_SHADOW_STACK_ENABLE)

Expand All @@ -69,7 +69,7 @@ void set_indir_lp_lock(struct task_struct *task);

#define is_shstk_allocated(task) false

#define set_shstk_lock(task) do {} while (0)
#define set_shstk_lock(task, lock) do {} while (0)

#define set_shstk_status(task, enable) do {} while (0)

Expand All @@ -79,7 +79,7 @@ void set_indir_lp_lock(struct task_struct *task);

#define set_indir_lp_status(task, enable) do {} while (0)

#define set_indir_lp_lock(task) do {} while (0)
#define set_indir_lp_lock(task, lock) do {} while (0)

#define restore_user_shstk(tsk, shstk_ptr) -EINVAL

Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,13 @@ void start_thread(struct pt_regs *regs, unsigned long pc,
set_shstk_status(current, false);
set_shstk_base(current, 0, 0);
set_active_shstk(current, 0);
set_shstk_lock(current, false);
/*
* disable indirect branch tracking on exec.
* libc will enable it later via prctl.
*/
set_indir_lp_status(current, false);
set_indir_lp_lock(current, false);

#ifdef CONFIG_64BIT
regs->status &= ~SR_UXL;
Expand Down
12 changes: 6 additions & 6 deletions arch/riscv/kernel/usercfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ void set_shstk_status(struct task_struct *task, bool enable)
csr_write(CSR_ENVCFG, task->thread.envcfg);
}

void set_shstk_lock(struct task_struct *task)
void set_shstk_lock(struct task_struct *task, bool lock)
{
task->thread_info.user_cfi_state.ubcfi_locked = 1;
task->thread_info.user_cfi_state.ubcfi_locked = lock;
}

bool is_indir_lp_enabled(struct task_struct *task)
Expand Down Expand Up @@ -104,9 +104,9 @@ void set_indir_lp_status(struct task_struct *task, bool enable)
csr_write(CSR_ENVCFG, task->thread.envcfg);
}

void set_indir_lp_lock(struct task_struct *task)
void set_indir_lp_lock(struct task_struct *task, bool lock)
{
task->thread_info.user_cfi_state.ufcfi_locked = 1;
task->thread_info.user_cfi_state.ufcfi_locked = lock;
}
/*
* If size is 0, then to be compatible with regular stack we want it to be as big as
Expand Down Expand Up @@ -452,7 +452,7 @@ int arch_lock_shadow_stack_status(struct task_struct *task,
!is_shstk_enabled(task) || arg != 0)
return -EINVAL;

set_shstk_lock(task);
set_shstk_lock(task, true);

return 0;
}
Expand Down Expand Up @@ -502,7 +502,7 @@ int arch_lock_indir_br_lp_status(struct task_struct *task,
!is_indir_lp_enabled(task) || arg != 0)
return -EINVAL;

set_indir_lp_lock(task);
set_indir_lp_lock(task, true);

return 0;
}
Expand Down
Loading