# Re: \[PATCH v18 24/25\] x86/cet/shstk: Add arch\_prctl functions for shadow stack

- From: Yu, Yu-cheng \<hidden\>
- Date: 2021-02-03 21:55:31 
- List: linux-mm
- Page: https://ratatoskr.run/linux-mm/2021/02/6257692
- Thread: https://ratatoskr.run/linux-doc/2021/01/6250114/t.md

```text
On 1/29/2021 10:56 AM, Yu, Yu-cheng wrote:
> On 1/29/2021 9:07 AM, Dave Hansen wrote:
>> On 1/27/21 1:25 PM, Yu-cheng Yu wrote:
>>> arch_prctl(ARCH_X86_CET_STATUS, u64 *args)
>>>      Get CET feature status.
>>>
>>>      The parameter 'args' is a pointer to a user buffer.  The kernel returns
>>>      the following information:
>>>
>>>      *args = shadow stack/IBT status
>>>      *(args + 1) = shadow stack base address
>>>      *(args + 2) = shadow stack size

[...]

>>> +int prctl_cet(int option, u64 arg2)
>>> +{
>>> +    struct cet_status *cet;
>>> +    unsigned int features;
>>> +
>>> +    /*
>>> +     * GLIBC's ENOTSUPP == EOPNOTSUPP == 95, and it does not recognize
>>> +     * the kernel's ENOTSUPP (524).  So return EOPNOTSUPP here.
>>> +     */
>>> +    if (!IS_ENABLED(CONFIG_X86_CET))
>>> +        return -EOPNOTSUPP;
>>
>> Let's ignore glibc for a moment.  What error code *should* the kernel be
>> returning here?  errno(3) says:
>>
>>         EOPNOTSUPP      Operation not supported on socket (POSIX.1)
>> ...
>>         ENOTSUP         Operation not supported (POSIX.1)
>>
>
> Yeah, other places in kernel use ENOTSUPP.  This seems to be out of line.  And since the issue is long-existing, applications already know how to deal with it.  I should have made that argument.  Change it to ENOTSUPP.

When I make the change, checkpatch says...

WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
#128: FILE: arch/x86/kernel/cet_prctl.c:33:
+		return -ENOTSUPP;

Do we want to reconsider?

[...]

```
