fd8ef11730
This reverts commit800d4d30c8
. Between commits8323f26ce3
("sched: Fix race in task_group()") and800d4d30c8
("sched, autogroup: Stop going ahead if autogroup is disabled"), autogroup is a wreck. With both applied, all you have to do to crash a box is disable autogroup during boot up, then reboot.. boom, NULL pointer dereference due to commit800d4d30c8
not allowing autogroup to move things, and commit8323f26ce3
making that the only way to switch runqueues: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff81063ac0>] effective_load.isra.43+0x50/0x90 Pid: 7047, comm: systemd-user-se Not tainted 3.6.8-smp #7 MEDIONPC MS-7502/MS-7502 RIP: effective_load.isra.43+0x50/0x90 Process systemd-user-se (pid: 7047, threadinfo ffff880221dde000, task ffff88022618b3a0) Call Trace: select_task_rq_fair+0x255/0x780 try_to_wake_up+0x156/0x2c0 wake_up_state+0xb/0x10 signal_wake_up+0x28/0x40 complete_signal+0x1d6/0x250 __send_signal+0x170/0x310 send_signal+0x40/0x80 do_send_sig_info+0x47/0x90 group_send_sig_info+0x4a/0x70 kill_pid_info+0x3a/0x60 sys_kill+0x97/0x1a0 ? vfs_read+0x120/0x160 ? sys_read+0x45/0x90 system_call_fastpath+0x16/0x1b Code: 49 0f af 41 50 31 d2 49 f7 f0 48 83 f8 01 48 0f 46 c6 48 2b 07 48 8b bf 40 01 00 00 48 85 ff 74 3a 45 31 c0 48 8b 8f 50 01 00 00 <48> 8b 11 4c 8b 89 80 00 00 00 49 89 d2 48 01 d0 45 8b 59 58 4c RIP [<ffffffff81063ac0>] effective_load.isra.43+0x50/0x90 RSP <ffff880221ddfbd8> CR2: 0000000000000000 Signed-off-by: Mike Galbraith <efault@gmx.de> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: Yong Zhang <yong.zhang0@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: stable@vger.kernel.org # 2.6.39+ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
#ifdef CONFIG_SCHED_AUTOGROUP
|
|
|
|
#include <linux/kref.h>
|
|
#include <linux/rwsem.h>
|
|
|
|
struct autogroup {
|
|
struct kref kref;
|
|
struct task_group *tg;
|
|
struct rw_semaphore lock;
|
|
unsigned long id;
|
|
int nice;
|
|
};
|
|
|
|
extern void autogroup_init(struct task_struct *init_task);
|
|
extern void autogroup_free(struct task_group *tg);
|
|
|
|
static inline bool task_group_is_autogroup(struct task_group *tg)
|
|
{
|
|
return !!tg->autogroup;
|
|
}
|
|
|
|
extern bool task_wants_autogroup(struct task_struct *p, struct task_group *tg);
|
|
|
|
static inline struct task_group *
|
|
autogroup_task_group(struct task_struct *p, struct task_group *tg)
|
|
{
|
|
int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
|
|
|
|
if (enabled && task_wants_autogroup(p, tg))
|
|
return p->signal->autogroup->tg;
|
|
|
|
return tg;
|
|
}
|
|
|
|
extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
|
|
|
|
#else /* !CONFIG_SCHED_AUTOGROUP */
|
|
|
|
static inline void autogroup_init(struct task_struct *init_task) { }
|
|
static inline void autogroup_free(struct task_group *tg) { }
|
|
static inline bool task_group_is_autogroup(struct task_group *tg)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline struct task_group *
|
|
autogroup_task_group(struct task_struct *p, struct task_group *tg)
|
|
{
|
|
return tg;
|
|
}
|
|
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* CONFIG_SCHED_AUTOGROUP */
|