From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 3C4EA3857406; Tue, 30 Nov 2021 11:56:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C4EA3857406 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: setrlimit: Add a permission check X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: d64cd470ae9b089d5e334efe7ed5ec4be68577d5 X-Git-Newrev: 670beaed0216aa59603501e8f14e1f04b138bc47 Message-Id: <20211130115609.3C4EA3857406@sourceware.org> Date: Tue, 30 Nov 2021 11:56:09 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 11:56:09 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=670beaed0216aa59603501e8f14e1f04b138bc47 commit 670beaed0216aa59603501e8f14e1f04b138bc47 Author: Corinna Vinschen Date: Tue Nov 30 12:48:34 2021 +0100 Cygwin: setrlimit: Add a permission check If the incoming soft limit is less restrictive than the current hard limit, bail out with EPERM. Given the previous sanity check, this implies trying to raise the hard limit. While, theoretically, this should be allowed for privileged processes, Windows has no matching concept in terms of job limits Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/resource.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 46d74b984..c4c79ca6f 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -261,6 +261,12 @@ setrlimit (int resource, const struct rlimit *rlp) __leave; } + if (rlp->rlim_cur > oldlimits.rlim_max) + { + set_errno (EPERM); + __leave; + } + switch (resource) { case RLIMIT_AS: