Skip to content

Commit 53c9985

Browse files
leitaowilldeacon
authored andcommitted
arm64/gcs: Fix error handling in arch_set_shadow_stack_status()
alloc_gcs() returns an error-encoded pointer on failure, which comes from do_mmap(), not NULL. The current NULL check fails to detect errors, which could lead to using an invalid GCS address. Use IS_ERR_VALUE() to properly detect errors, consistent with the check in gcs_alloc_thread_stack(). Fixes: b57180c ("arm64/gcs: Implement shadow stack prctl() interface") Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Will Deacon <will@kernel.org>
1 parent bb0c99e commit 53c9985

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/arm64/mm/gcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ int arch_set_shadow_stack_status(struct task_struct *task, unsigned long arg)
199199

200200
size = gcs_size(0);
201201
gcs = alloc_gcs(0, size);
202-
if (!gcs)
203-
return -ENOMEM;
202+
if (IS_ERR_VALUE(gcs))
203+
return gcs;
204204

205205
task->thread.gcspr_el0 = gcs + size - sizeof(u64);
206206
task->thread.gcs_base = gcs;

0 commit comments

Comments
 (0)