Re: [PATCH v2] arch: Reserve map_shadow_stack() syscall number for all architectures

2023-10-07 Thread Sohil Mehta
On 10/6/2023 1:29 PM, Arnd Bergmann wrote:
> On Fri, Oct 6, 2023, at 22:01, Edgecombe, Rick P wrote:
>> Hi Arnd,
>>
>> It doesn't look like anyone is pouncing on the syscall number in linux-
>> next currently. It might be nice to have this patch go through linux-
>> next since it touches so many architectures. And it sounds like x86
>> folk are ok with this, so if you could pick it up for 6.7 that would be
>> great. Thanks!
> 
> Ok, I picked it up now, should be in linux-next starting next week.
> 

Great, thanks Arnd and Rick!

Sohil




Re: [PATCH v2] syscalls: Cleanup references to sys_lookup_dcookie()

2023-10-03 Thread Sohil Mehta
On 10/3/2023 10:53 AM, Arnd Bergmann wrote:
> Thanks a lot for the reminder, I've added it to my asm-generic
> branch for v6.7 now, it should be in linux-next tomorrow.
> 

No problem at all. Thanks for picking up the patch!

Sohil


Re: [PATCH v2] syscalls: Cleanup references to sys_lookup_dcookie()

2023-10-03 Thread Sohil Mehta
Arnd, is this a good candidate for 6.7? Though old, the patch applies
cleanly on 6.6-rc4. I can re-send this one if you would prefer that.

On 8/3/2023 2:44 PM, Sohil Mehta wrote:
> On 7/10/2023 11:51 AM, Sohil Mehta wrote:
>> commit 'be65de6b03aa ("fs: Remove dcookies support")' removed the
>> syscall definition for lookup_dcookie.  However, syscall tables still
>> point to the old sys_lookup_dcookie() definition. Update syscall tables
>> of all architectures to directly point to sys_ni_syscall() instead.
>>
>> Signed-off-by: Sohil Mehta 
>> Reviewed-by: Randy Dunlap 
>> Acked-by: Namhyung Kim  # for perf
> 
> The patch has received a couple of additional Acks.
> 

Namely,

Acked-by: Geert Uytterhoeven 
Acked-by: Russell King (Oracle) 

> Does this seem like a valuable cleanup? If so, should it go through the
> asm-generic tree?
> 

The main motivation here is to make readers aware upfront (via the
syscall table itself) that no implementation exists for lookup_dcookie
instead of them searching for one and realizing the same. The syscall
tables do something similar for _sysctl().

Please let me know if this change seems unnecessary. I can drop the
annoying pings in that case.

Thanks,
Sohil



Re: [PATCH v2] arch: Reserve map_shadow_stack() syscall number for all architectures

2023-10-03 Thread Sohil Mehta
On 10/3/2023 9:54 AM, Arnd Bergmann wrote:
> On Tue, Oct 3, 2023, at 18:35, Sohil Mehta wrote:
>>
>> Gentle ping...
>>
>> Are there any additional comments? It applies cleanly on 6.6-rc4.
>>
>> Or does it seem ready to be merged? It has the following
>> acknowledgements until now:
>>
>> Reviewed-by: Rick Edgecombe 
>> Acked-by: Michael Ellerman  (powerpc)
>>
> 
> Reviewed-by: Arnd Bergmann 
> 

Thanks Arnd.

> If you like, I can pick this up for 6.7 through the asm-generic
> tree. If you think this should be part of 6.6, I would suggest
> to merge it through the tree that originally contained the
> syscall code.
> 

Dave, Ingo, would you prefer to take this patch through 6.6 or defer it
until 6.7?

It's not necessarily a fix but it does help finish up the shstk syscall
added with 6.6. Also, it might help reduce some merge conflicts later if
newer syscalls are being added during the 6.7 window.

Sohil



Re: [PATCH v2] arch: Reserve map_shadow_stack() syscall number for all architectures

2023-10-03 Thread Sohil Mehta
On 9/14/2023 11:58 AM, Sohil Mehta wrote:
> commit c35559f94ebc ("x86/shstk: Introduce map_shadow_stack syscall")
> recently added support for map_shadow_stack() but it is limited to x86
> only for now. There is a possibility that other architectures (namely,
> arm64 and RISC-V), that are implementing equivalent support for shadow
> stacks, might need to add support for it.
> 
> Independent of that, reserving arch-specific syscall numbers in the
> syscall tables of all architectures is good practice and would help
> avoid future conflicts. map_shadow_stack() is marked as a conditional
> syscall in sys_ni.c. Adding it to the syscall tables of other
> architectures is harmless and would return ENOSYS when exercised.
> 
> Note, map_shadow_stack() was assigned #453 during the merge process
> since #452 was taken by fchmodat2().
> 
> For Powerpc, map it to sys_ni_syscall() as is the norm for Powerpc
> syscall tables.
> 
> For Alpha, map_shadow_stack() takes up #563 as Alpha still diverges from
> the common syscall numbering system in the other architectures.
> 
> Link: 
> https://lore.kernel.org/lkml/20230515212255.ga562...@debug.ba.rivosinc.com/
> Link: 
> https://lore.kernel.org/lkml/b402b80b-a7c6-4ef0-b977-c0f5f582b...@sirena.org.uk/
> 
> Signed-off-by: Sohil Mehta 
> ---

