Re: [patch 05/12] rseq: Add prctl() to enable time slice extensions
From: K Prateek Nayak
Date: Thu Sep 11 2025 - 12:52:30 EST
Hello Mathieu,
On 9/11/2025 9:20 PM, Mathieu Desnoyers wrote:
>> +int rseq_slice_extension_prctl(unsigned long arg2, unsigned long arg3)
>> +{
>> + switch (arg2) {
>> + case PR_RSEQ_SLICE_EXTENSION_GET:
>> + if (arg3)
>> + return -EINVAL;
>> + return current->rseq.slice.state.enabled ? PR_RSEQ_SLICE_EXT_ENABLE : 0;
>> +
>> + case PR_RSEQ_SLICE_EXTENSION_SET: {
>> + u32 rflags, valid = RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
>> + bool enable = !!(arg3 & PR_RSEQ_SLICE_EXT_ENABLE);
>> +
>> + if (arg3 & ~PR_RSEQ_SLICE_EXT_ENABLE)
>> + return -EINVAL;
>> + if (!rseq_slice_extension_enabled())
>> + return -ENOTSUPP;
>> + if (!current->rseq.usrptr)
>> + return -ENXIO;
>> +
>> + /* No change? */
>> + if (enable == !!current->rseq.slice.state.enabled)
>> + return 0;
>> +
>> + if (get_user(rflags, ¤t->rseq.usrptr->flags))
>> + goto die;
>> +
>> + if (current->rseq.slice.state.enabled)
>> + valid |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
>> +
>> + if ((rflags & valid) != valid)
>> + goto die;
>> +
>> + rflags &= ~RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
>> + rflags |= RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
>> + if (enable)
>> + rflags |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
>> +
>> + if (put_user(rflags, ¤t->rseq.usrptr->flags))
>> + goto die;
>> +
>> + current->rseq.slice.state.enabled = enable;
>
> What should happen to this enabled state if rseq is unregistered
> after this prctl ?
Wouldn't rseq_reset() deal with it since it does a:
memset(&t->rseq, 0, sizeof(t->rseq));
--
Thanks and Regards,
Prateek