-
Notifications
You must be signed in to change notification settings - Fork 61
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
procstat: Add a 'compartments' command to list c18n compartments #2276
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,12 @@ | |
* SPDX-License-Identifier: BSD-2-Clause | ||
* | ||
* Copyright (c) 2024 Dapeng Gao | ||
* Copyright (c) 2024 Capabilities Limited | ||
* | ||
* This software was developed by SRI International, the University of | ||
* Cambridge Computer Laboratory (Department of Computer Science and | ||
* Technology), and Capabilities Limited under Defense Advanced Research | ||
* Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC"). | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
|
@@ -44,7 +50,7 @@ | |
* initialised. | ||
*/ | ||
struct rtld_c18n_stats { | ||
_Atomic(uint8_t) version; | ||
_Atomic(size_t) version; | ||
size_t rcs_compart; | ||
_Atomic(size_t) rcs_ustack; | ||
_Atomic(size_t) rcs_tramp; | ||
|
@@ -58,12 +64,38 @@ | |
* information. The version field doubles as a synchronisation flag where a | ||
* non-zero value indicates that the other fields have been initialised. | ||
*/ | ||
#define CHERI_C18N_INFO_VERSION 1 | ||
#define CHERI_C18N_INFO_VERSION 2 | ||
|
||
struct cheri_c18n_info { | ||
_Atomic(uint8_t) version; | ||
_Atomic(size_t) version; | ||
|
||
size_t stats_size; | ||
struct rtld_c18n_stats * __kerncap stats; | ||
|
||
/* | ||
* Since the `comparts` array may be reallocated or ortherwise change | ||
* whilst the kernel is reading it, the generation counter allows the | ||
* kernel to identify such races. An even value indicates that the | ||
* array and size data are in a consistent state, and an odd value | ||
* indicates that the data may be inconsistent. | ||
*/ | ||
_Atomic(size_t) comparts_gen; | ||
size_t comparts_size; | ||
size_t comparts_entry_size; | ||
void * __kerncap comparts; | ||
Check failure on line 85 in sys/cheri/c18n.h GitHub Actions / Style Checker
|
||
}; | ||
|
||
/* | ||
* The interface provided by the kernel via sysctl for compartmentalization | ||
* monitoring tools such as procstat. | ||
*/ | ||
#define CHERI_C18N_COMPART_MAXNAME 56 | ||
#define CHERI_C18N_COMPART_LAST -1 | ||
|
||
struct cheri_c18n_compart { | ||
ssize_t ccc_id; | ||
char ccc_name[CHERI_C18N_COMPART_MAXNAME]; | ||
char _ccc_pad[64]; /* Shrink as new fields added above. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should preemptively define a 'ccc_flags' field to capture concepts like "This is a non-default sub-library compartment", "this compartment can performance system calls", and similar? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can always add them in the future when they become needed. Right now RTLD doesn't track such information about compartments, so it is risky to to add the flags prematurely. |
||
}; | ||
|
||
#ifndef IN_RTLD | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documenting this is good, but it should be a separate commit.