[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ca7a02ad-2408-0cd8-e54e-d7dbecf9f0ba@rasmusvillemoes.dk>
Date: Sat, 18 Jan 2020 17:48:20 +0100
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Cyrill Gorcunov <gorcunov@...il.com>,
Kees Cook <keescook@...omium.org>
Subject: getrusage(RUSAGE_BOTH)
RUSAGE_BOTH exists in the uapi header, but currently sys_getrusage
rejects it with -EINVAL:
SYSCALL_DEFINE2(getrusage, int, who, struct rusage __user *, ru)
{
struct rusage r;
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN &&
who != RUSAGE_THREAD)
return -EINVAL;
getrusage(RUSAGE_BOTH) is used by the exit code in various places. But
is there any good reason not to allow userspace to use it? Of course one
can get the same info with two calls using RUSAGE_CHILDREN +
RUSAGE_SELF, but that seems a bit silly when the kernel already has the
code to do the summation.
Apart from the obvious addition above, I think the only thing needed is
to adjust the conditions where mm_highwater_rss gets updated:
if (who != RUSAGE_CHILDREN && who != RUSAGE_BOTH) {
struct mm_struct *mm = get_task_mm(p);
if (mm) {
setmax_mm_hiwater_rss(&maxrss, mm);
mmput(mm);
}
If RUSAGE_BOTH is not supposed to be used, perhaps it should be removed
from the uapi header?
Rasmus
Powered by blists - more mailing lists