* [tip: x86/shstk] x86/shstk: Check that SSP is aligned on sigreturn
@ 2023-07-19 22:47 tip-bot2 for Rick Edgecombe
0 siblings, 0 replies; 3+ messages in thread
From: tip-bot2 for Rick Edgecombe @ 2023-07-19 22:47 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Rick Edgecombe, Dave Hansen, x86, linux-kernel
The following commit has been merged into the x86/shstk branch of tip:
Commit-ID: 580c301b703f720a18bf0a03cedf57f961d80eea
Gitweb: https://git.kernel.org/tip/580c301b703f720a18bf0a03cedf57f961d80eea
Author: Rick Edgecombe <rick.p.edgecombe@intel.com>
AuthorDate: Mon, 12 Jun 2023 17:10:58 -07:00
Committer: Rick Edgecombe <rick.p.edgecombe@intel.com>
CommitterDate: Tue, 11 Jul 2023 14:12:50 -07:00
x86/shstk: Check that SSP is aligned on sigreturn
The shadow stack signal frame is read by the kernel on sigreturn. It
relies on shadow stack memory protections to prevent forgeries of this
signal frame (which included the pre-signal SSP). It also relies on the
shadow stack signal frame to have bit 63 set. Since this bit would not be
set via typical shadow stack operations, so the kernel can assume it was a
value it placed there.
However, in order to support 32 bit shadow stack, the INCSSPD instruction
can increment the shadow stack by 4 bytes. In this case SSP might be
pointing to a region spanning two 8 byte shadow stack frames. It could
confuse the checks described above.
Since the kernel only supports shadow stack in 64 bit, just check that
the SSP is 8 byte aligned in the sigreturn path.
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/20230613001108.3040476-33-rick.p.edgecombe%40intel.com
---
arch/x86/kernel/shstk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
index f02e8ea..a8705f7 100644
--- a/arch/x86/kernel/shstk.c
+++ b/arch/x86/kernel/shstk.c
@@ -252,6 +252,9 @@ static int shstk_pop_sigframe(unsigned long *ssp)
unsigned long token_addr;
int err;
+ if (!IS_ALIGNED(*ssp, 8))
+ return -EINVAL;
+
err = get_shstk_data(&token_addr, (unsigned long __user *)*ssp);
if (unlikely(err))
return err;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: x86/shstk] x86/shstk: Check that SSP is aligned on sigreturn
@ 2023-08-02 22:19 tip-bot2 for Rick Edgecombe
0 siblings, 0 replies; 3+ messages in thread
From: tip-bot2 for Rick Edgecombe @ 2023-08-02 22:19 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Rick Edgecombe, Dave Hansen, x86, linux-kernel
The following commit has been merged into the x86/shstk branch of tip:
Commit-ID: b93d6c78829ad1e22486ccc93d04bf77e45597df
Gitweb: https://git.kernel.org/tip/b93d6c78829ad1e22486ccc93d04bf77e45597df
Author: Rick Edgecombe <rick.p.edgecombe@intel.com>
AuthorDate: Mon, 12 Jun 2023 17:10:58 -07:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Wed, 02 Aug 2023 15:01:50 -07:00
x86/shstk: Check that SSP is aligned on sigreturn
The shadow stack signal frame is read by the kernel on sigreturn. It
relies on shadow stack memory protections to prevent forgeries of this
signal frame (which included the pre-signal SSP). It also relies on the
shadow stack signal frame to have bit 63 set. Since this bit would not be
set via typical shadow stack operations, so the kernel can assume it was a
value it placed there.
However, in order to support 32 bit shadow stack, the INCSSPD instruction
can increment the shadow stack by 4 bytes. In this case SSP might be
pointing to a region spanning two 8 byte shadow stack frames. It could
confuse the checks described above.
Since the kernel only supports shadow stack in 64 bit, just check that
the SSP is 8 byte aligned in the sigreturn path.
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/20230613001108.3040476-33-rick.p.edgecombe%40intel.com
---
arch/x86/kernel/shstk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
index f02e8ea..a8705f7 100644
--- a/arch/x86/kernel/shstk.c
+++ b/arch/x86/kernel/shstk.c
@@ -252,6 +252,9 @@ static int shstk_pop_sigframe(unsigned long *ssp)
unsigned long token_addr;
int err;
+ if (!IS_ALIGNED(*ssp, 8))
+ return -EINVAL;
+
err = get_shstk_data(&token_addr, (unsigned long __user *)*ssp);
if (unlikely(err))
return err;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: x86/shstk] x86/shstk: Check that SSP is aligned on sigreturn
@ 2023-06-16 19:16 tip-bot2 for Rick Edgecombe
0 siblings, 0 replies; 3+ messages in thread
From: tip-bot2 for Rick Edgecombe @ 2023-06-16 19:16 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Rick Edgecombe, Dave Hansen, x86, linux-kernel
The following commit has been merged into the x86/shstk branch of tip:
Commit-ID: 1d784497577b8f30374e4c0f12fbf1cb98986416
Gitweb: https://git.kernel.org/tip/1d784497577b8f30374e4c0f12fbf1cb98986416
Author: Rick Edgecombe <rick.p.edgecombe@intel.com>
AuthorDate: Mon, 12 Jun 2023 17:10:58 -07:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Thu, 15 Jun 2023 16:31:34 -07:00
x86/shstk: Check that SSP is aligned on sigreturn
The shadow stack signal frame is read by the kernel on sigreturn. It
relies on shadow stack memory protections to prevent forgeries of this
signal frame (which included the pre-signal SSP). It also relies on the
shadow stack signal frame to have bit 63 set. Since this bit would not be
set via typical shadow stack operations, so the kernel can assume it was a
value it placed there.
However, in order to support 32 bit shadow stack, the INCSSPD instruction
can increment the shadow stack by 4 bytes. In this case SSP might be
pointing to a region spanning two 8 byte shadow stack frames. It could
confuse the checks described above.
Since the kernel only supports shadow stack in 64 bit, just check that
the SSP is 8 byte aligned in the sigreturn path.
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/20230613001108.3040476-33-rick.p.edgecombe%40intel.com
---
arch/x86/kernel/shstk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
index f02e8ea..a8705f7 100644
--- a/arch/x86/kernel/shstk.c
+++ b/arch/x86/kernel/shstk.c
@@ -252,6 +252,9 @@ static int shstk_pop_sigframe(unsigned long *ssp)
unsigned long token_addr;
int err;
+ if (!IS_ALIGNED(*ssp, 8))
+ return -EINVAL;
+
err = get_shstk_data(&token_addr, (unsigned long __user *)*ssp);
if (unlikely(err))
return err;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-02 22:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-19 22:47 [tip: x86/shstk] x86/shstk: Check that SSP is aligned on sigreturn tip-bot2 for Rick Edgecombe
-- strict thread matches above, loose matches on Subject: below --
2023-08-02 22:19 tip-bot2 for Rick Edgecombe
2023-06-16 19:16 tip-bot2 for Rick Edgecombe
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®