Re: [patch V2 31/38] rlimit: Rewrite non-sensical RLIMIT_CPU comment

2019-08-26 Thread Frederic Weisbecker
On Wed, Aug 21, 2019 at 09:09:18PM +0200, Thomas Gleixner wrote:
> The comment above the function which arms RLIMIT_CPU in the posix CPU timer
> code makes no sense at all. It claims that the kernel does not return an
> error code when it rejected the attempt to set RLIMIT_CPU. That's clearly
> bogus as the code does an error check and the rlimit is only set and
> activated when the permission checks are ok. In case of a rejection an
> appropriate error code is returned.
> 
> This is a historical and outdated comment which got dragged along even when
> the rlimit handling code was rewritten.
> 
> Replace it with an explanation why the setup function is not called when
> the rlimit value is RLIM_INFINITY and how the 'disarming' is handled.
> 
> Signed-off-by: Thomas Gleixner 
> Cc: Andrew Morton 
> Cc: Jiri Slaby 

Reviewed-by: Frederic Weisbecker 


[patch V2 31/38] rlimit: Rewrite non-sensical RLIMIT_CPU comment

2019-08-21 Thread Thomas Gleixner
The comment above the function which arms RLIMIT_CPU in the posix CPU timer
code makes no sense at all. It claims that the kernel does not return an
error code when it rejected the attempt to set RLIMIT_CPU. That's clearly
bogus as the code does an error check and the rlimit is only set and
activated when the permission checks are ok. In case of a rejection an
appropriate error code is returned.

This is a historical and outdated comment which got dragged along even when
the rlimit handling code was rewritten.

Replace it with an explanation why the setup function is not called when
the rlimit value is RLIM_INFINITY and how the 'disarming' is handled.

Signed-off-by: Thomas Gleixner 
Cc: Andrew Morton 
Cc: Jiri Slaby 
---
 kernel/sys.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1576,10 +1576,9 @@ int do_prlimit(struct task_struct *tsk,
task_unlock(tsk->group_leader);
 
/*
-* RLIMIT_CPU handling.   Note that the kernel fails to return an error
-* code if it rejected the user's attempt to set RLIMIT_CPU.  This is a
-* very long-standing error, and fixing it now risks breakage of
-* applications, so we live with it
+* RLIMIT_CPU handling. Arm the posix CPU timer if the limit is not
+* infite. In case of RLIM_INFINITY the posix CPU timer code
+* ignores the rlimit.
 */
 if (!retval && new_rlim && resource == RLIMIT_CPU &&
 new_rlim->rlim_cur != RLIM_INFINITY &&