[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-ed594e4ba5bfe268d63d7cee3c1a827e3dd5056f@git.kernel.org>
Date: Wed, 1 Nov 2017 13:58:52 -0700
From: tip-bot for Ricardo Neri <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: jslaby@...e.cz, acme@...hat.com, shuah@...nel.org,
pbonzini@...hat.com, dave.hansen@...ux.intel.com,
peterz@...radead.org, hpa@...or.com, keescook@...omium.org,
ray.huang@....com, slaoub@...il.com, adrian.hunter@...el.com,
qiaowei.ren@...el.com, mst@...hat.com, ravi.v.shankar@...el.com,
akpm@...ux-foundation.org, cmetcalf@...lanox.com,
dvyukov@...gle.com, mhiramat@...nel.org,
linux-kernel@...r.kernel.org, brgerst@...il.com, mingo@...nel.org,
lstoakes@...il.com, bp@...e.de, colin.king@...onical.com,
vbabka@...e.cz, tglx@...utronix.de,
ricardo.neri-calderon@...ux.intel.com, adam.buchbinder@...il.com,
thgarnie@...gle.com, corbet@....net, luto@...nel.org,
paul.gortmaker@...driver.com
Subject: [tip:x86/mpx] x86/insn-eval: Do not BUG on invalid register type
Commit-ID: ed594e4ba5bfe268d63d7cee3c1a827e3dd5056f
Gitweb: https://git.kernel.org/tip/ed594e4ba5bfe268d63d7cee3c1a827e3dd5056f
Author: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
AuthorDate: Fri, 27 Oct 2017 13:25:37 -0700
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Wed, 1 Nov 2017 21:50:10 +0100
x86/insn-eval: Do not BUG on invalid register type
We are not in a critical failure path. The invalid register type is caused
when trying to decode invalid instruction bytes from a user-space program.
Thus, simply print an error message. To prevent this warning from being
abused from user space programs, use the rate-limited variant of pr_err().
along with a descriptive prefix.
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Borislav Petkov <bp@...e.de>
Cc: "Michael S. Tsirkin" <mst@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: ricardo.neri@...el.com
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Paul Gortmaker <paul.gortmaker@...driver.com>
Cc: Huang Rui <ray.huang@....com>
Cc: Qiaowei Ren <qiaowei.ren@...el.com>
Cc: Shuah Khan <shuah@...nel.org>
Cc: Kees Cook <keescook@...omium.org>
Cc: Jonathan Corbet <corbet@....net>
Cc: Jiri Slaby <jslaby@...e.cz>
Cc: Dmitry Vyukov <dvyukov@...gle.com>
Cc: "Ravi V. Shankar" <ravi.v.shankar@...el.com>
Cc: Chris Metcalf <cmetcalf@...lanox.com>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Colin Ian King <colin.king@...onical.com>
Cc: Chen Yucong <slaoub@...il.com>
Cc: Adam Buchbinder <adam.buchbinder@...il.com>
Cc: Vlastimil Babka <vbabka@...e.cz>
Cc: Lorenzo Stoakes <lstoakes@...il.com>
Cc: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Thomas Garnier <thgarnie@...gle.com>
Link: https://lkml.kernel.org/r/1509135945-13762-11-git-send-email-ricardo.neri-calderon@linux.intel.com
---
arch/x86/lib/insn-eval.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c
index df9418c..4931d92 100644
--- a/arch/x86/lib/insn-eval.c
+++ b/arch/x86/lib/insn-eval.c
@@ -5,10 +5,14 @@
*/
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/ratelimit.h>
#include <asm/inat.h>
#include <asm/insn.h>
#include <asm/insn-eval.h>
+#undef pr_fmt
+#define pr_fmt(fmt) "insn: " fmt
+
enum reg_type {
REG_TYPE_RM = 0,
REG_TYPE_INDEX,
@@ -85,9 +89,8 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
break;
default:
- pr_err("invalid register type");
- BUG();
- break;
+ pr_err_ratelimited("invalid register type: %d\n", type);
+ return -EINVAL;
}
if (regno >= nr_registers) {
Powered by blists - more mailing lists