Gentle ping...

Are there any additional comments? It applies cleanly on 6.6-rc4.

Or does it seem ready to be merged? It has the following
acknowledgements until now:

Reviewed-by: Rick Edgecombe 
Acked-by: Michael Ellerman  (powerpc)

>  arch/alpha/kernel/syscalls/syscall.tbl  | 1 +
>  arch/arm/tools/syscall.tbl  | 1 +
>  arch/arm64/include/asm/unistd.h | 2 +-
>  arch/arm64/include/asm/unistd32.h   | 2 ++
>  arch/ia64/kernel/syscalls/syscall.tbl   | 1 +
>  arch/m68k/kernel/syscalls/syscall.tbl   | 1 +
>  arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
>  arch/mips/kernel/syscalls/syscall_n32.tbl   | 1 +
>  arch/mips/kernel/syscalls/syscall_n64.tbl   | 1 +
>  arch/mips/kernel/syscalls/syscall_o32.tbl   | 1 +
>  arch/parisc/kernel/syscalls/syscall.tbl | 1 +
>  arch/powerpc/kernel/syscalls/syscall.tbl| 1 +
>  arch/s390/kernel/syscalls/syscall.tbl   | 1 +
>  arch/sh/kernel/syscalls/syscall.tbl | 1 +
>  arch/sparc/kernel/syscalls/syscall.tbl  | 1 +
>  arch/x86/entry/syscalls/syscall_32.tbl  | 1 +
>  arch/xtensa/kernel/syscalls/syscall.tbl | 1 +
>  include/uapi/asm-generic/unistd.h   | 5 -
>  18 files changed, 22 insertions(+), 2 deletions(-)
>> diff --git a/arch/alpha/kernel/syscalls/syscall.tbl
b/arch/alpha/kernel/syscalls/syscall.tbl
> index ad37569d0507..6e8479c96e65 100644
> --- a/arch/alpha/kernel/syscalls/syscall.tbl
> +++ b/arch/alpha/kernel/syscalls/syscall.tbl
> @@ -492,3 +492,4 @@
>  560  common  set_mempolicy_home_node sys_ni_syscall
>  561  common  cachestat   sys_cachestat
>  562  common  fchmodat2   sys_fchmodat2
> +563  common  map_shadow_stacksys_map_shadow_stack
> diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
> index c572d6c3dee0..6d494dfbf5e4 100644
> --- a/arch/arm/tools/syscall.tbl
> +++ b/arch/arm/tools/syscall.tbl
> @@ -466,3 +466,4 @@
>  450  common  set_mempolicy_home_node sys_set_mempolicy_home_node
>  451  common  cachestat   sys_cachestat
>  452  common  fchmodat2   sys_fchmodat2
> +453  common  map_shadow_stacksys_map_shadow_stack
> diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
> index bd77253b62e0..6a28fb91b85d 100644
> --- a/arch/arm64/include/asm/unistd.h
> +++ b/arch/arm64/include/asm/unistd.h
> @@ -39,7 +39,7 @@
>  #define __ARM_NR_compat_set_tls  (__ARM_NR_COMPAT_BASE + 5)
>  #define __ARM_NR_COMPAT_END  (__ARM_NR_COMPAT_BASE + 0x800)
>  
> -#define __NR_compat_syscalls 453
> +#define __NR_compat_syscalls 454
>  #endif
>  
>  #define __ARCH_WANT_SYS_CLONE
> diff --git a/arch/arm64/include/asm/unistd32.h 
> b/arch/arm64/include/asm/unistd32.h
> index 78b68311ec81..a201d842ec82 100644
> --- a/arch/arm64/include/asm/unistd32.h
> +++ b/arch/arm64/include/asm/unistd32.h
> @@ -911,6 +911,8 @@ __SYSCALL(__NR_set_mempolicy_home_node, 
> sys_set_mempolicy_home_node)
>  __SYSCALL(__NR_cachestat, sys_cachestat)
>  #define __NR_fchmodat2 452
>  __SYSCALL(__NR_fchmodat2, sys_fchmodat2)
> +#define __NR_map_shadow_stack 453
> +__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)
>  
>  /*
>   * Please add new compat syscalls above this comment and update
> diff --git a/arch/ia64/kernel/syscalls/syscall.tbl 
>

[PATCH v2] arch: Reserve map_shadow_stack() syscall number for all architectures

2023-09-14 Thread Sohil Mehta
commit c35559f94ebc ("x86/shstk: Introduce map_shadow_stack syscall")
recently added support for map_shadow_stack() but it is limited to x86
only for now. There is a possibility that other architectures (namely,
arm64 and RISC-V), that are implementing equivalent support for shadow
stacks, might need to add support for it.

Independent of that, reserving arch-specific syscall numbers in the
syscall tables of all architectures is good practice and would help
avoid future conflicts. map_shadow_stack() is marked as a conditional
syscall in sys_ni.c. Adding it to the syscall tables of other
architectures is harmless and would return ENOSYS when exercised.

Note, map_shadow_stack() was assigned #453 during the merge process
since #452 was taken by fchmodat2().

For Powerpc, map it to sys_ni_syscall() as is the norm for Powerpc
syscall tables.

For Alpha, map_shadow_stack() takes up #563 as Alpha still diverges from
the common syscall numbering system in the other architectures.

Link: 
https://lore.kernel.org/lkml/20230515212255.ga562...@debug.ba.rivosinc.com/
Link: 
https://lore.kernel.org/lkml/b402b80b-a7c6-4ef0-b977-c0f5f582b...@sirena.org.uk/

Signed-off-by: Sohil Mehta 
---
v2:
- Skip syscall table changes to tools/. They will be handled separetely by the
  perf folks.
- Map Powerpc to sys_ni_syscall (Rick Edgecombe)
---
 arch/alpha/kernel/syscalls/syscall.tbl  | 1 +
 arch/arm/tools/syscall.tbl  | 1 +
 arch/arm64/include/asm/unistd.h | 2 +-
 arch/arm64/include/asm/unistd32.h   | 2 ++
 arch/ia64/kernel/syscalls/syscall.tbl   | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl   | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl| 1 +
 arch/s390/kernel/syscalls/syscall.tbl   | 1 +
 arch/sh/kernel/syscalls/syscall.tbl | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl  | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl  | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl | 1 +
 include/uapi/asm-generic/unistd.h   | 5 -
 18 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl 
b/arch/alpha/kernel/syscalls/syscall.tbl
index ad37569d0507..6e8479c96e65 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -492,3 +492,4 @@
 560common  set_mempolicy_home_node sys_ni_syscall
 561common  cachestat   sys_cachestat
 562common  fchmodat2   sys_fchmodat2
+563common  map_shadow_stacksys_map_shadow_stack
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index c572d6c3dee0..6d494dfbf5e4 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -466,3 +466,4 @@
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
 452common  fchmodat2   sys_fchmodat2
+453common  map_shadow_stacksys_map_shadow_stack
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index bd77253b62e0..6a28fb91b85d 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -39,7 +39,7 @@
 #define __ARM_NR_compat_set_tls(__ARM_NR_COMPAT_BASE + 5)
 #define __ARM_NR_COMPAT_END(__ARM_NR_COMPAT_BASE + 0x800)
 
-#define __NR_compat_syscalls   453
+#define __NR_compat_syscalls   454
 #endif
 
 #define __ARCH_WANT_SYS_CLONE
diff --git a/arch/arm64/include/asm/unistd32.h 
b/arch/arm64/include/asm/unistd32.h
index 78b68311ec81..a201d842ec82 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -911,6 +911,8 @@ __SYSCALL(__NR_set_mempolicy_home_node, 
sys_set_mempolicy_home_node)
 __SYSCALL(__NR_cachestat, sys_cachestat)
 #define __NR_fchmodat2 452
 __SYSCALL(__NR_fchmodat2, sys_fchmodat2)
+#define __NR_map_shadow_stack 453
+__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)
 
 /*
  * Please add new compat syscalls above this comment and update
diff --git a/arch/ia64/kernel/syscalls/syscall.tbl 
b/arch/ia64/kernel/syscalls/syscall.tbl
index 83d8609aec03..be02ce9d376f 100644
--- a/arch/ia64/kernel/syscalls/syscall.tbl
+++ b/arch/ia64/kernel/syscalls/syscall.tbl
@@ -373,3 +373,4 @@
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
 452common  fchmodat2   sys_fchmodat2
+453common  map_shadow_stacksys_map_shadow_stack
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
index 259ceb125367..bee2d2f7f82c 100644
--- a

Re: [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls

2023-09-13 Thread Sohil Mehta
On 9/11/2023 11:02 AM, Sohil Mehta wrote:
> Sohil Mehta (2):
>   tools headers UAPI: Sync fchmodat2() syscall table entries

I now see a patch by Arnaldo that does something similar:
https://lore.kernel.org/lkml/zp8be7axdbu%2fd...@kernel.org/

Also, it states that:

"The tools/perf/check-headers.sh script, part of the tools/ build
process, points out changes in the original files.

So its important not to touch the copies in tools/ when doing changes in
the original kernel headers, that will be done later, when
check-headers.sh inform about the change to the perf tools hackers."

I was unaware of this and therefore I'll drop all the tools/ related
changes from this series.

Sohil


Re: [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures

2023-09-13 Thread Sohil Mehta
On 9/11/2023 2:10 PM, Edgecombe, Rick P wrote:
> On Mon, 2023-09-11 at 18:02 +0000, Sohil Mehta wrote:
>> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
>> b/arch/powerpc/kernel/syscalls/syscall.tbl
>> index 20e50586e8a2..2767b8a42636 100644
>> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
>> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
>> @@ -539,3 +539,4 @@
>>  450nospu   set_mempolicy_home_node sys_set_mempolicy_hom
>> e_node
>>  451common  cachestat   sys_cachestat
>>  452common  fchmodat2   sys_fchmodat2
>> +453common  map_shadow_stacksys_map_shadow_stack
> 
> I noticed in powerpc, the not implemented syscalls are manually mapped
> to sys_ni_syscall. It also has some special extra sys_ni_syscall()
> implementation bits to handle both ARCH_HAS_SYSCALL_WRAPPER and
> !ARCH_HAS_SYSCALL_WRAPPER. So wondering if it might need special
> treatment. Did you see those parts?
> 

Thanks for pointing this out. Powerpc seems to be unique in their
handling of not implemented syscalls. Maybe it's because of their
special casing of the ARCH_HAS_SYSCALL_WRAPPER.

The code below in arch/powerpc/include/asm/syscalls.h suggests to me
that it should be safe to map map_shadow_stack() to sys_ni_syscall() and
the special handling will be taken care of.

#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
long sys_ni_syscall(void);
#else
long sys_ni_syscall(const struct pt_regs *regs);
#endif

I don't quite understand the underlying reasoning for it though. Do you
have any additional insight into how we should handle this?

I am thinking of doing the following in the next iteration unless
someone chimes in and says otherwise.

--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -539,4 +539,4 @@
 450nospu   set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
 452common  fchmodat2   sys_fchmodat2
-453common  map_shadow_stacksys_map_shadow_stack
+453common  map_shadow_stacksys_ni_syscall



[PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures

2023-09-12 Thread Sohil Mehta
Support for map_shadow_stack() was recently added but it is an x86
only system call for now. There is a possibility that other
architectures (namely, arm64 and Risc-V) that are implementing support
for shadow stacks, might need to add support for it.

Independent of that, reserving arch-specific syscall numbers in the
syscall tables of all architectures is good practice and would help
avoid future conflicts.

Note, map_shadow_stack() was assigned #453 since #452 was taken by
fchmodat2().

Link:https://lore.kernel.org/lkml/20230830234752.19858-1-dave.han...@linux.intel.com/

Signed-off-by: Sohil Mehta 
---
 arch/alpha/kernel/syscalls/syscall.tbl  | 1 +
 arch/arm/tools/syscall.tbl  | 1 +
 arch/arm64/include/asm/unistd.h | 2 +-
 arch/arm64/include/asm/unistd32.h   | 2 ++
 arch/ia64/kernel/syscalls/syscall.tbl   | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl   | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl| 1 +
 arch/s390/kernel/syscalls/syscall.tbl   | 1 +
 arch/sh/kernel/syscalls/syscall.tbl | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl  | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl  | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl | 1 +
 include/uapi/asm-generic/unistd.h   | 5 -
 tools/include/uapi/asm-generic/unistd.h | 5 -
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 1 +
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 1 +
 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 1 +
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 1 +
 23 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl 
b/arch/alpha/kernel/syscalls/syscall.tbl
index ad37569d0507..6e8479c96e65 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -492,3 +492,4 @@
 560common  set_mempolicy_home_node sys_ni_syscall
 561common  cachestat   sys_cachestat
 562common  fchmodat2   sys_fchmodat2
+563common  map_shadow_stacksys_map_shadow_stack
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index c572d6c3dee0..6d494dfbf5e4 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -466,3 +466,4 @@
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
 452common  fchmodat2   sys_fchmodat2
+453common  map_shadow_stacksys_map_shadow_stack
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index bd77253b62e0..6a28fb91b85d 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -39,7 +39,7 @@
 #define __ARM_NR_compat_set_tls(__ARM_NR_COMPAT_BASE + 5)
 #define __ARM_NR_COMPAT_END(__ARM_NR_COMPAT_BASE + 0x800)
 
-#define __NR_compat_syscalls   453
+#define __NR_compat_syscalls   454
 #endif
 
 #define __ARCH_WANT_SYS_CLONE
diff --git a/arch/arm64/include/asm/unistd32.h 
b/arch/arm64/include/asm/unistd32.h
index 78b68311ec81..a201d842ec82 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -911,6 +911,8 @@ __SYSCALL(__NR_set_mempolicy_home_node, 
sys_set_mempolicy_home_node)
 __SYSCALL(__NR_cachestat, sys_cachestat)
 #define __NR_fchmodat2 452
 __SYSCALL(__NR_fchmodat2, sys_fchmodat2)
+#define __NR_map_shadow_stack 453
+__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)
 
 /*
  * Please add new compat syscalls above this comment and update
diff --git a/arch/ia64/kernel/syscalls/syscall.tbl 
b/arch/ia64/kernel/syscalls/syscall.tbl
index 83d8609aec03..be02ce9d376f 100644
--- a/arch/ia64/kernel/syscalls/syscall.tbl
+++ b/arch/ia64/kernel/syscalls/syscall.tbl
@@ -373,3 +373,4 @@
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
 452common  fchmodat2   sys_fchmodat2
+453common  map_shadow_stacksys_map_shadow_stack
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
index 259ceb125367..bee2d2f7f82c 100644
--- a/arch/m68k/kernel/syscalls/syscall.tbl
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -452,3 +452,4 @@
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
 452common  fchmodat2

[PATCH 1/2] tools headers UAPI: Sync fchmodat2() syscall table entries

2023-09-12 Thread Sohil Mehta
The syscall table entries in the core kernel and perf are expected to be
in sync. This would fix perf build warnings and also add support for
fchmodat2 in 'perf trace'.

Signed-off-by: Sohil Mehta 
---
 tools/include/uapi/asm-generic/unistd.h | 5 -
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 1 +
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 1 +
 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 1 +
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 1 +
 5 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/include/uapi/asm-generic/unistd.h 
b/tools/include/uapi/asm-generic/unistd.h
index fd6c1cb585db..abe087c53b4b 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -820,8 +820,11 @@ __SYSCALL(__NR_set_mempolicy_home_node, 
sys_set_mempolicy_home_node)
 #define __NR_cachestat 451
 __SYSCALL(__NR_cachestat, sys_cachestat)
 
+#define __NR_fchmodat2 452
+__SYSCALL(__NR_fchmodat2, sys_fchmodat2)
+
 #undef __NR_syscalls
-#define __NR_syscalls 452
+#define __NR_syscalls 453
 
 /*
  * 32 bit systems traditionally used different
diff --git a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl 
b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
index cfda2511badf..cb5e757f6621 100644
--- a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
+++ b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
@@ -366,3 +366,4 @@
 449n64 futex_waitv sys_futex_waitv
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451n64 cachestat   sys_cachestat
+452n64 fchmodat2   sys_fchmodat2
diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl 
b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
index 8c0b08b7a80e..20e50586e8a2 100644
--- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
@@ -538,3 +538,4 @@
 449common  futex_waitv sys_futex_waitv
 450nospu   set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
+452common  fchmodat2   sys_fchmodat2
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl 
b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
index a6935af2235c..0122cc156952 100644
--- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
@@ -454,3 +454,4 @@
 449  commonfutex_waitv sys_futex_waitv 
sys_futex_waitv
 450  commonset_mempolicy_home_node sys_set_mempolicy_home_node 
sys_set_mempolicy_home_node
 451  commoncachestat   sys_cachestat   
sys_cachestat
+452  commonfchmodat2   sys_fchmodat2   
sys_fchmodat2
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl 
b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index 227538b0ce80..a5db10ddf540 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -373,6 +373,7 @@
 449common  futex_waitv sys_futex_waitv
 450common  set_mempolicy_home_node sys_set_mempolicy_home_node
 451common  cachestat   sys_cachestat
+452common  fchmodat2   sys_fchmodat2
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
-- 
2.34.1



[PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls

2023-09-12 Thread Sohil Mehta
6.6-rc1 has added support for 2 new system calls:
[1] fchmodat2()
[2] x86-specific map_shadow_stack()

This series mainly synchronizes the syscall tables arcoss the core kernel and
tools to reflect the recent updates.

For fchmodat2(), it fixes the missing entries in the tools directory.

For map_shadow_stack(), it reserves the syscall across the board. Since
map_shadow_stack() is x86 specific for now, it is marked as a conditional
syscall in sys_ni.c. Adding it to the syscall tables of other architectures is
harmless and would return ENOSYS when exercised.

Reserving arch-specific syscall numbers in the tables of all architectures is
good practice and would help avoid future conflicts.

[1]: 
https://lore.kernel.org/lkml/20230824-frohlocken-vorabend-725f6fdaad50@brauner/
[2]: 
https://lore.kernel.org/lkml/20230830234752.19858-1-dave.han...@linux.intel.com/

Sohil Mehta (2):
  tools headers UAPI: Sync fchmodat2() syscall table entries
  arch: Reserve map_shadow_stack() syscall number for all architectures

 arch/alpha/kernel/syscalls/syscall.tbl  | 1 +
 arch/arm/tools/syscall.tbl  | 1 +
 arch/arm64/include/asm/unistd.h | 2 +-
 arch/arm64/include/asm/unistd32.h   | 2 ++
 arch/ia64/kernel/syscalls/syscall.tbl   | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl   | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl| 1 +
 arch/s390/kernel/syscalls/syscall.tbl   | 1 +
 arch/sh/kernel/syscalls/syscall.tbl | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl  | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl  | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl | 1 +
 include/uapi/asm-generic/unistd.h   | 5 -
 tools/include/uapi/asm-generic/unistd.h | 8 +++-
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 2 ++
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 2 ++
 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 2 ++
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 2 ++
 23 files changed, 37 insertions(+), 3 deletions(-)


base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
-- 
2.34.1



Re: [PATCH v2] syscalls: Cleanup references to sys_lookup_dcookie()

2023-08-03 Thread Sohil Mehta
Hi Arnd,

On 7/10/2023 11:51 AM, Sohil Mehta wrote:
> commit 'be65de6b03aa ("fs: Remove dcookies support")' removed the
> syscall definition for lookup_dcookie.  However, syscall tables still
> point to the old sys_lookup_dcookie() definition. Update syscall tables
> of all architectures to directly point to sys_ni_syscall() instead.
> 
> Signed-off-by: Sohil Mehta 
> Reviewed-by: Randy Dunlap 
> Acked-by: Namhyung Kim  # for perf

The patch has received a couple of additional Acks.

Does this seem like a valuable cleanup? If so, should it go through the
asm-generic tree?

Sohil


[PATCH v2] syscalls: Cleanup references to sys_lookup_dcookie()

2023-07-10 Thread Sohil Mehta
commit 'be65de6b03aa ("fs: Remove dcookies support")' removed the
syscall definition for lookup_dcookie.  However, syscall tables still
point to the old sys_lookup_dcookie() definition. Update syscall tables
of all architectures to directly point to sys_ni_syscall() instead.

Signed-off-by: Sohil Mehta 
Reviewed-by: Randy Dunlap 
Acked-by: Namhyung Kim  # for perf
---
v2:
- Rebased to v6.5-rc1. No other dependencies.
- Added acquired tags.
---
 arch/alpha/kernel/syscalls/syscall.tbl  | 2 +-
 arch/arm/tools/syscall.tbl  | 2 +-
 arch/arm64/include/asm/unistd32.h   | 4 ++--
 arch/ia64/kernel/syscalls/syscall.tbl   | 2 +-
 arch/m68k/kernel/syscalls/syscall.tbl   | 2 +-
 arch/microblaze/kernel/syscalls/syscall.tbl | 2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 2 +-
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 2 +-
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 2 +-
 arch/parisc/kernel/syscalls/syscall.tbl | 2 +-
 arch/powerpc/kernel/syscalls/syscall.tbl| 2 +-
 arch/s390/kernel/syscalls/syscall.tbl   | 2 +-
 arch/sh/kernel/syscalls/syscall.tbl | 2 +-
 arch/sparc/kernel/syscalls/syscall.tbl  | 2 +-
 arch/x86/entry/syscalls/syscall_32.tbl  | 2 +-
 arch/x86/entry/syscalls/syscall_64.tbl  | 2 +-
 arch/xtensa/kernel/syscalls/syscall.tbl | 2 +-
 include/linux/compat.h  | 1 -
 include/linux/syscalls.h| 1 -
 include/uapi/asm-generic/unistd.h   | 2 +-
 kernel/sys_ni.c | 2 --
 tools/include/uapi/asm-generic/unistd.h | 2 +-
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 2 +-
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 2 +-
 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 2 +-
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 2 +-
 26 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl 
b/arch/alpha/kernel/syscalls/syscall.tbl
index 1f13995d00d7..1349012f5c2e 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -334,7 +334,7 @@
 401common  io_submit   sys_io_submit
 402common  io_cancel   sys_io_cancel
 405common  exit_group  sys_exit_group
-406common  lookup_dcookie  sys_lookup_dcookie
+406common  lookup_dcookie  sys_ni_syscall
 407common  epoll_createsys_epoll_create
 408common  epoll_ctl   sys_epoll_ctl
 409common  epoll_wait  sys_epoll_wait
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index 8ebed8a13874..cb7ea3bf18cf 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -263,7 +263,7 @@
 246common  io_submit   sys_io_submit
 247common  io_cancel   sys_io_cancel
 248common  exit_group  sys_exit_group
-249common  lookup_dcookie  sys_lookup_dcookie
+249common  lookup_dcookie  sys_ni_syscall
 250common  epoll_createsys_epoll_create
 251common  epoll_ctl   sys_epoll_ctl   
sys_oabi_epoll_ctl
 252common  epoll_wait  sys_epoll_wait
diff --git a/arch/arm64/include/asm/unistd32.h 
b/arch/arm64/include/asm/unistd32.h
index d952a28463e0..2d8ab890818a 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -508,8 +508,8 @@ __SYSCALL(__NR_io_submit, compat_sys_io_submit)
 __SYSCALL(__NR_io_cancel, sys_io_cancel)
 #define __NR_exit_group 248
 __SYSCALL(__NR_exit_group, sys_exit_group)
-#define __NR_lookup_dcookie 249
-__SYSCALL(__NR_lookup_dcookie, compat_sys_lookup_dcookie)
+   /* 249 was lookup_dcookie */
+__SYSCALL(249, sys_ni_syscall)
 #define __NR_epoll_create 250
 __SYSCALL(__NR_epoll_create, sys_epoll_create)
 #define __NR_epoll_ctl 251
