diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cred.c | 25 | ||||
-rw-r--r-- | kernel/debug/debug_core.c | 2 | ||||
-rw-r--r-- | kernel/debug/gdbstub.c | 9 | ||||
-rw-r--r-- | kernel/debug/kdb/kdb_main.c | 7 | ||||
-rw-r--r-- | kernel/early_res.c | 6 | ||||
-rw-r--r-- | kernel/module.c | 27 | ||||
-rw-r--r-- | kernel/sched.c | 4 | ||||
-rw-r--r-- | kernel/time/tick-sched.c | 16 |
8 files changed, 68 insertions, 28 deletions
diff --git a/kernel/cred.c b/kernel/cred.c index a2d5504fbcc2..60bc8b1e32e6 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
@@ -209,6 +209,31 @@ void exit_creds(struct task_struct *tsk) | |||
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | /** | ||
213 | * get_task_cred - Get another task's objective credentials | ||
214 | * @task: The task to query | ||
215 | * | ||
216 | * Get the objective credentials of a task, pinning them so that they can't go | ||
217 | * away. Accessing a task's credentials directly is not permitted. | ||
218 | * | ||
219 | * The caller must also make sure task doesn't get deleted, either by holding a | ||
220 | * ref on task or by holding tasklist_lock to prevent it from being unlinked. | ||
221 | */ | ||
222 | const struct cred *get_task_cred(struct task_struct *task) | ||
223 | { | ||
224 | const struct cred *cred; | ||
225 | |||
226 | rcu_read_lock(); | ||
227 | |||
228 | do { | ||
229 | cred = __task_cred((task)); | ||
230 | BUG_ON(!cred); | ||
231 | } while (!atomic_inc_not_zero(&((struct cred *)cred)->usage)); | ||
232 | |||
233 | rcu_read_unlock(); | ||
234 | return cred; | ||
235 | } | ||
236 | |||
212 | /* | 237 | /* |
213 | * Allocate blank credentials, such that the credentials can be filled in at a | 238 | * Allocate blank credentials, such that the credentials can be filled in at a |
214 | * later date without risk of ENOMEM. | 239 | * later date without risk of ENOMEM. |
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 5cb7cd1de10c..8bc5eeffec8a 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c | |||
@@ -605,13 +605,13 @@ cpu_master_loop: | |||
605 | if (dbg_kdb_mode) { | 605 | if (dbg_kdb_mode) { |
606 | kgdb_connected = 1; | 606 | kgdb_connected = 1; |
607 | error = kdb_stub(ks); | 607 | error = kdb_stub(ks); |
608 | kgdb_connected = 0; | ||
608 | } else { | 609 | } else { |
609 | error = gdb_serial_stub(ks); | 610 | error = gdb_serial_stub(ks); |
610 | } | 611 | } |
611 | 612 | ||
612 | if (error == DBG_PASS_EVENT) { | 613 | if (error == DBG_PASS_EVENT) { |
613 | dbg_kdb_mode = !dbg_kdb_mode; | 614 | dbg_kdb_mode = !dbg_kdb_mode; |
614 | kgdb_connected = 0; | ||
615 | } else if (error == DBG_SWITCH_CPU_EVENT) { | 615 | } else if (error == DBG_SWITCH_CPU_EVENT) { |
616 | dbg_cpu_switch(cpu, dbg_switch_cpu); | 616 | dbg_cpu_switch(cpu, dbg_switch_cpu); |
617 | goto cpu_loop; | 617 | goto cpu_loop; |
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index 4b17b3269525..e8fd6868682d 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c | |||
@@ -621,10 +621,8 @@ static void gdb_cmd_query(struct kgdb_state *ks) | |||
621 | switch (remcom_in_buffer[1]) { | 621 | switch (remcom_in_buffer[1]) { |
622 | case 's': | 622 | case 's': |
623 | case 'f': | 623 | case 'f': |
624 | if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) { | 624 | if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) |
625 | error_packet(remcom_out_buffer, -EINVAL); | ||
626 | break; | 625 | break; |
627 | } | ||
628 | 626 | ||
629 | i = 0; | 627 | i = 0; |
630 | remcom_out_buffer[0] = 'm'; | 628 | remcom_out_buffer[0] = 'm'; |
@@ -665,10 +663,9 @@ static void gdb_cmd_query(struct kgdb_state *ks) | |||
665 | pack_threadid(remcom_out_buffer + 2, thref); | 663 | pack_threadid(remcom_out_buffer + 2, thref); |
666 | break; | 664 | break; |
667 | case 'T': | 665 | case 'T': |
668 | if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) { | 666 | if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) |
669 | error_packet(remcom_out_buffer, -EINVAL); | ||
670 | break; | 667 | break; |
671 | } | 668 | |
672 | ks->threadid = 0; | 669 | ks->threadid = 0; |
673 | ptr = remcom_in_buffer + 17; | 670 | ptr = remcom_in_buffer + 17; |
674 | kgdb_hex2long(&ptr, &ks->threadid); | 671 | kgdb_hex2long(&ptr, &ks->threadid); |
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 184cd8209c36..ebe4a287419e 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
@@ -1820,9 +1820,8 @@ static int kdb_sr(int argc, const char **argv) | |||
1820 | { | 1820 | { |
1821 | if (argc != 1) | 1821 | if (argc != 1) |
1822 | return KDB_ARGCOUNT; | 1822 | return KDB_ARGCOUNT; |
1823 | sysrq_toggle_support(1); | ||
1824 | kdb_trap_printk++; | 1823 | kdb_trap_printk++; |
1825 | handle_sysrq(*argv[1], NULL); | 1824 | __handle_sysrq(*argv[1], NULL, 0); |
1826 | kdb_trap_printk--; | 1825 | kdb_trap_printk--; |
1827 | 1826 | ||
1828 | return 0; | 1827 | return 0; |
@@ -1883,6 +1882,7 @@ static int kdb_lsmod(int argc, const char **argv) | |||
1883 | kdb_printf(" (Loading)"); | 1882 | kdb_printf(" (Loading)"); |
1884 | else | 1883 | else |
1885 | kdb_printf(" (Live)"); | 1884 | kdb_printf(" (Live)"); |
1885 | kdb_printf(" 0x%p", mod->module_core); | ||
1886 | 1886 | ||
1887 | #ifdef CONFIG_MODULE_UNLOAD | 1887 | #ifdef CONFIG_MODULE_UNLOAD |
1888 | { | 1888 | { |
@@ -2291,6 +2291,9 @@ static int kdb_ll(int argc, const char **argv) | |||
2291 | while (va) { | 2291 | while (va) { |
2292 | char buf[80]; | 2292 | char buf[80]; |
2293 | 2293 | ||
2294 | if (KDB_FLAG(CMD_INTERRUPT)) | ||
2295 | return 0; | ||
2296 | |||
2294 | sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va); | 2297 | sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va); |
2295 | diag = kdb_parse(buf); | 2298 | diag = kdb_parse(buf); |
2296 | if (diag) | 2299 | if (diag) |
diff --git a/kernel/early_res.c b/kernel/early_res.c index 31aa9332ef3f..7bfae887f211 100644 --- a/kernel/early_res.c +++ b/kernel/early_res.c | |||
@@ -7,6 +7,8 @@ | |||
7 | #include <linux/bootmem.h> | 7 | #include <linux/bootmem.h> |
8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
9 | #include <linux/early_res.h> | 9 | #include <linux/early_res.h> |
10 | #include <linux/slab.h> | ||
11 | #include <linux/kmemleak.h> | ||
10 | 12 | ||
11 | /* | 13 | /* |
12 | * Early reserved memory areas. | 14 | * Early reserved memory areas. |
@@ -319,6 +321,8 @@ void __init free_early(u64 start, u64 end) | |||
319 | struct early_res *r; | 321 | struct early_res *r; |
320 | int i; | 322 | int i; |
321 | 323 | ||
324 | kmemleak_free_part(__va(start), end - start); | ||
325 | |||
322 | i = find_overlapped_early(start, end); | 326 | i = find_overlapped_early(start, end); |
323 | r = &early_res[i]; | 327 | r = &early_res[i]; |
324 | if (i >= max_early_res || r->end != end || r->start != start) | 328 | if (i >= max_early_res || r->end != end || r->start != start) |
@@ -333,6 +337,8 @@ void __init free_early_partial(u64 start, u64 end) | |||
333 | struct early_res *r; | 337 | struct early_res *r; |
334 | int i; | 338 | int i; |
335 | 339 | ||
340 | kmemleak_free_part(__va(start), end - start); | ||
341 | |||
336 | if (start == end) | 342 | if (start == end) |
337 | return; | 343 | return; |
338 | 344 | ||
diff --git a/kernel/module.c b/kernel/module.c index 8c6b42840dd1..6c562828c85c 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -787,7 +787,6 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, | |||
787 | 787 | ||
788 | /* Store the name of the last unloaded module for diagnostic purposes */ | 788 | /* Store the name of the last unloaded module for diagnostic purposes */ |
789 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); | 789 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); |
790 | ddebug_remove_module(mod->name); | ||
791 | 790 | ||
792 | free_module(mod); | 791 | free_module(mod); |
793 | return 0; | 792 | return 0; |
@@ -1550,6 +1549,9 @@ static void free_module(struct module *mod) | |||
1550 | remove_sect_attrs(mod); | 1549 | remove_sect_attrs(mod); |
1551 | mod_kobject_remove(mod); | 1550 | mod_kobject_remove(mod); |
1552 | 1551 | ||
1552 | /* Remove dynamic debug info */ | ||
1553 | ddebug_remove_module(mod->name); | ||
1554 | |||
1553 | /* Arch-specific cleanup. */ | 1555 | /* Arch-specific cleanup. */ |
1554 | module_arch_cleanup(mod); | 1556 | module_arch_cleanup(mod); |
1555 | 1557 | ||
@@ -2062,6 +2064,12 @@ static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num) | |||
2062 | #endif | 2064 | #endif |
2063 | } | 2065 | } |
2064 | 2066 | ||
2067 | static void dynamic_debug_remove(struct _ddebug *debug) | ||
2068 | { | ||
2069 | if (debug) | ||
2070 | ddebug_remove_module(debug->modname); | ||
2071 | } | ||
2072 | |||
2065 | static void *module_alloc_update_bounds(unsigned long size) | 2073 | static void *module_alloc_update_bounds(unsigned long size) |
2066 | { | 2074 | { |
2067 | void *ret = module_alloc(size); | 2075 | void *ret = module_alloc(size); |
@@ -2124,6 +2132,8 @@ static noinline struct module *load_module(void __user *umod, | |||
2124 | void *ptr = NULL; /* Stops spurious gcc warning */ | 2132 | void *ptr = NULL; /* Stops spurious gcc warning */ |
2125 | unsigned long symoffs, stroffs, *strmap; | 2133 | unsigned long symoffs, stroffs, *strmap; |
2126 | void __percpu *percpu; | 2134 | void __percpu *percpu; |
2135 | struct _ddebug *debug = NULL; | ||
2136 | unsigned int num_debug = 0; | ||
2127 | 2137 | ||
2128 | mm_segment_t old_fs; | 2138 | mm_segment_t old_fs; |
2129 | 2139 | ||
@@ -2476,15 +2486,9 @@ static noinline struct module *load_module(void __user *umod, | |||
2476 | kfree(strmap); | 2486 | kfree(strmap); |
2477 | strmap = NULL; | 2487 | strmap = NULL; |
2478 | 2488 | ||
2479 | if (!mod->taints) { | 2489 | if (!mod->taints) |
2480 | struct _ddebug *debug; | ||
2481 | unsigned int num_debug; | ||
2482 | |||
2483 | debug = section_objs(hdr, sechdrs, secstrings, "__verbose", | 2490 | debug = section_objs(hdr, sechdrs, secstrings, "__verbose", |
2484 | sizeof(*debug), &num_debug); | 2491 | sizeof(*debug), &num_debug); |
2485 | if (debug) | ||
2486 | dynamic_debug_setup(debug, num_debug); | ||
2487 | } | ||
2488 | 2492 | ||
2489 | err = module_finalize(hdr, sechdrs, mod); | 2493 | err = module_finalize(hdr, sechdrs, mod); |
2490 | if (err < 0) | 2494 | if (err < 0) |
@@ -2526,10 +2530,13 @@ static noinline struct module *load_module(void __user *umod, | |||
2526 | goto unlock; | 2530 | goto unlock; |
2527 | } | 2531 | } |
2528 | 2532 | ||
2533 | if (debug) | ||
2534 | dynamic_debug_setup(debug, num_debug); | ||
2535 | |||
2529 | /* Find duplicate symbols */ | 2536 | /* Find duplicate symbols */ |
2530 | err = verify_export_symbols(mod); | 2537 | err = verify_export_symbols(mod); |
2531 | if (err < 0) | 2538 | if (err < 0) |
2532 | goto unlock; | 2539 | goto ddebug; |
2533 | 2540 | ||
2534 | list_add_rcu(&mod->list, &modules); | 2541 | list_add_rcu(&mod->list, &modules); |
2535 | mutex_unlock(&module_mutex); | 2542 | mutex_unlock(&module_mutex); |
@@ -2557,6 +2564,8 @@ static noinline struct module *load_module(void __user *umod, | |||
2557 | mutex_lock(&module_mutex); | 2564 | mutex_lock(&module_mutex); |
2558 | /* Unlink carefully: kallsyms could be walking list. */ | 2565 | /* Unlink carefully: kallsyms could be walking list. */ |
2559 | list_del_rcu(&mod->list); | 2566 | list_del_rcu(&mod->list); |
2567 | ddebug: | ||
2568 | dynamic_debug_remove(debug); | ||
2560 | unlock: | 2569 | unlock: |
2561 | mutex_unlock(&module_mutex); | 2570 | mutex_unlock(&module_mutex); |
2562 | synchronize_sched(); | 2571 | synchronize_sched(); |
diff --git a/kernel/sched.c b/kernel/sched.c index cb816e36cc8b..f52a8801b7a2 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -2873,9 +2873,9 @@ unsigned long nr_iowait(void) | |||
2873 | return sum; | 2873 | return sum; |
2874 | } | 2874 | } |
2875 | 2875 | ||
2876 | unsigned long nr_iowait_cpu(void) | 2876 | unsigned long nr_iowait_cpu(int cpu) |
2877 | { | 2877 | { |
2878 | struct rq *this = this_rq(); | 2878 | struct rq *this = cpu_rq(cpu); |
2879 | return atomic_read(&this->nr_iowait); | 2879 | return atomic_read(&this->nr_iowait); |
2880 | } | 2880 | } |
2881 | 2881 | ||
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 783fbadf2202..813993b5fb61 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
@@ -154,14 +154,14 @@ static void tick_nohz_update_jiffies(ktime_t now) | |||
154 | * Updates the per cpu time idle statistics counters | 154 | * Updates the per cpu time idle statistics counters |
155 | */ | 155 | */ |
156 | static void | 156 | static void |
157 | update_ts_time_stats(struct tick_sched *ts, ktime_t now, u64 *last_update_time) | 157 | update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now, u64 *last_update_time) |
158 | { | 158 | { |
159 | ktime_t delta; | 159 | ktime_t delta; |
160 | 160 | ||
161 | if (ts->idle_active) { | 161 | if (ts->idle_active) { |
162 | delta = ktime_sub(now, ts->idle_entrytime); | 162 | delta = ktime_sub(now, ts->idle_entrytime); |
163 | ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); | 163 | ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); |
164 | if (nr_iowait_cpu() > 0) | 164 | if (nr_iowait_cpu(cpu) > 0) |
165 | ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta); | 165 | ts->iowait_sleeptime = ktime_add(ts->iowait_sleeptime, delta); |
166 | ts->idle_entrytime = now; | 166 | ts->idle_entrytime = now; |
167 | } | 167 | } |
@@ -175,19 +175,19 @@ static void tick_nohz_stop_idle(int cpu, ktime_t now) | |||
175 | { | 175 | { |
176 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); | 176 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); |
177 | 177 | ||
178 | update_ts_time_stats(ts, now, NULL); | 178 | update_ts_time_stats(cpu, ts, now, NULL); |
179 | ts->idle_active = 0; | 179 | ts->idle_active = 0; |
180 | 180 | ||
181 | sched_clock_idle_wakeup_event(0); | 181 | sched_clock_idle_wakeup_event(0); |
182 | } | 182 | } |
183 | 183 | ||
184 | static ktime_t tick_nohz_start_idle(struct tick_sched *ts) | 184 | static ktime_t tick_nohz_start_idle(int cpu, struct tick_sched *ts) |
185 | { | 185 | { |
186 | ktime_t now; | 186 | ktime_t now; |
187 | 187 | ||
188 | now = ktime_get(); | 188 | now = ktime_get(); |
189 | 189 | ||
190 | update_ts_time_stats(ts, now, NULL); | 190 | update_ts_time_stats(cpu, ts, now, NULL); |
191 | 191 | ||
192 | ts->idle_entrytime = now; | 192 | ts->idle_entrytime = now; |
193 | ts->idle_active = 1; | 193 | ts->idle_active = 1; |
@@ -216,7 +216,7 @@ u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time) | |||
216 | if (!tick_nohz_enabled) | 216 | if (!tick_nohz_enabled) |
217 | return -1; | 217 | return -1; |
218 | 218 | ||
219 | update_ts_time_stats(ts, ktime_get(), last_update_time); | 219 | update_ts_time_stats(cpu, ts, ktime_get(), last_update_time); |
220 | 220 | ||
221 | return ktime_to_us(ts->idle_sleeptime); | 221 | return ktime_to_us(ts->idle_sleeptime); |
222 | } | 222 | } |
@@ -242,7 +242,7 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time) | |||
242 | if (!tick_nohz_enabled) | 242 | if (!tick_nohz_enabled) |
243 | return -1; | 243 | return -1; |
244 | 244 | ||
245 | update_ts_time_stats(ts, ktime_get(), last_update_time); | 245 | update_ts_time_stats(cpu, ts, ktime_get(), last_update_time); |
246 | 246 | ||
247 | return ktime_to_us(ts->iowait_sleeptime); | 247 | return ktime_to_us(ts->iowait_sleeptime); |
248 | } | 248 | } |
@@ -284,7 +284,7 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
284 | */ | 284 | */ |
285 | ts->inidle = 1; | 285 | ts->inidle = 1; |
286 | 286 | ||
287 | now = tick_nohz_start_idle(ts); | 287 | now = tick_nohz_start_idle(cpu, ts); |
288 | 288 | ||
289 | /* | 289 | /* |
290 | * If this cpu is offline and it is the one which updates | 290 | * If this cpu is offline and it is the one which updates |