[PATCH v15 04/10] arm64: Kprobes with single stepping support

Catalin Marinas catalin.marinas at arm.com
Thu Jul 21 10:16:36 PDT 2016


On Thu, Jul 21, 2016 at 12:33:36PM -0400, David Long wrote:
> On 07/20/2016 12:09 PM, Marc Zyngier wrote:
> >On 08/07/16 17:35, David Long wrote:
> >>diff --git a/arch/arm64/include/asm/kprobes.h b/arch/arm64/include/asm/kprobes.h
> >>new file mode 100644
> >>index 0000000..79c9511
> >>--- /dev/null
> >>+++ b/arch/arm64/include/asm/kprobes.h
> >>@@ -0,0 +1,60 @@
> >>+/*
> >>+ * arch/arm64/include/asm/kprobes.h
> >>+ *
> >>+ * Copyright (C) 2013 Linaro Limited
> >>+ *
> >>+ * This program is free software; you can redistribute it and/or modify
> >>+ * it under the terms of the GNU General Public License version 2 as
> >>+ * published by the Free Software Foundation.
> >>+ *
> >>+ * This program is distributed in the hope that it will be useful,
> >>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >>+ * General Public License for more details.
> >>+ */
> >>+
> >>+#ifndef _ARM_KPROBES_H
> >>+#define _ARM_KPROBES_H
> >>+
> >>+#include <linux/types.h>
> >>+#include <linux/ptrace.h>
> >>+#include <linux/percpu.h>
> >>+
> >>+#define __ARCH_WANT_KPROBES_INSN_SLOT
> >>+#define MAX_INSN_SIZE			1
> >>+#define MAX_STACK_SIZE			128
> >
> >Where is that value coming from? Because even on my 6502, I have a 256
> >byte stack.
> 
> Although I don't claim to know the original author's thoughts I would guess
> it is based on the seven other existing implementations for kprobes on
> various architectures, all of which appear to use either 64 or 128 for
> MAX_STACK_SIZE.  The code is not trying to duplicate the whole stack.

This seems to be some random choice in the hope that arguments passed on
the stack cannot exceed MAX_STACK_SIZE.

I'll put a patch together which checks the previous stack frame and
limit the copying. If the fp information or if the size to be copied
exceeds MAX_STACK_SIZE, just skip the probe hook (return 0 in
setjmp_pre_handler).

-- 
Catalin



More information about the linux-arm-kernel mailing list