diff --git a/arch/ia64/kernel/syscalls/syscall.tbl 
b/arch/ia64/kernel/syscalls/syscall.tbl
index f8c74ffeeefb..ac8bd817b1b9 100644
--- a/arch/ia64/kernel/syscalls/syscall.tbl
+++ b/arch/ia64/kernel/syscalls/syscall.tbl
@@ -222,7 +222,7 @@
 210common  fadvise64   sys_fadvise64_64
 211common  tgkill  sys_tgkill
 212common  exit_group  sys_exit_group
-213common  lookup_dcookie  sys_lookup_dcookie
+213common  lookup_dcookie  sys_ni_syscall
 214common  io_setupsys_io_setup
 215common  io_destroy  sys_io_destroy
 216common  io_geteventssys_io_getevents
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscal

[PATCH] syscalls: Cleanup references to sys_lookup_dcookie()

2023-06-28 Thread Sohil Mehta
commit 'be65de6b03aa ("fs: Remove dcookies support")' removed the
syscall definition for lookup_dcookie.  However, syscall tables still
point to the old sys_lookup_dcookie() definition. Update syscall tables
of all architectures to directly point to sys_ni_syscall() instead.

Signed-off-by: Sohil Mehta 
---
This patch has a dependency on another patch that has been applied to the
asm-generic tree:
https://lore.kernel.org/lkml/20230621223600.1348693-1-sohil.me...@intel.com/
---
 arch/alpha/kernel/syscalls/syscall.tbl  | 2 +-
 arch/arm/tools/syscall.tbl  | 2 +-
 arch/arm64/include/asm/unistd32.h   | 4 ++--
 arch/ia64/kernel/syscalls/syscall.tbl   | 2 +-
 arch/m68k/kernel/syscalls/syscall.tbl   | 2 +-
 arch/microblaze/kernel/syscalls/syscall.tbl | 2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl   | 2 +-
 arch/mips/kernel/syscalls/syscall_n64.tbl   | 2 +-
 arch/mips/kernel/syscalls/syscall_o32.tbl   | 2 +-
 arch/parisc/kernel/syscalls/syscall.tbl | 2 +-
 arch/powerpc/kernel/syscalls/syscall.tbl| 2 +-
 arch/s390/kernel/syscalls/syscall.tbl   | 2 +-
 arch/sh/kernel/syscalls/syscall.tbl | 2 +-
 arch/sparc/kernel/syscalls/syscall.tbl  | 2 +-
 arch/x86/entry/syscalls/syscall_32.tbl  | 2 +-
 arch/x86/entry/syscalls/syscall_64.tbl  | 2 +-
 arch/xtensa/kernel/syscalls/syscall.tbl | 2 +-
 include/linux/compat.h  | 1 -
 include/linux/syscalls.h| 1 -
 include/uapi/asm-generic/unistd.h   | 2 +-
 kernel/sys_ni.c | 2 --
 tools/include/uapi/asm-generic/unistd.h | 2 +-
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 2 +-
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 2 +-
 tools/perf/arch/s390/entry/syscalls/syscall.tbl | 2 +-
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 2 +-
 26 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl 
