All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] arm64: stack helper cleanups
@ 2022-11-17 12:09 Mark Rutland
  2022-11-17 12:09 ` [PATCH 1/2] arm64: remove current_top_of_stack() Mark Rutland
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mark Rutland @ 2022-11-17 12:09 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: catalin.marinas, keescook, mark.rutland, will

Hi,

These two patches are minor cleanup for the stacktrace helpers, removing 
some dead code and making the header includes a bit easier to follow.

This is effectively some residual cleanup from the STACLKEAK rework in
v5.19, all local to arch/arm64.

Thanks,
Mark.

Mark Rutland (2):
  arm64: remove current_top_of_stack()
  arm64: move on_thread_stack() to <asm/stacktrace.h>

 arch/arm64/include/asm/processor.h  | 13 -------------
 arch/arm64/include/asm/stacktrace.h |  2 ++
 arch/arm64/kernel/irq.c             |  9 +++++----
 3 files changed, 7 insertions(+), 17 deletions(-)

-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/2] arm64: remove current_top_of_stack()
  2022-11-17 12:09 [PATCH 0/2] arm64: stack helper cleanups Mark Rutland
@ 2022-11-17 12:09 ` Mark Rutland
  2022-11-17 15:46   ` Mark Brown
  2022-11-17 22:09   ` Kees Cook
  2022-11-17 12:09 ` [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h> Mark Rutland
  2022-11-18 19:40 ` [PATCH 0/2] arm64: stack helper cleanups Will Deacon
  2 siblings, 2 replies; 8+ messages in thread
From: Mark Rutland @ 2022-11-17 12:09 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: catalin.marinas, keescook, mark.rutland, will

We no longer use current_top_of_stack() on arm64, so it can be removed.

We introduced current_top_of_stack() for STACKLEAK in commit:

  0b3e336601b82c6a ("arm64: Add support for STACKLEAK gcc plugin")

... then we figured out the intended semantics were unclear, and
reworked it in commit:

  e85094c31ddb794a ("arm64: stackleak: fix current_top_of_stack()")

... then we removed the only user in commit:

  0cfa2ccd285d98ad ("stackleak: rework stack high bound handling")

Given that it's no longer used, and it's very easy to misuse, this patch
removes current_top_of_stack(). For the moment, on_thread_stack() is
left where it is as moving it will change some header dependencies.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/processor.h | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 445aa3af3b76..cf4eefaacafc 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -396,17 +396,6 @@ long get_tagged_addr_ctrl(struct task_struct *task);
 #define GET_TAGGED_ADDR_CTRL()		get_tagged_addr_ctrl(current)
 #endif
 
