]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/proc/base.c
Merge tag 'arm64-uapi' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas...
[karo-tx-linux.git] / fs / proc / base.c
index d295af993677dda290242adb5e0187deef1bcb7c..144a96732dd7d602df0d5f8a504e435cfdb07229 100644 (file)
@@ -873,111 +873,6 @@ static const struct file_operations proc_environ_operations = {
        .release        = mem_release,
 };
 
-static ssize_t oom_adjust_read(struct file *file, char __user *buf,
-                               size_t count, loff_t *ppos)
-{
-       struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
-       char buffer[PROC_NUMBUF];
-       size_t len;
-       int oom_adjust = OOM_DISABLE;
-       unsigned long flags;
-
-       if (!task)
-               return -ESRCH;
-
-       if (lock_task_sighand(task, &flags)) {
-               oom_adjust = task->signal->oom_adj;
-               unlock_task_sighand(task, &flags);
-       }
-
-       put_task_struct(task);
-
-       len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
-
-       return simple_read_from_buffer(buf, count, ppos, buffer, len);
-}
-
-static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
-                               size_t count, loff_t *ppos)
-{
-       struct task_struct *task;
-       char buffer[PROC_NUMBUF];
-       int oom_adjust;
-       unsigned long flags;
-       int err;
-
-       memset(buffer, 0, sizeof(buffer));
-       if (count > sizeof(buffer) - 1)
-               count = sizeof(buffer) - 1;
-       if (copy_from_user(buffer, buf, count)) {
-               err = -EFAULT;
-               goto out;
-       }
-
-       err = kstrtoint(strstrip(buffer), 0, &oom_adjust);
-       if (err)
-               goto out;
-       if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) &&
-            oom_adjust != OOM_DISABLE) {
-               err = -EINVAL;
-               goto out;
-       }
-
-       task = get_proc_task(file->f_path.dentry->d_inode);
-       if (!task) {
-               err = -ESRCH;
-               goto out;
-       }
-
-       task_lock(task);
-       if (!task->mm) {
-               err = -EINVAL;
-               goto err_task_lock;
-       }
-
-       if (!lock_task_sighand(task, &flags)) {
-               err = -ESRCH;
-               goto err_task_lock;
-       }
-
-       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
-               err = -EACCES;
-               goto err_sighand;
-       }
-
-       /*
-        * Warn that /proc/pid/oom_adj is deprecated, see
-        * Documentation/feature-removal-schedule.txt.
-        */
-       printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
-                 current->comm, task_pid_nr(current), task_pid_nr(task),
-                 task_pid_nr(task));
-       task->signal->oom_adj = oom_adjust;
-       /*
-        * Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum
-        * value is always attainable.
-        */
-       if (task->signal->oom_adj == OOM_ADJUST_MAX)
-               task->signal->oom_score_adj = OOM_SCORE_ADJ_MAX;
-       else
-               task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) /
-                                                               -OOM_DISABLE;
-       trace_oom_score_adj_update(task);
-err_sighand:
-       unlock_task_sighand(task, &flags);
-err_task_lock:
-       task_unlock(task);
-       put_task_struct(task);
-out:
-       return err < 0 ? err : count;
-}
-
-static const struct file_operations proc_oom_adjust_operations = {
-       .read           = oom_adjust_read,
-       .write          = oom_adjust_write,
-       .llseek         = generic_file_llseek,
-};
-
 static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
                                        size_t count, loff_t *ppos)
 {
@@ -1051,15 +946,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
        if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
                task->signal->oom_score_adj_min = oom_score_adj;
        trace_oom_score_adj_update(task);
-       /*
-        * Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is
-        * always attainable.
-        */
-       if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
-               task->signal->oom_adj = OOM_DISABLE;
-       else
-               task->signal->oom_adj = (oom_score_adj * OOM_ADJUST_MAX) /
-                                                       OOM_SCORE_ADJ_MAX;
+
 err_sighand:
        unlock_task_sighand(task, &flags);
 err_task_lock:
@@ -2371,7 +2258,8 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
        pid_t tgid = task_tgid_nr_ns(current, ns);
        char *name = ERR_PTR(-ENOENT);
        if (tgid) {
-               name = __getname();
+               /* 11 for max length of signed int in decimal + NULL term */
+               name = kmalloc(12, GFP_KERNEL);
                if (!name)
                        name = ERR_PTR(-ENOMEM);
                else
@@ -2386,7 +2274,7 @@ static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
 {
        char *s = nd_get_link(nd);
        if (!IS_ERR(s))
-               __putname(s);
+               kfree(s);
 }
 
 static const struct inode_operations proc_self_inode_operations = {
@@ -2710,7 +2598,6 @@ static const struct pid_entry tgid_base_stuff[] = {
        REG("cgroup",  S_IRUGO, proc_cgroup_operations),
 #endif
        INF("oom_score",  S_IRUGO, proc_oom_score),
-       REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
        REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
 #ifdef CONFIG_AUDITSYSCALL
        REG("loginuid",   S_IWUSR|S_IRUGO, proc_loginuid_operations),
@@ -3077,7 +2964,6 @@ static const struct pid_entry tid_base_stuff[] = {
        REG("cgroup",  S_IRUGO, proc_cgroup_operations),
 #endif
        INF("oom_score", S_IRUGO, proc_oom_score),
-       REG("oom_adj",   S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
        REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
 #ifdef CONFIG_AUDITSYSCALL
        REG("loginuid",  S_IWUSR|S_IRUGO, proc_loginuid_operations),