b/arch/alpha/kernel/syscalls/syscall.tbl
index 8ebacf37a8cf..b299f877034e 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -334,7 +334,7 @@
 401common  io_submit   sys_io_submit
 402common  io_cancel   sys_io_cancel
 405common  exit_group  sys_exit_group
-406common  lookup_dcookie  sys_lookup_dcookie
+406common  lookup_dcookie  sys_ni_syscall
 407common  epoll_createsys_epoll_create
 408common  epoll_ctl   sys_epoll_ctl
 409common  epoll_wait  sys_epoll_wait
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index ac964612d8b0..ef9424cebe79 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -263,7 +263,7 @@
 246common  io_submit   sys_io_submit
 247common  io_cancel   sys_io_cancel
 248common  exit_group  sys_exit_group
-249common  lookup_dcookie  sys_lookup_dcookie
+249common  lookup_dcookie  sys_ni_syscall
 250common  epoll_createsys_epoll_create
 251common  epoll_ctl   sys_epoll_ctl   
sys_oabi_epoll_ctl
 252common  epoll_wait  sys_epoll_wait
diff --git a/arch/arm64/include/asm/unistd32.h 
b/arch/arm64/include/asm/unistd32.h
index 604a2053d006..c2e37f6b7d86 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -508,8 +508,8 @@ __SYSCALL(__NR_io_submit, compat_sys_io_submit)
 __SYSCALL(__NR_io_cancel, sys_io_cancel)
 #define __NR_exit_group 248
 __SYSCALL(__NR_exit_group, sys_exit_group)
