aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug150
-rw-r--r--lib/digsig.c6
-rw-r--r--lib/idr.c4
-rw-r--r--lib/iov_iter.c6
-rw-r--r--lib/kobject_uevent.c49
-rw-r--r--lib/locking-selftest.c2
-rw-r--r--lib/lz4/lz4_decompress.c4
-rw-r--r--lib/ratelimit.c4
-rw-r--r--lib/rhashtable.c9
-rw-r--r--lib/ts_fsm.c2
-rw-r--r--lib/ts_kmp.c2
11 files changed, 142 insertions, 96 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b19c491cbc4e..dfdad67d8f6c 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -219,7 +219,8 @@ config FRAME_WARN
219 range 0 8192 219 range 0 8192
220 default 0 if KASAN 220 default 0 if KASAN
221 default 2048 if GCC_PLUGIN_LATENT_ENTROPY 221 default 2048 if GCC_PLUGIN_LATENT_ENTROPY
222 default 1024 if !64BIT 222 default 1280 if (!64BIT && PARISC)
223 default 1024 if (!64BIT && !PARISC)
223 default 2048 if 64BIT 224 default 2048 if 64BIT
224 help 225 help
225 Tell gcc to warn at build time for stack frames larger than this. 226 Tell gcc to warn at build time for stack frames larger than this.
@@ -1091,8 +1092,8 @@ config PROVE_LOCKING
1091 select DEBUG_MUTEXES 1092 select DEBUG_MUTEXES
1092 select DEBUG_RT_MUTEXES if RT_MUTEXES 1093 select DEBUG_RT_MUTEXES if RT_MUTEXES
1093 select DEBUG_LOCK_ALLOC 1094 select DEBUG_LOCK_ALLOC
1094 select LOCKDEP_CROSSRELEASE 1095 select LOCKDEP_CROSSRELEASE if BROKEN
1095 select LOCKDEP_COMPLETIONS 1096 select LOCKDEP_COMPLETIONS if BROKEN
1096 select TRACE_IRQFLAGS 1097 select TRACE_IRQFLAGS
1097 default n 1098 default n
1098 help 1099 help
@@ -1589,6 +1590,54 @@ config LATENCYTOP
1589 1590
1590source kernel/trace/Kconfig 1591source kernel/trace/Kconfig
1591 1592
1593config PROVIDE_OHCI1394_DMA_INIT
1594 bool "Remote debugging over FireWire early on boot"
1595 depends on PCI && X86
1596 help
1597 If you want to debug problems which hang or crash the kernel early
1598 on boot and the crashing machine has a FireWire port, you can use
1599 this feature to remotely access the memory of the crashed machine
1600 over FireWire. This employs remote DMA as part of the OHCI1394
1601 specification which is now the standard for FireWire controllers.
1602
1603 With remote DMA, you can monitor the printk buffer remotely using
1604 firescope and access all memory below 4GB using fireproxy from gdb.
1605 Even controlling a kernel debugger is possible using remote DMA.
1606
1607 Usage:
1608
1609 If ohci1394_dma=early is used as boot parameter, it will initialize
1610 all OHCI1394 controllers which are found in the PCI config space.
1611
1612 As all changes to the FireWire bus such as enabling and disabling
1613 devices cause a bus reset and thereby disable remote DMA for all
1614 devices, be sure to have the cable plugged and FireWire enabled on
1615 the debugging host before booting the debug target for debugging.
1616
1617 This code (~1k) is freed after boot. By then, the firewire stack
1618 in charge of the OHCI-1394 controllers should be used instead.
1619
1620 See Documentation/debugging-via-ohci1394.txt for more information.
1621
1622config DMA_API_DEBUG
1623 bool "Enable debugging of DMA-API usage"
1624 depends on HAVE_DMA_API_DEBUG
1625 help
1626 Enable this option to debug the use of the DMA API by device drivers.
1627 With this option you will be able to detect common bugs in device
1628 drivers like double-freeing of DMA mappings or freeing mappings that
1629 were never allocated.
1630
1631 This also attempts to catch cases where a page owned by DMA is
1632 accessed by the cpu in a way that could cause data corruption. For
1633 example, this enables cow_user_page() to check that the source page is
1634 not undergoing DMA.
1635
1636 This option causes a performance degradation. Use only if you want to
1637 debug device drivers and dma interactions.
1638
1639 If unsure, say N.
1640
1592menu "Runtime Testing" 1641menu "Runtime Testing"
1593 1642
1594config LKDTM 1643config LKDTM
@@ -1748,56 +1797,6 @@ config TEST_PARMAN
1748 1797
1749 If unsure, say N. 1798 If unsure, say N.
1750 1799
1751endmenu # runtime tests
1752
1753config PROVIDE_OHCI1394_DMA_INIT
1754 bool "Remote debugging over FireWire early on boot"
1755 depends on PCI && X86
1756 help
1757 If you want to debug problems which hang or crash the kernel early
1758 on boot and the crashing machine has a FireWire port, you can use
1759 this feature to remotely access the memory of the crashed machine
1760 over FireWire. This employs remote DMA as part of the OHCI1394
1761 specification which is now the standard for FireWire controllers.
1762
1763 With remote DMA, you can monitor the printk buffer remotely using
1764 firescope and access all memory below 4GB using fireproxy from gdb.
1765 Even controlling a kernel debugger is possible using remote DMA.
1766
1767 Usage:
1768
1769 If ohci1394_dma=early is used as boot parameter, it will initialize
1770 all OHCI1394 controllers which are found in the PCI config space.
1771
1772 As all changes to the FireWire bus such as enabling and disabling
1773 devices cause a bus reset and thereby disable remote DMA for all
1774 devices, be sure to have the cable plugged and FireWire enabled on
1775 the debugging host before booting the debug target for debugging.
1776
1777 This code (~1k) is freed after boot. By then, the firewire stack
1778 in charge of the OHCI-1394 controllers should be used instead.
1779
1780 See Documentation/debugging-via-ohci1394.txt for more information.
1781
1782config DMA_API_DEBUG
1783 bool "Enable debugging of DMA-API usage"
1784 depends on HAVE_DMA_API_DEBUG
1785 help
1786 Enable this option to debug the use of the DMA API by device drivers.
1787 With this option you will be able to detect common bugs in device
1788 drivers like double-freeing of DMA mappings or freeing mappings that
1789 were never allocated.
1790
1791 This also attempts to catch cases where a page owned by DMA is
1792 accessed by the cpu in a way that could cause data corruption. For
1793 example, this enables cow_user_page() to check that the source page is
1794 not undergoing DMA.
1795
1796 This option causes a performance degradation. Use only if you want to
1797 debug device drivers and dma interactions.
1798
1799 If unsure, say N.
1800
1801config TEST_LKM 1800config TEST_LKM
1802 tristate "Test module loading with 'hello world' module" 1801 tristate "Test module loading with 'hello world' module"
1803 default n 1802 default n
@@ -1872,18 +1871,6 @@ config TEST_UDELAY
1872 1871
1873 If unsure, say N. 1872 If unsure, say N.
1874 1873
1875config MEMTEST
1876 bool "Memtest"
1877 depends on HAVE_MEMBLOCK
1878 ---help---
1879 This option adds a kernel parameter 'memtest', which allows memtest
1880 to be set.
1881 memtest=0, mean disabled; -- default
1882 memtest=1, mean do 1 test pattern;
1883 ...
1884 memtest=17, mean do 17 test patterns.
1885 If you are unsure how to answer this question, answer N.
1886
1887config TEST_STATIC_KEYS 1874config TEST_STATIC_KEYS
1888 tristate "Test static keys" 1875 tristate "Test static keys"
1889 default n 1876 default n
@@ -1893,16 +1880,6 @@ config TEST_STATIC_KEYS
1893 1880
1894 If unsure, say N. 1881 If unsure, say N.
1895 1882
1896config BUG_ON_DATA_CORRUPTION
1897 bool "Trigger a BUG when data corruption is detected"
1898 select DEBUG_LIST
1899 help
1900 Select this option if the kernel should BUG when it encounters
1901 data corruption in kernel memory structures when they get checked
1902 for validity.
1903
1904 If unsure, say N.
1905
1906config TEST_KMOD 1883config TEST_KMOD
1907 tristate "kmod stress tester" 1884 tristate "kmod stress tester"
1908 default n 1885 default n
@@ -1940,6 +1917,29 @@ config TEST_DEBUG_VIRTUAL
1940 1917
1941 If unsure, say N. 1918 If unsure, say N.
1942 1919
1920endmenu # runtime tests
1921
1922config MEMTEST
1923 bool "Memtest"
1924 depends on HAVE_MEMBLOCK
1925 ---help---
1926 This option adds a kernel parameter 'memtest', which allows memtest
1927 to be set.
1928 memtest=0, mean disabled; -- default
1929 memtest=1, mean do 1 test pattern;
1930 ...
1931 memtest=17, mean do 17 test patterns.
1932 If you are unsure how to answer this question, answer N.
1933
1934config BUG_ON_DATA_CORRUPTION
1935 bool "Trigger a BUG when data corruption is detected"
1936 select DEBUG_LIST
1937 help
1938 Select this option if the kernel should BUG when it encounters
1939 data corruption in kernel memory structures when they get checked
1940 for validity.
1941
1942 If unsure, say N.
1943 1943
1944source "samples/Kconfig" 1944source "samples/Kconfig"
1945 1945
diff --git a/lib/digsig.c b/lib/digsig.c
index 03d7c63837ae..6ba6fcd92dd1 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key,
87 down_read(&key->sem); 87 down_read(&key->sem);
88 ukp = user_key_payload_locked(key); 88 ukp = user_key_payload_locked(key);
89 89
90 if (!ukp) {
91 /* key was revoked before we acquired its semaphore */
92 err = -EKEYREVOKED;
93 goto err1;
94 }
95
90 if (ukp->datalen < sizeof(*pkh)) 96 if (ukp->datalen < sizeof(*pkh))
91 goto err1; 97 goto err1;
92 98
diff --git a/lib/idr.c b/lib/idr.c
index f9adf4805fd7..edd9b2be1651 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -146,8 +146,8 @@ EXPORT_SYMBOL(idr_get_next_ext);
146 * idr_alloc() and idr_remove() (as long as the ID being removed is not 146 * idr_alloc() and idr_remove() (as long as the ID being removed is not
147 * the one being replaced!). 147 * the one being replaced!).
148 * 148 *
149 * Returns: 0 on success. %-ENOENT indicates that @id was not found. 149 * Returns: the old value on success. %-ENOENT indicates that @id was not
150 * %-EINVAL indicates that @id or @ptr were not valid. 150 * found. %-EINVAL indicates that @id or @ptr were not valid.
151 */ 151 */
152void *idr_replace(struct idr *idr, void *ptr, int id) 152void *idr_replace(struct idr *idr, void *ptr, int id)
153{ 153{
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 52c8dd6d8e82..1c1c06ddc20a 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -687,8 +687,10 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
687 687
688static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) 688static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
689{ 689{
690 size_t v = n + offset; 690 struct page *head = compound_head(page);
691 if (likely(n <= v && v <= (PAGE_SIZE << compound_order(page)))) 691 size_t v = n + offset + page_address(page) - page_address(head);
692
693 if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head))))
692 return true; 694 return true;
693 WARN_ON(1); 695 WARN_ON(1);
694 return false; 696 return false;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index e590523ea476..f237a09a5862 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -294,6 +294,26 @@ static void cleanup_uevent_env(struct subprocess_info *info)
294} 294}
295#endif 295#endif
296 296
297static void zap_modalias_env(struct kobj_uevent_env *env)
298{
299 static const char modalias_prefix[] = "MODALIAS=";
300 int i;
301
302 for (i = 0; i < env->envp_idx;) {
303 if (strncmp(env->envp[i], modalias_prefix,
304 sizeof(modalias_prefix) - 1)) {
305 i++;
306 continue;
307 }
308
309 if (i != env->envp_idx - 1)
310 memmove(&env->envp[i], &env->envp[i + 1],
311 sizeof(env->envp[i]) * env->envp_idx - 1);
312
313 env->envp_idx--;
314 }
315}
316
297/** 317/**
298 * kobject_uevent_env - send an uevent with environmental data 318 * kobject_uevent_env - send an uevent with environmental data
299 * 319 *
@@ -409,16 +429,29 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
409 } 429 }
410 } 430 }
411 431
412 /* 432 switch (action) {
413 * Mark "add" and "remove" events in the object to ensure proper 433 case KOBJ_ADD:
414 * events to userspace during automatic cleanup. If the object did 434 /*
415 * send an "add" event, "remove" will automatically generated by 435 * Mark "add" event so we can make sure we deliver "remove"
416 * the core, if not already done by the caller. 436 * event to userspace during automatic cleanup. If
417 */ 437 * the object did send an "add" event, "remove" will
418 if (action == KOBJ_ADD) 438 * automatically generated by the core, if not already done
439 * by the caller.
440 */
419 kobj->state_add_uevent_sent = 1; 441 kobj->state_add_uevent_sent = 1;
420 else if (action == KOBJ_REMOVE) 442 break;
443
444 case KOBJ_REMOVE:
421 kobj->state_remove_uevent_sent = 1; 445 kobj->state_remove_uevent_sent = 1;
446 break;
447
448 case KOBJ_UNBIND:
449 zap_modalias_env(env);
450 break;
451
452 default:
453 break;
454 }
422 455
423 mutex_lock(&uevent_sock_mutex); 456 mutex_lock(&uevent_sock_mutex);
424 /* we will send an event, so request a new sequence number */ 457 /* we will send an event, so request a new sequence number */
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index cd0b5c964bd0..2b827b8a1d8c 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2031,11 +2031,13 @@ void locking_selftest(void)
2031 print_testname("mixed read-lock/lock-write ABBA"); 2031 print_testname("mixed read-lock/lock-write ABBA");
2032 pr_cont(" |"); 2032 pr_cont(" |");
2033 dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK); 2033 dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK);
2034#ifdef CONFIG_PROVE_LOCKING
2034 /* 2035 /*
2035 * Lockdep does indeed fail here, but there's nothing we can do about 2036 * Lockdep does indeed fail here, but there's nothing we can do about
2036 * that now. Don't kill lockdep for it. 2037 * that now. Don't kill lockdep for it.
2037 */ 2038 */
2038 unexpected_testcase_failures--; 2039 unexpected_testcase_failures--;
2040#endif
2039 2041
2040 pr_cont(" |"); 2042 pr_cont(" |");
2041 dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM); 2043 dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM);
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
index bd3574312b82..141734d255e4 100644
--- a/lib/lz4/lz4_decompress.c
+++ b/lib/lz4/lz4_decompress.c
@@ -85,8 +85,8 @@ static FORCE_INLINE int LZ4_decompress_generic(
85 const BYTE * const lowLimit = lowPrefix - dictSize; 85 const BYTE * const lowLimit = lowPrefix - dictSize;
86 86
87 const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize; 87 const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize;
88 const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; 88 static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 };
89 const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; 89 static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
90 90
91 const int safeDecode = (endOnInput == endOnInputSize); 91 const int safeDecode = (endOnInput == endOnInputSize);
92 const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB))); 92 const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB)));
diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 08f8043cac61..d01f47135239 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -48,7 +48,9 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)
48 if (time_is_before_jiffies(rs->begin + rs->interval)) { 48 if (time_is_before_jiffies(rs->begin + rs->interval)) {
49 if (rs->missed) { 49 if (rs->missed) {
50 if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) { 50 if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
51 pr_warn("%s: %d callbacks suppressed\n", func, rs->missed); 51 printk_deferred(KERN_WARNING
52 "%s: %d callbacks suppressed\n",
53 func, rs->missed);
52 rs->missed = 0; 54 rs->missed = 0;
53 } 55 }
54 } 56 }
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 707ca5d677c6..ddd7dde87c3c 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -735,9 +735,9 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_exit);
735 * rhashtable_walk_start - Start a hash table walk 735 * rhashtable_walk_start - Start a hash table walk
736 * @iter: Hash table iterator 736 * @iter: Hash table iterator
737 * 737 *
738 * Start a hash table walk. Note that we take the RCU lock in all 738 * Start a hash table walk at the current iterator position. Note that we take
739 * cases including when we return an error. So you must always call 739 * the RCU lock in all cases including when we return an error. So you must
740 * rhashtable_walk_stop to clean up. 740 * always call rhashtable_walk_stop to clean up.
741 * 741 *
742 * Returns zero if successful. 742 * Returns zero if successful.
743 * 743 *
@@ -846,7 +846,8 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_next);
846 * rhashtable_walk_stop - Finish a hash table walk 846 * rhashtable_walk_stop - Finish a hash table walk
847 * @iter: Hash table iterator 847 * @iter: Hash table iterator
848 * 848 *
849 * Finish a hash table walk. 849 * Finish a hash table walk. Does not reset the iterator to the start of the
850 * hash table.
850 */ 851 */
851void rhashtable_walk_stop(struct rhashtable_iter *iter) 852void rhashtable_walk_stop(struct rhashtable_iter *iter)
852 __releases(RCU) 853 __releases(RCU)
diff --git a/lib/ts_fsm.c b/lib/ts_fsm.c
index 5696a35184e4..69557c74ef9f 100644
--- a/lib/ts_fsm.c
+++ b/lib/ts_fsm.c
@@ -11,7 +11,7 @@
11 * ========================================================================== 11 * ==========================================================================
12 * 12 *
13 * A finite state machine consists of n states (struct ts_fsm_token) 13 * A finite state machine consists of n states (struct ts_fsm_token)
14 * representing the pattern as a finite automation. The data is read 14 * representing the pattern as a finite automaton. The data is read
15 * sequentially on an octet basis. Every state token specifies the number 15 * sequentially on an octet basis. Every state token specifies the number
16 * of recurrences and the type of value accepted which can be either a 16 * of recurrences and the type of value accepted which can be either a
17 * specific character or ctype based set of characters. The available 17 * specific character or ctype based set of characters. The available
diff --git a/lib/ts_kmp.c b/lib/ts_kmp.c
index 632f783e65f1..ffbe66cbb0ed 100644
--- a/lib/ts_kmp.c
+++ b/lib/ts_kmp.c
@@ -27,7 +27,7 @@
27 * 27 *
28 * [1] Cormen, Leiserson, Rivest, Stein 28 * [1] Cormen, Leiserson, Rivest, Stein
29 * Introdcution to Algorithms, 2nd Edition, MIT Press 29 * Introdcution to Algorithms, 2nd Edition, MIT Press
30 * [2] See finite automation theory 30 * [2] See finite automaton theory
31 */ 31 */
32 32
33#include <linux/module.h> 33#include <linux/module.h>