mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS
@ 2025-06-07 13:15 wangfushuai
  2025-06-07 18:17 ` David Hildenbrand
  2025-06-07 21:31 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: wangfushuai @ 2025-06-07 13:15 UTC (permalink / raw)
  To: akpm, david, andrii, osalvador, Liam.Howlett, christophe.leroy
  Cc: linux-kernel, linux-fsdevel, wangfushuai

The recent commit adding VM_SHADOW_STACK for arm64 GCS did not update
the /proc/[pid]/smaps display logic to show the "ss" flag for GCS pages.
This patch adds the necessary condition to display "ss" flag.

Fixes: ae80e1629aea ("mm: Define VM_SHADOW_STACK for arm64 when we support GCS")
Signed-off-by: wangfushuai <wangfushuai@baidu.com>
---
 fs/proc/task_mmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 27972c0749e7..2c2ee893a797 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -994,6 +994,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
 #ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK
 		[ilog2(VM_SHADOW_STACK)] = "ss",
 #endif
+#if defined(CONFIG_ARM64_GCS)
+		[ilog2(VM_SHADOW_STACK)] = "ss",
+#endif
 #if defined(CONFIG_64BIT) || defined(CONFIG_PPC32)
 		[ilog2(VM_DROPPABLE)] = "dp",
 #endif
-- 
2.36.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS
  2025-06-07 13:15 [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS wangfushuai
@ 2025-06-07 18:17 ` David Hildenbrand
  2025-06-07 21:31 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2025-06-07 18:17 UTC (permalink / raw)
  To: wangfushuai, akpm, andrii, osalvador, Liam.Howlett, christophe.leroy
  Cc: linux-kernel, linux-fsdevel

On 07.06.25 15:15, wangfushuai wrote:
> The recent commit adding VM_SHADOW_STACK for arm64 GCS did not update
> the /proc/[pid]/smaps display logic to show the "ss" flag for GCS pages.
> This patch adds the necessary condition to display "ss" flag.
> 
> Fixes: ae80e1629aea ("mm: Define VM_SHADOW_STACK for arm64 when we support GCS")
> Signed-off-by: wangfushuai <wangfushuai@baidu.com>
> ---
>   fs/proc/task_mmu.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 27972c0749e7..2c2ee893a797 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -994,6 +994,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
>   #ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK
>   		[ilog2(VM_SHADOW_STACK)] = "ss",
>   #endif
> +#if defined(CONFIG_ARM64_GCS)
> +		[ilog2(VM_SHADOW_STACK)] = "ss",
> +#endif

Which makes me wonder why we don't select 
CONFIG_ARCH_HAS_USER_SHADOW_STACK for CONFIG_ARM64_GCS?

>   #if defined(CONFIG_64BIT) || defined(CONFIG_PPC32)
>   		[ilog2(VM_DROPPABLE)] = "dp",
>   #endif


-- 
Cheers,

