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 20661 invoked from network); 15 Oct 2020 20:03:18 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 15 Oct 2020 20:03:18 -0000 Received: (qmail 21933 invoked by uid 550); 15 Oct 2020 20:03:13 -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 21915 invoked from network); 15 Oct 2020 20:03:13 -0000 Date: Thu, 15 Oct 2020 16:03:01 -0400 From: Rich Felker To: Alexey Izbyshev Cc: musl@lists.openwall.com Message-ID: <20201015200300.GW17637@brightrain.aerifal.cx> References: <948f6fc6f3458f18152c0f8b505beec0@ispras.ru> <20201015085024.GR2947641@port70.net> <20201015154925.GU17637@brightrain.aerifal.cx> <68e70f27d78c9507631dd2c22187f77d@ispras.ru> <20201015171315.GV17637@brightrain.aerifal.cx> <78f5a8ff7d2b8168bc2f65ae68b23f33@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <78f5a8ff7d2b8168bc2f65ae68b23f33@ispras.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Why is setrlimit() considered to have per-thread effect? 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