History

Merge branches 'sched-urgent-for-linus' and 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull stack vmap fixups from Thomas Gleixner: "Two small patches related to sched_show_task(): - make sure to hold a reference on the task stack while accessing it - remove the thread_saved_pc printout .. and add a sanity check into release_task_stack() to catch problems with task stack references" * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/core: Remove pointless printout in sched_show_task() sched/core: Fix oops in sched_show_task() * 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: fork: Add task stack refcounting sanity check and prevent premature task stack freeing

Linus Torvalds committed 10 years ago

Commit ffbcbfc3 parents 6c286e8 8243d55 405c0752 files · +7 −9Browse files

Unified · Split

2 files
  1. kernel/fork.c +4 −0
  2. kernel/sched/core.c +3 −9
kernel/fork.c+4−0
@@ -315,6 +315,9 @@ static void account_kernel_stack(struct task_struct *tsk, int account) · 314 unmodified lines
315 315
316static void release_task_stack(struct task_struct *tsk)316static void release_task_stack(struct task_struct *tsk)
317{317{
318 if (WARN_ON(tsk->state != TASK_DEAD))
319 return; /* Better to leak the stack than to free prematurely */
320
318 account_kernel_stack(tsk, -1);321 account_kernel_stack(tsk, -1);
319 arch_release_thread_stack(tsk->stack);322 arch_release_thread_stack(tsk->stack);
320 free_thread_stack(tsk);323 free_thread_stack(tsk);
@@ -1862,6 +1865,7 @@ bad_fork_cleanup_count: · 1541 unmodified lines
1862 atomic_dec(&p->cred->user->processes);1865 atomic_dec(&p->cred->user->processes);
1863 exit_creds(p);1866 exit_creds(p);
1864bad_fork_free:1867bad_fork_free:
1868 p->state = TASK_DEAD;
1865 put_task_stack(p);1869 put_task_stack(p);
1866 free_task(p);1870 free_task(p);
1867fork_out:1871fork_out:
kernel/sched/core.c+3−9
@@ -5192,21 +5192,14 @@ void sched_show_task(struct task_struct *p) · 5191 unmodified lines
5192 int ppid;5192 int ppid;
5193 unsigned long state = p->state;5193 unsigned long state = p->state;
5194 5194
5195 if (!try_get_task_stack(p))
5196 return;
5195 if (state)5197 if (state)
5196 state = __ffs(state) + 1;5198 state = __ffs(state) + 1;
5197 printk(KERN_INFO "%-15.15s %c", p->comm,5199 printk(KERN_INFO "%-15.15s %c", p->comm,
5198 state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');5200 state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
5199#if BITS_PER_LONG == 32
5200 if (state == TASK_RUNNING)
5201 printk(KERN_CONT " running ");
5202 else
5203 printk(KERN_CONT " %08lx ", thread_saved_pc(p));
5204#else
5205 if (state == TASK_RUNNING)5201 if (state == TASK_RUNNING)
5206 printk(KERN_CONT " running task ");5202 printk(KERN_CONT " running task ");
5207 else
5208 printk(KERN_CONT " %016lx ", thread_saved_pc(p));
5209#endif
5210#ifdef CONFIG_DEBUG_STACK_USAGE5203#ifdef CONFIG_DEBUG_STACK_USAGE
5211 free = stack_not_used(p);5204 free = stack_not_used(p);
5212#endif5205#endif
@@ -5221,6 +5214,7 @@ void sched_show_task(struct task_struct *p) · 8 unmodified lines
5221 5214
5222 print_worker_info(KERN_INFO, p);5215 print_worker_info(KERN_INFO, p);
5223 show_stack(p, NULL);5216 show_stack(p, NULL);
5217 put_task_stack(p);
5224}5218}
5225 5219
5226void show_state_filter(unsigned long state_filter)5220void show_state_filter(unsigned long state_filter)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t