Mark Johnston f5d6f7cb47 kdb: Modify securelevel policy
Currently, sysctls which enable KDB in some way are flagged with
CTLFLAG_SECURE, meaning that you can't modify them if securelevel > 0.
This is so that KDB cannot be used to lower a running system's
securelevel, see commit 3d7618d8bf0b7.  However, the newer mac_ddb(4)
restricts DDB operations which could be abused to lower securelevel
while retaining some ability to gather useful debugging information.

To enable the use of KDB (specifically, DDB) on systems with a raised
securelevel, change the KDB sysctl policy: rather than relying on
CTLFLAG_SECURE, add a check of the current securelevel to kdb_trap().
If the securelevel is raised, only pass control to the backend if MAC
specifically grants access; otherwise simply check to see if mac_ddb
vetoes the request, as before.

Add a new secure sysctl, debug.kdb.enter_securelevel, to override this
behaviour.  That is, the sysctl lets one enter a KDB backend even with a
raised securelevel, so long as it is set before the securelevel is
raised.

Reviewed by:	mhorne, stevek
MFC after:	1 month
Sponsored by:	Juniper Networks
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37122
2023-04-03 04:14:02 -04:00
..
2023-04-03 04:10:00 -04:00
c.7
2021-04-20 10:33:34 +02:00
2021-04-04 00:50:28 +03:00
2013-05-13 18:13:50 +00:00
2019-04-09 10:17:24 +00:00
2020-11-19 16:57:45 +00:00
2022-12-13 06:43:28 +02:00
2022-11-20 19:24:57 +01:00
2023-01-27 14:01:12 -05:00
2023-04-03 04:14:02 -04:00
2022-12-14 07:44:04 +02:00
2022-03-04 12:35:55 +01:00