usercopy: reimplement arch_within_stack_frames
Subsystems (13)
v2 cover usercopy: reimplement arch_within_stack_frames
From: Sahara <[email protected]>
This series of patches introduce the arm64 arch_within_stack_frames implementation using stacktrace functions. Also the base code is moved from thread_info.h to stacktrace.h. x86 code is reimplemented to use frame pointer unwinder functions.
Note: The code is still missing in case of using x86 ORC unwinder and guess unwinder.
v2 changes:
- Remove 'arm64: usercopy: consider dynamic array stack variable'
- minor fix in x86 arch_within_stack_frames code.
James Morse (1):
arm64: usercopy: implement arch_within_stack_frames
Sahara (2):
stacktrace: move arch_within_stack_frames from thread_info.h
x86: usercopy: reimplement arch_within_stack_frames with unwinder
arch/arm/kernel/stacktrace.c | 1 - arch/arm64/Kconfig | 1 + arch/arm64/kernel/stacktrace.c | 77 ++++++++++++++++++++++++++++++++- arch/mips/kernel/stacktrace.c | 1 - arch/mips/oprofile/backtrace.c | 1 - arch/sh/kernel/stacktrace.c | 1 - arch/sparc/kernel/stacktrace.c | 1 - arch/um/kernel/stacktrace.c | 1 - arch/unicore32/kernel/process.c | 1 - arch/unicore32/kernel/stacktrace.c | 2 - arch/x86/include/asm/thread_info.h | 51 +--------------------- arch/x86/include/asm/unwind.h | 5 +++ arch/x86/kernel/Makefile | 2 +- arch/x86/kernel/stacktrace.c | 88 +++++++++++++++++++++++++++++++++++++- arch/x86/kernel/unwind_frame.c | 4 +- arch/xtensa/kernel/stacktrace.c | 1 - include/linux/page_ext.h | 1 - include/linux/stacktrace.h | 25 +++++++++++ include/linux/thread_info.h | 21 --------- kernel/sysctl.c | 1 - mm/usercopy.c | 2 +- 21 files changed, 198 insertions(+), 90 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/3 stacktrace: move arch_within_stack_frames from thread_info.h
From: Sahara <[email protected]>
Since the inlined arch_within_stack_frames function was placed within asm/thread_info.h, using stacktrace functions to unwind stack was restricted. Now in order to have this function use more abundant apis, it is moved to architecture's stacktrace.c. And, it is changed from inline to noinline function to clearly have three depth calls like:
do_usercopy_stack()
copy_[to|from]_user() : inline
check_copy_size() : inline
__check_object_size()
check_stack_object()
arch_within_stack_frames()
With this change, the x86's implementation was slightly changed also. And, linux/stacktrace.h includes asm/stacktrace.h from now on.
--- arch/arm/kernel/stacktrace.c | 1 - arch/arm64/kernel/stacktrace.c | 1 - arch/mips/kernel/stacktrace.c | 1 - arch/mips/oprofile/backtrace.c | 1 - arch/sh/kernel/stacktrace.c | 1 - arch/sparc/kernel/stacktrace.c | 1 - arch/um/kernel/stacktrace.c | 1 - arch/unicore32/kernel/process.c | 1 - arch/unicore32/kernel/stacktrace.c | 2 -- arch/x86/include/asm/thread_info.h | 51 +------------------------------------- arch/x86/kernel/Makefile | 2 +- arch/x86/kernel/stacktrace.c | 50 ++++++++++++++++++++++++++++++++++++- arch/xtensa/kernel/stacktrace.c | 1 - include/linux/page_ext.h | 1 - include/linux/stacktrace.h | 25 +++++++++++++++++++ include/linux/thread_info.h | 21 ---------------- kernel/sysctl.c | 1 - mm/usercopy.c | 2 +- 18 files changed, 77 insertions(+), 87 deletions(-)
arch/arm/kernel/stacktrace.c +0 -1
@@ -4,7 +4,6 @@#include <linux/stacktrace.h> #include <asm/sections.h> -#include <asm/stacktrace.h> #include <asm/traps.h> #if defined(CONFIG_FRAME_POINTER ) && !defined(CONFIG_ARM_UNWIND )
arch/arm64/kernel/stacktrace.c +0 -1
@@ -25,7 +25,6 @@#include <asm/irq.h> #include <asm/stack_pointer.h> -#include <asm/stacktrace.h> /* * AArch64 PCS assigns the frame pointer to x29.
arch/mips/kernel/stacktrace.c +0 -1
@@ -8,7 +8,6 @@#include <linux/sched/task_stack.h> #include <linux/stacktrace.h> #include <linux/export.h> -#include <asm/stacktrace.h> /* * Save stack-backtrace addresses into a stack_trace buffer:
arch/mips/oprofile/backtrace.c +0 -1
@@ -4,7 +4,6 @@#include <linux/mm.h> #include <linux/uaccess.h> #include <asm/ptrace.h> -#include <asm/stacktrace.h> #include <linux/stacktrace.h> #include <linux/kernel.h> #include <asm/sections.h>
arch/sh/kernel/stacktrace.c +0 -1
@@ -16,7 +16,6 @@#include <linux/module.h> #include <asm/unwinder.h> #include <asm/ptrace.h> -#include <asm/stacktrace.h> static int save_stack_stack (void *data,char *name) {
arch/sparc/kernel/stacktrace.c +0 -1
@@ -5,7 +5,6 @@#include <linux/ftrace.h> #include <linux/export.h> #include <asm/ptrace.h> -#include <asm/stacktrace.h> #include "kstack.h"
arch/um/kernel/stacktrace.c +0 -1
@@ -14,7 +14,6 @@#include <linux/stacktrace.h> #include <linux/module.h> #include <linux/uaccess.h> -#include <asm/stacktrace.h> void dump_trace(struct task_struct *tsk, const struct stacktrace_ops *ops,
arch/unicore32/kernel/process.c +0 -1
@@ -36,7 +36,6 @@#include <asm/cacheflush.h> #include <asm/processor.h> -#include <asm/stacktrace.h> #include "setup.h"
arch/unicore32/kernel/stacktrace.c +0 -2
@@ -14,8 +14,6 @@#include <linux/sched/debug.h> #include <linux/stacktrace.h> -#include <asm/stacktrace.h> -#if defined(CONFIG_FRAME_POINTER )/* * Unwind the current stack frame and store the new register values in the
arch/x86/include/asm/thread_info.h +1 -50
60 lines not on this page · raw message
arch/x86/kernel/Makefile +1 -1
@@ -70,7 +70,7 @@ obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o obj-$(CONFIG_INTEL_TXT) += tboot.o obj-$(CONFIG_ISA_DMA_API) += i8237.o -obj-$(CONFIG_STACKTRACE) += stacktrace.o +obj-y += stacktrace.o obj-y += cpu/ obj-y += acpi/ obj-y += reboot.o
arch/x86/kernel/stacktrace.c +49 -1
61 lines not on this page · raw message
arch/xtensa/kernel/stacktrace.c +0 -1
@@ -12,7 +12,6 @@#include <linux/sched.h> #include <linux/stacktrace.h> -#include <asm/stacktrace.h> #include <asm/traps.h> #include <linux/uaccess.h>
include/linux/page_ext.h +0 -1
@@ -3,7 +3,6 @@#define __LINUX_PAGE_EXT_H#include <linux/types.h> -#include <linux/stacktrace.h> #include <linux/stackdepot.h> struct pglist_data ;
include/linux/stacktrace.h +25 -0
@@ -3,10 +3,35 @@#define __LINUX_STACKTRACE_H#include <linux/types.h> +#include <asm/stacktrace.h> struct task_struct ;struct pt_regs ; +/* +* For per-arch arch_within_stack_frames() implementations, defined in +* kernel/stacktrace.c. +*/ +enum { +BAD_STACK =-1 , +NOT_STACK =0 , +GOOD_FRAME , +GOOD_STACK , +}; + +#ifdef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES +extern int arch_within_stack_frames (const void *const stack, +const void *const stackend, +const void *obj,unsigned long len); +#else +static inline int arch_within_stack_frames (const void *const stack, +const void *const stackend, +const void *obj,unsigned long len) +{ +return NOT_STACK ; +} +#endif + #ifdef CONFIG_STACKTRACE struct stack_trace { unsigned int nr_entries, max_entries;
include/linux/thread_info.h +0 -21
@@ -23,18 +23,6 @@#endif #include <linux/bitops.h> - -/* -* For per-arch arch_within_stack_frames() implementations, defined in -* asm/thread_info.h. -*/ -enum { -BAD_STACK =-1 , -NOT_STACK =0 , -GOOD_FRAME , -GOOD_STACK , -}; -#include <asm/thread_info.h> #ifdef __KERNEL__
@@ -92,15 +80,6 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)#define tif_need_resched () test_thread_flag(TIF_NEED_RESCHED) -#ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES -static inline int arch_within_stack_frames (const void *const stack, -const void *const stackend, -const void *obj,unsigned long len) -{ -return 0 ; -} -#endif -#ifdef CONFIG_HARDENED_USERCOPY extern void __check_object_size (const void *ptr,unsigned long n,bool to_user);
kernel/sysctl.c +0 -1
@@ -73,7 +73,6 @@#ifdef CONFIG_X86 #include <asm/nmi.h> -#include <asm/stacktrace.h> #include <asm/io.h> #endif #ifdef CONFIG_SPARC
mm/usercopy.c +1 -1
@@ -19,7 +19,7 @@#include <linux/sched.h> #include <linux/sched/task.h> #include <linux/sched/task_stack.h> -#include <linux/thread_info.h> +#include <linux/stacktrace.h> #include <asm/sections.h> /*
Signature · 1 line
2.7.4
PATCH v2 2/3 arm64: usercopy: implement arch_within_stack_frames
From: James Morse <[email protected]>
This implements arch_within_stack_frames() for arm64 that should validate if a given object is contained by a kernel stack frame.
--- arch/arm64/Kconfig | 1 + arch/arm64/kernel/stacktrace.c | 76 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -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
arch/arm64/kernel/stacktrace.c +76 -0
88 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/3 x86: usercopy: reimplement arch_within_stack_frames with unwinder
From: Sahara <[email protected]>
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.
--- 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(-)
arch/x86/include/asm/unwind.h +5 -0
@@ -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,
arch/x86/kernel/stacktrace.c +51 -13
88 lines not on this page · raw message
arch/x86/kernel/unwind_frame.c +1 -3
@@ -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))
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h
In reply to [email protected]Thank you for the patch! Yet something to improve:
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_irqrestorevim +/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 <[email protected]> :::::: CC: Ingo Molnar <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH v2 1/3] stacktrace: move arch_within_stack_frames from thread_info.h
In reply to [email protected]Thank you for the patch! Yet something to improve:
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 <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation