Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caprevoke: rework the enablement of revocation #1901

Merged
merged 11 commits into from
Oct 23, 2023
Merged

Conversation

brooksdavis
Copy link
Member

Implement procctl (settable with proccontrol) and ELF note (settable with elfctl) values to override the system default revocation hint. These values are now presented as a pair of flags in the AT_BSDFLAGS ELF auxargs variable. One flag indicates that revocation is enabled or disabled and the other indicates if it was set by procctl/elf note (forced) or if it is the default value. On top of these, add a malloc_quaranting weak global variable which can be set to override the global default or completely ignore management interfaces. In order of increasing precedence the priority of these options is:

  • security.cheri.runtime_quarantine_default sysctl
  • un-forced malloc_quaranting (MQ_ENABLE and MQ_DISABLE)
  • forced elf note values
  • forced procctl values
  • forced malloc_quaranting (MQ_ENABLE_FORCED and MQ_DISABLE_FORCED)

@brooksdavis
Copy link
Member Author

Now would be the ideal time to bike shed the names of various knobs.

cc @rwatson

sys/kern/imgact_elf.c Outdated Show resolved Hide resolved
sys/kern/imgact_elf.c Outdated Show resolved Hide resolved
sys/kern/imgact_elf.c Outdated Show resolved Hide resolved
usr.bin/elfctl/elfctl.c Outdated Show resolved Hide resolved
sys/kern/imgact_elf.c Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
include/malloc_np.h Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.c Outdated Show resolved Hide resolved
sys/kern/imgact_elf.c Outdated Show resolved Hide resolved
sys/kern/imgact_elf.c Outdated Show resolved Hide resolved
sys/kern/kern_procctl.c Show resolved Hide resolved
sys/sys/proc.h Show resolved Hide resolved
usr.bin/elfctl/elfctl.c Outdated Show resolved Hide resolved
usr.bin/proccontrol/proccontrol.1 Outdated Show resolved Hide resolved
@brooksdavis brooksdavis force-pushed the revocation-management branch 3 times, most recently from 91ac08b to 3a475cc Compare October 19, 2023 23:25
lib/libc/stdlib/malloc/mrs/mrs.3 Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
@brooksdavis brooksdavis force-pushed the revocation-management branch 3 times, most recently from ff5868d to a528b3f Compare October 20, 2023 18:56
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/stdlib/malloc/mrs/mrs.3 Outdated Show resolved Hide resolved
lib/libc/sys/procctl.2 Outdated Show resolved Hide resolved
sys/cheri/cheri_sysctl.c Outdated Show resolved Hide resolved
@brooksdavis brooksdavis force-pushed the revocation-management branch from a528b3f to f27196c Compare October 20, 2023 19:02
@jrtc27
Copy link
Member

jrtc27 commented Oct 20, 2023

Also "cheribsdtest: request that malloc revoking" is missing some words

@brooksdavis brooksdavis force-pushed the revocation-management branch from f27196c to d8073d4 Compare October 20, 2023 19:11
AT_BSDFLAGS shouldn't be sign extended on 64-bit systems so use a
uint32_t instead of an int.
Rename CHERI_REVOKE_SHADOW_NOVMMAP(_ENTIRE) to
CHERI_REVOKE_SHADOW_NOVMEM(_ENTIRE) following the rename of
CHERI_PERM_CHERIABI_VMMAP to CHERI_PERM_SW_VMEM in
00d71bd.

Fix up a number of comments where VMMAP was still used.  This
is a mix of revocation related bits and other stale comments
missed in prior sweeps.

Fix up a number of stale comments
This avoids a syscall during startup and will allow further controls via
procctl and ELF note flags.

Rename security.cheri.runtime_quarantining_default to
security.cheri.runtime_revocation_default.  Quarantining without
revocation doesn't make sense to just refer to the latter.
Add flag bits for both enable and disable since the system default is
configurable at runtime and we want to be able to express all three of
enable, disable, and system-default.  If both are set, disable wins.
@brooksdavis brooksdavis force-pushed the revocation-management branch 2 times, most recently from 78337e4 to 2939b17 Compare October 23, 2023 14:54
Controls are tri-state as usual allowing revocation to be forcably
enabled or disabled, or for the system default to be used.
If ELF_BSDF_CHERI_REVOKE_FORCED is set in AT_BSDFLAGS then the presence
or absense of ELF_BSDF_CHERI_REVOKE was caused explicit action from
proccontrol or elfctl, not the system-wide default.
Add a weak symbol (malloc_revocation) which a program can override in
order to change revocation behavior.  By default, the system behavior is
is used, but if a symbol is provided it can be used to change the
default or even completely ignore proccontrol or ELF note overrides.
We want to be able to test malloc_revoke() even if the system default is
off the request that it be turned on, but don't force it to allow
testing with revocation administratively disabled.
Generally depend on the underlying allocator for documentation of
standard malloc(3) and non-standard jemalloc(3) interfaces.  Document
how MRS revocation can be controlled by the programmer, user, and
administrator.  Error on the side of providing a complete picture rather
than documenting non-MRS specific kernel bits elsewhere.

Install MLINKS as appropriate for standard interfaces so users can
learn about MRS.
Settle on "revoking" for public APIs.  Quarantining makes no sense
without revocation and other APIs generally mention revocation.
In dynamically linked programs, malloc_revoke isn't sufficently
preempted when the init() constructor is run so does not work.
Document this to allow the rest of the patch to land.
@brooksdavis brooksdavis force-pushed the revocation-management branch from 2939b17 to 7691622 Compare October 23, 2023 19:11
@brooksdavis brooksdavis merged commit d2d54fa into dev Oct 23, 2023
@brooksdavis brooksdavis deleted the revocation-management branch October 23, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants