linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, mingo@redhat.com,
	Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Subject: [PATCH 2/2] x86/unwind/orc: Fix address check size for deref_stack_iret_regs
Date: Tue, 12 Apr 2022 10:40:04 +0300	[thread overview]
Message-ID: <1649749204-186363-2-git-send-email-dmtrmonakhov@yandex-team.ru> (raw)
In-Reply-To: <1649749204-186363-1-git-send-email-dmtrmonakhov@yandex-team.ru>

For historical reasons we check only IRET_FRAME_OFFSET, but this check
is no longer valid because  we also access regs->sp field which is
located beyond IRET_FRAME, so it is reasonable to validate full structure.

Signed-off-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
---
 arch/x86/kernel/unwind_orc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
index 80b878772b86..a249ecabe689 100644
--- a/arch/x86/kernel/unwind_orc.c
+++ b/arch/x86/kernel/unwind_orc.c
@@ -379,7 +379,7 @@ static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr
 {
 	struct pt_regs *regs = (void *)addr - IRET_FRAME_OFFSET;
 
-	if (!stack_access_ok(state, addr, IRET_FRAME_SIZE))
+	if (!stack_access_ok(state, addr, sizeof(struct pt_regs)))
 		return false;
 
 	*ip = READ_ONCE_NOCHECK(regs->ip);
-- 
2.7.4


  reply	other threads:[~2022-04-12  9:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12  7:40 [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Dmitry Monakhov
2022-04-12  7:40 ` Dmitry Monakhov [this message]
2022-04-12 10:01   ` [PATCH 2/2] x86/unwind/orc: Fix address check size for deref_stack_iret_regs Peter Zijlstra
2022-04-12 10:57     ` Dmitry Monakhov
2022-04-12 10:08 ` [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Peter Zijlstra
2022-04-16  0:49   ` Josh Poimboeuf
2022-04-29  5:14   ` [PATCH] perf/amd/ibs: Use interrupt regs ip for stack unwinding Ravi Bangoria
2022-04-29 20:28     ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2022-05-02  6:07     ` [PATCH] " Namhyung Kim
2022-05-04  9:23     ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
2022-05-10  9:11     ` tip-bot2 for Ravi Bangoria
2022-04-12 10:11 ` [PATCH 1/2] x86/unwind/orc: recheck address range after stack info was updated Peter Zijlstra
2022-04-14 15:18   ` Josh Poimboeuf
2022-04-16  0:46 ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1649749204-186363-2-git-send-email-dmtrmonakhov@yandex-team.ru \
    --to=dmtrmonakhov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).