-#define __NR_lookup_dcookie 249
-__SYSCALL(__NR_lookup_dcookie, compat_sys_lookup_dcookie)
+   /* 249 was lookup_dcookie */
+__SYSCALL(249, sys_ni_syscall)
 #define __NR_epoll_create 250
 __SYSCALL(__NR_epoll_create, sys_epoll_create)
 #define __NR_epoll_ctl 251
diff --git a/arch/ia64/kernel/syscalls/syscall.tbl 
b/arch/ia64/kernel/syscalls/syscall.tbl
index 72c929d9902b..e76e2dcd2f5a 100644
--- a/arch/ia64/kernel/syscalls/syscall.tbl
+++ b/arch/ia64/kernel/syscalls/syscall.tbl
@@ -222,7 +222,7 @@
 210common  fadvise64   sys_fadvise64_64
 211common  tgkill  sys_tgkill
 212common  exit_group  sys_exit_group
-213common  lookup_dcookie  sys_lookup_dcookie
+213common  lookup_dcookie  sys_ni_syscall
 214common  io_setupsys_io_setup
 215common  io_destroy  sys_io_destroy
 216common  io_geteventssys_io_getevents
diff --git a/arch/m68k/kernel/syscalls/sysc

Re: [RFC PATCH 4/6] pkeys: Lift pkey hardware check for pkey_alloc()

