Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Maneesh Soni <manesoni@cisco.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: David Daney <david.daney@cavium.com>,
	ananth@in.ibm.com, kamensky@cisco.com,
	linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: [PATCH 2/4] MIPS Kprobes: Deny probes on ll/sc instructions
Date: Tue, 8 Nov 2011 22:35:35 +0530	[thread overview]
Message-ID: <20111108170535.GC16526@cisco.com> (raw)
In-Reply-To: <20111108170336.GA16526@cisco.com>


From: Maneesh Soni <manesoni@cisco.com>

Deny probes on ll/sc instructions for MIPS kprobes

As ll/sc instruction are for atomic read-modify-write operations, allowing
probes on top of these insturctions is a bad idea.

Signed-off-by: Victor Kamensky <kamensky@cisco.com>
Signed-off-by: Maneesh Soni <manesoni@cisco.com>
---
 arch/mips/kernel/kprobes.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/mips/kernel/kprobes.c b/arch/mips/kernel/kprobes.c
index 9fb1876..0ab1a5f 100644
--- a/arch/mips/kernel/kprobes.c
+++ b/arch/mips/kernel/kprobes.c
@@ -113,6 +113,30 @@ insn_ok:
 	return 0;
 }
 
+/*
+ * insn_has_ll_or_sc function checks whether instruction is ll or sc
+ * one; putting breakpoint on top of atomic ll/sc pair is bad idea;
+ * so we need to prevent it and refuse kprobes insertion for such
+ * instructions; cannot do much about breakpoint in the middle of
+ * ll/sc pair; it is upto user to avoid those places
+ */
+static int __kprobes insn_has_ll_or_sc(union mips_instruction insn)
+{
+	int ret = 0;
+
+	switch (insn.i_format.opcode) {
+	case ll_op:
+	case lld_op:
+	case sc_op:
+	case scd_op:
+		ret = 1;
+		break;
+	default:
+		break;
+	}
+	return ret;
+}
+
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
 	union mips_instruction insn;
@@ -121,6 +145,13 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 
 	insn = p->addr[0];
 
+	if (insn_has_ll_or_sc(insn)) {
+		pr_notice("Kprobes for ll and sc instructions are not"
+			  "supported\n");
+		ret = -EINVAL;
+		goto out;
+	}
+
 	if (insn_has_delayslot(insn)) {
 		pr_notice("Kprobes for branch and jump instructions are not"
 			  "supported\n");
-- 
1.7.1

  parent reply	other threads:[~2011-11-08 17:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 17:03 [PATCH 0/4] MIPS Kprobes Maneesh Soni
2011-11-08 17:04 ` [PATCH 1/4] MIPS Kprobes: Fix OOPS in arch_prepare_kprobe() Maneesh Soni
2011-11-08 19:57   ` David Daney
2011-11-09  5:26     ` Maneesh Soni
2011-11-17 23:17   ` Ralf Baechle
2011-11-08 17:05 ` Maneesh Soni [this message]
2011-11-08 20:01   ` [PATCH 2/4] MIPS Kprobes: Deny probes on ll/sc instructions David Daney
2011-11-08 23:26     ` Victor Kamensky
2011-11-16 12:12       ` Ralf Baechle
2011-11-16 17:39         ` Victor Kamensky
2011-11-17 23:18   ` Ralf Baechle
2011-11-08 17:07 ` [PATCH 3/4] MIPS Kprobes: Refactoring Branch emulation Maneesh Soni
2011-11-17 23:18   ` Ralf Baechle
2011-11-08 17:08 ` [PATCH 4/4] MIPS Kprobes: Support branch instructions probing - v2 Maneesh Soni
2011-11-17 23:18   ` Ralf Baechle

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=20111108170535.GC16526@cisco.com \
    --to=manesoni@cisco.com \
    --cc=ananth@in.ibm.com \
    --cc=david.daney@cavium.com \
    --cc=kamensky@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.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