From: "tip-bot2 for Joerg Roedel" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Joerg Roedel <jroedel@suse.de>, Borislav Petkov <bp@suse.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/sev] x86/insn-eval: Make 0 a valid RIP for insn_get_effective_ip()
Date: Tue, 15 Jun 2021 10:51:57 -0000 [thread overview]
Message-ID: <162375431710.19906.15502392185639709333.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210614135327.9921-5-joro@8bytes.org>
The following commit has been merged into the x86/sev branch of tip:
Commit-ID: f2df15639e44d23bf82a86a03092472c7278cd39
Gitweb: https://git.kernel.org/tip/f2df15639e44d23bf82a86a03092472c7278cd39
Author: Joerg Roedel <jroedel@suse.de>
AuthorDate: Wed, 19 May 2021 15:52:49 +02:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Tue, 15 Jun 2021 11:24:21 +02:00
x86/insn-eval: Make 0 a valid RIP for insn_get_effective_ip()
In theory, 0 is a valid value for the instruction pointer so don't use
it as the error return value from insn_get_effective_ip().
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210614135327.9921-5-joro@8bytes.org
---
arch/x86/lib/insn-eval.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c
index a67afd7..4eecb9c 100644
--- a/arch/x86/lib/insn-eval.c
+++ b/arch/x86/lib/insn-eval.c
@@ -1417,7 +1417,7 @@ void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)
}
}
-static unsigned long insn_get_effective_ip(struct pt_regs *regs)
+static int insn_get_effective_ip(struct pt_regs *regs, unsigned long *ip)
{
unsigned long seg_base = 0;
@@ -1430,10 +1430,12 @@ static unsigned long insn_get_effective_ip(struct pt_regs *regs)
if (!user_64bit_mode(regs)) {
seg_base = insn_get_seg_base(regs, INAT_SEG_REG_CS);
if (seg_base == -1L)
- return 0;
+ return -EINVAL;
}
- return seg_base + regs->ip;
+ *ip = seg_base + regs->ip;
+
+ return 0;
}
/**
@@ -1455,8 +1457,7 @@ int insn_fetch_from_user(struct pt_regs *regs, unsigned char buf[MAX_INSN_SIZE])
unsigned long ip;
int not_copied;
- ip = insn_get_effective_ip(regs);
- if (!ip)
+ if (insn_get_effective_ip(regs, &ip))
return 0;
not_copied = copy_from_user(buf, (void __user *)ip, MAX_INSN_SIZE);
@@ -1484,8 +1485,7 @@ int insn_fetch_from_user_inatomic(struct pt_regs *regs, unsigned char buf[MAX_IN
unsigned long ip;
int not_copied;
- ip = insn_get_effective_ip(regs);
- if (!ip)
+ if (insn_get_effective_ip(regs, &ip))
return 0;
not_copied = __copy_from_user_inatomic(buf, (void __user *)ip, MAX_INSN_SIZE);
next prev parent reply other threads:[~2021-06-15 10:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-14 13:53 [PATCH v5 0/6] x86/sev-es: Fixes for SEV-ES Guest Support Joerg Roedel
2021-06-14 13:53 ` [PATCH v5 1/6] x86/sev-es: Fix error message in runtime #VC handler Joerg Roedel
2021-06-15 10:51 ` [tip: x86/sev] x86/sev: " tip-bot2 for Joerg Roedel
2021-06-14 13:53 ` [PATCH v5 2/6] x86/sev-es: Make sure IRQs are disabled while GHCB is active Joerg Roedel
2021-06-14 16:25 ` Borislav Petkov
2021-06-14 16:30 ` Borislav Petkov
2021-06-15 9:37 ` Joerg Roedel
2021-06-14 13:53 ` [PATCH v5 3/6] x86/sev-es: Split up runtime #VC handler for correct state tracking Joerg Roedel
2021-06-16 16:04 ` Peter Zijlstra
2021-06-16 19:01 ` Joerg Roedel
2021-06-14 13:53 ` [PATCH v5 4/6] x86/insn-eval: Make 0 a valid RIP for insn_get_effective_ip() Joerg Roedel
2021-06-15 10:51 ` tip-bot2 for Joerg Roedel [this message]
2021-06-14 13:53 ` [PATCH v5 5/6] x86/insn: Extend error reporting from insn_fetch_from_user[_inatomic]() Joerg Roedel
2021-06-15 10:51 ` [tip: x86/sev] " tip-bot2 for Joerg Roedel
2021-06-14 13:53 ` [PATCH v5 6/6] x86/sev-es: Propagate #GP if getting linear instruction address failed Joerg Roedel
2021-06-15 10:51 ` [tip: x86/sev] x86/sev: " tip-bot2 for Joerg Roedel
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=162375431710.19906.15502392185639709333.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@suse.de \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--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
all inboxes | Powered by JetHome®