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
..
2022-06-23 16:07:00 -03:00
2022-05-20 14:54:03 +03:00
2023-04-03 04:13:52 -04:00
2022-08-20 09:44:05 +00:00
2023-04-03 04:13:51 -04:00
2022-09-05 11:54:47 +00:00
2023-02-06 12:32:04 -05:00
2022-09-16 21:49:16 -06:00
2023-02-09 17:13:02 -04:00
2022-08-02 21:11:09 +03:00
2022-08-02 21:11:09 +03:00
2022-08-23 19:15:48 +00:00
2022-12-28 22:43:49 +00:00
2023-04-03 04:14:02 -04:00
2022-12-23 01:53:41 +02:00
2023-04-03 04:11:47 -04:00
2022-11-27 13:22:31 -07:00
2022-12-07 11:30:04 -07:00
2023-01-27 17:22:31 +00:00
2023-04-03 04:12:47 -04:00
2023-04-03 04:14:02 -04:00
2021-12-14 14:52:25 +00:00
2023-03-01 11:05:12 +00:00
2022-08-02 21:11:09 +03:00
2022-10-08 10:41:21 +00:00
2022-09-14 21:29:31 -06:00
2023-04-03 04:13:52 -04:00
2023-04-03 04:13:51 -04:00
2023-04-03 04:13:52 -04:00
2023-02-08 00:11:10 +00:00
2022-03-21 10:27:35 +00:00
2022-08-20 09:44:05 +00:00
2022-02-22 18:53:43 +00:00
2021-11-17 20:12:26 +00:00
2023-02-13 18:20:29 +00:00
2022-12-19 08:07:23 +00:00
2023-02-07 23:03:20 +00:00
2022-12-19 08:07:23 +00:00
2022-09-26 18:03:34 -06:00
2023-04-03 04:12:52 -04:00