-/*
- * For CONFIG_GCC_PLUGIN_STACKLEAK
- *
- * These need to be macros because otherwise we get stuck in a nightmare
- * of header definitions for the use of task_stack_page.
- */
-
-/*
- * The top of the current task's task stack
- */
-#define current_top_of_stack()	((unsigned long)current->stack + THREAD_SIZE)
 #define on_thread_stack()	(on_task_stack(current, current_stack_pointer, 1))
 
 #endif /* __ASSEMBLY__ */
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h>
  2022-11-17 12:09 [PATCH 0/2] arm64: stack helper cleanups Mark Rutland
  2022-11-17 12:09 ` [PATCH 1/2] arm64: remove current_top_of_stack() Mark Rutland
@ 2022-11-17 12:09 ` Mark Rutland
  2022-11-17 15:47   ` Mark Brown
  2022-11-17 22:09   ` Kees Cook
  2022-11-18 19:40 ` [PATCH 0/2] arm64: stack helper cleanups Will Deacon
  2 siblings, 2 replies; 8+ messages in thread
From: Mark Rutland @ 2022-11-17 12:09 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: catalin.marinas, keescook, mark.rutland, will

Currently on_thread_stack() is defined in <asm/processor.h>, depending
upon definitiong from <asm/stacktrace.h> despite this header not being
included. This ends up being fragile, and any user of on_thread_stack()
must include both <asm/processor.h> and <asm/stacktrace.h>.

We organised things this way due to header dependencies back in commit:

  0b3e336601b82c6a ("arm64: Add support for STACKLEAK gcc plugin")

... but now that we no longer use current_top_of_stack(), and given that
stackleak includes <asm/stacktrace.h> via <linux/stackleak.h>, we no
longer need the definition to live in <asm/processor.h>.

Move on_thread_stack() to <asm/stacktrace.h>, where all its dependencies
are guaranteed to be defined. This requires having arm64's irq.c
explicitly include <asm/stacktrace.h>, and I've taken the opportunity to
sort the includes, which were slightly out of order.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/processor.h  | 2 --
 arch/arm64/include/asm/stacktrace.h | 2 ++
 arch/arm64/kernel/irq.c             | 9 +++++----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index cf4eefaacafc..b15fd6c11294 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -396,7 +396,5 @@ long get_tagged_addr_ctrl(struct task_struct *task);
 #define GET_TAGGED_ADDR_CTRL()		get_tagged_addr_ctrl(current)
 #endif
 
-#define on_thread_stack()	(on_task_stack(current, current_stack_pointer, 1))
-
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_PROCESSOR_H */
diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h
index 5a0edb064ea4..4e5354beafb0 100644
--- a/arch/arm64/include/asm/stacktrace.h
+++ b/arch/arm64/include/asm/stacktrace.h
@@ -57,6 +57,8 @@ static inline bool on_task_stack(const struct task_struct *tsk,
 	return stackinfo_on_stack(&info, sp, size);
 }
 
+#define on_thread_stack()	(on_task_stack(current, current_stack_pointer, 1))
+
 #ifdef CONFIG_VMAP_STACK
 DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);
 
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 38dbd3828f13..0c8e30ff8eaa 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -10,20 +10,21 @@
  * Copyright (C) 2012 ARM Ltd.
  */
 
-#include <linux/irq.h>
-#include <linux/memory.h>
-#include <linux/smp.h>
 #include <linux/hardirq.h>
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/irqchip.h>
 #include <linux/kprobes.h>
+#include <linux/memory.h>
 #include <linux/scs.h>
 #include <linux/seq_file.h>
+#include <linux/smp.h>
 #include <linux/vmalloc.h>
 #include <asm/daifflags.h>
 #include <asm/exception.h>
-#include <asm/vmap_stack.h>
 #include <asm/softirq_stack.h>
+#include <asm/stacktrace.h>
+#include <asm/vmap_stack.h>
 
 /* Only access this in an NMI enter/exit */
 DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] arm64: remove current_top_of_stack()
  2022-11-17 12:09 ` [PATCH 1/2] arm64: remove current_top_of_stack() Mark Rutland
@ 2022-11-17 15:46   ` Mark Brown
  2022-11-17 22:09   ` Kees Cook
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-11-17 15:46 UTC (permalink / raw)
  To: Mark Rutland; +Cc: linux-arm-kernel, catalin.marinas, keescook, will