2022-06-16 Thread Sohil Mehta




diff --git a/mm/mprotect.c b/mm/mprotect.c
index ba5592655ee3..56d35de33725 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -773,6 +773,9 @@ SYSCALL_DEFINE2(pkey_alloc, unsigned long, flags, unsigned 
long, init_val)
int pkey;
int ret;
  
+	if (!arch_pkeys_enabled())

+   return -ENOSPC;
+


See comments in patch 3/6. Since we are modifying (fixing) old behavior, 
should we just return ENOSYS to make this consistent?


Sohil


/* No flags supported yet. */
if (flags)
return -EINVAL;




Re: [RFC PATCH 3/6] testing/pkeys: Add additional test for pkey_alloc()

2022-06-16 Thread Sohil Mehta

On 6/10/2022 4:35 PM, ira.we...@intel.com wrote:
  
+void test_pkey_alloc_on_unsupported_cpu(void)

+{
+   int test_pkey = sys_pkey_alloc(0, 0);
+
+   dprintf1("pkey_alloc: %d (%d %s)\n", test_pkey, errno,
+strerror(errno));
+   pkey_assert(test_pkey < 0);
+   pkey_assert(errno == ENOSPC);


This assert fails on a kernel with 
CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS disabled.


Since pkey_alloc() is an architecture dependent syscall, ENOSYS is 
returned instead of ENOSPC when support is disabled at compile time.

See kernel/sys_ni.c

This brings us to an interesting question.

Should we have different return error codes when compile support is 
disabled vs when runtime support is missing?


Here is the current behavior for pkey_alloc():

No compile time support -> return ENOSYS
No runtime support (but compile time support present) -> return ENOSPC

I would think applications would prefer the same error code. But, I am 
not sure if we can achieve this now due to ABI reasons.




+}
+


