aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-09-19 01:56:44 -0400
committerDmitry Torokhov <dtor@insightbb.com>2006-09-19 01:56:44 -0400
commit0612ec48762bf8712db1925b2e67246d2237ebab (patch)
tree01b0d69c9c9915015c0f23ad4263646dd5413e99 /lib
parent4263cf0fac28122c8381b6f4f9441a43cd93c81f (diff)
parent47a5c6fa0e204a2b63309c648bb2fde36836c826 (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig5
-rw-r--r--lib/Kconfig.debug10
-rw-r--r--lib/Makefile1
-rw-r--r--lib/audit.c53
-rw-r--r--lib/idr.c16
-rw-r--r--lib/kobject_uevent.c4
-rw-r--r--lib/spinlock_debug.c10
-rw-r--r--lib/ts_bm.c11
-rw-r--r--lib/zlib_inflate/inflate.c5
9 files changed, 90 insertions, 25 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index f6299342b882..734ce95a93d1 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -38,6 +38,11 @@ config LIBCRC32C
38 require M here. See Castagnoli93. 38 require M here. See Castagnoli93.
39 Module will be libcrc32c. 39 Module will be libcrc32c.
40 40
41config AUDIT_GENERIC
42 bool
43 depends on AUDIT && !AUDIT_ARCH
44 default y
45
41# 46#
42# compression support is select'ed if needed 47# compression support is select'ed if needed
43# 48#
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e5889b1a33ff..554ee688a9f8 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -158,7 +158,7 @@ config DEBUG_RWSEMS
158 158
159config DEBUG_LOCK_ALLOC 159config DEBUG_LOCK_ALLOC
160 bool "Lock debugging: detect incorrect freeing of live locks" 160 bool "Lock debugging: detect incorrect freeing of live locks"
161 depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 161 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
162 select DEBUG_SPINLOCK 162 select DEBUG_SPINLOCK
163 select DEBUG_MUTEXES 163 select DEBUG_MUTEXES
164 select DEBUG_RWSEMS 164 select DEBUG_RWSEMS
@@ -173,7 +173,7 @@ config DEBUG_LOCK_ALLOC
173 173
174config PROVE_LOCKING 174config PROVE_LOCKING
175 bool "Lock debugging: prove locking correctness" 175 bool "Lock debugging: prove locking correctness"
176 depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 176 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
177 select LOCKDEP 177 select LOCKDEP
178 select DEBUG_SPINLOCK 178 select DEBUG_SPINLOCK
179 select DEBUG_MUTEXES 179 select DEBUG_MUTEXES
@@ -216,7 +216,7 @@ config PROVE_LOCKING
216 216
217config LOCKDEP 217config LOCKDEP
218 bool 218 bool
219 depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 219 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
220 select STACKTRACE 220 select STACKTRACE
221 select FRAME_POINTER 221 select FRAME_POINTER
222 select KALLSYMS 222 select KALLSYMS
@@ -224,13 +224,14 @@ config LOCKDEP
224 224
225config DEBUG_LOCKDEP 225config DEBUG_LOCKDEP
226 bool "Lock dependency engine debugging" 226 bool "Lock dependency engine debugging"
227 depends on LOCKDEP 227 depends on DEBUG_KERNEL && LOCKDEP
228 help 228 help
229 If you say Y here, the lock dependency engine will do 229 If you say Y here, the lock dependency engine will do
230 additional runtime checks to debug itself, at the price 230 additional runtime checks to debug itself, at the price
231 of more runtime overhead. 231 of more runtime overhead.
232 232
233config TRACE_IRQFLAGS 233config TRACE_IRQFLAGS
234 depends on DEBUG_KERNEL
234 bool 235 bool
235 default y 236 default y
236 depends on TRACE_IRQFLAGS_SUPPORT 237 depends on TRACE_IRQFLAGS_SUPPORT
@@ -256,6 +257,7 @@ config DEBUG_LOCKING_API_SELFTESTS
256 257
257config STACKTRACE 258config STACKTRACE
258 bool 259 bool
260 depends on DEBUG_KERNEL
259 depends on STACKTRACE_SUPPORT 261 depends on STACKTRACE_SUPPORT
260 262
261config DEBUG_KOBJECT 263config DEBUG_KOBJECT
diff --git a/lib/Makefile b/lib/Makefile
index be9719ae82d0..ef1d37afbbb6 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o
49obj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o 49obj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o
50obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o 50obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
51obj-$(CONFIG_SMP) += percpu_counter.o 51obj-$(CONFIG_SMP) += percpu_counter.o
52obj-$(CONFIG_AUDIT_GENERIC) += audit.o
52 53
53obj-$(CONFIG_SWIOTLB) += swiotlb.o 54obj-$(CONFIG_SWIOTLB) += swiotlb.o
54 55
diff --git a/lib/audit.c b/lib/audit.c
new file mode 100644
index 000000000000..8c21625ef938
--- /dev/null
+++ b/lib/audit.c
@@ -0,0 +1,53 @@
1#include <linux/init.h>
2#include <linux/types.h>
3#include <linux/audit.h>
4#include <asm/unistd.h>
5
6static unsigned dir_class[] = {
7#include <asm-generic/audit_dir_write.h>
8~0U
9};
10
11static unsigned read_class[] = {
12#include <asm-generic/audit_read.h>
13~0U
14};
15
16static unsigned write_class[] = {
17#include <asm-generic/audit_write.h>
18~0U
19};
20
21static unsigned chattr_class[] = {
22#include <asm-generic/audit_change_attr.h>
23~0U
24};
25
26int audit_classify_syscall(int abi, unsigned syscall)
27{
28 switch(syscall) {
29 case __NR_open:
30 return 2;
31 case __NR_openat:
32 return 3;
33#ifdef __NR_socketcall
34 case __NR_socketcall:
35 return 4;
36#endif
37 case __NR_execve:
38 return 5;
39 default:
40 return 0;
41 }
42}
43
44static int __init audit_classes_init(void)
45{
46 audit_register_class(AUDIT_CLASS_WRITE, write_class);
47 audit_register_class(AUDIT_CLASS_READ, read_class);
48 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
49 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
50 return 0;
51}
52
53__initcall(audit_classes_init);
diff --git a/lib/idr.c b/lib/idr.c
index 4d096819511a..16d2143fea48 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -38,14 +38,15 @@ static kmem_cache_t *idr_layer_cache;
38static struct idr_layer *alloc_layer(struct idr *idp) 38static struct idr_layer *alloc_layer(struct idr *idp)
39{ 39{
40 struct idr_layer *p; 40 struct idr_layer *p;
41 unsigned long flags;
41 42
42 spin_lock(&idp->lock); 43 spin_lock_irqsave(&idp->lock, flags);
43 if ((p = idp->id_free)) { 44 if ((p = idp->id_free)) {
44 idp->id_free = p->ary[0]; 45 idp->id_free = p->ary[0];
45 idp->id_free_cnt--; 46 idp->id_free_cnt--;
46 p->ary[0] = NULL; 47 p->ary[0] = NULL;
47 } 48 }
48 spin_unlock(&idp->lock); 49 spin_unlock_irqrestore(&idp->lock, flags);
49 return(p); 50 return(p);
50} 51}
51 52
@@ -59,12 +60,14 @@ static void __free_layer(struct idr *idp, struct idr_layer *p)
59 60
60static void free_layer(struct idr *idp, struct idr_layer *p) 61static void free_layer(struct idr *idp, struct idr_layer *p)
61{ 62{
63 unsigned long flags;
64
62 /* 65 /*
63 * Depends on the return element being zeroed. 66 * Depends on the return element being zeroed.
64 */ 67 */
65 spin_lock(&idp->lock); 68 spin_lock_irqsave(&idp->lock, flags);
66 __free_layer(idp, p); 69 __free_layer(idp, p);
67 spin_unlock(&idp->lock); 70 spin_unlock_irqrestore(&idp->lock, flags);
68} 71}
69 72
70/** 73/**
@@ -168,6 +171,7 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id)
168{ 171{
169 struct idr_layer *p, *new; 172 struct idr_layer *p, *new;
170 int layers, v, id; 173 int layers, v, id;
174 unsigned long flags;
171 175
172 id = starting_id; 176 id = starting_id;
173build_up: 177build_up:
@@ -191,14 +195,14 @@ build_up:
191 * The allocation failed. If we built part of 195 * The allocation failed. If we built part of
192 * the structure tear it down. 196 * the structure tear it down.
193 */ 197 */
194 spin_lock(&idp->lock); 198 spin_lock_irqsave(&idp->lock, flags);
195 for (new = p; p && p != idp->top; new = p) { 199 for (new = p; p && p != idp->top; new = p) {
196 p = p->ary[0]; 200 p = p->ary[0];
197 new->ary[0] = NULL; 201 new->ary[0] = NULL;
198 new->bitmap = new->count = 0; 202 new->bitmap = new->count = 0;
199 __free_layer(idp, new); 203 __free_layer(idp, new);
200 } 204 }
201 spin_unlock(&idp->lock); 205 spin_unlock_irqrestore(&idp->lock, flags);
202 return -1; 206 return -1;
203 } 207 }
204 new->ary[0] = p; 208 new->ary[0] = p;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 2b1530fc573b..7f20e7b857cb 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -50,10 +50,6 @@ static char *action_to_string(enum kobject_action action)
50 return "offline"; 50 return "offline";
51 case KOBJ_ONLINE: 51 case KOBJ_ONLINE:
52 return "online"; 52 return "online";
53 case KOBJ_DOCK:
54 return "dock";
55 case KOBJ_UNDOCK:
56 return "undock";
57 default: 53 default:
58 return NULL; 54 return NULL;
59 } 55 }
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index 3d9c4dc965ed..58c577dd82e5 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -162,6 +162,7 @@ static void rwlock_bug(rwlock_t *lock, const char *msg)
162 162
163#define RWLOCK_BUG_ON(cond, lock, msg) if (unlikely(cond)) rwlock_bug(lock, msg) 163#define RWLOCK_BUG_ON(cond, lock, msg) if (unlikely(cond)) rwlock_bug(lock, msg)
164 164
165#if 0 /* __write_lock_debug() can lock up - maybe this can too? */
165static void __read_lock_debug(rwlock_t *lock) 166static void __read_lock_debug(rwlock_t *lock)
166{ 167{
167 int print_once = 1; 168 int print_once = 1;
@@ -184,12 +185,12 @@ static void __read_lock_debug(rwlock_t *lock)
184 } 185 }
185 } 186 }
186} 187}
188#endif
187 189
188void _raw_read_lock(rwlock_t *lock) 190void _raw_read_lock(rwlock_t *lock)
189{ 191{
190 RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic"); 192 RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
191 if (unlikely(!__raw_read_trylock(&lock->raw_lock))) 193 __raw_read_lock(&lock->raw_lock);
192 __read_lock_debug(lock);
193} 194}
194 195
195int _raw_read_trylock(rwlock_t *lock) 196int _raw_read_trylock(rwlock_t *lock)
@@ -235,6 +236,7 @@ static inline void debug_write_unlock(rwlock_t *lock)
235 lock->owner_cpu = -1; 236 lock->owner_cpu = -1;
236} 237}
237 238
239#if 0 /* This can cause lockups */
238static void __write_lock_debug(rwlock_t *lock) 240static void __write_lock_debug(rwlock_t *lock)
239{ 241{
240 int print_once = 1; 242 int print_once = 1;
@@ -257,12 +259,12 @@ static void __write_lock_debug(rwlock_t *lock)
257 } 259 }
258 } 260 }
259} 261}
262#endif
260 263
261void _raw_write_lock(rwlock_t *lock) 264void _raw_write_lock(rwlock_t *lock)
262{ 265{
263 debug_write_lock_before(lock); 266 debug_write_lock_before(lock);
264 if (unlikely(!__raw_write_trylock(&lock->raw_lock))) 267 __raw_write_lock(&lock->raw_lock);
265 __write_lock_debug(lock);
266 debug_write_lock_after(lock); 268 debug_write_lock_after(lock);
267} 269}
268 270
diff --git a/lib/ts_bm.c b/lib/ts_bm.c
index 0110e4414805..d90822c378a4 100644
--- a/lib/ts_bm.c
+++ b/lib/ts_bm.c
@@ -111,15 +111,14 @@ static int subpattern(u8 *pattern, int i, int j, int g)
111 return ret; 111 return ret;
112} 112}
113 113
114static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern, 114static void compute_prefix_tbl(struct ts_bm *bm)
115 unsigned int len)
116{ 115{
117 int i, j, g; 116 int i, j, g;
118 117
119 for (i = 0; i < ASIZE; i++) 118 for (i = 0; i < ASIZE; i++)
120 bm->bad_shift[i] = len; 119 bm->bad_shift[i] = bm->patlen;
121 for (i = 0; i < len - 1; i++) 120 for (i = 0; i < bm->patlen - 1; i++)
122 bm->bad_shift[pattern[i]] = len - 1 - i; 121 bm->bad_shift[bm->pattern[i]] = bm->patlen - 1 - i;
123 122
124 /* Compute the good shift array, used to match reocurrences 123 /* Compute the good shift array, used to match reocurrences
125 * of a subpattern */ 124 * of a subpattern */
@@ -150,8 +149,8 @@ static struct ts_config *bm_init(const void *pattern, unsigned int len,
150 bm = ts_config_priv(conf); 149 bm = ts_config_priv(conf);
151 bm->patlen = len; 150 bm->patlen = len;
152 bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len; 151 bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len;
153 compute_prefix_tbl(bm, pattern, len);
154 memcpy(bm->pattern, pattern, len); 152 memcpy(bm->pattern, pattern, len);
153 compute_prefix_tbl(bm);
155 154
156 return conf; 155 return conf;
157} 156}
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index 7f922dccf1a5..fceb97c3aff7 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -347,7 +347,10 @@ int zlib_inflate(z_streamp strm, int flush)
347 static const unsigned short order[19] = /* permutation of code lengths */ 347 static const unsigned short order[19] = /* permutation of code lengths */
348 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; 348 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
349 349
350 if (strm == NULL || strm->state == NULL || strm->next_out == NULL || 350 /* Do not check for strm->next_out == NULL here as ppc zImage
351 inflates to strm->next_out = 0 */
352
353 if (strm == NULL || strm->state == NULL ||
351 (strm->next_in == NULL && strm->avail_in != 0)) 354 (strm->next_in == NULL && strm->avail_in != 0))
352 return Z_STREAM_ERROR; 355 return Z_STREAM_ERROR;
353 356