mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Why is setrlimit() considered to have per-thread effect?
Date: Thu, 15 Oct 2020 16:03:01 -0400	[thread overview]
Message-ID: <20201015200300.GW17637@brightrain.aerifal.cx> (raw)
In-Reply-To: <78f5a8ff7d2b8168bc2f65ae68b23f33@ispras.ru>

On Thu, Oct 15, 2020 at 09:26:33PM +0300, Alexey Izbyshev wrote:
> On 2020-10-15 20:13, Rich Felker wrote:
> >On Thu, Oct 15, 2020 at 07:13:30PM +0300, Alexey Izbyshev wrote:
> >If correct, I agree -- we can avoid the need for __synccall when
> >prlimit works. I'd like to find commits or source lines supporting
> >that in their actual (code) content though rather than just as a
> >mention in commit messages, since it's contrary to what my (probably
> >outdated) understanding of how rlimits worked was.
> >
> Here they are (the first two were referenced in my reply to Szabolcs).
> 
> * Change of setrlimit() to operate on signal_struct in 2.6.10:
> https://elixir.bootlin.com/linux/v2.6.10/source/kernel/sys.c#L1487
> (compare with
> https://elixir.bootlin.com/linux/v2.6.9/source/kernel/sys.c#L1537)
> 
> * Definition of signal_struct in 2.6.10, which is per-thread-group
> (apart from "rlim", it contains many other thread-group-related
> fields): https://elixir.bootlin.com/linux/v2.6.10/source/include/linux/sched.h#L268
> 
> * Usage if signal_struct in 2.6.36 (the first kernel with prlimit())
> in do_prlimit(), which is a common function implementing
> setrlimit(), getrlimit() and prlimit():
> https://elixir.bootlin.com/linux/v2.6.36/source/kernel/sys.c#L1333
> 
> Finally, I performed a simple experiment: on 2.6.30 kernel (with
> glibc 2.5), created a thread and changed RLIMIT_FSIZE via
> setrlimit(). After that, "/proc/pid/limits" reported the new limit,
> so it was applied to the whole process. Strace confirmed that only a
> single setrlimit() system call was performed.

Excellent, thanks for doing this research! I'll adjust setrlimit to
use __synccall only in the fallback where SYS_prlimit fails.

Rich

  reply	other threads:[~2020-10-15 20:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15  5:01 Alexey Izbyshev
2020-10-15  8:50 ` Szabolcs Nagy
2020-10-15 15:49   ` Rich Felker
2020-10-15 16:13     ` Alexey Izbyshev
2020-10-15 17:13       ` Rich Felker
2020-10-15 18:26         ` Alexey Izbyshev
2020-10-15 20:03           ` Rich Felker [this message]
2020-10-15 15:50   ` Alexey Izbyshev
2020-10-15 20:05     ` Rich Felker
2020-10-15 15:43 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201015200300.GW17637@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=izbyshev@ispras.ru \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).