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)
Mon, Apr 22, 12:32 PM
Unknown Object (File)
Feb 22 2024, 6:14 PM
Unknown Object (File)
Feb 22 2024, 6:13 PM
Unknown Object (File)
Feb 22 2024, 6:13 PM
Unknown Object (File)
Feb 22 2024, 6:13 PM
Unknown Object (File)
Feb 22 2024, 12:33 AM
Unknown Object (File)
Feb 14 2024, 4:59 AM
Unknown Object (File)
Jan 14 2024, 10:09 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.