Re: [PATCH] proc: also check the opener's capability for oom_score_adj and oom_adj

From: Oleg Nesterov

Date: Thu Nov 26 2026 - 14:03:46 EST


On 11/26, Hungyu Lin wrote:
>
> On Thu, Nov 26, 2026 at 11:50:54AM +0100, Oleg Nesterov wrote:
> > do we really need to keep the old capable(CAP_SYS_RESOURCE) check?
> >
> > If a privileged opener of /proc/<pid>/oom_score_adj passes fd to
> > to unprivileged writer, we probably don't care?
>
> A write that needs CAP_SYS_RESOURCE still needs it from the writer,
> even if the opener was privileged. For example, a task can open its
> own oom_score_adj with CAP_SYS_RESOURCE and still have the fd after
> dropping that capability and calling execve(). If we only check the
> opener, it could then lower its value down to OOM_SCORE_ADJ_MIN, and
> any children it creates afterward would inherit that.

And my question was: do we really care about this case?

> I kept capable() so that a fix for stable doesn't relax anything.

OK,

> Or do
> you think the opener check alone is enough?

Well, let me quote the part of my email you have removed:

Just in case, I am not saying that the old check should be removed,
I am trying to understand.

So no, I am not sure the opener check alone is enough.

Oleg.