From nobody Fri Feb 2 22:31:43 2024 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TRVr727dbz58QWk for ; Fri, 2 Feb 2024 22:31:51 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4TRVr64Bppz41dQ for ; Fri, 2 Feb 2024 22:31:50 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=freebsd.org (policy=none); spf=none (mx1.freebsd.org: domain of brooks@spindle.one-eyed-alien.net has no SPF policy when checking 199.48.129.229) smtp.mailfrom=brooks@spindle.one-eyed-alien.net Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 084E23C019A; Fri, 2 Feb 2024 22:31:44 +0000 (UTC) Date: Fri, 2 Feb 2024 22:31:43 +0000 From: Brooks Davis To: current@freebsd.org Subject: libc/libsys split coming soon Message-ID: List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spamd-Bar: - X-Spamd-Result: default: False [-1.61 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; FORGED_SENDER(0.30)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net]; ONCE_RECEIVED(0.10)[]; DMARC_POLICY_SOFTFAIL(0.10)[freebsd.org : No valid SPF, No valid DKIM,none]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_SHORT(-0.01)[-0.010]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ONE(0.00)[1]; FREEFALL_USER(0.00)[brooks]; RCPT_COUNT_ONE(0.00)[1]; MISSING_XM_UA(0.00)[]; ASN(0.00)[asn:36236, ipnet:199.48.128.0/22, country:US]; R_DKIM_NA(0.00)[]; MLMMJ_DEST(0.00)[current@freebsd.org]; FROM_NEQ_ENVFROM(0.00)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net]; FROM_HAS_DN(0.00)[]; TO_DOM_EQ_FROM_DOM(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; R_SPF_NA(0.00)[no SPF record] X-Rspamd-Queue-Id: 4TRVr64Bppz41dQ TL;DR: The implementation of system calls is moving to a seperate library (libsys). No changes are required to existing software (except to ensure that libsys is present when building custom disk images). Code: https://github.com/freebsd/freebsd-src/pull/908 After nearly a decade of intermittent work, I'm about to land a series of patches which moves system calls, vdso support, and libc's parsing of the ELF auxiliary argument vector into a separate library (libsys). I plan to do this early next week (February 5th). This change serves three primary purposes: 1. It's easier to completely replace system call implementations for tracing or compartmentalization purposes. 2. It simplifies the implementation of restrictions on system calls such as those implemented by OpenBSD's msyscall(2) (https://man.openbsd.org/msyscall.2). 3. It allows language runtimes to link with libsys for system call implementations without requiring libc. libsys is an auxiliary filter for libc. This means that for any symbol defined by both, the libsys version takes precedence at runtime. For system call implementations, libc contains empty stubs. For others it contains copies of the functions (this could be further refined at a later date). The statically linked libc contains the full implementations so linking libsys is not required. Additionally, libthr is now linked with libsys to provide _umtx_op_err(). The overall implementation follows https://reviews.freebsd.org/D14609, but is redone from scratch as multiple commits to facilitate review and assist git's rename detection. Testing: - Boot testing on amd64, aarch64, and riscv - make tinderbox (prior version, final run in progress) - exp-run: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276391 - Kyua tests in poudriere amd64 jails: same 359 failures as with the latest freebsdci build Thanks to Ali Mashtizadeh and Tal Garfinkel for D14609 and many apologies for not landing this in a timely manner. Additional thanks to kib@ for many rounds of review, markj@ and kib@ for debugging rtld issues exposed by this patch, and antoine@ for exp-runs. Future work: - Purely functional interfaces to system calls (no errorno). Unfortunately there isn't an obvious way to do this without significant (possibly generated) assembly code. - Investigate msyscall(2) and pinsyscalls(2). - Reduce the size of stubs in libc. I’ve errored on the side of not touching the copies that end up in libc to keep diff size down. We might want to generate empty stubs instead. See also: - Solaris Linker and Libraries Guide: https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter4-4.html -- Brooks