Re: [RFC PATCH 2/6] testing/pkeys: Don't use uninitialized variable

2022-06-14 Thread Sohil Mehta

On 6/10/2022 4:35 PM, ira.we...@intel.com wrote:

diff --git a/tools/testing/selftests/vm/protection_keys.c 
b/tools/testing/selftests/vm/protection_keys.c
index d0183c381859..43e47de19c0d 100644
--- a/tools/testing/selftests/vm/protection_keys.c
+++ b/tools/testing/selftests/vm/protection_keys.c
@@ -1225,9 +1225,9 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey)
int new_pkey;
dprintf1("%s() alloc loop: %d\n", __func__, i);
new_pkey = alloc_pkey();
-   dprintf4("%s()::%d, err: %d pkey_reg: 0x%016llx"
+   dprintf4("%s()::%d, errno: %d pkey_reg: 0x%016llx"


What is errno referring to over here? There are a few things happening 
in alloc_pkey(). I guess it would show the latest error that happened. 
Does errno need to be set to 0 before the call?


Also, would it be useful to print the return value (new_pkey) from 
alloc_pkey() here?



" shadow: 0x%016llx\n",
-   __func__, __LINE__, err, __read_pkey_reg(),
+   __func__, __LINE__, errno, __read_pkey_reg(),
shadow_pkey_reg);
read_pkey_reg(); /* for shadow checking */
dprintf2("%s() errno: %d ENOSPC: %d\n", __func__, errno, 
ENOSPC);


Sohil


Re: [RFC PATCH 1/6] testing/pkeys: Add command line options

2022-06-14 Thread Sohil Mehta

On 6/10/2022 4:35 PM, ira.we...@intel.com wrote:


Add command line options for debug level and number of iterations.

$ ./protection_keys_64 -h
Usage: ./protection_keys_64 [-h,-d,-i ]
 --help,-h   This help
--debug,-d  Increase debug level for each -d


Is this mechanism (of counting d's) commonplace in other selftests as 
well? Looking at the test code for pkeys the debug levels run from 1-5. 
That feels like quite a few d's to input :)


Would it be easier to input the number in the command line directly?

Either way it would be useful to know the debug range in the help.
Maybe something like:
--debug,-d  Increase debug level for each -d (1-5)

The patch seems fine to me otherwise.


--iterations,-i   repeate test  times
default: 22



Thanks,
Sohil


Re: [RFC PATCH 0/6] User pkey minor bug fixes

2022-06-14 Thread Sohil Mehta

On 6/10/2022 4:35 PM, ira.we...@intel.com wrote:



glibc says it returns ENOSYS if the system does not support pkeys but I don't
see where ENOSYS is returned?  AFAICS it just returns what the kernel returns.
So it is probably up to user of glibc.



Implementation of the pkeys system calls is arch specific and 
conditional. See kernel/sys_ni.c


glibc is probably talking about ENOSYS being returned when the 
architecture doesn't have support or the CONFIG option is disabled on 
supported architectures.


Thanks,
Sohil