David / dhildenb


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS
  2025-06-07 13:15 [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS wangfushuai
  2025-06-07 18:17 ` David Hildenbrand
@ 2025-06-07 21:31 ` Andrew Morton
  2025-06-08  7:35   ` wangfushuai
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2025-06-07 21:31 UTC (permalink / raw)
  To: wangfushuai
  Cc: david, andrii, osalvador, Liam.Howlett, christophe.leroy,
	linux-kernel, linux-fsdevel, Mark Brown, Catalin Marinas

On Sat, 7 Jun 2025 21:15:25 +0800 wangfushuai <wangfushuai@baidu.com> wrote:

> The recent commit adding VM_SHADOW_STACK for arm64 GCS did not update
> the /proc/[pid]/smaps display logic to show the "ss" flag for GCS pages.
> This patch adds the necessary condition to display "ss" flag.
> 
> ...
>
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -994,6 +994,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
>  #ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK
>  		[ilog2(VM_SHADOW_STACK)] = "ss",
>  #endif
> +#if defined(CONFIG_ARM64_GCS)
> +		[ilog2(VM_SHADOW_STACK)] = "ss",
> +#endif
>  #if defined(CONFIG_64BIT) || defined(CONFIG_PPC32)
>  		[ilog2(VM_DROPPABLE)] = "dp",
>  #endif

It is possible to have CONFIG_ARM64_GCS=y when
CONFIG_ARCH_HAS_USER_SHADOW_STACK=n?  If so, is this a correct
combination?


Also, wouldn't it be nicer to code this as 

--- a/fs/proc/task_mmu.c~a
+++ a/fs/proc/task_mmu.c
@@ -991,7 +991,7 @@ static void show_smap_vma_flags(struct s
 #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
 		[ilog2(VM_UFFD_MINOR)]	= "ui",
 #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
-#ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK
+#if defined(CONFIG_ARCH_HAS_USER_SHADOW_STACK) || defined(CONFIG_ARM64_GCS)
 		[ilog2(VM_SHADOW_STACK)] = "ss",
 #endif
 #if defined(CONFIG_64BIT) || defined(CONFIG_PPC32)
_




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS
  2025-06-07 21:31 ` Andrew Morton
@ 2025-06-08  7:35   ` wangfushuai
  0 siblings, 0 replies; 4+ messages in thread
From: wangfushuai @ 2025-06-08  7:35 UTC (permalink / raw)
  To: akpm
  Cc: Liam.Howlett, andrii, broonie, catalin.marinas, christophe.leroy,
	david, linux-fsdevel, linux-kernel, osalvador, wangfushuai

>> The recent commit adding VM_SHADOW_STACK for arm64 GCS did not update
>> the /proc/[pid]/smaps display logic to show the "ss" flag for GCS pages.
>> This patch adds the necessary condition to display "ss" flag.
>> 
>> ...
>>
>> --- a/fs/proc/task_mmu.c
>> +++ b/fs/proc/task_mmu.c
>> @@ -994,6 +994,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
>>  #ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK
>>  		[ilog2(VM_SHADOW_STACK)] = "ss",
>>  #endif
>> +#if defined(CONFIG_ARM64_GCS)
>> +		[ilog2(VM_SHADOW_STACK)] = "ss",
>> +#endif
>>  #if defined(CONFIG_64BIT) || defined(CONFIG_PPC32)
>>  		[ilog2(VM_DROPPABLE)] = "dp",
>>  #endif
> 
> It is possible to have CONFIG_ARM64_GCS=y when
> CONFIG_ARCH_HAS_USER_SHADOW_STACK=n?  If so, is this a correct
> combination?
Hi, Morton
After revisiting the code logic, I realized that if CONFIG_ARM64_GCS is enabled,
CONFIG_ARCH_HAS_USER_SHADOW_STACK will always be enabled as well. Therefore,
it seems unnecessary to add separate VM_SHADOW_STACK support specifically for
CONFIG_ARM64_GCS at this stage.

I will make sure to review future patches more carefully to avoid such oversights.

Regards,
Wang
> 
> 
> Also, wouldn't it be nicer to code this as 
> 
> --- a/fs/proc/task_mmu.c~a
> +++ a/fs/proc/task_mmu.c
> @@ -991,7 +991,7 @@ static void show_smap_vma_flags(struct s
>  #ifdef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
>  		[ilog2(VM_UFFD_MINOR)]	= "ui",
>  #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
> -#ifdef CONFIG_ARCH_HAS_USER_SHADOW_STACK
> +#if defined(CONFIG_ARCH_HAS_USER_SHADOW_STACK) || defined(CONFIG_ARM64_GCS)
>  		[ilog2(VM_SHADOW_STACK)] = "ss",
>  #endif
>  #if defined(CONFIG_64BIT) || defined(CONFIG_PPC32)
> _
> --

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-08  7:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-07 13:15 [PATCH v2] fs/proc/task_mmu: add VM_SHADOW_STACK for arm64 when support GCS wangfushuai
2025-06-07 18:17 ` David Hildenbrand
2025-06-07 21:31 ` Andrew Morton
2025-06-08  7:35   ` wangfushuai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®