From nobody Mon Apr 17 11:39:03 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q0Q7N3ZDzz45mWK; Mon, 17 Apr 2023 11:39:12 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q0Q7N09n6z4PqL; Mon, 17 Apr 2023 11:39:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.17.1/8.17.1) with ESMTPS id 33HBd4FV007174 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 17 Apr 2023 14:39:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 33HBd4FV007174 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 33HBd3qs007173; Mon, 17 Apr 2023 14:39:03 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 17 Apr 2023 14:39:03 +0300 From: Konstantin Belousov To: "Simon J. Gerraty" Cc: "Stephen J. Kiernan" , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 4819e5aeda4e - main - Add new privilege PRIV_KDB_SET_BACKEND Message-ID: References: <202304161838.33GIcJiX079190@gitrepo.freebsd.org> <11356.1681707027@kaos.jnpr.net> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11356.1681707027@kaos.jnpr.net> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Rspamd-Queue-Id: 4Q0Q7N09n6z4PqL X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Sun, Apr 16, 2023 at 09:50:27PM -0700, Simon J. Gerraty wrote: > Konstantin Belousov wrote: > > > @@ -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); > > priv_check() fails for jailed, or even simply non-root process. > > kdb_dbbe_select() is called from a random context, e.g. from > > kdb_alt_break_gdb(), where it inherits whatever thread was running > > at the moment of break to debugger. > > That sounds like a bug? Definitely. > > > In other words, this function no longer works reliably. > > > > > + if (error) > > > + return (error); > > > > > > SET_FOREACH(iter, kdb_dbbe_set) { > > > be = *iter; > > > diff --git a/sys/sys/priv.h b/sys/sys/priv.h > > > index 20bfc7312ce3..cb4dcecea4aa 100644 > > > --- a/sys/sys/priv.h > > > +++ b/sys/sys/priv.h > > > @@ -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