aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug4
-rw-r--r--lib/debugobjects.c8
-rw-r--r--lib/genalloc.c3
-rw-r--r--lib/iov_iter.c4
-rw-r--r--lib/locking-selftest.c66
-rw-r--r--lib/mpi/mpi-pow.c7
-rw-r--r--lib/stackdepot.c4
-rw-r--r--lib/test_bpf.c2
-rw-r--r--lib/test_kasan.c29
9 files changed, 89 insertions, 38 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 33bc56cf60d7..a6c8db1d62f6 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -198,6 +198,7 @@ config FRAME_WARN
198 int "Warn for stack frames larger than (needs gcc 4.4)" 198 int "Warn for stack frames larger than (needs gcc 4.4)"
199 range 0 8192 199 range 0 8192
200 default 0 if KASAN 200 default 0 if KASAN
201 default 2048 if GCC_PLUGIN_LATENT_ENTROPY
201 default 1024 if !64BIT 202 default 1024 if !64BIT
202 default 2048 if 64BIT 203 default 2048 if 64BIT
203 help 204 help
@@ -1084,6 +1085,9 @@ config PROVE_LOCKING
1084 1085
1085 For more details, see Documentation/locking/lockdep-design.txt. 1086 For more details, see Documentation/locking/lockdep-design.txt.
1086 1087
1088config PROVE_LOCKING_SMALL
1089 bool
1090
1087config LOCKDEP 1091config LOCKDEP
1088 bool 1092 bool
1089 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 1093 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index a8e12601eb37..056052dc8e91 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -362,6 +362,7 @@ void debug_object_init(void *addr, struct debug_obj_descr *descr)
362 362
363 __debug_object_init(addr, descr, 0); 363 __debug_object_init(addr, descr, 0);
364} 364}
365EXPORT_SYMBOL_GPL(debug_object_init);
365 366
366/** 367/**
367 * debug_object_init_on_stack - debug checks when an object on stack is 368 * debug_object_init_on_stack - debug checks when an object on stack is
@@ -376,6 +377,7 @@ void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr)
376 377
377 __debug_object_init(addr, descr, 1); 378 __debug_object_init(addr, descr, 1);
378} 379}
380EXPORT_SYMBOL_GPL(debug_object_init_on_stack);
379 381
380/** 382/**
381 * debug_object_activate - debug checks when an object is activated 383 * debug_object_activate - debug checks when an object is activated
@@ -449,6 +451,7 @@ int debug_object_activate(void *addr, struct debug_obj_descr *descr)
449 } 451 }
450 return 0; 452 return 0;
451} 453}
454EXPORT_SYMBOL_GPL(debug_object_activate);
452 455
453/** 456/**
454 * debug_object_deactivate - debug checks when an object is deactivated 457 * debug_object_deactivate - debug checks when an object is deactivated
@@ -496,6 +499,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
496 499
497 raw_spin_unlock_irqrestore(&db->lock, flags); 500 raw_spin_unlock_irqrestore(&db->lock, flags);
498} 501}
502EXPORT_SYMBOL_GPL(debug_object_deactivate);
499 503
500/** 504/**
501 * debug_object_destroy - debug checks when an object is destroyed 505 * debug_object_destroy - debug checks when an object is destroyed
@@ -542,6 +546,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
542out_unlock: 546out_unlock:
543 raw_spin_unlock_irqrestore(&db->lock, flags); 547 raw_spin_unlock_irqrestore(&db->lock, flags);
544} 548}
549EXPORT_SYMBOL_GPL(debug_object_destroy);
545 550
546/** 551/**
547 * debug_object_free - debug checks when an object is freed 552 * debug_object_free - debug checks when an object is freed
@@ -582,6 +587,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr)
582out_unlock: 587out_unlock:
583 raw_spin_unlock_irqrestore(&db->lock, flags); 588 raw_spin_unlock_irqrestore(&db->lock, flags);
584} 589}
590EXPORT_SYMBOL_GPL(debug_object_free);
585 591
586/** 592/**
587 * debug_object_assert_init - debug checks when object should be init-ed 593 * debug_object_assert_init - debug checks when object should be init-ed
@@ -626,6 +632,7 @@ void debug_object_assert_init(void *addr, struct debug_obj_descr *descr)
626 632
627 raw_spin_unlock_irqrestore(&db->lock, flags); 633 raw_spin_unlock_irqrestore(&db->lock, flags);
628} 634}
635EXPORT_SYMBOL_GPL(debug_object_assert_init);
629 636
630/** 637/**
631 * debug_object_active_state - debug checks object usage state machine 638 * debug_object_active_state - debug checks object usage state machine
@@ -673,6 +680,7 @@ debug_object_active_state(void *addr, struct debug_obj_descr *descr,
673 680
674 raw_spin_unlock_irqrestore(&db->lock, flags); 681 raw_spin_unlock_irqrestore(&db->lock, flags);
675} 682}
683EXPORT_SYMBOL_GPL(debug_object_active_state);
676 684
677#ifdef CONFIG_DEBUG_OBJECTS_FREE 685#ifdef CONFIG_DEBUG_OBJECTS_FREE
678static void __debug_check_no_obj_freed(const void *address, unsigned long size) 686static void __debug_check_no_obj_freed(const void *address, unsigned long size)
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 0a1139644d32..144fe6b1a03e 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -292,7 +292,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
292 struct gen_pool_chunk *chunk; 292 struct gen_pool_chunk *chunk;
293 unsigned long addr = 0; 293 unsigned long addr = 0;
294 int order = pool->min_alloc_order; 294 int order = pool->min_alloc_order;
295 int nbits, start_bit = 0, end_bit, remain; 295 int nbits, start_bit, end_bit, remain;
296 296
297#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG 297#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
298 BUG_ON(in_nmi()); 298 BUG_ON(in_nmi());
@@ -307,6 +307,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
307 if (size > atomic_read(&chunk->avail)) 307 if (size > atomic_read(&chunk->avail))
308 continue; 308 continue;
309 309
310 start_bit = 0;
310 end_bit = chunk_size(chunk) >> order; 311 end_bit = chunk_size(chunk) >> order;
311retry: 312retry:
312 start_bit = algo(chunk->bits, end_bit, start_bit, 313 start_bit = algo(chunk->bits, end_bit, start_bit,
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index f0c7f1481bae..f2bd21b93dfc 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -683,10 +683,11 @@ static void pipe_advance(struct iov_iter *i, size_t size)
683 struct pipe_inode_info *pipe = i->pipe; 683 struct pipe_inode_info *pipe = i->pipe;
684 struct pipe_buffer *buf; 684 struct pipe_buffer *buf;
685 int idx = i->idx; 685 int idx = i->idx;
686 size_t off = i->iov_offset; 686 size_t off = i->iov_offset, orig_sz;
687 687
688 if (unlikely(i->count < size)) 688 if (unlikely(i->count < size))
689 size = i->count; 689 size = i->count;
690 orig_sz = size;
690 691
691 if (size) { 692 if (size) {
692 if (off) /* make it relative to the beginning of buffer */ 693 if (off) /* make it relative to the beginning of buffer */
@@ -713,6 +714,7 @@ static void pipe_advance(struct iov_iter *i, size_t size)
713 pipe->nrbufs--; 714 pipe->nrbufs--;
714 } 715 }
715 } 716 }
717 i->count -= orig_sz;
716} 718}
717 719
718void iov_iter_advance(struct iov_iter *i, size_t size) 720void iov_iter_advance(struct iov_iter *i, size_t size)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 872a15a2a637..f3a217ea0388 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -980,23 +980,23 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
980#ifndef CONFIG_PROVE_LOCKING 980#ifndef CONFIG_PROVE_LOCKING
981 if (expected == FAILURE && debug_locks) { 981 if (expected == FAILURE && debug_locks) {
982 expected_testcase_failures++; 982 expected_testcase_failures++;
983 printk("failed|"); 983 pr_cont("failed|");
984 } 984 }
985 else 985 else
986#endif 986#endif
987 if (debug_locks != expected) { 987 if (debug_locks != expected) {
988 unexpected_testcase_failures++; 988 unexpected_testcase_failures++;
989 printk("FAILED|"); 989 pr_cont("FAILED|");
990 990
991 dump_stack(); 991 dump_stack();
992 } else { 992 } else {
993 testcase_successes++; 993 testcase_successes++;
994 printk(" ok |"); 994 pr_cont(" ok |");
995 } 995 }
996 testcase_total++; 996 testcase_total++;
997 997
998 if (debug_locks_verbose) 998 if (debug_locks_verbose)
999 printk(" lockclass mask: %x, debug_locks: %d, expected: %d\n", 999 pr_cont(" lockclass mask: %x, debug_locks: %d, expected: %d\n",
1000 lockclass_mask, debug_locks, expected); 1000 lockclass_mask, debug_locks, expected);
1001 /* 1001 /*
1002 * Some tests (e.g. double-unlock) might corrupt the preemption 1002 * Some tests (e.g. double-unlock) might corrupt the preemption
@@ -1021,26 +1021,26 @@ static inline void print_testname(const char *testname)
1021#define DO_TESTCASE_1(desc, name, nr) \ 1021#define DO_TESTCASE_1(desc, name, nr) \
1022 print_testname(desc"/"#nr); \ 1022 print_testname(desc"/"#nr); \
1023 dotest(name##_##nr, SUCCESS, LOCKTYPE_RWLOCK); \ 1023 dotest(name##_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
1024 printk("\n"); 1024 pr_cont("\n");
1025 1025
1026#define DO_TESTCASE_1B(desc, name, nr) \ 1026#define DO_TESTCASE_1B(desc, name, nr) \
1027 print_testname(desc"/"#nr); \ 1027 print_testname(desc"/"#nr); \
1028 dotest(name##_##nr, FAILURE, LOCKTYPE_RWLOCK); \ 1028 dotest(name##_##nr, FAILURE, LOCKTYPE_RWLOCK); \
1029 printk("\n"); 1029 pr_cont("\n");
1030 1030
1031#define DO_TESTCASE_3(desc, name, nr) \ 1031#define DO_TESTCASE_3(desc, name, nr) \
1032 print_testname(desc"/"#nr); \ 1032 print_testname(desc"/"#nr); \
1033 dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN); \ 1033 dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN); \
1034 dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \ 1034 dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \
1035 dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \ 1035 dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
1036 printk("\n"); 1036 pr_cont("\n");
1037 1037
1038#define DO_TESTCASE_3RW(desc, name, nr) \ 1038#define DO_TESTCASE_3RW(desc, name, nr) \
1039 print_testname(desc"/"#nr); \ 1039 print_testname(desc"/"#nr); \
1040 dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN|LOCKTYPE_RWLOCK);\ 1040 dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN|LOCKTYPE_RWLOCK);\
1041 dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \ 1041 dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \
1042 dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \ 1042 dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
1043 printk("\n"); 1043 pr_cont("\n");
1044 1044
1045#define DO_TESTCASE_6(desc, name) \ 1045#define DO_TESTCASE_6(desc, name) \
1046 print_testname(desc); \ 1046 print_testname(desc); \
@@ -1050,7 +1050,7 @@ static inline void print_testname(const char *testname)
1050 dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \ 1050 dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \
1051 dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \ 1051 dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
1052 dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \ 1052 dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
1053 printk("\n"); 1053 pr_cont("\n");
1054 1054
1055#define DO_TESTCASE_6_SUCCESS(desc, name) \ 1055#define DO_TESTCASE_6_SUCCESS(desc, name) \
1056 print_testname(desc); \ 1056 print_testname(desc); \
@@ -1060,7 +1060,7 @@ static inline void print_testname(const char *testname)
1060 dotest(name##_mutex, SUCCESS, LOCKTYPE_MUTEX); \ 1060 dotest(name##_mutex, SUCCESS, LOCKTYPE_MUTEX); \
1061 dotest(name##_wsem, SUCCESS, LOCKTYPE_RWSEM); \ 1061 dotest(name##_wsem, SUCCESS, LOCKTYPE_RWSEM); \
1062 dotest(name##_rsem, SUCCESS, LOCKTYPE_RWSEM); \ 1062 dotest(name##_rsem, SUCCESS, LOCKTYPE_RWSEM); \
1063 printk("\n"); 1063 pr_cont("\n");
1064 1064
1065/* 1065/*
1066 * 'read' variant: rlocks must not trigger. 1066 * 'read' variant: rlocks must not trigger.
@@ -1073,7 +1073,7 @@ static inline void print_testname(const char *testname)
1073 dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \ 1073 dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \
1074 dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \ 1074 dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
1075 dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \ 1075 dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
1076 printk("\n"); 1076 pr_cont("\n");
1077 1077
1078#define DO_TESTCASE_2I(desc, name, nr) \ 1078#define DO_TESTCASE_2I(desc, name, nr) \
1079 DO_TESTCASE_1("hard-"desc, name##_hard, nr); \ 1079 DO_TESTCASE_1("hard-"desc, name##_hard, nr); \
@@ -1726,25 +1726,25 @@ static void ww_tests(void)
1726 dotest(ww_test_fail_acquire, SUCCESS, LOCKTYPE_WW); 1726 dotest(ww_test_fail_acquire, SUCCESS, LOCKTYPE_WW);
1727 dotest(ww_test_normal, SUCCESS, LOCKTYPE_WW); 1727 dotest(ww_test_normal, SUCCESS, LOCKTYPE_WW);
1728 dotest(ww_test_unneeded_slow, FAILURE, LOCKTYPE_WW); 1728 dotest(ww_test_unneeded_slow, FAILURE, LOCKTYPE_WW);
1729 printk("\n"); 1729 pr_cont("\n");
1730 1730
1731 print_testname("ww contexts mixing"); 1731 print_testname("ww contexts mixing");
1732 dotest(ww_test_two_contexts, FAILURE, LOCKTYPE_WW); 1732 dotest(ww_test_two_contexts, FAILURE, LOCKTYPE_WW);
1733 dotest(ww_test_diff_class, FAILURE, LOCKTYPE_WW); 1733 dotest(ww_test_diff_class, FAILURE, LOCKTYPE_WW);
1734 printk("\n"); 1734 pr_cont("\n");
1735 1735
1736 print_testname("finishing ww context"); 1736 print_testname("finishing ww context");
1737 dotest(ww_test_context_done_twice, FAILURE, LOCKTYPE_WW); 1737 dotest(ww_test_context_done_twice, FAILURE, LOCKTYPE_WW);
1738 dotest(ww_test_context_unlock_twice, FAILURE, LOCKTYPE_WW); 1738 dotest(ww_test_context_unlock_twice, FAILURE, LOCKTYPE_WW);
1739 dotest(ww_test_context_fini_early, FAILURE, LOCKTYPE_WW); 1739 dotest(ww_test_context_fini_early, FAILURE, LOCKTYPE_WW);
1740 dotest(ww_test_context_lock_after_done, FAILURE, LOCKTYPE_WW); 1740 dotest(ww_test_context_lock_after_done, FAILURE, LOCKTYPE_WW);
1741 printk("\n"); 1741 pr_cont("\n");
1742 1742
1743 print_testname("locking mismatches"); 1743 print_testname("locking mismatches");
1744 dotest(ww_test_object_unlock_twice, FAILURE, LOCKTYPE_WW); 1744 dotest(ww_test_object_unlock_twice, FAILURE, LOCKTYPE_WW);
1745 dotest(ww_test_object_lock_unbalanced, FAILURE, LOCKTYPE_WW); 1745 dotest(ww_test_object_lock_unbalanced, FAILURE, LOCKTYPE_WW);
1746 dotest(ww_test_object_lock_stale_context, FAILURE, LOCKTYPE_WW); 1746 dotest(ww_test_object_lock_stale_context, FAILURE, LOCKTYPE_WW);
1747 printk("\n"); 1747 pr_cont("\n");
1748 1748
1749 print_testname("EDEADLK handling"); 1749 print_testname("EDEADLK handling");
1750 dotest(ww_test_edeadlk_normal, SUCCESS, LOCKTYPE_WW); 1750 dotest(ww_test_edeadlk_normal, SUCCESS, LOCKTYPE_WW);
@@ -1757,11 +1757,11 @@ static void ww_tests(void)
1757 dotest(ww_test_edeadlk_acquire_more_edeadlk_slow, FAILURE, LOCKTYPE_WW); 1757 dotest(ww_test_edeadlk_acquire_more_edeadlk_slow, FAILURE, LOCKTYPE_WW);
1758 dotest(ww_test_edeadlk_acquire_wrong, FAILURE, LOCKTYPE_WW); 1758 dotest(ww_test_edeadlk_acquire_wrong, FAILURE, LOCKTYPE_WW);
1759 dotest(ww_test_edeadlk_acquire_wrong_slow, FAILURE, LOCKTYPE_WW); 1759 dotest(ww_test_edeadlk_acquire_wrong_slow, FAILURE, LOCKTYPE_WW);
1760 printk("\n"); 1760 pr_cont("\n");
1761 1761
1762 print_testname("spinlock nest unlocked"); 1762 print_testname("spinlock nest unlocked");
1763 dotest(ww_test_spin_nest_unlocked, FAILURE, LOCKTYPE_WW); 1763 dotest(ww_test_spin_nest_unlocked, FAILURE, LOCKTYPE_WW);
1764 printk("\n"); 1764 pr_cont("\n");
1765 1765
1766 printk(" -----------------------------------------------------\n"); 1766 printk(" -----------------------------------------------------\n");
1767 printk(" |block | try |context|\n"); 1767 printk(" |block | try |context|\n");
@@ -1771,25 +1771,25 @@ static void ww_tests(void)
1771 dotest(ww_test_context_block, FAILURE, LOCKTYPE_WW); 1771 dotest(ww_test_context_block, FAILURE, LOCKTYPE_WW);
1772 dotest(ww_test_context_try, SUCCESS, LOCKTYPE_WW); 1772 dotest(ww_test_context_try, SUCCESS, LOCKTYPE_WW);
1773 dotest(ww_test_context_context, SUCCESS, LOCKTYPE_WW); 1773 dotest(ww_test_context_context, SUCCESS, LOCKTYPE_WW);
1774 printk("\n"); 1774 pr_cont("\n");
1775 1775
1776 print_testname("try"); 1776 print_testname("try");
1777 dotest(ww_test_try_block, FAILURE, LOCKTYPE_WW); 1777 dotest(ww_test_try_block, FAILURE, LOCKTYPE_WW);
1778 dotest(ww_test_try_try, SUCCESS, LOCKTYPE_WW); 1778 dotest(ww_test_try_try, SUCCESS, LOCKTYPE_WW);
1779 dotest(ww_test_try_context, FAILURE, LOCKTYPE_WW); 1779 dotest(ww_test_try_context, FAILURE, LOCKTYPE_WW);
1780 printk("\n"); 1780 pr_cont("\n");
1781 1781
1782 print_testname("block"); 1782 print_testname("block");
1783 dotest(ww_test_block_block, FAILURE, LOCKTYPE_WW); 1783 dotest(ww_test_block_block, FAILURE, LOCKTYPE_WW);
1784 dotest(ww_test_block_try, SUCCESS, LOCKTYPE_WW); 1784 dotest(ww_test_block_try, SUCCESS, LOCKTYPE_WW);
1785 dotest(ww_test_block_context, FAILURE, LOCKTYPE_WW); 1785 dotest(ww_test_block_context, FAILURE, LOCKTYPE_WW);
1786 printk("\n"); 1786 pr_cont("\n");
1787 1787
1788 print_testname("spinlock"); 1788 print_testname("spinlock");
1789 dotest(ww_test_spin_block, FAILURE, LOCKTYPE_WW); 1789 dotest(ww_test_spin_block, FAILURE, LOCKTYPE_WW);
1790 dotest(ww_test_spin_try, SUCCESS, LOCKTYPE_WW); 1790 dotest(ww_test_spin_try, SUCCESS, LOCKTYPE_WW);
1791 dotest(ww_test_spin_context, FAILURE, LOCKTYPE_WW); 1791 dotest(ww_test_spin_context, FAILURE, LOCKTYPE_WW);
1792 printk("\n"); 1792 pr_cont("\n");
1793} 1793}
1794 1794
1795void locking_selftest(void) 1795void locking_selftest(void)
@@ -1829,32 +1829,32 @@ void locking_selftest(void)
1829 1829
1830 printk(" --------------------------------------------------------------------------\n"); 1830 printk(" --------------------------------------------------------------------------\n");
1831 print_testname("recursive read-lock"); 1831 print_testname("recursive read-lock");
1832 printk(" |"); 1832 pr_cont(" |");
1833 dotest(rlock_AA1, SUCCESS, LOCKTYPE_RWLOCK); 1833 dotest(rlock_AA1, SUCCESS, LOCKTYPE_RWLOCK);
1834 printk(" |"); 1834 pr_cont(" |");
1835 dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM); 1835 dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM);
1836 printk("\n"); 1836 pr_cont("\n");
1837 1837
1838 print_testname("recursive read-lock #2"); 1838 print_testname("recursive read-lock #2");
1839 printk(" |"); 1839 pr_cont(" |");
1840 dotest(rlock_AA1B, SUCCESS, LOCKTYPE_RWLOCK); 1840 dotest(rlock_AA1B, SUCCESS, LOCKTYPE_RWLOCK);
1841 printk(" |"); 1841 pr_cont(" |");
1842 dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM); 1842 dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM);
1843 printk("\n"); 1843 pr_cont("\n");
1844 1844
1845 print_testname("mixed read-write-lock"); 1845 print_testname("mixed read-write-lock");
1846 printk(" |"); 1846 pr_cont(" |");
1847 dotest(rlock_AA2, FAILURE, LOCKTYPE_RWLOCK); 1847 dotest(rlock_AA2, FAILURE, LOCKTYPE_RWLOCK);
1848 printk(" |"); 1848 pr_cont(" |");
1849 dotest(rsem_AA2, FAILURE, LOCKTYPE_RWSEM); 1849 dotest(rsem_AA2, FAILURE, LOCKTYPE_RWSEM);
1850 printk("\n"); 1850 pr_cont("\n");
1851 1851
1852 print_testname("mixed write-read-lock"); 1852 print_testname("mixed write-read-lock");
1853 printk(" |"); 1853 pr_cont(" |");
1854 dotest(rlock_AA3, FAILURE, LOCKTYPE_RWLOCK); 1854 dotest(rlock_AA3, FAILURE, LOCKTYPE_RWLOCK);
1855 printk(" |"); 1855 pr_cont(" |");
1856 dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM); 1856 dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM);
1857 printk("\n"); 1857 pr_cont("\n");
1858 1858
1859 printk(" --------------------------------------------------------------------------\n"); 1859 printk(" --------------------------------------------------------------------------\n");
1860 1860
diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
index 5464c8744ea9..e24388a863a7 100644
--- a/lib/mpi/mpi-pow.c
+++ b/lib/mpi/mpi-pow.c
@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
64 if (!esize) { 64 if (!esize) {
65 /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 65 /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
66 * depending on if MOD equals 1. */ 66 * depending on if MOD equals 1. */
67 rp[0] = 1;
68 res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1; 67 res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
68 if (res->nlimbs) {
69 if (mpi_resize(res, 1) < 0)
70 goto enomem;
71 rp = res->d;
72 rp[0] = 1;
73 }
69 res->sign = 0; 74 res->sign = 0;
70 goto leave; 75 goto leave;
71 } 76 }
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 60f77f1d470a..f87d138e9672 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -50,7 +50,7 @@
50 STACK_ALLOC_ALIGN) 50 STACK_ALLOC_ALIGN)
51#define STACK_ALLOC_INDEX_BITS (DEPOT_STACK_BITS - \ 51#define STACK_ALLOC_INDEX_BITS (DEPOT_STACK_BITS - \
52 STACK_ALLOC_NULL_PROTECTION_BITS - STACK_ALLOC_OFFSET_BITS) 52 STACK_ALLOC_NULL_PROTECTION_BITS - STACK_ALLOC_OFFSET_BITS)
53#define STACK_ALLOC_SLABS_CAP 1024 53#define STACK_ALLOC_SLABS_CAP 8192
54#define STACK_ALLOC_MAX_SLABS \ 54#define STACK_ALLOC_MAX_SLABS \
55 (((1LL << (STACK_ALLOC_INDEX_BITS)) < STACK_ALLOC_SLABS_CAP) ? \ 55 (((1LL << (STACK_ALLOC_INDEX_BITS)) < STACK_ALLOC_SLABS_CAP) ? \
56 (1LL << (STACK_ALLOC_INDEX_BITS)) : STACK_ALLOC_SLABS_CAP) 56 (1LL << (STACK_ALLOC_INDEX_BITS)) : STACK_ALLOC_SLABS_CAP)
@@ -192,6 +192,7 @@ void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace)
192 trace->entries = stack->entries; 192 trace->entries = stack->entries;
193 trace->skip = 0; 193 trace->skip = 0;
194} 194}
195EXPORT_SYMBOL_GPL(depot_fetch_stack);
195 196
196/** 197/**
197 * depot_save_stack - save stack in a stack depot. 198 * depot_save_stack - save stack in a stack depot.
@@ -283,3 +284,4 @@ exit:
283fast_exit: 284fast_exit:
284 return retval; 285 return retval;
285} 286}
287EXPORT_SYMBOL_GPL(depot_save_stack);
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 94346b4d8984..0362da0b66c3 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4831,7 +4831,7 @@ static struct bpf_test tests[] = {
4831 { }, 4831 { },
4832 INTERNAL, 4832 INTERNAL,
4833 { 0x34 }, 4833 { 0x34 },
4834 { { 1, 0xbef } }, 4834 { { ETH_HLEN, 0xbef } },
4835 .fill_helper = bpf_fill_ld_abs_vlan_push_pop, 4835 .fill_helper = bpf_fill_ld_abs_vlan_push_pop,
4836 }, 4836 },
4837 /* 4837 /*
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 5e51872b3fc1..fbdf87920093 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -20,6 +20,11 @@
20#include <linux/uaccess.h> 20#include <linux/uaccess.h>
21#include <linux/module.h> 21#include <linux/module.h>
22 22
23/*
24 * Note: test functions are marked noinline so that their names appear in
25 * reports.
26 */
27
23static noinline void __init kmalloc_oob_right(void) 28static noinline void __init kmalloc_oob_right(void)
24{ 29{
25 char *ptr; 30 char *ptr;
@@ -411,6 +416,29 @@ static noinline void __init copy_user_test(void)
411 kfree(kmem); 416 kfree(kmem);
412} 417}
413 418
419static noinline void __init use_after_scope_test(void)
420{
421 volatile char *volatile p;
422
423 pr_info("use-after-scope on int\n");
424 {
425 int local = 0;
426
427 p = (char *)&local;
428 }
429 p[0] = 1;
430 p[3] = 1;
431
432 pr_info("use-after-scope on array\n");
433 {
434 char local[1024] = {0};
435
436 p = local;
437 }
438 p[0] = 1;
439 p[1023] = 1;
440}
441
414static int __init kmalloc_tests_init(void) 442static int __init kmalloc_tests_init(void)
415{ 443{
416 kmalloc_oob_right(); 444 kmalloc_oob_right();
@@ -436,6 +464,7 @@ static int __init kmalloc_tests_init(void)
436 kasan_global_oob(); 464 kasan_global_oob();
437 ksize_unpoisons_memory(); 465 ksize_unpoisons_memory();
438 copy_user_test(); 466 copy_user_test();
467 use_after_scope_test();
439 return -EAGAIN; 468 return -EAGAIN;
440} 469}
441 470