* [PATCH v2 2/3] arm64: usercopy: implement arch_within_stack_frames
2018-04-09 6:06 ` [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h kpark3469
@ 2018-04-09 6:06 ` kpark3469
2018-04-09 6:06 ` [PATCH v2 3/3] x86: usercopy: reimplement arch_within_stack_frames with unwinder kpark3469
2018-04-09 7:26 ` [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h kbuild test robot
2018-04-09 8:58 ` kbuild test robot
2 siblings, 1 reply; 6+ messages in thread
From: kpark3469 @ 2018-04-09 6:06 UTC (permalink / raw)
To: kernel-hardening
Cc: catalin.marinas, keescook, will.deacon, mark.rutland,
james.morse, panand, keun-o.park, psodagud, jpoimboe, mingo,
linux-kernel
From: James Morse <james.morse@arm.com>
This implements arch_within_stack_frames() for arm64 that should
validate if a given object is contained by a kernel stack frame.
Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Sahara <keun-o.park@darkmatter.ae>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/stacktrace.c | 76 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 177be0d..72d0747 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -128,6 +128,7 @@ config ARM64
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_KPROBES
select HAVE_KRETPROBES
+ select HAVE_ARCH_WITHIN_STACK_FRAMES
select IOMMU_DMA if IOMMU_SUPPORT
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 33c4028..9918698 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -26,6 +26,11 @@
#include <asm/irq.h>
#include <asm/stack_pointer.h>
+#define FAKE_FRAME(frame, my_func) do { \
+ frame.fp = (unsigned long)__builtin_frame_address(0); \
+ frame.pc = (unsigned long)my_func; \
+} while (0)
+
/*
* AArch64 PCS assigns the frame pointer to x29.
*
@@ -99,6 +104,77 @@ void notrace walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
}
}
+struct check_frame_arg {
+ unsigned long obj_start;
+ unsigned long obj_end;
+ unsigned long frame_start;
+ int discard_frames;
+ int err;
+};
+
+static int check_frame(struct stackframe *frame, void *d)
+{
+ struct check_frame_arg *arg = d;
+ unsigned long frame_end = frame->fp;
+
+ /* object overlaps multiple frames */
+ if (arg->obj_start < frame->fp && frame->fp < arg->obj_end) {
+ arg->err = BAD_STACK;
+ return 1;
+ }
+
+ /*
+ * Discard frames and check object is in a frame written early
+ * enough.
+ */
+ if (arg->discard_frames)
+ arg->discard_frames--;
+ else if ((arg->frame_start <= arg->obj_start &&
+ arg->obj_start < frame_end) &&
+ (arg->frame_start < arg->obj_end && arg->obj_end <= frame_end))
+ return 1;
+
+ /* object exists in a previous frame */
+ if (arg->obj_end < arg->frame_start) {
+ arg->err = BAD_STACK;
+ return 1;
+ }
+
+ arg->frame_start = frame_end + 0x10;
+
+ return 0;
+}
+
+/* Check obj doesn't overlap a stack frame record */
+int arch_within_stack_frames(const void *stack,
+ const void *stack_end,
+ const void *obj, unsigned long obj_len)
+{
+ struct stackframe frame;
+ struct check_frame_arg arg;
+
+ if (!IS_ENABLED(CONFIG_FRAME_POINTER))
+ return NOT_STACK;
+
+ arg.err = GOOD_FRAME;
+ arg.obj_start = (unsigned long)obj;
+ arg.obj_end = arg.obj_start + obj_len;
+
+ FAKE_FRAME(frame, arch_within_stack_frames);
+ arg.frame_start = frame.fp;
+
+ /*
+ * Skip 4 non-inlined frames: <fake frame>,
+ * arch_within_stack_frames(), check_stack_object() and
+ * __check_object_size().
+ */
+ arg.discard_frames = 4;
+
+ walk_stackframe(current, &frame, check_frame, &arg);
+
+ return arg.err;
+}
+
#ifdef CONFIG_STACKTRACE
struct stack_trace_data {
struct stack_trace *trace;
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 3/3] x86: usercopy: reimplement arch_within_stack_frames with unwinder
2018-04-09 6:06 ` [PATCH v2 2/3] arm64: usercopy: implement arch_within_stack_frames kpark3469
@ 2018-04-09 6:06 ` kpark3469
0 siblings, 0 replies; 6+ messages in thread
From: kpark3469 @ 2018-04-09 6:06 UTC (permalink / raw)
To: kernel-hardening
Cc: catalin.marinas, keescook, will.deacon, mark.rutland,
james.morse, panand, keun-o.park, psodagud, jpoimboe, mingo,
linux-kernel
From: Sahara <keun-o.park@darkmatter.ae>
The old arch_within_stack_frames which used the frame pointer is
now reimplemented to use frame pointer unwinder apis. So the main
functionality is same as before.
Signed-off-by: Sahara <keun-o.park@darkmatter.ae>
---
arch/x86/include/asm/unwind.h | 5 ++++
arch/x86/kernel/stacktrace.c | 64 +++++++++++++++++++++++++++++++++---------
arch/x86/kernel/unwind_frame.c | 4 +--
3 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
index 1f86e1b..6f04906f 100644
--- a/arch/x86/include/asm/unwind.h
+++ b/arch/x86/include/asm/unwind.h
@@ -87,6 +87,11 @@ void unwind_init(void);
void unwind_module_init(struct module *mod, void *orc_ip, size_t orc_ip_size,
void *orc, size_t orc_size);
#else
+#ifdef CONFIG_UNWINDER_FRAME_POINTER
+#define FRAME_HEADER_SIZE (sizeof(long) * 2)
+size_t regs_size(struct pt_regs *regs);
+#endif
+
static inline void unwind_init(void) {}
static inline
void unwind_module_init(struct module *mod, void *orc_ip, size_t orc_ip_size,
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index f433a33..11ec101 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -12,6 +12,33 @@
#include <asm/unwind.h>
+static inline void *get_cur_frame(struct unwind_state *state)
+{
+ void *frame = NULL;
+
+#if defined(CONFIG_UNWINDER_FRAME_POINTER)
+ if (state->regs)
+ frame = (void *)state->regs;
+ else
+ frame = (void *)state->bp;
+#endif
+ return frame;
+}
+
+static inline void *get_frame_end(struct unwind_state *state)
+{
+ void *frame_end = NULL;
+
+#if defined(CONFIG_UNWINDER_FRAME_POINTER)
+ if (state->regs) {
+ frame_end = (void *)state->regs + regs_size(state->regs);
+ } else {
+ frame_end = (void *)state->bp + FRAME_HEADER_SIZE;
+ }
+#endif
+ return frame_end;
+}
+
/*
* Walks up the stack frames to make sure that the specified object is
* entirely contained by a single stack frame.
@@ -25,31 +52,42 @@ int arch_within_stack_frames(const void * const stack,
const void * const stackend,
const void *obj, unsigned long len)
{
-#if defined(CONFIG_FRAME_POINTER)
- const void *frame = NULL;
- const void *oldframe;
-
- oldframe = __builtin_frame_address(2);
- if (oldframe)
- frame = __builtin_frame_address(3);
+#if defined(CONFIG_UNWINDER_FRAME_POINTER)
+ struct unwind_state state;
+ void *prev_frame_end = NULL;
/*
* low ----------------------------------------------> high
* [saved bp][saved ip][args][local vars][saved bp][saved ip]
* ^----------------^
* allow copies only within here
+ *
+ * Skip 3 non-inlined frames: arch_within_stack_frames(),
+ * check_stack_object() and __check_object_size().
+ *
*/
- while (stack <= frame && frame < stackend) {
+ unsigned int discard_frames = 3;
+
+ for (unwind_start(&state, current, NULL, NULL); !unwind_done(&state);
+ unwind_next_frame(&state)) {
/*
* If obj + len extends past the last frame, this
* check won't pass and the next frame will be 0,
* causing us to bail out and correctly report
* the copy as invalid.
*/
- if (obj + len <= frame)
- return obj >= oldframe + 2 * sizeof(void *) ?
- GOOD_FRAME : BAD_STACK;
- oldframe = frame;
- frame = *(const void * const *)frame;
+ if (discard_frames) {
+ discard_frames--;
+ } else {
+ void *frame = get_cur_frame(&state);
+
+ if (!frame || !prev_frame_end)
+ return NOT_STACK;
+ if (obj + len <= frame)
+ return obj >= prev_frame_end ?
+ GOOD_FRAME : BAD_STACK;
+ }
+ /* save current frame end before move to next frame */
+ prev_frame_end = get_frame_end(&state);
}
return BAD_STACK;
#else
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 3dc26f9..c8bfa5c 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -8,8 +8,6 @@
#include <asm/stacktrace.h>
#include <asm/unwind.h>
-#define FRAME_HEADER_SIZE (sizeof(long) * 2)
-
unsigned long unwind_get_return_address(struct unwind_state *state)
{
if (unwind_done(state))
@@ -69,7 +67,7 @@ static void unwind_dump(struct unwind_state *state)
}
}
-static size_t regs_size(struct pt_regs *regs)
+size_t regs_size(struct pt_regs *regs)
{
/* x86_32 regs from kernel mode are two words shorter: */
if (IS_ENABLED(CONFIG_X86_32) && !user_mode(regs))
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h
2018-04-09 6:06 ` [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h kpark3469
2018-04-09 6:06 ` [PATCH v2 2/3] arm64: usercopy: implement arch_within_stack_frames kpark3469
@ 2018-04-09 7:26 ` kbuild test robot
2018-04-09 8:58 ` kbuild test robot
2 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2018-04-09 7:26 UTC (permalink / raw)
To: kpark3469
Cc: kbuild-all, kernel-hardening, catalin.marinas, keescook,
will.deacon, mark.rutland, james.morse, panand, keun-o.park,
psodagud, jpoimboe, mingo, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 15034 bytes --]
Hi Sahara,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.16 next-20180406]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/kpark3469-gmail-com/usercopy-reimplement-arch_within_stack_frames/20180409-144349
config: i386-randconfig-x071-201814 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
from include/linux/time.h:6,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/spinlock.h:297:24: error: unknown type name 'raw_spinlock_t'
static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
^~~~~~~~~~~~~~
include/linux/spinlock.h:297:55: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:308:39: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_lock(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:313:42: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_lock_bh(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:318:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_trylock(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:333:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_lock_irq(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:348:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:353:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock_bh(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:358:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock_irq(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:363:52: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:368:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_trylock_bh(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:373:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_trylock_irq(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:383:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_is_locked(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:388:46: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_is_contended(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:408:51: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
^~~~~~~~~~
clock_t
include/linux/spinlock.h:412:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
^~~~~~~~~~
clock_t
include/linux/spinlock.h:416:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
void free_bucket_spinlocks(spinlock_t *locks);
^~~~~~~~~~
clock_t
In file included from include/linux/time.h:6:0,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/seqlock.h:51:21: error: field 'dep_map' has incomplete type
struct lockdep_map dep_map;
^~~~~~~
include/linux/seqlock.h:56:15: warning: 'struct lock_class_key' declared inside parameter list will not be visible outside of this definition or declaration
struct lock_class_key *key)
^~~~~~~~~~~~~~
include/linux/seqlock.h: In function '__seqcount_init':
>> include/linux/seqlock.h:61:2: error: implicit declaration of function 'lockdep_init_map' [-Werror=implicit-function-declaration]
lockdep_init_map(&s->dep_map, name, key, 0);
^~~~~~~~~~~~~~~~
include/linux/seqlock.h: In function 'seqcount_lockdep_reader_access':
include/linux/seqlock.h:81:2: error: implicit declaration of function 'seqcount_acquire_read' [-Werror=implicit-function-declaration]
seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
^~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:82:2: error: implicit declaration of function 'seqcount_release'; did you mean 'xchg_release'? [-Werror=implicit-function-declaration]
seqcount_release(&l->dep_map, 1, _RET_IP_);
^~~~~~~~~~~~~~~~
xchg_release
include/linux/seqlock.h: In function 'write_seqcount_begin_nested':
include/linux/seqlock.h:377:2: error: implicit declaration of function 'seqcount_acquire'; did you mean 'seqcount_init'? [-Werror=implicit-function-declaration]
seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
^~~~~~~~~~~~~~~~
seqcount_init
include/linux/seqlock.h: At top level:
include/linux/seqlock.h:406:2: error: unknown type name 'spinlock_t'
spinlock_t lock;
^~~~~~~~~~
include/linux/seqlock.h: In function 'write_seqlock':
include/linux/seqlock.h:448:2: error: implicit declaration of function 'spin_lock'; did you mean 'write_lock'? [-Werror=implicit-function-declaration]
spin_lock(&sl->lock);
^~~~~~~~~
write_lock
include/linux/seqlock.h: In function 'write_sequnlock':
include/linux/seqlock.h:455:2: error: implicit declaration of function 'spin_unlock'; did you mean 'raw_spin_unlock'? [-Werror=implicit-function-declaration]
spin_unlock(&sl->lock);
^~~~~~~~~~~
raw_spin_unlock
include/linux/seqlock.h: In function 'write_seqlock_bh':
include/linux/seqlock.h:460:2: error: implicit declaration of function 'spin_lock_bh'; did you mean 'raw_spin_lock_bh'? [-Werror=implicit-function-declaration]
spin_lock_bh(&sl->lock);
^~~~~~~~~~~~
raw_spin_lock_bh
include/linux/seqlock.h: In function 'write_sequnlock_bh':
include/linux/seqlock.h:467:2: error: implicit declaration of function 'spin_unlock_bh'; did you mean 'write_unlock_bh'? [-Werror=implicit-function-declaration]
spin_unlock_bh(&sl->lock);
^~~~~~~~~~~~~~
write_unlock_bh
include/linux/seqlock.h: In function 'write_seqlock_irq':
include/linux/seqlock.h:472:2: error: implicit declaration of function 'spin_lock_irq'; did you mean 'spin_lock_init'? [-Werror=implicit-function-declaration]
spin_lock_irq(&sl->lock);
^~~~~~~~~~~~~
spin_lock_init
include/linux/seqlock.h: In function 'write_sequnlock_irq':
include/linux/seqlock.h:479:2: error: implicit declaration of function 'spin_unlock_irq'; did you mean 'read_unlock_irq'? [-Werror=implicit-function-declaration]
spin_unlock_irq(&sl->lock);
^~~~~~~~~~~~~~~
read_unlock_irq
In file included from include/linux/seqlock.h:36:0,
from include/linux/time.h:6,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/seqlock.h: In function '__write_seqlock_irqsave':
include/linux/spinlock.h:222:11: error: implicit declaration of function '_raw_spin_lock_irqsave'; did you mean 'raw_spin_lock_irqsave'? [-Werror=implicit-function-declaration]
flags = _raw_spin_lock_irqsave(lock); \
^
include/linux/spinlock.h:340:2: note: in expansion of macro 'raw_spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
spin_lock_irqsave(&sl->lock, flags);
^~~~~~~~~~~~~~~~~
include/linux/spinlock.h:340:24: error: implicit declaration of function 'spinlock_check'; did you mean 'cpumask_check'? [-Werror=implicit-function-declaration]
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:222:34: note: in definition of macro 'raw_spin_lock_irqsave'
flags = _raw_spin_lock_irqsave(lock); \
^~~~
include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
spin_lock_irqsave(&sl->lock, flags);
^~~~~~~~~~~~~~~~~
In file included from include/linux/time.h:6:0,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/seqlock.h: In function 'write_sequnlock_irqrestore':
include/linux/seqlock.h:498:2: error: implicit declaration of function 'spin_unlock_irqrestore'; did you mean 'write_unlock_irqrestore'? [-Werror=implicit-function-declaration]
spin_unlock_irqrestore(&sl->lock, flags);
^~~~~~~~~~~~~~~~~~~~~~
write_unlock_irqrestore
vim +/lockdep_init_map +61 include/linux/seqlock.h
^1da177e Linus Torvalds 2005-04-16 41
^1da177e Linus Torvalds 2005-04-16 42 /*
^1da177e Linus Torvalds 2005-04-16 43 * Version using sequence counter only.
^1da177e Linus Torvalds 2005-04-16 44 * This can be used when code has its own mutex protecting the
^1da177e Linus Torvalds 2005-04-16 45 * updating starting before the write_seqcountbeqin() and ending
^1da177e Linus Torvalds 2005-04-16 46 * after the write_seqcount_end().
^1da177e Linus Torvalds 2005-04-16 47 */
^1da177e Linus Torvalds 2005-04-16 48 typedef struct seqcount {
^1da177e Linus Torvalds 2005-04-16 49 unsigned sequence;
1ca7d67c John Stultz 2013-10-07 50 #ifdef CONFIG_DEBUG_LOCK_ALLOC
1ca7d67c John Stultz 2013-10-07 @51 struct lockdep_map dep_map;
1ca7d67c John Stultz 2013-10-07 52 #endif
^1da177e Linus Torvalds 2005-04-16 53 } seqcount_t;
^1da177e Linus Torvalds 2005-04-16 54
1ca7d67c John Stultz 2013-10-07 55 static inline void __seqcount_init(seqcount_t *s, const char *name,
1ca7d67c John Stultz 2013-10-07 56 struct lock_class_key *key)
1ca7d67c John Stultz 2013-10-07 57 {
1ca7d67c John Stultz 2013-10-07 58 /*
1ca7d67c John Stultz 2013-10-07 59 * Make sure we are not reinitializing a held lock:
1ca7d67c John Stultz 2013-10-07 60 */
1ca7d67c John Stultz 2013-10-07 @61 lockdep_init_map(&s->dep_map, name, key, 0);
1ca7d67c John Stultz 2013-10-07 62 s->sequence = 0;
1ca7d67c John Stultz 2013-10-07 63 }
1ca7d67c John Stultz 2013-10-07 64
:::::: The code at line 61 was first introduced by commit
:::::: 1ca7d67cf5d5a2aef26a8d9afd789006fa098347 seqcount: Add lockdep functionality to seqcount/seqlock structures
:::::: TO: John Stultz <john.stultz@linaro.org>
:::::: CC: Ingo Molnar <mingo@kernel.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32297 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h
2018-04-09 6:06 ` [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h kpark3469
2018-04-09 6:06 ` [PATCH v2 2/3] arm64: usercopy: implement arch_within_stack_frames kpark3469
2018-04-09 7:26 ` [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h kbuild test robot
@ 2018-04-09 8:58 ` kbuild test robot
2 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2018-04-09 8:58 UTC (permalink / raw)
To: kpark3469
Cc: kbuild-all, kernel-hardening, catalin.marinas, keescook,
will.deacon, mark.rutland, james.morse, panand, keun-o.park,
psodagud, jpoimboe, mingo, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 15556 bytes --]
Hi Sahara,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.16 next-20180406]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/kpark3469-gmail-com/usercopy-reimplement-arch_within_stack_frames/20180409-144349
config: x86_64-randconfig-x013-201814 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/spinlock.h:297:24: error: unknown type name 'raw_spinlock_t'
static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
^~~~~~~~~~~~~~
include/linux/spinlock.h:297:55: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:308:39: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_lock(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:313:42: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_lock_bh(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:318:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_trylock(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:333:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_lock_irq(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:348:41: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:353:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock_bh(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:358:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock_irq(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:363:52: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:368:44: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_trylock_bh(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:373:45: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_trylock_irq(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:383:43: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_is_locked(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:388:46: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
static __always_inline int spin_is_contended(spinlock_t *lock)
^~~~~~~~~~
clock_t
include/linux/spinlock.h:408:51: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
^~~~~~~~~~
clock_t
include/linux/spinlock.h:412:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
^~~~~~~~~~
clock_t
include/linux/spinlock.h:416:28: error: unknown type name 'spinlock_t'; did you mean 'clock_t'?
void free_bucket_spinlocks(spinlock_t *locks);
^~~~~~~~~~
clock_t
In file included from include/linux/time.h:6:0,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/seqlock.h:51:21: error: field 'dep_map' has incomplete type
struct lockdep_map dep_map;
^~~~~~~
include/linux/seqlock.h:56:15: warning: 'struct lock_class_key' declared inside parameter list will not be visible outside of this definition or declaration
struct lock_class_key *key)
^~~~~~~~~~~~~~
include/linux/seqlock.h: In function '__seqcount_init':
include/linux/seqlock.h:61:2: error: implicit declaration of function 'lockdep_init_map' [-Werror=implicit-function-declaration]
lockdep_init_map(&s->dep_map, name, key, 0);
^~~~~~~~~~~~~~~~
include/linux/seqlock.h: In function 'seqcount_lockdep_reader_access':
include/linux/seqlock.h:81:2: error: implicit declaration of function 'seqcount_acquire_read' [-Werror=implicit-function-declaration]
seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
^~~~~~~~~~~~~~~~~~~~~
>> include/linux/seqlock.h:82:2: error: implicit declaration of function 'seqcount_release'; did you mean 'seqcount_init'? [-Werror=implicit-function-declaration]
seqcount_release(&l->dep_map, 1, _RET_IP_);
^~~~~~~~~~~~~~~~
seqcount_init
include/linux/seqlock.h: In function 'write_seqcount_begin_nested':
include/linux/seqlock.h:377:2: error: implicit declaration of function 'seqcount_acquire'; did you mean 'seqcount_init'? [-Werror=implicit-function-declaration]
seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
^~~~~~~~~~~~~~~~
seqcount_init
include/linux/seqlock.h: At top level:
include/linux/seqlock.h:406:2: error: unknown type name 'spinlock_t'
spinlock_t lock;
^~~~~~~~~~
include/linux/seqlock.h: In function 'write_seqlock':
include/linux/seqlock.h:448:2: error: implicit declaration of function 'spin_lock'; did you mean 'write_lock'? [-Werror=implicit-function-declaration]
spin_lock(&sl->lock);
^~~~~~~~~
write_lock
include/linux/seqlock.h: In function 'write_sequnlock':
include/linux/seqlock.h:455:2: error: implicit declaration of function 'spin_unlock'; did you mean 'raw_spin_unlock'? [-Werror=implicit-function-declaration]
spin_unlock(&sl->lock);
^~~~~~~~~~~
raw_spin_unlock
include/linux/seqlock.h: In function 'write_seqlock_bh':
include/linux/seqlock.h:460:2: error: implicit declaration of function 'spin_lock_bh'; did you mean 'raw_spin_lock_bh'? [-Werror=implicit-function-declaration]
spin_lock_bh(&sl->lock);
^~~~~~~~~~~~
raw_spin_lock_bh
include/linux/seqlock.h: In function 'write_sequnlock_bh':
include/linux/seqlock.h:467:2: error: implicit declaration of function 'spin_unlock_bh'; did you mean 'write_unlock_bh'? [-Werror=implicit-function-declaration]
spin_unlock_bh(&sl->lock);
^~~~~~~~~~~~~~
write_unlock_bh
include/linux/seqlock.h: In function 'write_seqlock_irq':
include/linux/seqlock.h:472:2: error: implicit declaration of function 'spin_lock_irq'; did you mean 'spin_lock_init'? [-Werror=implicit-function-declaration]
spin_lock_irq(&sl->lock);
^~~~~~~~~~~~~
spin_lock_init
include/linux/seqlock.h: In function 'write_sequnlock_irq':
include/linux/seqlock.h:479:2: error: implicit declaration of function 'spin_unlock_irq'; did you mean 'read_unlock_irq'? [-Werror=implicit-function-declaration]
spin_unlock_irq(&sl->lock);
^~~~~~~~~~~~~~~
read_unlock_irq
In file included from include/linux/seqlock.h:36:0,
from include/linux/time.h:6,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/seqlock.h: In function '__write_seqlock_irqsave':
include/linux/spinlock.h:222:11: error: implicit declaration of function '_raw_spin_lock_irqsave'; did you mean 'raw_spin_lock_irqsave'? [-Werror=implicit-function-declaration]
flags = _raw_spin_lock_irqsave(lock); \
^
include/linux/spinlock.h:340:2: note: in expansion of macro 'raw_spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
spin_lock_irqsave(&sl->lock, flags);
^~~~~~~~~~~~~~~~~
include/linux/spinlock.h:340:24: error: implicit declaration of function 'spinlock_check'; did you mean 'cpumask_check'? [-Werror=implicit-function-declaration]
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:222:34: note: in definition of macro 'raw_spin_lock_irqsave'
flags = _raw_spin_lock_irqsave(lock); \
^~~~
include/linux/seqlock.h:486:2: note: in expansion of macro 'spin_lock_irqsave'
spin_lock_irqsave(&sl->lock, flags);
^~~~~~~~~~~~~~~~~
In file included from include/linux/time.h:6:0,
from include/linux/ktime.h:24,
from include/linux/rcutiny.h:28,
from include/linux/rcupdate.h:211,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
from include/linux/spinlock_types.h:18,
from kernel/bounds.c:14:
include/linux/seqlock.h: In function 'write_sequnlock_irqrestore':
include/linux/seqlock.h:498:2: error: implicit declaration of function 'spin_unlock_irqrestore'; did you mean 'raw_spin_unlock_irqrestore'? [-Werror=implicit-function-declaration]
spin_unlock_irqrestore(&sl->lock, flags);
^~~~~~~~~~~~~~~~~~~~~~
raw_spin_unlock_irqrestore
In file included from include/linux/rculist.h:11:0,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:5,
from arch/x86/include/asm/stacktrace.h:10,
from include/linux/stacktrace.h:6,
from include/linux/lockdep.h:29,
vim +82 include/linux/seqlock.h
^1da177e Linus Torvalds 2005-04-16 54
1ca7d67c John Stultz 2013-10-07 55 static inline void __seqcount_init(seqcount_t *s, const char *name,
1ca7d67c John Stultz 2013-10-07 56 struct lock_class_key *key)
1ca7d67c John Stultz 2013-10-07 57 {
1ca7d67c John Stultz 2013-10-07 58 /*
1ca7d67c John Stultz 2013-10-07 59 * Make sure we are not reinitializing a held lock:
1ca7d67c John Stultz 2013-10-07 60 */
1ca7d67c John Stultz 2013-10-07 @61 lockdep_init_map(&s->dep_map, name, key, 0);
1ca7d67c John Stultz 2013-10-07 62 s->sequence = 0;
1ca7d67c John Stultz 2013-10-07 63 }
1ca7d67c John Stultz 2013-10-07 64
1ca7d67c John Stultz 2013-10-07 65 #ifdef CONFIG_DEBUG_LOCK_ALLOC
1ca7d67c John Stultz 2013-10-07 66 # define SEQCOUNT_DEP_MAP_INIT(lockname) \
1ca7d67c John Stultz 2013-10-07 67 .dep_map = { .name = #lockname } \
1ca7d67c John Stultz 2013-10-07 68
1ca7d67c John Stultz 2013-10-07 69 # define seqcount_init(s) \
1ca7d67c John Stultz 2013-10-07 70 do { \
1ca7d67c John Stultz 2013-10-07 71 static struct lock_class_key __key; \
1ca7d67c John Stultz 2013-10-07 72 __seqcount_init((s), #s, &__key); \
1ca7d67c John Stultz 2013-10-07 73 } while (0)
1ca7d67c John Stultz 2013-10-07 74
1ca7d67c John Stultz 2013-10-07 75 static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
1ca7d67c John Stultz 2013-10-07 76 {
1ca7d67c John Stultz 2013-10-07 77 seqcount_t *l = (seqcount_t *)s;
1ca7d67c John Stultz 2013-10-07 78 unsigned long flags;
1ca7d67c John Stultz 2013-10-07 79
1ca7d67c John Stultz 2013-10-07 80 local_irq_save(flags);
1ca7d67c John Stultz 2013-10-07 81 seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
1ca7d67c John Stultz 2013-10-07 @82 seqcount_release(&l->dep_map, 1, _RET_IP_);
1ca7d67c John Stultz 2013-10-07 83 local_irq_restore(flags);
1ca7d67c John Stultz 2013-10-07 84 }
1ca7d67c John Stultz 2013-10-07 85
:::::: The code at line 82 was first introduced by commit
:::::: 1ca7d67cf5d5a2aef26a8d9afd789006fa098347 seqcount: Add lockdep functionality to seqcount/seqlock structures
:::::: TO: John Stultz <john.stultz@linaro.org>
:::::: CC: Ingo Molnar <mingo@kernel.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29305 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread