Page MenuHomeFreeBSD

runtime: add the ability to set exterrors in userspace
ClosedPublic

Authored by brooks on Jul 6 2026, 4:06 PM.
Tags
None
Referenced Files
F167659484: D58059.id182026.diff
Sun, Aug 23, 2:52 PM
Unknown Object (File)
Fri, Aug 21, 5:03 AM
Unknown Object (File)
Thu, Aug 20, 3:41 AM
Unknown Object (File)
Wed, Aug 19, 4:24 PM
Unknown Object (File)
Wed, Aug 19, 9:56 AM
Unknown Object (File)
Wed, Aug 19, 6:05 AM
Unknown Object (File)
Tue, Aug 18, 5:43 PM
Unknown Object (File)
Mon, Aug 17, 2:34 AM
Subscribers

Details

Summary

The UEXTERROR(3) macro is a partial analog to EXTERROR(9) that sets
the current user exterror state and errno. The main difference is
that it returns no value and sets errno directly since that's the
typical pattern in libraries.

Effort: CHERI upstreaming
Sponsored by: Innovate UK

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 74824
Build 71707: arc lint + arc unit

Event Timeline

brooks requested review of this revision.Jul 6 2026, 4:06 PM

The big thing that needs to be dealt with for this to make sense is to have a way to specify the filename that isn't a table embedded in libc. A first cut could be a special index that means no-file and perhaps using -1 as the line, but without that, we can't scale beyond files in the base system. (This also poses a problem for out of tree kernel modules.) We might also want macros like the kernel, but I'm less sure of that.

lib/libthr/thread/thr_syscalls.c
664

Create a libc helper in the private version namespace that takes uexterrp, and call it there and in the libc' uexterr_set().

Add helper in libc. Tag categories as user space.

This revision is now accepted and ready to land.Jul 18 2026, 1:45 PM
lib/libc/gen/uexterr_gettext.c
58

Stylistically, I do not see a need in this blank line, and in the blank line at 60.

brooks retitled this revision from runtime: add uexterr_set(3) to set errors in userspace to runtime: add the ability to set exterrors in userspace.Jul 22 2026, 1:53 PM

Add UEXTERROR() analog to EXTERROR(). It differs in that it just wraps uexterr_set and thus it gets a different name.

This revision now requires review to proceed.Jul 22 2026, 1:58 PM

Add docs. Make uexterr_set return void.

include/uexterror.h
8 ↗(On Diff #182464)

I believe you need to add your copyright there and in other sources.

lib/libc/gen/uexterr_gettext.c
47

I think these functions should go into separate source file in libc. There is no reason to bring uexterror_set() into the static binary if only gettext() is used.

brooks marked 3 inline comments as done.

Move to its own file, document, update copyrights

include/uexterror.h
8 ↗(On Diff #182464)

Indeed, can we drop the All rights reserved.? The project doesn't want that in new copyrights.

kib added inline comments.
include/uexterror.h
8 ↗(On Diff #182464)

Perhaps. Ask Ed, I used the header mandated by my contract.

lib/libc/gen/uexterr_gettext.c
19

To be perfect, this structure should go into a dedicated .c/.o as well.

This revision is now accepted and ready to land.Jul 23 2026, 11:10 PM

Move global struct uexterror and constructor to its own file

This revision now requires review to proceed.Jul 24 2026, 10:36 AM
brooks added a subscriber: emaste.
brooks added inline comments.
include/uexterror.h
8 ↗(On Diff #182464)

Tagging @emaste

lib/libc/gen/uexterror.3
129 ↗(On Diff #182596)

Definitely not 15.0

Correct feature introduction to 16.0. Bump doc date.

This revision was not accepted when it landed; it landed in state Needs Review.Thu, Aug 20, 10:42 AM
This revision was automatically updated to reflect the committed changes.