Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: setrlimit(2) can set stack segement hard limit lower than soft limit ?



In article <20160712095447.GA27920%issan.sis.pasteur.fr@localhost>,
Nicolas Joly  <njoly%pasteur.fr@localhost> wrote:
>-=-=-=-=-=-
>
>
>Hi,
>
>Juste encountered a small case where setting stack segement limits
>made the hard limit smaller than the soft one, which seems problematic
>to me. Soft limit should never be larger than hard limit.
>
>The attached sample illustrate this small issue.
>
>njoly@issan [~]> cc -o setrlimit setrlimit.c 
>njoly@issan [~]> ./setrlimit 
>set RLIMIT_STACK: 4192256/4192256
>get RLIMIT_STACK: 4194304/4192256
>
>Cheching the corresponding code in dosetrlimit() show rlim_cur is page
>rounded ... but rlim_max is not :
>
>[...]
>                 * Since allocation is done in terms of page, roundup
>                 * "rlim_cur" (otherwise, contiguous regions
>                 * overlap).  If stack limit is going up make more
>                 * accessible, if going down make inaccessible.
>                 */
>                limp->rlim_cur = round_page(limp->rlim_cur);
>                if (limp->rlim_cur != alimp->rlim_cur) {
>[...]
>
>Do we need to call round_page() on limp->rlim_max too, or should we
>only raise it to limp->rlim_cur if needed ?

I think we should call round_page to it too...

christos



Home | Main Index | Thread Index | Old Index