From nobody Fri Jun 5 21:50:57 2026 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 4gXFVp0qnGz6gbWl for ; Fri, 05 Jun 2026 21:50:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gXFVn6qr0z3V8Y for ; Fri, 05 Jun 2026 21:50:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780696258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e2mPaVaLGRAbrjLOhe8cjokrFcECBZ/hHdWtNJ9A2pw=; b=B/kSkfCYszuZCHJ83ZIcNpUIrnNyYv8mxnoUdahqK5pdJDZo6OmHParxOiFHX9dVX/3lfz NJUtqRboaqdwLBr4AtqOnMysSlmdTujls1uozAFvJAMeniCREc06rSqunE4Iq2EF8vzC0J SI4g/d1fuVqK4goFN6BQlNNFPCezkNEOHnrnzbJeor12nXJVg8ar2EWDS4dKQv+UwWbqKz ep1kgoaiyBzFMB/gWBQ5U1xL1qwg3H1myAQLf5shmEaxehQuoce+djviDSCAzkLAyuj/Wa 9O9R9/zgFVrqZWOBCzsBll+weI7uJCI796XPfuPxXgwrlCes71ltHY/hNquinw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780696258; a=rsa-sha256; cv=none; b=tJnbwPwZfpVBhMHFc5eD9wPeY5FKjvIsz8uzzEyz1n5vipPmxoo4PWkDcBNIMqCX2bHZNG COsx48zlkxMEUwUMC6/Sqhr2N77J3TSCvXd7wX542zLvcCZmGESRLY3cxrt34NcDUDbXi6 mkZXp9XYaz647l/AWljpVkkGDFv016mf55ikbeMSVWMghH5ZrXpFp0/H/HKFsB8RCKYKRu CDKvPmQszyisNgn9WITb1omDNjr7J83xEcH57i/mJUIJ+Ac5NXWJRNRSz/NU+nQOa+KZtC iE7rUfNOuLBcnSLm/6oRdkwbKfg08dqq3fbiJA2zyXX8kdI/3ETPgAqMUoSNCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780696258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e2mPaVaLGRAbrjLOhe8cjokrFcECBZ/hHdWtNJ9A2pw=; b=iTBLOTcSyDICO/1gqKT4H14MLpFt/YUGX17jpteDuEJl2m/2BOLX0CGlgJgDONXreuZMs0 XKEh5LyKxEbvwh9+QEg3qYScGMhVW6tURGwh7SuEPoAA/yfpOEgRUF7whMcUheiPR5Z8Y2 zcGq6ieoNOsSHcVeZX4nTEvMUG7mdjG+PZz7AuAAZVO+qcCSsuc/JocpRyWmr30W1bBV0c ogZXsioqA+GE2pK8yNpAVnl1YloYdcJQ4fDT76su5i5uDe4ZO0+VnO+9oaf6EPWFsraHH9 mh9SwPZhgXPNpyHzjR0Cm3u3KA8PPtOVM7jbd82Mc+Eo+fbXtO3Vinh/w5jTlA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gXFVn6GDZzp1P for ; Fri, 05 Jun 2026 21:50:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19bb6 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 05 Jun 2026 21:50:57 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 0620c99d278b - main - audit: Add poll / select support 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0620c99d278b6a2fd6fe995f5bb365158e04ad7c Auto-Submitted: auto-generated Date: Fri, 05 Jun 2026 21:50:57 +0000 Message-Id: <6a2344c1.19bb6.6ef47c63@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=0620c99d278b6a2fd6fe995f5bb365158e04ad7c commit 0620c99d278b6a2fd6fe995f5bb365158e04ad7c Author: Dag-Erling Smørgrav AuthorDate: 2026-06-05 21:50:38 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-06-05 21:50:38 +0000 audit: Add poll / select support It was previously not possible to poll() or select() on the trigger device, which made implementing proper signal handling in auditd difficult. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans, markj Differential Revision: https://reviews.freebsd.org/D57457 --- sys/security/audit/audit_trigger.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/security/audit/audit_trigger.c b/sys/security/audit/audit_trigger.c index 482f7c56a2ef..e2520292cc5d 100644 --- a/sys/security/audit/audit_trigger.c +++ b/sys/security/audit/audit_trigger.c @@ -32,8 +32,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -45,8 +47,6 @@ * used to communicate with userland. /dev/audit reliably delivers one-byte * messages to a listening application (or discards them if there is no * listening application). - * - * Currently, select/poll are not supported on the trigger device. */ struct trigger_info { unsigned int trigger; @@ -58,6 +58,7 @@ static struct cdev *audit_dev; static int audit_isopen = 0; static TAILQ_HEAD(, trigger_info) trigger_list; static struct mtx audit_trigger_mtx; +static struct selinfo audit_trigger_rsel; static int audit_open(struct cdev *dev, int oflags, int devtype, struct thread *td) @@ -127,6 +128,22 @@ audit_write(struct cdev *dev, struct uio *uio, int ioflag) return (EOPNOTSUPP); } +static int +audit_poll(struct cdev *dev, int events, struct thread *td) +{ + int revents = 0; + + if (events & (POLLIN | POLLRDNORM)) { + mtx_lock(&audit_trigger_mtx); + if (!TAILQ_EMPTY(&trigger_list)) + revents = events & (POLLIN | POLLRDNORM); + else + selrecord(td, &audit_trigger_rsel); + mtx_unlock(&audit_trigger_mtx); + } + return (revents); +} + int audit_send_trigger(unsigned int trigger) { @@ -142,6 +159,7 @@ audit_send_trigger(unsigned int trigger) } ti->trigger = trigger; TAILQ_INSERT_TAIL(&trigger_list, ti, list); + selwakeup(&audit_trigger_rsel); wakeup(&trigger_list); mtx_unlock(&audit_trigger_mtx); return (0); @@ -153,6 +171,7 @@ static struct cdevsw audit_cdevsw = { .d_close = audit_close, .d_read = audit_read, .d_write = audit_write, + .d_poll = audit_poll, .d_name = "audit" };