Page MenuHomeFreeBSD

ddb: add the DB_CMD_MEMSAFE flag for commands
ClosedPublic

Authored by mhorne on Jun 23 2022, 6:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 16 2024, 4:27 PM
Unknown Object (File)
Oct 2 2024, 6:19 AM
Unknown Object (File)
Sep 20 2024, 1:02 AM
Unknown Object (File)
Sep 19 2024, 8:20 PM
Unknown Object (File)
Sep 18 2024, 11:40 AM
Unknown Object (File)
Sep 18 2024, 1:46 AM
Unknown Object (File)
Sep 8 2024, 8:31 AM
Unknown Object (File)
Sep 8 2024, 6:23 AM

Details

Summary

This flag value can be used to indicate if a command has the property of
being "memory safe". In this instance, memory safe means that the
command does not allow/enable reads or writes of arbitrary memory,
regardless of the arguments passed to it. For example, 'backtrace' is
considered a memory-safe command since its output is deterministic,
while 'show vnode' is not, since it requires a memory address as an
argument and will print the contents beginning at that location.

Provide _FLAGS variants of the various command definition macros, so
that command definitions can be augmented with this new flag, and
conceivably any others they require.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/ddb/ddb.h
188

Note that I've simply applied the flag here rather than providing DB_SHOW_ALL_COMMAND_FLAGS, the reason that every 'show all foo' command would end up getting this flag. I think this is a reasonable enough assumption going forward..

markj added inline comments.
sys/ddb/ddb.h
188

I think that's probably safe.

This revision is now accepted and ready to land.Jun 24 2022, 2:09 PM
sys/ddb/ddb.h
169

BTW, there is a DB_COMMAND man page that should be updated.

Adding the *_FLAGS variants is useful separate from this and can probably be used to replace most (all?) of the inline _DB_SET/_DB_FUNC invocations in the tree that mostly exist to permit setting CS_OWN.

(In fact, I would suggest adding the flags variants for all of them as a separate commit before this along with the CS_OWN cleanup if you are inclined and make this patch just be about adding the MEMSAFE flag.)

This revision was automatically updated to reflect the committed changes.

I committed just the new macros, so this review is now just about the new flag value. To be updated shortly.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 18 2022, 10:07 PM
This revision was automatically updated to reflect the committed changes.