Add new privilege PRIV_KDB_SET_BACKEND

Summary:
Check for PRIV_KDB_SET_BACKEND before allowing a thread to change
the KDB backend.

Obtained from:	Juniper Networks, Inc.
Reviewers: sjg, emaste
Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D39538
This commit is contained in:
Stephen J. Kiernan 2023-04-15 23:59:52 -04:00
parent c753f49f70
commit 4819e5aeda
2 changed files with 12 additions and 1 deletions

View File

@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/lock.h>
#include <sys/pcpu.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/smp.h>
@ -484,6 +485,11 @@ int
kdb_dbbe_select(const char *name)
{
struct kdb_dbbe *be, **iter;
int error;
error = priv_check(curthread, PRIV_KDB_SET_BACKEND);
if (error)
return (error);
SET_FOREACH(iter, kdb_dbbe_set) {
be = *iter;

View File

@ -515,10 +515,15 @@
#define PRIV_KMEM_READ 680 /* Open mem/kmem for reading. */
#define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */
/*
* Kernel debugger privileges.
*/
#define PRIV_KDB_SET_BACKEND 690 /* Allow setting KDB backend. */
/*
* Track end of privilege list.
*/
#define _PRIV_HIGHEST 682
#define _PRIV_HIGHEST 691
/*
* Validate that a named privilege is known by the privilege system. Invalid