aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2018-06-19 12:05:07 -0400
committerIngo Molnar <mingo@kernel.org>2018-06-21 06:33:05 -0400
commit5a6cf77f5e35e7af35d36a1e7dc21a42f6412e4f (patch)
tree9771cda2ff6de0459f071d650d889a1d5e2b620d
parentbc8c9da5a24bb5087197820a2ccabd9c37627035 (diff)
kprobes: Remove jprobe API implementation
Remove functionally empty jprobe API implementations and test cases. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: linux-arch@vger.kernel.org Link: https://lore.kernel.org/lkml/152942430705.15209.2307050500995264322.stgit@devbox Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--include/linux/kprobes.h3
-rw-r--r--kernel/kprobes.c78
-rw-r--r--kernel/test_kprobes.c94
-rw-r--r--lib/Kconfig.debug2
4 files changed, 2 insertions, 175 deletions
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 9440a2fc8893..b520baa65682 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -389,9 +389,6 @@ int register_kprobe(struct kprobe *p);
389void unregister_kprobe(struct kprobe *p); 389void unregister_kprobe(struct kprobe *p);
390int register_kprobes(struct kprobe **kps, int num); 390int register_kprobes(struct kprobe **kps, int num);
391void unregister_kprobes(struct kprobe **kps, int num); 391void unregister_kprobes(struct kprobe **kps, int num);
392int setjmp_pre_handler(struct kprobe *, struct pt_regs *);
393int longjmp_break_handler(struct kprobe *, struct pt_regs *);
394void jprobe_return(void);
395unsigned long arch_deref_entry_point(void *); 392unsigned long arch_deref_entry_point(void *);
396 393
397int register_kretprobe(struct kretprobe *rp); 394int register_kretprobe(struct kretprobe *rp);
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ea619021d901..69de130595f7 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1272,7 +1272,7 @@ NOKPROBE_SYMBOL(cleanup_rp_inst);
1272 1272
1273/* 1273/*
1274* Add the new probe to ap->list. Fail if this is the 1274* Add the new probe to ap->list. Fail if this is the
1275* second jprobe at the address - two jprobes can't coexist 1275* second break_handler at the address
1276*/ 1276*/
1277static int add_new_kprobe(struct kprobe *ap, struct kprobe *p) 1277static int add_new_kprobe(struct kprobe *ap, struct kprobe *p)
1278{ 1278{
@@ -1812,77 +1812,6 @@ unsigned long __weak arch_deref_entry_point(void *entry)
1812 return (unsigned long)entry; 1812 return (unsigned long)entry;
1813} 1813}
1814 1814
1815#if 0
1816int register_jprobes(struct jprobe **jps, int num)
1817{
1818 int ret = 0, i;
1819
1820 if (num <= 0)
1821 return -EINVAL;
1822
1823 for (i = 0; i < num; i++) {
1824 ret = register_jprobe(jps[i]);
1825
1826 if (ret < 0) {
1827 if (i > 0)
1828 unregister_jprobes(jps, i);
1829 break;
1830 }
1831 }
1832
1833 return ret;
1834}
1835EXPORT_SYMBOL_GPL(register_jprobes);
1836
1837int register_jprobe(struct jprobe *jp)
1838{
1839 unsigned long addr, offset;
1840 struct kprobe *kp = &jp->kp;
1841
1842 /*
1843 * Verify probepoint as well as the jprobe handler are
1844 * valid function entry points.
1845 */
1846 addr = arch_deref_entry_point(jp->entry);
1847
1848 if (kallsyms_lookup_size_offset(addr, NULL, &offset) && offset == 0 &&
1849 kprobe_on_func_entry(kp->addr, kp->symbol_name, kp->offset)) {
1850 kp->pre_handler = setjmp_pre_handler;
1851 kp->break_handler = longjmp_break_handler;
1852 return register_kprobe(kp);
1853 }
1854
1855 return -EINVAL;
1856}
1857EXPORT_SYMBOL_GPL(register_jprobe);
1858
1859void unregister_jprobe(struct jprobe *jp)
1860{
1861 unregister_jprobes(&jp, 1);
1862}
1863EXPORT_SYMBOL_GPL(unregister_jprobe);
1864
1865void unregister_jprobes(struct jprobe **jps, int num)
1866{
1867 int i;
1868
1869 if (num <= 0)
1870 return;
1871 mutex_lock(&kprobe_mutex);
1872 for (i = 0; i < num; i++)
1873 if (__unregister_kprobe_top(&jps[i]->kp) < 0)
1874 jps[i]->kp.addr = NULL;
1875 mutex_unlock(&kprobe_mutex);
1876
1877 synchronize_sched();
1878 for (i = 0; i < num; i++) {
1879 if (jps[i]->kp.addr)
1880 __unregister_kprobe_bottom(&jps[i]->kp);
1881 }
1882}
1883EXPORT_SYMBOL_GPL(unregister_jprobes);
1884#endif
1885
1886#ifdef CONFIG_KRETPROBES 1815#ifdef CONFIG_KRETPROBES
1887/* 1816/*
1888 * This kprobe pre_handler is registered with every kretprobe. When probe 1817 * This kprobe pre_handler is registered with every kretprobe. When probe
@@ -2329,8 +2258,6 @@ static void report_probe(struct seq_file *pi, struct kprobe *p,
2329 2258
2330 if (p->pre_handler == pre_handler_kretprobe) 2259 if (p->pre_handler == pre_handler_kretprobe)
2331 kprobe_type = "r"; 2260 kprobe_type = "r";
2332 else if (p->pre_handler == setjmp_pre_handler)
2333 kprobe_type = "j";
2334 else 2261 else
2335 kprobe_type = "k"; 2262 kprobe_type = "k";
2336 2263
@@ -2637,6 +2564,3 @@ late_initcall(debugfs_kprobe_init);
2637#endif /* CONFIG_DEBUG_FS */ 2564#endif /* CONFIG_DEBUG_FS */
2638 2565
2639module_init(init_kprobes); 2566module_init(init_kprobes);
2640
2641/* defined in arch/.../kernel/kprobes.c */
2642EXPORT_SYMBOL_GPL(jprobe_return);
diff --git a/kernel/test_kprobes.c b/kernel/test_kprobes.c
index dd53e354f630..7bca480151b0 100644
--- a/kernel/test_kprobes.c
+++ b/kernel/test_kprobes.c
@@ -162,90 +162,6 @@ static int test_kprobes(void)
162 162
163} 163}
164 164
165#if 0
166static u32 jph_val;
167
168static u32 j_kprobe_target(u32 value)
169{
170 if (preemptible()) {
171 handler_errors++;
172 pr_err("jprobe-handler is preemptible\n");
173 }
174 if (value != rand1) {
175 handler_errors++;
176 pr_err("incorrect value in jprobe handler\n");
177 }
178
179 jph_val = rand1;
180 jprobe_return();
181 return 0;
182}
183
184static struct jprobe jp = {
185 .entry = j_kprobe_target,
186 .kp.symbol_name = "kprobe_target"
187};
188
189static int test_jprobe(void)
190{
191 int ret;
192
193 ret = register_jprobe(&jp);
194 if (ret < 0) {
195 pr_err("register_jprobe returned %d\n", ret);
196 return ret;
197 }
198
199 ret = target(rand1);
200 unregister_jprobe(&jp);
201 if (jph_val == 0) {
202 pr_err("jprobe handler not called\n");
203 handler_errors++;
204 }
205
206 return 0;
207}
208
209static struct jprobe jp2 = {
210 .entry = j_kprobe_target,
211 .kp.symbol_name = "kprobe_target2"
212};
213
214static int test_jprobes(void)
215{
216 int ret;
217 struct jprobe *jps[2] = {&jp, &jp2};
218
219 /* addr and flags should be cleard for reusing kprobe. */
220 jp.kp.addr = NULL;
221 jp.kp.flags = 0;
222 ret = register_jprobes(jps, 2);
223 if (ret < 0) {
224 pr_err("register_jprobes returned %d\n", ret);
225 return ret;
226 }
227
228 jph_val = 0;
229 ret = target(rand1);
230 if (jph_val == 0) {
231 pr_err("jprobe handler not called\n");
232 handler_errors++;
233 }
234
235 jph_val = 0;
236 ret = target2(rand1);
237 if (jph_val == 0) {
238 pr_err("jprobe handler2 not called\n");
239 handler_errors++;
240 }
241 unregister_jprobes(jps, 2);
242
243 return 0;
244}
245#else
246#define test_jprobe() (0)
247#define test_jprobes() (0)
248#endif
249#ifdef CONFIG_KRETPROBES 165#ifdef CONFIG_KRETPROBES
250static u32 krph_val; 166static u32 krph_val;
251 167
@@ -383,16 +299,6 @@ int init_test_probes(void)
383 if (ret < 0) 299 if (ret < 0)
384 errors++; 300 errors++;
385 301
386 num_tests++;
387 ret = test_jprobe();
388 if (ret < 0)
389 errors++;
390
391 num_tests++;
392 ret = test_jprobes();
393 if (ret < 0)
394 errors++;
395
396#ifdef CONFIG_KRETPROBES 302#ifdef CONFIG_KRETPROBES
397 num_tests++; 303 num_tests++;
398 ret = test_kretprobe(); 304 ret = test_kretprobe();
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 8838d1158d19..0b066b3c9284 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1718,7 +1718,7 @@ config KPROBES_SANITY_TEST
1718 default n 1718 default n
1719 help 1719 help
1720 This option provides for testing basic kprobes functionality on 1720 This option provides for testing basic kprobes functionality on
1721 boot. A sample kprobe, jprobe and kretprobe are inserted and 1721 boot. Samples of kprobe and kretprobe are inserted and
1722 verified for functionality. 1722 verified for functionality.
1723 1723
1724 Say N if you are unsure. 1724 Say N if you are unsure.