Skip to content

Commit c17a6ff

Browse files
compudjIngo Molnar
authored andcommitted
rseq: Kill process when unknown flags are encountered in ABI structures
rseq_abi()->flags and rseq_abi()->rseq_cs->flags 29 upper bits are currently unused. The current behavior when those bits are set is to ignore them. This is not an ideal behavior, because when future features will start using those flags, if user-space fails to correctly validate that the kernel indeed supports those flags (e.g. with a new sys_rseq flags bit) before using them, it may incorrectly assume that the kernel will handle those flags way when in fact those will be silently ignored on older kernels. Validating that unused flags bits are cleared will allow a smoother transition when those flags will start to be used by allowing applications to fail early, and obviously, when they attempt to use the new flags on an older kernel that does not support them. Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 0190e41 commit c17a6ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rseq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
176176
u32 flags, event_mask;
177177
int ret;
178178

179-
if (WARN_ON_ONCE(cs_flags & RSEQ_CS_NO_RESTART_FLAGS))
179+
if (WARN_ON_ONCE(cs_flags & RSEQ_CS_NO_RESTART_FLAGS) || cs_flags)
180180
return -EINVAL;
181181

182182
/* Get thread flags. */
183183
ret = get_user(flags, &t->rseq->flags);
184184
if (ret)
185185
return ret;
186186

187-
if (WARN_ON_ONCE(flags & RSEQ_CS_NO_RESTART_FLAGS))
187+
if (WARN_ON_ONCE(flags & RSEQ_CS_NO_RESTART_FLAGS) || flags)
188188
return -EINVAL;
189189

190190
/*

0 commit comments

Comments
 (0)