[-- Attachment #1.1: Type: text/plain, Size: 255 bytes --]

On Thu, Nov 17, 2022 at 12:09:01PM +0000, Mark Rutland wrote:
> We no longer use current_top_of_stack() on arm64, so it can be removed.
> 
> We introduced current_top_of_stack() for STACKLEAK in commit:

Reviewed-by: Mark Brown <broonie@kernel.org>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h>
  2022-11-17 12:09 ` [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h> Mark Rutland
@ 2022-11-17 15:47   ` Mark Brown
  2022-11-17 22:09   ` Kees Cook
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-11-17 15:47 UTC (permalink / raw)
  To: Mark Rutland; +Cc: linux-arm-kernel, catalin.marinas, keescook, will


[-- Attachment #1.1: Type: text/plain, Size: 390 bytes --]

On Thu, Nov 17, 2022 at 12:09:02PM +0000, Mark Rutland wrote:
> Currently on_thread_stack() is defined in <asm/processor.h>, depending
> upon definitiong from <asm/stacktrace.h> despite this header not being
> included. This ends up being fragile, and any user of on_thread_stack()
> must include both <asm/processor.h> and <asm/stacktrace.h>.

Reviewed-by: Mark Brown <broonie@kernel.org>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] arm64: remove current_top_of_stack()
  2022-11-17 12:09 ` [PATCH 1/2] arm64: remove current_top_of_stack() Mark Rutland
  2022-11-17 15:46   ` Mark Brown
@ 2022-11-17 22:09   ` Kees Cook
  1 sibling, 0 replies; 8+ messages in thread
From: Kees Cook @ 2022-11-17 22:09 UTC (permalink / raw)
  To: Mark Rutland; +Cc: linux-arm-kernel, catalin.marinas, will

On Thu, Nov 17, 2022 at 12:09:01PM +0000, Mark Rutland wrote:
> We no longer use current_top_of_stack() on arm64, so it can be removed.
> 
> We introduced current_top_of_stack() for STACKLEAK in commit:
> 
>   0b3e336601b82c6a ("arm64: Add support for STACKLEAK gcc plugin")
> 
> ... then we figured out the intended semantics were unclear, and
> reworked it in commit:
> 
>   e85094c31ddb794a ("arm64: stackleak: fix current_top_of_stack()")
> 
> ... then we removed the only user in commit:
> 
>   0cfa2ccd285d98ad ("stackleak: rework stack high bound handling")
> 
> Given that it's no longer used, and it's very easy to misuse, this patch
> removes current_top_of_stack(). For the moment, on_thread_stack() is
> left where it is as moving it will change some header dependencies.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h>
  2022-11-17 12:09 ` [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h> Mark Rutland
  2022-11-17 15:47   ` Mark Brown
@ 2022-11-17 22:09   ` Kees Cook
  1 sibling, 0 replies; 8+ messages in thread
From: Kees Cook @ 2022-11-17 22:09 UTC (permalink / raw)
  To: Mark Rutland; +Cc: linux-arm-kernel, catalin.marinas, will

On Thu, Nov 17, 2022 at 12:09:02PM +0000, Mark Rutland wrote:
> Currently on_thread_stack() is defined in <asm/processor.h>, depending
> upon definitiong from <asm/stacktrace.h> despite this header not being
> included. This ends up being fragile, and any user of on_thread_stack()
> must include both <asm/processor.h> and <asm/stacktrace.h>.
> 
> We organised things this way due to header dependencies back in commit:
> 
>   0b3e336601b82c6a ("arm64: Add support for STACKLEAK gcc plugin")
> 
> ... but now that we no longer use current_top_of_stack(), and given that
> stackleak includes <asm/stacktrace.h> via <linux/stackleak.h>, we no
> longer need the definition to live in <asm/processor.h>.
> 
> Move on_thread_stack() to <asm/stacktrace.h>, where all its dependencies
> are guaranteed to be defined. This requires having arm64's irq.c
> explicitly include <asm/stacktrace.h>, and I've taken the opportunity to
> sort the includes, which were slightly out of order.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/2] arm64: stack helper cleanups
  2022-11-17 12:09 [PATCH 0/2] arm64: stack helper cleanups Mark Rutland
  2022-11-17 12:09 ` [PATCH 1/2] arm64: remove current_top_of_stack() Mark Rutland
  2022-11-17 12:09 ` [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h> Mark Rutland
@ 2022-11-18 19:40 ` Will Deacon
  2 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2022-11-18 19:40 UTC (permalink / raw)
  To: linux-arm-kernel, Mark Rutland
  Cc: catalin.marinas, kernel-team, Will Deacon, keescook

On Thu, 17 Nov 2022 12:09:00 +0000, Mark Rutland wrote:
> These two patches are minor cleanup for the stacktrace helpers, removing
> some dead code and making the header includes a bit easier to follow.
> 
> This is effectively some residual cleanup from the STACLKEAK rework in
> v5.19, all local to arch/arm64.
> 
> Thanks,
> Mark.
> 
> [...]

Applied to arm64 (for-next/stacks), thanks!

[1/2] arm64: remove current_top_of_stack()
      https://git.kernel.org/arm64/c/c8c384d7b397
[2/2] arm64: move on_thread_stack() to <asm/stacktrace.h>
      https://git.kernel.org/arm64/c/4585a934203d

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-11-18 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 12:09 [PATCH 0/2] arm64: stack helper cleanups Mark Rutland
2022-11-17 12:09 ` [PATCH 1/2] arm64: remove current_top_of_stack() Mark Rutland
2022-11-17 15:46   ` Mark Brown
2022-11-17 22:09   ` Kees Cook
2022-11-17 12:09 ` [PATCH 2/2] arm64: move on_thread_stack() to <asm/stacktrace.h> Mark Rutland
2022-11-17 15:47   ` Mark Brown
2022-11-17 22:09   ` Kees Cook
2022-11-18 19:40 ` [PATCH 0/2] arm64: stack helper cleanups Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.