From patchwork Fri Oct 9 13:00:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11825797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2C806CA for ; Fri, 9 Oct 2020 13:01:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD9A8222D5 for ; Fri, 9 Oct 2020 13:01:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TkdZ6PtC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732706AbgJINBF (ORCPT ); Fri, 9 Oct 2020 09:01:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47062 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729347AbgJINBF (ORCPT ); Fri, 9 Oct 2020 09:01:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602248463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bliAGEGppea0R+afTBlb53Edc2NvCaHr+sHZ7NDGN7Y=; b=TkdZ6PtCR/Q6ZgbQC5+U2nj3lqS/SGOQQ7Y0H6m1OZUwU3VY9JSiDzgrUoKUhS8t2JxcDf 2xnZ+ZeXngygxnLGSwCnrI5YhMraImzsQME6+rwpdGuJ7eRo0Wv1JQq2Kiu7/Odqiy2xDo cubya9aaA/I8puzLIu6Ab+JkOlRfmWU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-90-7g9fl2KdM1O1hX3OPYbBpg-1; Fri, 09 Oct 2020 09:00:59 -0400 X-MC-Unique: 7g9fl2KdM1O1hX3OPYbBpg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCAC9835B8F for ; Fri, 9 Oct 2020 13:00:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98CAB76647; Fri, 9 Oct 2020 13:00:57 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH v2 1/6] libsepol: Get rid of the old and duplicated symbols Date: Fri, 9 Oct 2020 15:00:47 +0200 Message-Id: <20201009130052.52409-2-plautrba@redhat.com> In-Reply-To: <20201009130052.52409-1-plautrba@redhat.com> References: <20201009130052.52409-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Versioned duplicate symbols cause problems for LTO. These symbols were introduced during the CIL integration several releases ago and were only consumed by other SELinux userspace components. Fixes: https://github.com/SELinuxProject/selinux/issues/245 Signed-off-by: Petr Lautrbach Acked-by: James Carter --- libsepol/cil/src/cil.c | 84 ------------------------------------ libsepol/src/libsepol.map.in | 5 --- 2 files changed, 89 deletions(-) diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c index a3c6a2934c72..95bdb5e5854c 100644 --- a/libsepol/cil/src/cil.c +++ b/libsepol/cil/src/cil.c @@ -51,27 +51,6 @@ #include "cil_policy.h" #include "cil_strpool.h" -#if !defined(SHARED) || defined(ANDROID) || defined(__APPLE__) - #define DISABLE_SYMVER 1 -#endif - -#ifndef DISABLE_SYMVER -asm(".symver cil_build_policydb_pdb, cil_build_policydb@LIBSEPOL_1.0"); -asm(".symver cil_build_policydb_create_pdb, cil_build_policydb@@LIBSEPOL_1.1"); - -asm(".symver cil_compile_pdb, cil_compile@LIBSEPOL_1.0"); -asm(".symver cil_compile_nopdb, cil_compile@@LIBSEPOL_1.1"); - -asm(".symver cil_userprefixes_to_string_pdb, cil_userprefixes_to_string@LIBSEPOL_1.0"); -asm(".symver cil_userprefixes_to_string_nopdb, cil_userprefixes_to_string@@LIBSEPOL_1.1"); - -asm(".symver cil_selinuxusers_to_string_pdb, cil_selinuxusers_to_string@LIBSEPOL_1.0"); -asm(".symver cil_selinuxusers_to_string_nopdb, cil_selinuxusers_to_string@@LIBSEPOL_1.1"); - -asm(".symver cil_filecons_to_string_pdb, cil_filecons_to_string@LIBSEPOL_1.0"); -asm(".symver cil_filecons_to_string_nopdb, cil_filecons_to_string@@LIBSEPOL_1.1"); -#endif - int cil_sym_sizes[CIL_SYM_ARRAY_NUM][CIL_SYM_NUM] = { {64, 64, 64, 1 << 13, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, {64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, @@ -549,11 +528,7 @@ exit: return rc; } -#ifdef DISABLE_SYMVER int cil_compile(struct cil_db *db) -#else -int cil_compile_nopdb(struct cil_db *db) -#endif { int rc = SEPOL_ERR; @@ -597,33 +572,7 @@ exit: return rc; } -#ifndef DISABLE_SYMVER -int cil_compile_pdb(struct cil_db *db, __attribute__((unused)) sepol_policydb_t *sepol_db) -{ - return cil_compile_nopdb(db); -} - -int cil_build_policydb_pdb(cil_db_t *db, sepol_policydb_t *sepol_db) -{ - int rc; - - cil_log(CIL_INFO, "Building policy binary\n"); - rc = cil_binary_create_allocated_pdb(db, sepol_db); - if (rc != SEPOL_OK) { - cil_log(CIL_ERR, "Failed to generate binary\n"); - goto exit; - } - -exit: - return rc; -} -#endif - -#ifdef DISABLE_SYMVER int cil_build_policydb(cil_db_t *db, sepol_policydb_t **sepol_db) -#else -int cil_build_policydb_create_pdb(cil_db_t *db, sepol_policydb_t **sepol_db) -#endif { int rc; @@ -1371,11 +1320,7 @@ const char * cil_node_to_string(struct cil_tree_node *node) return ""; } -#ifdef DISABLE_SYMVER int cil_userprefixes_to_string(struct cil_db *db, char **out, size_t *size) -#else -int cil_userprefixes_to_string_nopdb(struct cil_db *db, char **out, size_t *size) -#endif { int rc = SEPOL_ERR; size_t str_len = 0; @@ -1420,13 +1365,6 @@ exit: } -#ifndef DISABLE_SYMVER -int cil_userprefixes_to_string_pdb(struct cil_db *db, __attribute__((unused)) sepol_policydb_t *sepol_db, char **out, size_t *size) -{ - return cil_userprefixes_to_string_nopdb(db, out, size); -} -#endif - static int cil_cats_to_ebitmap(struct cil_cats *cats, struct ebitmap* cats_ebitmap) { int rc = SEPOL_ERR; @@ -1614,11 +1552,7 @@ static int __cil_level_to_string(struct cil_level *lvl, char *out) return str_tmp - out; } -#ifdef DISABLE_SYMVER int cil_selinuxusers_to_string(struct cil_db *db, char **out, size_t *size) -#else -int cil_selinuxusers_to_string_nopdb(struct cil_db *db, char **out, size_t *size) -#endif { size_t str_len = 0; int buf_pos = 0; @@ -1675,18 +1609,7 @@ int cil_selinuxusers_to_string_nopdb(struct cil_db *db, char **out, size_t *size return SEPOL_OK; } -#ifndef DISABLE_SYMVER -int cil_selinuxusers_to_string_pdb(struct cil_db *db, __attribute__((unused)) sepol_policydb_t *sepol_db, char **out, size_t *size) -{ - return cil_selinuxusers_to_string_nopdb(db, out, size); -} -#endif - -#ifdef DISABLE_SYMVER int cil_filecons_to_string(struct cil_db *db, char **out, size_t *size) -#else -int cil_filecons_to_string_nopdb(struct cil_db *db, char **out, size_t *size) -#endif { uint32_t i = 0; int buf_pos = 0; @@ -1804,13 +1727,6 @@ int cil_filecons_to_string_nopdb(struct cil_db *db, char **out, size_t *size) return SEPOL_OK; } -#ifndef DISABLE_SYMVER -int cil_filecons_to_string_pdb(struct cil_db *db, __attribute__((unused)) sepol_policydb_t *sepol_db, char **out, size_t *size) -{ - return cil_filecons_to_string_nopdb(db, out, size); -} -#endif - void cil_set_disable_dontaudit(struct cil_db *db, int disable_dontaudit) { db->disable_dontaudit = disable_dontaudit; diff --git a/libsepol/src/libsepol.map.in b/libsepol/src/libsepol.map.in index f08c2a861693..98da9789b71b 100644 --- a/libsepol/src/libsepol.map.in +++ b/libsepol/src/libsepol.map.in @@ -1,19 +1,14 @@ LIBSEPOL_1.0 { global: cil_add_file; - cil_build_policydb; - cil_compile; cil_db_destroy; cil_db_init; - cil_filecons_to_string; - cil_selinuxusers_to_string; cil_set_disable_dontaudit; cil_set_disable_neverallow; cil_set_handle_unknown; cil_set_log_handler; cil_set_log_level; cil_set_preserve_tunables; - cil_userprefixes_to_string; expand_module_avrules; sepol_bool_clone; sepol_bool_compare; From patchwork Fri Oct 9 13:00:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11825801 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F11D109B for ; Fri, 9 Oct 2020 13:01:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 273BE222E7 for ; Fri, 9 Oct 2020 13:01:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YM79a5o7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732803AbgJINBH (ORCPT ); Fri, 9 Oct 2020 09:01:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48624 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729347AbgJINBH (ORCPT ); Fri, 9 Oct 2020 09:01:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602248465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HBj1Hr6AxJHuJcCtCDETozEDjrjAOpBolsuXLIGDfeI=; b=YM79a5o7ZDXoTVKfq/JmdHbzTFFrsb8HZ5u2qk49Yb4aThFd4ogioWrzZsPVxVUU3dZ68q t+zh5BXvG1qztYOZgOAR2tAL68uC/PoRcP09s75Xvs6eClbu4EyjqeiuQ8x8KuID0o8Fq8 fPCZlsMb2GlJxsnsndB3wUO/NqSwCQE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-509-YNZwCPcFOyqKEnanUZIpgg-1; Fri, 09 Oct 2020 09:01:01 -0400 X-MC-Unique: YNZwCPcFOyqKEnanUZIpgg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7657384BA14 for ; Fri, 9 Oct 2020 13:01:00 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7280F7665E; Fri, 9 Oct 2020 13:00:59 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH v2 2/6] libsepol: Drop deprecated functions Date: Fri, 9 Oct 2020 15:00:48 +0200 Message-Id: <20201009130052.52409-3-plautrba@redhat.com> In-Reply-To: <20201009130052.52409-1-plautrba@redhat.com> References: <20201009130052.52409-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org These functions were converted to no-op by commit c3f9492d7ff0 ("selinux: Remove legacy local boolean and user code") and left in libsepol/src/deprecated_functions.c to preserve API/ABI. As we change libsepol ABI dropping duplicate symbols it's time to drop these functions too. Signed-off-by: Petr Lautrbach Acked-by: James Carter --- libsepol/include/sepol/booleans.h | 5 ---- libsepol/include/sepol/users.h | 6 ---- libsepol/src/deprecated_funcs.c | 50 ------------------------------- libsepol/src/libsepol.map.in | 4 --- 4 files changed, 65 deletions(-) delete mode 100644 libsepol/src/deprecated_funcs.c diff --git a/libsepol/include/sepol/booleans.h b/libsepol/include/sepol/booleans.h index 06d2230c395d..25229057dbd7 100644 --- a/libsepol/include/sepol/booleans.h +++ b/libsepol/include/sepol/booleans.h @@ -10,11 +10,6 @@ extern "C" { #endif -/* These two functions are deprecated. See src/deprecated_funcs.c */ -extern int sepol_genbools(void *data, size_t len, const char *boolpath); -extern int sepol_genbools_array(void *data, size_t len, - char **names, int *values, int nel); - /* Set the specified boolean */ extern int sepol_bool_set(sepol_handle_t * handle, sepol_policydb_t * policydb, diff --git a/libsepol/include/sepol/users.h b/libsepol/include/sepol/users.h index 70158ac41e40..156d1adb2d60 100644 --- a/libsepol/include/sepol/users.h +++ b/libsepol/include/sepol/users.h @@ -10,12 +10,6 @@ extern "C" { #endif -/* These two functions are deprecated. See src/deprecated_funcs.c */ -extern int sepol_genusers(void *data, size_t len, - const char *usersdir, - void **newdata, size_t * newlen); -extern void sepol_set_delusers(int on); - /* Modify the user, or add it, if the key is not found */ extern int sepol_user_modify(sepol_handle_t * handle, sepol_policydb_t * policydb, diff --git a/libsepol/src/deprecated_funcs.c b/libsepol/src/deprecated_funcs.c deleted file mode 100644 index d0dab7dfcb4a..000000000000 --- a/libsepol/src/deprecated_funcs.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "debug.h" - -/* - * Need to keep these stubs for the libsepol interfaces exported in - * libsepol.map.in, as they are part of the shared library ABI. - */ - -static const char *msg = "Deprecated interface"; - -/* - * These two functions are deprecated and referenced in: - * include/libsepol/users.h - */ -int sepol_genusers(void *data __attribute((unused)), - size_t len __attribute((unused)), - const char *usersdir __attribute((unused)), - void **newdata __attribute((unused)), - size_t *newlen __attribute((unused))) -{ - WARN(NULL, "%s", msg); - return -1; -} - -void sepol_set_delusers(int on __attribute((unused))) -{ - WARN(NULL, "%s", msg); -} - -/* - * These two functions are deprecated and referenced in: - * include/libsepol/booleans.h - */ -int sepol_genbools(void *data __attribute((unused)), - size_t len __attribute((unused)), - const char *booleans __attribute((unused))) -{ - WARN(NULL, "%s", msg); - return -1; -} - -int sepol_genbools_array(void *data __attribute((unused)), - size_t len __attribute((unused)), - char **names __attribute((unused)), - int *values __attribute((unused)), - int nel __attribute((unused))) -{ - WARN(NULL, "%s", msg); - return -1; -} diff --git a/libsepol/src/libsepol.map.in b/libsepol/src/libsepol.map.in index 98da9789b71b..eb5721257638 100644 --- a/libsepol/src/libsepol.map.in +++ b/libsepol/src/libsepol.map.in @@ -45,9 +45,6 @@ LIBSEPOL_1.0 { sepol_context_to_string; sepol_debug; sepol_expand_module; - sepol_genbools; - sepol_genbools_array; - sepol_genusers; sepol_get_disable_dontaudit; sepol_get_preserve_tunables; sepol_handle_create; @@ -213,7 +210,6 @@ LIBSEPOL_1.0 { sepol_port_set_port; sepol_port_set_proto; sepol_port_set_range; - sepol_set_delusers; sepol_set_disable_dontaudit; sepol_set_expand_consume_base; sepol_set_policydb_from_file; From patchwork Fri Oct 9 13:00:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11825799 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A3986CA for ; Fri, 9 Oct 2020 13:01:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6AC8222D5 for ; Fri, 9 Oct 2020 13:01:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jKtE0YOM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387995AbgJINBH (ORCPT ); Fri, 9 Oct 2020 09:01:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34877 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732803AbgJINBH (ORCPT ); Fri, 9 Oct 2020 09:01:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602248466; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oUwrhjqFjW1DbsJB3/78yyb1zMktr98bYje0PKzqyms=; b=jKtE0YOMBdrWrFUu1awC2CzrfvvPbezHk2VpI16ZNnsxpTWXwz4fBq6METkJjCzMIWoNgX Aqi/Fs0epROSp1dRBm05JesCetxkTCmOckLcmOY1YqdsReabUpojkildre2xE3mgDay3UF 5ewiRiWqmsezo/0IOAzl1Jb6wzN5GLo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-qedw0PGAMdOfDQBPaZ_2SQ-1; Fri, 09 Oct 2020 09:01:02 -0400 X-MC-Unique: qedw0PGAMdOfDQBPaZ_2SQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D561219080A0 for ; Fri, 9 Oct 2020 13:01:01 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE26676642; Fri, 9 Oct 2020 13:01:00 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH v2 3/6] libsepol: Bump libsepol.so version Date: Fri, 9 Oct 2020 15:00:49 +0200 Message-Id: <20201009130052.52409-4-plautrba@redhat.com> In-Reply-To: <20201009130052.52409-1-plautrba@redhat.com> References: <20201009130052.52409-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Previous commits removed some symbols and broke ABI, therefore we need to change SONAME. See the following quotes from distribution guidelines: https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#run-time-shared-libraries Every time the shared library ABI changes in a way that may break binaries linked against older versions of the shared library, the SONAME of the library and the corresponding name for the binary package containing the runtime shared library should change. https://docs.fedoraproject.org/en-US/packaging-guidelines/#_downstream_so_name_versioning When new versions of the library are released, you should use an ABI comparison tool to check for ABI differences in the built shared libraries. If it detects any incompatibilities, bump the n number by one. Signed-off-by: Petr Lautrbach Acked-by: James Carter --- libselinux/src/load_policy.c | 2 +- libsepol/src/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libselinux/src/load_policy.c b/libselinux/src/load_policy.c index 2aea826f863e..0034fa53d6e6 100644 --- a/libselinux/src/load_policy.c +++ b/libselinux/src/load_policy.c @@ -76,7 +76,7 @@ int selinux_mkload_policy(int preservebools __attribute__((unused))) #ifdef SHARED char *errormsg = NULL; void *libsepolh = NULL; - libsepolh = dlopen("libsepol.so.1", RTLD_NOW); + libsepolh = dlopen("libsepol.so.2", RTLD_NOW); if (libsepolh) { usesepol = 1; dlerror(); diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile index 8d466f56ed0e..dc8b1773d974 100644 --- a/libsepol/src/Makefile +++ b/libsepol/src/Makefile @@ -7,7 +7,7 @@ RANLIB ?= ranlib CILDIR ?= ../cil VERSION = $(shell cat ../VERSION) -LIBVERSION = 1 +LIBVERSION = 2 LEX = flex CIL_GENERATED = $(CILDIR)/src/cil_lexer.c From patchwork Fri Oct 9 13:00:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11825805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEB801592 for ; Fri, 9 Oct 2020 13:01:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 875D6222D5 for ; Fri, 9 Oct 2020 13:01:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iUheYBXR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387996AbgJINBJ (ORCPT ); Fri, 9 Oct 2020 09:01:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44671 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387992AbgJINBI (ORCPT ); Fri, 9 Oct 2020 09:01:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602248466; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pjt/uEuGRF/x2LkKgZH+EHE8tJpmcCOU7oej3x2YB8Q=; b=iUheYBXRXXEZmcObTQcPSTmR1eHdipDGAkpiJAJwKNLatD4lyGd82+FZX+FmCgNTnGdnBX 70OFYdFuA8QiwnFKslkX9Wdm4rJ/gyDjVgjFj3iqLPgiT73QxPSfWYW7h1OvtdWoEYeaMF SH6kRLAFIHryrQvP3jlmbsO0ExZQMts= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-26-6yQPBvStM-2HN4LnaUraog-1; Fri, 09 Oct 2020 09:01:04 -0400 X-MC-Unique: 6yQPBvStM-2HN4LnaUraog-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4767F10866A0 for ; Fri, 9 Oct 2020 13:01:03 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50AC07665D; Fri, 9 Oct 2020 13:01:02 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH v2 4/6] libsemanage: Remove legacy and duplicate symbols Date: Fri, 9 Oct 2020 15:00:50 +0200 Message-Id: <20201009130052.52409-5-plautrba@redhat.com> In-Reply-To: <20201009130052.52409-1-plautrba@redhat.com> References: <20201009130052.52409-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Versioned duplicate symbols cause problems for LTO. These symbols were introduced during the CIL integration several releases ago and were only consumed by other SELinux userspace components. Related: https://github.com/SELinuxProject/selinux/issues/245 Signed-off-by: Petr Lautrbach Acked-by: James Carter --- libsemanage/include/semanage/modules.h | 2 +- libsemanage/src/libsemanage.map | 5 -- libsemanage/src/modules.c | 100 +------------------------ libsemanage/src/modules.h | 9 +-- libsemanage/src/semanageswig_python.i | 2 - 5 files changed, 4 insertions(+), 114 deletions(-) diff --git a/libsemanage/include/semanage/modules.h b/libsemanage/include/semanage/modules.h index ac4039314857..b51f61f033d5 100644 --- a/libsemanage/include/semanage/modules.h +++ b/libsemanage/include/semanage/modules.h @@ -33,7 +33,7 @@ typedef struct semanage_module_key semanage_module_key_t; */ extern int semanage_module_install(semanage_handle_t *, - char *module_data, size_t data_len, char *name, char *ext_lang); + char *module_data, size_t data_len, const char *name, const char *ext_lang); extern int semanage_module_install_file(semanage_handle_t *, const char *module_name); extern int semanage_module_remove(semanage_handle_t *, char *module_name); diff --git a/libsemanage/src/libsemanage.map b/libsemanage/src/libsemanage.map index 1375a8ca0ea7..4bec06aaae27 100644 --- a/libsemanage/src/libsemanage.map +++ b/libsemanage/src/libsemanage.map @@ -167,18 +167,13 @@ LIBSEMANAGE_1.0 { semanage_mls_enabled; semanage_module_disable; semanage_module_enable; - semanage_module_get_enabled; semanage_module_get_name; semanage_module_get_version; semanage_module_info_datum_destroy; - semanage_module_install; - semanage_module_install_base; - semanage_module_install_base_file; semanage_module_install_file; semanage_module_list; semanage_module_list_nth; semanage_module_remove; - semanage_module_upgrade; semanage_module_upgrade_file; semanage_msg_get_channel; semanage_msg_get_fname; diff --git a/libsemanage/src/modules.c b/libsemanage/src/modules.c index 6d3eb60ae462..8b36801038df 100644 --- a/libsemanage/src/modules.c +++ b/libsemanage/src/modules.c @@ -42,70 +42,7 @@ #include "modules.h" #include "debug.h" -asm(".symver semanage_module_get_enabled_1_1,semanage_module_get_enabled@@LIBSEMANAGE_1.1"); -asm(".symver semanage_module_get_enabled_1_0,semanage_module_get_enabled@LIBSEMANAGE_1.0"); -asm(".symver semanage_module_install_pp,semanage_module_install@LIBSEMANAGE_1.0"); -asm(".symver semanage_module_install_hll,semanage_module_install@@LIBSEMANAGE_1.1"); - -/* Takes a module stored in 'module_data' and parses its headers. - * Sets reference variables 'module_name' to module's name and - * 'version' to module's version. The caller is responsible for - * free()ing 'module_name' and 'version'; they will be - * set to NULL upon entering this function. Returns 0 on success, -1 - * if out of memory, or -2 if data did not represent a module. - */ -static int parse_module_headers(semanage_handle_t * sh, char *module_data, - size_t data_len, char **module_name, char **version) -{ - struct sepol_policy_file *pf; - int file_type; - *version = NULL; - - if (sepol_policy_file_create(&pf)) { - ERR(sh, "Out of memory!"); - return -1; - } - sepol_policy_file_set_mem(pf, module_data, data_len); - sepol_policy_file_set_handle(pf, sh->sepolh); - if (module_data == NULL || - data_len == 0 || - sepol_module_package_info(pf, &file_type, module_name, version) == -1) { - sepol_policy_file_free(pf); - ERR(sh, "Could not parse module data."); - return -2; - } - sepol_policy_file_free(pf); - if (file_type != SEPOL_POLICY_MOD) { - ERR(sh, "Data did not represent a pp module. Please upgrade to the latest version of libsemanage to support hll modules."); - return -2; - } - - return 0; -} - -/* This function is used to preserve ABI compatibility with - * versions of semodule using LIBSEMANAGE_1.0 - */ -int semanage_module_install_pp(semanage_handle_t * sh, - char *module_data, size_t data_len) -{ - char *name = NULL; - char *version = NULL; - int status; - - if ((status = parse_module_headers(sh, module_data, data_len, &name, &version)) != 0) { - goto cleanup; - } - - status = semanage_module_install_hll(sh, module_data, data_len, name, "pp"); - -cleanup: - free(name); - free(version); - return status; -} - -int semanage_module_install_hll(semanage_handle_t * sh, +int semanage_module_install(semanage_handle_t * sh, char *module_data, size_t data_len, const char *name, const char *ext_lang) { if (sh->funcs->install == NULL) { @@ -160,16 +97,6 @@ int semanage_module_extract(semanage_handle_t * sh, return sh->funcs->extract(sh, modkey, extract_cil, mapped_data, data_len, modinfo); } -/* Legacy function that remains to preserve ABI - * compatibility. Please use semanage_module_install instead. - */ -int semanage_module_upgrade(semanage_handle_t * sh, - char *module_data, size_t data_len) -{ - return semanage_module_install_pp(sh, module_data, data_len); - -} - /* Legacy function that remains to preserve ABI * compatibility. Please use semanage_module_install_file instead. */ @@ -179,24 +106,6 @@ int semanage_module_upgrade_file(semanage_handle_t * sh, return semanage_module_install_file(sh, module_name); } -/* Legacy function that remains to preserve ABI - * compatibility. Please use semanage_module_install instead. - */ -int semanage_module_install_base(semanage_handle_t * sh, - char *module_data, size_t data_len) -{ - return semanage_module_install_pp(sh, module_data, data_len); -} - -/* Legacy function that remains to preserve ABI - * compatibility. Please use semanage_module_install_file instead. - */ -int semanage_module_install_base_file(semanage_handle_t * sh, - const char *module_name) -{ - return semanage_module_install_file(sh, module_name); -} - int semanage_module_remove(semanage_handle_t * sh, char *module_name) { if (sh->funcs->remove == NULL) { @@ -780,7 +689,7 @@ int semanage_module_key_set_priority(semanage_handle_t *sh, } -int semanage_module_get_enabled_1_1(semanage_handle_t *sh, +int semanage_module_get_enabled(semanage_handle_t *sh, const semanage_module_key_t *modkey, int *enabled) { @@ -800,11 +709,6 @@ int semanage_module_get_enabled_1_1(semanage_handle_t *sh, return sh->funcs->get_enabled(sh, modkey, enabled); } -int semanage_module_get_enabled_1_0(semanage_module_info_t *modinfo) -{ - return modinfo->enabled; -} - int semanage_module_set_enabled(semanage_handle_t *sh, const semanage_module_key_t *modkey, int enabled) diff --git a/libsemanage/src/modules.h b/libsemanage/src/modules.h index 2d3576fb15df..64d4a157f5ca 100644 --- a/libsemanage/src/modules.h +++ b/libsemanage/src/modules.h @@ -26,16 +26,9 @@ #include "semanage/modules.h" -int semanage_module_install_pp(semanage_handle_t * sh, - char *module_data, size_t data_len); -int semanage_module_install_hll(semanage_handle_t * sh, - char *module_data, size_t data_len, const char *name, const char *ext_lang); -int semanage_module_upgrade(semanage_handle_t * sh, - char *module_data, size_t data_len); + int semanage_module_upgrade_file(semanage_handle_t * sh, const char *module_name); -int semanage_module_install_base(semanage_handle_t * sh, - char *module_data, size_t data_len); int semanage_module_install_base_file(semanage_handle_t * sh, const char *module_name); diff --git a/libsemanage/src/semanageswig_python.i b/libsemanage/src/semanageswig_python.i index 8dd79fc24213..5f0113966962 100644 --- a/libsemanage/src/semanageswig_python.i +++ b/libsemanage/src/semanageswig_python.i @@ -30,8 +30,6 @@ %} %include "stdint.i" -%ignore semanage_module_install_pp; -%ignore semanage_module_install_hll; %wrapper %{ From patchwork Fri Oct 9 13:00:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11825803 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E718109B for ; Fri, 9 Oct 2020 13:01:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED0BB222D5 for ; Fri, 9 Oct 2020 13:01:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OWASjFnz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729347AbgJINBI (ORCPT ); Fri, 9 Oct 2020 09:01:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26439 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387996AbgJINBI (ORCPT ); Fri, 9 Oct 2020 09:01:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602248467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6YuYcG/VuIumVTcwv4wGEyKkJ3Y9RUfEx/+s7JmSJr8=; b=OWASjFnz6P6lL2NKpJVXQA/OJYCZZhQ28nQOGx1SmpSrmNyiXR/VhCwIH9gzqJtnEAR9oE 4YTg9dgtfgH87pQxRVXaNTEWJzO84IcvqPfgqw82GxgYcko/uwkklm3t1794QmIEaBDS3f dN6PVIYqqBSKA+wQKs5KO9LNZjVbyb4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-cWkcASu7PhiRdG8i7QKAiA-1; Fri, 09 Oct 2020 09:01:05 -0400 X-MC-Unique: cWkcASu7PhiRdG8i7QKAiA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A0CA802B4E for ; Fri, 9 Oct 2020 13:01:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id A26E876642; Fri, 9 Oct 2020 13:01:03 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH v2 5/6] libsemanage: Drop deprecated functions Date: Fri, 9 Oct 2020 15:00:51 +0200 Message-Id: <20201009130052.52409-6-plautrba@redhat.com> In-Reply-To: <20201009130052.52409-1-plautrba@redhat.com> References: <20201009130052.52409-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org semanage_module_enable() and semanage_module_disable() were deprecated by commit 9fbc6d14418f ("libsemanage: add back original module enable/disable functions for ABI compatability") in 2014 in order to preserve ABI compatibility. As we the libsemanage ABI is changed by the previous commit, it makes sense to drop them completely. Signed-off-by: Petr Lautrbach Acked-by: James Carter --- libsemanage/src/libsemanage.map | 2 -- libsemanage/src/modules.c | 56 --------------------------------- 2 files changed, 58 deletions(-) diff --git a/libsemanage/src/libsemanage.map b/libsemanage/src/libsemanage.map index 4bec06aaae27..3ea7b60f97bb 100644 --- a/libsemanage/src/libsemanage.map +++ b/libsemanage/src/libsemanage.map @@ -165,8 +165,6 @@ LIBSEMANAGE_1.0 { semanage_is_connected; semanage_is_managed; semanage_mls_enabled; - semanage_module_disable; - semanage_module_enable; semanage_module_get_name; semanage_module_get_version; semanage_module_info_datum_destroy; diff --git a/libsemanage/src/modules.c b/libsemanage/src/modules.c index 8b36801038df..b6dd456cac32 100644 --- a/libsemanage/src/modules.c +++ b/libsemanage/src/modules.c @@ -734,62 +734,6 @@ int semanage_module_set_enabled(semanage_handle_t *sh, } -/* This function exists only for ABI compatibility. It has been deprecated and - * should not be used. Instead, use semanage_module_set_enabled() */ -int semanage_module_enable(semanage_handle_t *sh, char *module_name) -{ - int rc = -1; - semanage_module_key_t *modkey = NULL; - - rc = semanage_module_key_create(sh, &modkey); - if (rc != 0) - goto exit; - - rc = semanage_module_key_set_name(sh, modkey, module_name); - if (rc != 0) - goto exit; - - rc = semanage_module_set_enabled(sh, modkey, 1); - if (rc != 0) - goto exit; - - rc = 0; - -exit: - semanage_module_key_destroy(sh, modkey); - free(modkey); - - return rc; -} - -/* This function exists only for ABI compatibility. It has been deprecated and - * should not be used. Instead, use semanage_module_set_enabled() */ -int semanage_module_disable(semanage_handle_t *sh, char *module_name) -{ - int rc = -1; - semanage_module_key_t *modkey = NULL; - - rc = semanage_module_key_create(sh, &modkey); - if (rc != 0) - goto exit; - - rc = semanage_module_key_set_name(sh, modkey, module_name); - if (rc != 0) - goto exit; - - rc = semanage_module_set_enabled(sh, modkey, 0); - if (rc != 0) - goto exit; - - rc = 0; - -exit: - semanage_module_key_destroy(sh, modkey); - free(modkey); - - return rc; -} - /* Converts a string to a priority * * returns -1 if str is not a valid priority. From patchwork Fri Oct 9 13:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 11825807 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 297386CA for ; Fri, 9 Oct 2020 13:01:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E89AC222D5 for ; Fri, 9 Oct 2020 13:01:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SznoOXGL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387992AbgJINBT (ORCPT ); Fri, 9 Oct 2020 09:01:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51367 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732468AbgJINBT (ORCPT ); Fri, 9 Oct 2020 09:01:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602248478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CeDxwGvq1MbQ8fsclvmtrgtykXqL6FqZoVRYiixnbIg=; b=SznoOXGLWhWixx65znhhACEOSGFSxhHhNbD2Ye+l3c1yHy7umyU4qJZ8BFO5kPU/4RLlyO OcUlQTuy1cUiMcZxpjEGd+gSaZ8zM3t49/X/H2PNXtP8yJNlZ1GeeX4SqprXFqDsbJvZUD o8ja7RCMti1K+bhGtpQa99RQZZnLG4c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-OcN7SstgPQaAcTD_rKhUtg-1; Fri, 09 Oct 2020 09:01:06 -0400 X-MC-Unique: OcN7SstgPQaAcTD_rKhUtg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2CFD1015EDE for ; Fri, 9 Oct 2020 13:01:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id F36D076642; Fri, 9 Oct 2020 13:01:04 +0000 (UTC) From: Petr Lautrbach To: selinux@vger.kernel.org Cc: Petr Lautrbach Subject: [PATCH v2 6/6] libsemanage: Bump libsemanage.so version Date: Fri, 9 Oct 2020 15:00:52 +0200 Message-Id: <20201009130052.52409-7-plautrba@redhat.com> In-Reply-To: <20201009130052.52409-1-plautrba@redhat.com> References: <20201009130052.52409-1-plautrba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Previous commits removed some symbols and broke ABI, therefore we need to change SONAME. See the following quotes from distribution guidelines: https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#run-time-shared-libraries Every time the shared library ABI changes in a way that may break binaries linked against older versions of the shared library, the SONAME of the library and the corresponding name for the binary package containing the runtime shared library should change. https://docs.fedoraproject.org/en-US/packaging-guidelines/#_downstream_so_name_versioning When new versions of the library are released, you should use an ABI comparison tool to check for ABI differences in the built shared libraries. If it detects any incompatibilities, bump the n number by one. Signed-off-by: Petr Lautrbach Acked-by: James Carter --- libsemanage/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile index a0eb3747d74b..ab6cae51f5c3 100644 --- a/libsemanage/src/Makefile +++ b/libsemanage/src/Makefile @@ -32,7 +32,7 @@ YACC = bison YFLAGS = -d VERSION = $(shell cat ../VERSION) -LIBVERSION = 1 +LIBVERSION = 2 LIBA=libsemanage.a TARGET=libsemanage.so