Re: [PATCH v2] oom: allow a non-CAP_SYS_RESOURCE proces to oom_score_adjdown

From: David Rientjes
Date: Mon Nov 15 2010 - 17:07:04 EST


On Mon, 15 Nov 2010, Mandeep Singh Baines wrote:

> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index f3d02ca..e617413 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1164,7 +1164,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
> goto err_task_lock;
> }
>
> - if (oom_score_adj < task->signal->oom_score_adj &&
> + if (oom_score_adj < task->signal->oom_score_adj_min &&
> !capable(CAP_SYS_RESOURCE)) {
> err = -EACCES;
> goto err_sighand;
> @@ -1177,6 +1177,8 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
> atomic_dec(&task->mm->oom_disable_count);
> }
> task->signal->oom_score_adj = oom_score_adj;
> + if (capable(CAP_SYS_RESOURCE))
> + task->signal->oom_score_adj_min = oom_score_adj;
> /*
> * Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is
> * always attainable.

This should be has_capability_noaudit(current, CAP_SYS_RESOURCE) instead,
we don't want an audit message to be emitted when checking if
oom_score_adj_min should be set.

Other than that:

Acked-by: David Rientjes <rientjes@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/