-
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?
Conversation
Co-authored-by: Dapeng Gao <dapeng.gao@cl.cam.ac.uk>
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 comment
The 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 comment
The 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.
*/ | ||
if (len != sizeof(info) || | ||
info.version != CHERI_C18N_INFO_VERSION || | ||
info.comparts_gen % 2 != 0 || |
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.
I somewhat wondered if we wanted some sort of memory-barrier arrangement to ensure that we got a clean(ish) snapshot -- i.e., that if we saw the current generation, we saw all the stores we read from the compartment / string tables came before the generation number we read was stored, and that at the end of the sysctl function we haven't seen any stores that post-dated that generation-number store?
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.
Every iteration below we also re-read the generation number and check that it hasn’t changed. Presumably this achieves the desired effect?
return; | ||
} | ||
if ((procstat_opts & PS_OPT_NOHEADER) == 0) | ||
xo_emit("{T:/%5s %-19s %4s %-40s}\n", "PID", "COMM", "CID", |
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.
I always feel that 19 characters wide is quite a long slot for COMM, which most of the time uses list. Not sure if other procstat/ps modes might give less by default?
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.
I think 19 is fine (in fact it is too short for the cheribsdtest
variants). And the existing c18n
and cheri
commands both use 19.
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.
I widened to 19 (MAXCOMLEN) for auxv in 64e9f6a. It can be shorter, but it should probably the right most column so it can safely spill if it's not going to be MAXCOMLEN.
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.
Generally speaking it would be nice if this were split into kernel, libprocstat, and prostatic commits.
@@ -47,6 +53,8 @@ | |||
.Nm procstat_getargv , | |||
.Nm procstat_getauxv , | |||
.Nm procstat_getenvv , | |||
.Nm procstat_getc18n , |
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.
return; | ||
} | ||
if ((procstat_opts & PS_OPT_NOHEADER) == 0) | ||
xo_emit("{T:/%5s %-19s %4s %-40s}\n", "PID", "COMM", "CID", |
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.
I widened to 19 (MAXCOMLEN) for auxv in 64e9f6a. It can be shorter, but it should probably the right most column so it can safely spill if it's not going to be MAXCOMLEN.
This rebases #2272 to dev and adds more features (incl. a generation counter for the compartment array to deal with races).