aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorMike Galbraith <efault@gmx.de>2012-10-28 15:19:23 -0400
committerIngo Molnar <mingo@kernel.org>2012-10-30 05:26:04 -0400
commit5258f386ea4e8454bc801fb443e8a4217da1947c (patch)
treec97487f040b95f83a2c9d31d51cbfe57f35e59e3 /fs/proc
parent8ed92e51f99c2199c64cb33b4ba95ab12940a94c (diff)
sched/autogroup: Fix crash on reboot when autogroup is disabled
Due to these two commits: 8323f26ce342 sched: Fix race in task_group() 800d4d30c8f2 sched, autogroup: Stop going ahead if autogroup is disabled ... autogroup scheduling's dynamic knobs are wrecked. With both patches applied, all you have to do to crash a box is disable autogroup during boot up, then reboot.. boom, NULL pointer dereference due to 800d4d30 not allowing autogroup to move things, and 8323f26ce making that the only way to switch runqueues. Remove most of the (dysfunctional) knobs and turn the remaining sched_autogroup_enabled knob readonly. If the user fiddles with cgroups hereafter, once tasks are moved, autogroup won't mess with them again unless they call setsid(). No knobs, no glitz, nada, just a cute little thing folks can turn on if they don't want to muck about with cgroups and/or systemd. Signed-off-by: Mike Galbraith <efault@gmx.de> Cc: Xiaotian Feng <xtfeng@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Xiaotian Feng <dannyfeng@tencent.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: <stable@vger.kernel.org> # v3.6 Link: http://lkml.kernel.org/r/1351451963.4999.8.camel@maggy.simpson.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c78
1 files changed, 0 insertions, 78 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1b6c84cbdb73..bb1d9623bad2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1271,81 +1271,6 @@ static const struct file_operations proc_pid_sched_operations = {
1271 1271
1272#endif 1272#endif
1273 1273
1274#ifdef CONFIG_SCHED_AUTOGROUP
1275/*
1276 * Print out autogroup related information:
1277 */
1278static int sched_autogroup_show(struct seq_file *m, void *v)
1279{
1280 struct inode *inode = m->private;
1281 struct task_struct *p;
1282
1283 p = get_proc_task(inode);
1284 if (!p)
1285 return -ESRCH;
1286 proc_sched_autogroup_show_task(p, m);
1287
1288 put_task_struct(p);
1289
1290 return 0;
1291}
1292
1293static ssize_t
1294sched_autogroup_write(struct file *file, const char __user *buf,
1295 size_t count, loff_t *offset)
1296{
1297 struct inode *inode = file->f_path.dentry->d_inode;
1298 struct task_struct *p;
1299 char buffer[PROC_NUMBUF];
1300 int nice;
1301 int err;
1302
1303 memset(buffer, 0, sizeof(buffer));
1304 if (count > sizeof(buffer) - 1)
1305 count = sizeof(buffer) - 1;
1306 if (copy_from_user(buffer, buf, count))
1307 return -EFAULT;
1308
1309 err = kstrtoint(strstrip(buffer), 0, &nice);
1310 if (err < 0)
1311 return err;
1312
1313 p = get_proc_task(inode);
1314 if (!p)
1315 return -ESRCH;
1316
1317 err = proc_sched_autogroup_set_nice(p, nice);
1318 if (err)
1319 count = err;
1320
1321 put_task_struct(p);
1322
1323 return count;
1324}
1325
1326static int sched_autogroup_open(struct inode *inode, struct file *filp)
1327{
1328 int ret;
1329
1330 ret = single_open(filp, sched_autogroup_show, NULL);
1331 if (!ret) {
1332 struct seq_file *m = filp->private_data;
1333
1334 m->private = inode;
1335 }
1336 return ret;
1337}
1338
1339static const struct file_operations proc_pid_sched_autogroup_operations = {
1340 .open = sched_autogroup_open,
1341 .read = seq_read,
1342 .write = sched_autogroup_write,
1343 .llseek = seq_lseek,
1344 .release = single_release,
1345};
1346
1347#endif /* CONFIG_SCHED_AUTOGROUP */
1348
1349static ssize_t comm_write(struct file *file, const char __user *buf, 1274static ssize_t comm_write(struct file *file, const char __user *buf,
1350 size_t count, loff_t *offset) 1275 size_t count, loff_t *offset)
1351{ 1276{
@@ -3036,9 +2961,6 @@ static const struct pid_entry tgid_base_stuff[] = {
3036#ifdef CONFIG_SCHED_DEBUG 2961#ifdef CONFIG_SCHED_DEBUG
3037 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), 2962 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
3038#endif 2963#endif
3039#ifdef CONFIG_SCHED_AUTOGROUP
3040 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
3041#endif
3042 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), 2964 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
3043#ifdef CONFIG_HAVE_ARCH_TRACEHOOK 2965#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
3044 INF("syscall", S_IRUGO, proc_pid_syscall), 2966 INF("syscall", S_IRUGO, proc_pid_syscall),