From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9678 invoked from network); 15 Oct 2020 18:26:48 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 15 Oct 2020 18:26:48 -0000 Received: (qmail 3338 invoked by uid 550); 15 Oct 2020 18:26:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 3320 invoked from network); 15 Oct 2020 18:26:44 -0000 MIME-Version: 1.0 Date: Thu, 15 Oct 2020 21:26:33 +0300 From: Alexey Izbyshev To: musl@lists.openwall.com In-Reply-To: <20201015171315.GV17637@brightrain.aerifal.cx> References: <948f6fc6f3458f18152c0f8b505beec0@ispras.ru> <20201015085024.GR2947641@port70.net> <20201015154925.GU17637@brightrain.aerifal.cx> <68e70f27d78c9507631dd2c22187f77d@ispras.ru> <20201015171315.GV17637@brightrain.aerifal.cx> User-Agent: Roundcube Webmail/1.4.4 Message-ID: <78f5a8ff7d2b8168bc2f65ae68b23f33@ispras.ru> X-Sender: izbyshev@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [musl] Why is setrlimit() considered to have per-thread effect? 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.