From patchwork Thu Mar 2 19:40:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stsp X-Patchwork-Id: 55547 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02AAB385828D for ; Thu, 2 Mar 2023 19:41:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02AAB385828D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677786086; bh=LLa7ZS+mtM+QWgLufUWuRlLPQK72aEZMSQkRafIhodU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Lso+/ffYazVa+Xl33qPzcHWXtAVmWPDyY6SfJSZowz6MfnZ4WMprrir9J6EAotmRr C6bgKTHKKC5KQq5ZffDTturRHRNWb8UlSPthyHFPE6vLaw3wt0THpZ10ZH4d1ETFml zRUnedsBHu4QD5iTi395I2CaP/8mMqgvlZmGD3a4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [178.154.239.148]) by sourceware.org (Postfix) with ESMTPS id 9FF783858CDB for ; Thu, 2 Mar 2023 19:40:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FF783858CDB Received: from iva4-143b1447cf50.qloud-c.yandex.net (iva4-143b1447cf50.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:7511:0:640:143b:1447]) by forward101b.mail.yandex.net (Yandex) with ESMTP id AB9F4600CE for ; Thu, 2 Mar 2023 22:40:55 +0300 (MSK) Received: by iva4-143b1447cf50.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id secDfN2bcmI1-xIYxJ2wr; Thu, 02 Mar 2023 22:40:55 +0300 X-Yandex-Fwd: 1 To: libc-alpha@sourceware.org Cc: Stas Sergeev Subject: [PATCH v7 0/3] minimal run-time audit support Date: Fri, 3 Mar 2023 00:40:48 +0500 Message-Id: <20230302194051.3677691-1-stsp2@yandex.ru> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Stas Sergeev via Libc-alpha From: stsp Reply-To: Stas Sergeev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Changes in v7: address the review comment of Jonathon Anderson: allow dynamically loaded audit module to work with previously loaded modules. The technique is the same as in dl_main(): call la_objopen() for every pre-existing object to "introduce" it to an auditor. Changes in v6: fix what seems to be a problem in v5: call unload_audit_module() before _dl_signal_error(), rather than after. It seems _dl_signal_error() may involve longjmp() so it should be called the last, after any clean-ups. Changes in v5: address the review comment of Jonathon Anderson: Disabling existing audit call-backs may break some existing auditors if they attempted to be loaded with dlload_audit_module(). Instead return an error EINVAL and refuse to load an audit module that has the unallowed call-backs (symbind, pltenter, pltexit). Extend test to make sure the error is reported as expected. Changes in v4: rebased, conflicts resolved. Changes in v3: address the review comment of Jonathon Anderson: Disable 3 audit call-backs for dynamically loaded modules. Namely symbind, pltenter, pltexit. Extend test-case to make sure they are not resolved and not called. Changes in v2: address the review comment of Jonathon Anderson: Add per-linkmap l_naudit counter to make sure each object is audited only with the modules loaded before it. That avoids the possibility of getting the "unrecognized" cookie. Test-case was enhanced to check for unrecognized cookies. This patch-set introduces the bare minimum functionality for working with audit modules at run-time. Patch1 fixes the check in dlmopen() which avoids loading solibs into the auditing namespace. But RTLD_NOLOAD was forgotten to check, and with that flags nothing gets loaded into auditing namespace, so dlmopen() should succeed and return the handle for auditing object. Patch2 adds dlload_audit_module() function and a test-case for it.