| #
f0a7df4a
|
| 09-Jul-2024 |
Ryan Libby <rlibby@FreeBSD.org> |
ddb: make db_error reliably no-return
Most code assumes db_error does not return, but according to kdb_reenter_silent, there may be cases where it could. Instead, panic if kdb_reenter_silent return
ddb: make db_error reliably no-return
Most code assumes db_error does not return, but according to kdb_reenter_silent, there may be cases where it could. Instead, panic if kdb_reenter_silent returns and mark the routine as __dead2. This addresses gcc warnings.
Reported by: GCC -Wmaybe-uninitialized Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45918
show more ...
|
| #
076b64e8
|
| 12-Mar-2024 |
Andrew Turner <andrew@FreeBSD.org> |
sys/ddb: Add hardware breakpoint support to ddb
As with hardware watchpoints add support for hardware breakpoints. The command is only enabled on architectures that report support for them. Currentl
sys/ddb: Add hardware breakpoint support to ddb
As with hardware watchpoints add support for hardware breakpoints. The command is only enabled on architectures that report support for them. Currently no architectures do, however arm64 will add support in a future change.
Reviewed by: jhb (earlier version) Sponsored by: Arm Ltd Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D22191
show more ...
|
| #
c21bc6f3
|
| 22-Mar-2024 |
Bojan Novković <bnovkov@FreeBSD.org> |
ddb: Add CTF-based pretty printing
Add basic CTF support and a CTF-powered pretty-printer to ddb.
The db_ctf.* files expose a basic interface for fetching type data for ELF symbols, interacting wit
ddb: Add CTF-based pretty printing
Add basic CTF support and a CTF-powered pretty-printer to ddb.
The db_ctf.* files expose a basic interface for fetching type data for ELF symbols, interacting with the CTF string table, and translating type identifiers to type data.
The db_pprint.c file uses those interfaces to implement a pretty-printer for all kernel ELF symbols. The pretty-printer works with symbol names and arbitrary addresses: pprint struct thread 0xffffffff8194ad90
Pretty-printing currently only works after the root filesystem gets mounted because the CTF info is not available during early boot.
Differential Revision: https://reviews.freebsd.org/D37899 Approved by: markj (mentor)
show more ...
|
| #
95ee2897
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
| #
884eaacd
|
| 05-Jul-2023 |
John Baldwin <jhb@FreeBSD.org> |
ddb: Rework macros to make it easier to add new command tables.
- Add new DB_DEFINE_TABLE and DB_DECLARE_TABLE macros to define new command tables. DB_DECLARE_TABLE is intended for use in headers
ddb: Rework macros to make it easier to add new command tables.
- Add new DB_DEFINE_TABLE and DB_DECLARE_TABLE macros to define new command tables. DB_DECLARE_TABLE is intended for use in headers similar to MALLOC_DECLARE and SYSCTL_DECL.
DB_DEFINE_TABLE takes three arguments, the name of the parent table, the command name, and the name of the table itself, e.g. DB_DEFINE_TABLE(show, foo, show_foo) defines a new "show foo" table.
- DB_TABLE_COMMAND, DB_TABLE_COMMAND_FLAGS, DB_TABLE_ALIAS, and DB_ALIAS_FLAGS allow new commands and aliases to be defined. These are similar to the existing DB_COMMAND, etc. except that they take an initial argument giving the name of the parent table, e.g.:
DB_TABLE_COMMAND(show_foo, bar, db_show_foo_bar)
defines a new "show foo bar" command.
This provides a cleaner interface than the ad-hoc use of internal macros like _DB_SET that was required previously (e.g. in cxgbe(4)).
This retires DB_FUNC macro as well as the internal _DB_FUNC macro.
Reviewed by: melifaro, kib, markj Differential Revision: https://reviews.freebsd.org/D40819
show more ...
|
| #
287d467c
|
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
mac: add new mac_ddb(4) policy
Generally, access to the kernel debugger is considered to be unsafe from a security perspective since it presents an unrestricted interface to inspect or modify the sy
mac: add new mac_ddb(4) policy
Generally, access to the kernel debugger is considered to be unsafe from a security perspective since it presents an unrestricted interface to inspect or modify the system state, including sensitive data such as signing keys.
However, having some access to debugger functionality on production systems may be useful in determining the cause of a panic or hang. Therefore, it is desirable to have an optional policy which allows limited use of ddb(4) while disabling the functionality which could reveal system secrets.
This loadable MAC module allows for the use of some ddb(4) commands while preventing the execution of others. The commands have been broadly grouped into three categories: - Those which are 'safe' and will not emit sensitive data (e.g. trace). Generally, these commands are deterministic and don't accept arguments. - Those which are definitively unsafe (e.g. examine <addr>, search <addr> <value>) - Commands which may be safe to execute depending on the arguments provided (e.g. show thread <addr>).
Safe commands have been flagged as such with the DB_CMD_MEMSAFE flag.
Commands requiring extra validation can provide a function to do so. For example, 'show thread <addr>' can be used as long as addr can be checked against the system's list of process structures.
The policy also prevents debugger backends other than ddb(4) from executing, for example gdb(4).
Reviewed by: markj, pauamma_gundo.com (manpages) Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35371
show more ...
|
| #
2449b9e5
|
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
mac: kdb/ddb framework hooks
Add three simple hooks to the debugger allowing for a loaded MAC policy to intervene if desired: 1. Before invoking the kdb backend 2. Before ddb command registration
mac: kdb/ddb framework hooks
Add three simple hooks to the debugger allowing for a loaded MAC policy to intervene if desired: 1. Before invoking the kdb backend 2. Before ddb command registration 3. Before ddb command execution
We extend struct db_command with a private pointer and two flag bits reserved for policy use.
Reviewed by: markj Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35370
show more ...
|
| #
bb61cba7
|
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: add the DB_CMD_MEMSAFE flag for commands
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
ddb: add the DB_CMD_MEMSAFE flag for commands
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.
Apply the flag to the "show all" command macros. It is expected that commands added to this table will always exhibit this property.
Reviewed by: markj Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35581
show more ...
|
| #
7ce58d4e
|
| 30-Jun-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: add _FLAGS command variants
Provide _FLAGS variants of the various command definition macros, in anticipation of adding a new flag. This can also be used for some existing commands which requir
ddb: add _FLAGS command variants
Provide _FLAGS variants of the various command definition macros, in anticipation of adding a new flag. This can also be used for some existing commands which require special flag values.
Reviewed by: markj MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35581
show more ...
|
| #
4ef7db5a
|
| 14-Jun-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: namespacing of struct command
'command' is too generic for something specific to the kernel debugger; change this so it is less likely to collide with local variable names. Also rename struct c
ddb: namespacing of struct command
'command' is too generic for something specific to the kernel debugger; change this so it is less likely to collide with local variable names. Also rename struct command_table to struct db_command_table.
Reviewed by: markj MFC after: 1 week Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35367
show more ...
|
| #
9d81dd54
|
| 08-Mar-2021 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: replace watchpoint set/clear functions
Use the new kdb variants. Print more specific error messages.
Reviewed by: jhb, markj MFC after: 3 weeks Sponsored by: NetApp, Inc. Sponsored by: Klara,
ddb: replace watchpoint set/clear functions
Use the new kdb variants. Print more specific error messages.
Reviewed by: jhb, markj MFC after: 3 weeks Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D29156
show more ...
|
| #
3e5e9939
|
| 14-Mar-2021 |
Ryan Libby <rlibby@FreeBSD.org> |
ddb: enable the use of ^C and ^S/^Q
This lets one interrupt DDB's output, which is useful if paging is disabled and the output device is slow.
This follows a previous implementation in svn r311952
ddb: enable the use of ^C and ^S/^Q
This lets one interrupt DDB's output, which is useful if paging is disabled and the output device is slow.
This follows a previous implementation in svn r311952 / git 5fddef79998678d256ba30316353393b4d8ebb32 which was reverted because it broke DDB type-ahead.
Now, try this again, but with a 512-byte type-ahead buffer. While there is buffer space, control input is handled and non-control input is buffered. When the buffer is exhausted, the default is to print a warning and drop further non-control input in order to continue handling control input. sysctl debug.ddb.prioritize_control_input can be set to 0 to instead preserve all input but lose immediate handling of control input. This could for example effect pasting of a large script into the ddb console.
Suggested by: Anton Rang <rang@acm.org> Reviewed by: markj Discussed with: imp Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D28676
show more ...
|
| #
40b664f6
|
| 21-Jun-2020 |
Brandon Bergren <bdragon@FreeBSD.org> |
[PowerPC] More relocation fixes
It turns out relocating the symbol table itself can cause issues, like fbt crashing because it applies the offsets to the kernel twice.
This had been previously brou
[PowerPC] More relocation fixes
It turns out relocating the symbol table itself can cause issues, like fbt crashing because it applies the offsets to the kernel twice.
This had been previously brought up in rS333447 when the stoffs hack was added, but I had been unaware of this and reimplemented symtab relocation.
Instead of relocating the symbol table, keep track of the relocation base in ddb, so the ddb symbols behave like the kernel linker-provided symbols.
This is intended to be NFC on platforms other than PowerPC, which do not use fully relocatable kernels. (The relbase will always be 0)
* Remove the rest of the stoffs hack. * Remove my half-baked displace_symbol_table() function. * Extend ddb initialization to cope with having a relocation offset on the kernel symbol table. * Fix my kernel-as-initrd hack to work with booke64 by using a temporary mapping to access the data. * Fix another instance of __powerpc__ that is actually RELOCATABLE_KERNEL. * Change the behavior or X_db_symbol_values to apply the relocation base when updating valp, to match link_elf_symbol_values() behavior.
Reviewed by: jhibbits Sponsored by: Tag1 Consulting, Inc. Differential Revision: https://reviews.freebsd.org/D25223
show more ...
|
| #
f0a7df4a
|
| 09-Jul-2024 |
Ryan Libby <rlibby@FreeBSD.org> |
ddb: make db_error reliably no-return
Most code assumes db_error does not return, but according to kdb_reenter_silent, there may be cases where it could. Instead, panic if kdb_reenter_silent return
ddb: make db_error reliably no-return
Most code assumes db_error does not return, but according to kdb_reenter_silent, there may be cases where it could. Instead, panic if kdb_reenter_silent returns and mark the routine as __dead2. This addresses gcc warnings.
Reported by: GCC -Wmaybe-uninitialized Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45918
show more ...
|
| #
076b64e8
|
| 12-Mar-2024 |
Andrew Turner <andrew@FreeBSD.org> |
sys/ddb: Add hardware breakpoint support to ddb
As with hardware watchpoints add support for hardware breakpoints. The command is only enabled on architectures that report support for them. Currentl
sys/ddb: Add hardware breakpoint support to ddb
As with hardware watchpoints add support for hardware breakpoints. The command is only enabled on architectures that report support for them. Currently no architectures do, however arm64 will add support in a future change.
Reviewed by: jhb (earlier version) Sponsored by: Arm Ltd Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D22191
show more ...
|
| #
c21bc6f3
|
| 22-Mar-2024 |
Bojan Novković <bnovkov@FreeBSD.org> |
ddb: Add CTF-based pretty printing
Add basic CTF support and a CTF-powered pretty-printer to ddb.
The db_ctf.* files expose a basic interface for fetching type data for ELF symbols, interacting wit
ddb: Add CTF-based pretty printing
Add basic CTF support and a CTF-powered pretty-printer to ddb.
The db_ctf.* files expose a basic interface for fetching type data for ELF symbols, interacting with the CTF string table, and translating type identifiers to type data.
The db_pprint.c file uses those interfaces to implement a pretty-printer for all kernel ELF symbols. The pretty-printer works with symbol names and arbitrary addresses: pprint struct thread 0xffffffff8194ad90
Pretty-printing currently only works after the root filesystem gets mounted because the CTF info is not available during early boot.
Differential Revision: https://reviews.freebsd.org/D37899 Approved by: markj (mentor)
show more ...
|
| #
95ee2897
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
| #
884eaacd
|
| 05-Jul-2023 |
John Baldwin <jhb@FreeBSD.org> |
ddb: Rework macros to make it easier to add new command tables.
- Add new DB_DEFINE_TABLE and DB_DECLARE_TABLE macros to define new command tables. DB_DECLARE_TABLE is intended for use in headers
ddb: Rework macros to make it easier to add new command tables.
- Add new DB_DEFINE_TABLE and DB_DECLARE_TABLE macros to define new command tables. DB_DECLARE_TABLE is intended for use in headers similar to MALLOC_DECLARE and SYSCTL_DECL.
DB_DEFINE_TABLE takes three arguments, the name of the parent table, the command name, and the name of the table itself, e.g. DB_DEFINE_TABLE(show, foo, show_foo) defines a new "show foo" table.
- DB_TABLE_COMMAND, DB_TABLE_COMMAND_FLAGS, DB_TABLE_ALIAS, and DB_ALIAS_FLAGS allow new commands and aliases to be defined. These are similar to the existing DB_COMMAND, etc. except that they take an initial argument giving the name of the parent table, e.g.:
DB_TABLE_COMMAND(show_foo, bar, db_show_foo_bar)
defines a new "show foo bar" command.
This provides a cleaner interface than the ad-hoc use of internal macros like _DB_SET that was required previously (e.g. in cxgbe(4)).
This retires DB_FUNC macro as well as the internal _DB_FUNC macro.
Reviewed by: melifaro, kib, markj Differential Revision: https://reviews.freebsd.org/D40819
show more ...
|
| #
287d467c
|
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
mac: add new mac_ddb(4) policy
Generally, access to the kernel debugger is considered to be unsafe from a security perspective since it presents an unrestricted interface to inspect or modify the sy
mac: add new mac_ddb(4) policy
Generally, access to the kernel debugger is considered to be unsafe from a security perspective since it presents an unrestricted interface to inspect or modify the system state, including sensitive data such as signing keys.
However, having some access to debugger functionality on production systems may be useful in determining the cause of a panic or hang. Therefore, it is desirable to have an optional policy which allows limited use of ddb(4) while disabling the functionality which could reveal system secrets.
This loadable MAC module allows for the use of some ddb(4) commands while preventing the execution of others. The commands have been broadly grouped into three categories: - Those which are 'safe' and will not emit sensitive data (e.g. trace). Generally, these commands are deterministic and don't accept arguments. - Those which are definitively unsafe (e.g. examine <addr>, search <addr> <value>) - Commands which may be safe to execute depending on the arguments provided (e.g. show thread <addr>).
Safe commands have been flagged as such with the DB_CMD_MEMSAFE flag.
Commands requiring extra validation can provide a function to do so. For example, 'show thread <addr>' can be used as long as addr can be checked against the system's list of process structures.
The policy also prevents debugger backends other than ddb(4) from executing, for example gdb(4).
Reviewed by: markj, pauamma_gundo.com (manpages) Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35371
show more ...
|
| #
2449b9e5
|
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
mac: kdb/ddb framework hooks
Add three simple hooks to the debugger allowing for a loaded MAC policy to intervene if desired: 1. Before invoking the kdb backend 2. Before ddb command registration
mac: kdb/ddb framework hooks
Add three simple hooks to the debugger allowing for a loaded MAC policy to intervene if desired: 1. Before invoking the kdb backend 2. Before ddb command registration 3. Before ddb command execution
We extend struct db_command with a private pointer and two flag bits reserved for policy use.
Reviewed by: markj Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35370
show more ...
|
| #
bb61cba7
|
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: add the DB_CMD_MEMSAFE flag for commands
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
ddb: add the DB_CMD_MEMSAFE flag for commands
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.
Apply the flag to the "show all" command macros. It is expected that commands added to this table will always exhibit this property.
Reviewed by: markj Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35581
show more ...
|
| #
7ce58d4e
|
| 30-Jun-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: add _FLAGS command variants
Provide _FLAGS variants of the various command definition macros, in anticipation of adding a new flag. This can also be used for some existing commands which requir
ddb: add _FLAGS command variants
Provide _FLAGS variants of the various command definition macros, in anticipation of adding a new flag. This can also be used for some existing commands which require special flag values.
Reviewed by: markj MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35581
show more ...
|
| #
4ef7db5a
|
| 14-Jun-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: namespacing of struct command
'command' is too generic for something specific to the kernel debugger; change this so it is less likely to collide with local variable names. Also rename struct c
ddb: namespacing of struct command
'command' is too generic for something specific to the kernel debugger; change this so it is less likely to collide with local variable names. Also rename struct command_table to struct db_command_table.
Reviewed by: markj MFC after: 1 week Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35367
show more ...
|
| #
9d81dd54
|
| 08-Mar-2021 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: replace watchpoint set/clear functions
Use the new kdb variants. Print more specific error messages.
Reviewed by: jhb, markj MFC after: 3 weeks Sponsored by: NetApp, Inc. Sponsored by: Klara,
ddb: replace watchpoint set/clear functions
Use the new kdb variants. Print more specific error messages.
Reviewed by: jhb, markj MFC after: 3 weeks Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D29156
show more ...
|
| #
3e5e9939
|
| 14-Mar-2021 |
Ryan Libby <rlibby@FreeBSD.org> |
ddb: enable the use of ^C and ^S/^Q
This lets one interrupt DDB's output, which is useful if paging is disabled and the output device is slow.
This follows a previous implementation in svn r311952
ddb: enable the use of ^C and ^S/^Q
This lets one interrupt DDB's output, which is useful if paging is disabled and the output device is slow.
This follows a previous implementation in svn r311952 / git 5fddef79998678d256ba30316353393b4d8ebb32 which was reverted because it broke DDB type-ahead.
Now, try this again, but with a 512-byte type-ahead buffer. While there is buffer space, control input is handled and non-control input is buffered. When the buffer is exhausted, the default is to print a warning and drop further non-control input in order to continue handling control input. sysctl debug.ddb.prioritize_control_input can be set to 0 to instead preserve all input but lose immediate handling of control input. This could for example effect pasting of a large script into the ddb console.
Suggested by: Anton Rang <rang@acm.org> Reviewed by: markj Discussed with: imp Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D28676
show more ...
|