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

From: Hungyu Lin

Date: Thu Nov 26 2026 - 13:08:59 EST


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.

I kept capable() so that a fix for stable doesn't relax anything. Or do
you think the opener check alone is enough?

Thanks,
Hungyu