From owner-svn-src-head@freebsd.org Thu Nov 28 00:46:04 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4124D1BD309; Thu, 28 Nov 2019 00:46:04 +0000 (UTC) (envelope-from cem@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47Nf8D0ydpz3KKs; Thu, 28 Nov 2019 00:46:04 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F3FB21DCD5; Thu, 28 Nov 2019 00:46:03 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAS0k37f063469; Thu, 28 Nov 2019 00:46:03 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAS0k39c063468; Thu, 28 Nov 2019 00:46:03 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201911280046.xAS0k39c063468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Thu, 28 Nov 2019 00:46:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355155 - head/contrib/openbsm/bin/auditd X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/contrib/openbsm/bin/auditd X-SVN-Commit-Revision: 355155 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Nov 2019 00:46:04 -0000 Author: cem Date: Thu Nov 28 00:46:03 2019 New Revision: 355155 URL: https://svnweb.freebsd.org/changeset/base/355155 Log: auditd(8): fix long-standing uninitialized memory use bug The bogus use could lead to an infinite loop depending on how fast the audit_warn script to execute. By fixing read(2) interruptibility, d060887 (r335899) revealed another bug in auditd_wait_for_events. When read is interrupted by SIGCHLD, auditd_reap_children will always return with errno set to ECHILD. But auditd_wait_for_events checks errno after that point, expecting it to be unchanged since read. As a result, it calls auditd_handle_trigger with bogus stack garbage. The result is the error message "Got unknown trigger 48." Fix by simply ignoring errno at that point; there's only one value it could've possibly had, thanks to the check up above. The best part is we've had a fix for this for like 18 months and just never merged it. Merge it now. PR: 234209 Reported by: Marie Helene Kvello-Aune (2018-12) Submitted by: asomers (2018-07) Reviewed by: me (in OpenBSM) Obtained from: OpenBSM X-MFC-With: r335899 Security: ¯\_(ツ)_/¯ Differential Revision: https://github.com/openbsm/openbsm/pull/45 Modified: head/contrib/openbsm/bin/auditd/auditd_fbsd.c Modified: head/contrib/openbsm/bin/auditd/auditd_fbsd.c ============================================================================== --- head/contrib/openbsm/bin/auditd/auditd_fbsd.c Thu Nov 28 00:42:55 2019 (r355154) +++ head/contrib/openbsm/bin/auditd/auditd_fbsd.c Thu Nov 28 00:46:03 2019 (r355155) @@ -241,7 +241,7 @@ auditd_wait_for_events(void) auditd_config_controls(); } - if ((num == -1) && (errno == EINTR)) + if (num == -1) continue; if (num == 0) { auditd_log_err("%s: read EOF", __FUNCTION__);