From patchwork Tue Sep 28 15:46:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10509C433F5 for ; Tue, 28 Sep 2021 15:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF38B60F44 for ; Tue, 28 Sep 2021 15:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241683AbhI1Ps6 (ORCPT ); Tue, 28 Sep 2021 11:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241680AbhI1Ps5 (ORCPT ); Tue, 28 Sep 2021 11:48:57 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0BA6C06161C for ; Tue, 28 Sep 2021 08:47:17 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id v18so49332204edc.11 for ; Tue, 28 Sep 2021 08:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=RI4Q6OQvX08XzA+CVSOJCOxHd/0AM0iHQwfhFwGuhZ0=; b=EXmZZlZvazNCHjCav1ISCmEcfZP9+16J2d7zuig+4wlzMnm0kprctIvSxt5000F0gR F0mhL90Y35tkHdZ/JqGcUr/x3Biv7V1ISOoU5usJTYMz7cWT6DRrV0uBqfJFDr2O5qMz DrObpEOvET3dfgCCvZHMRE4s50EWjRiNl1L3RHExTfC93bibS9ohqhVJ5+MP1nL5WcgI oG1a6cs1fxykPO6MbP7QziKWehjtqVRbVX2AxZ6ZelSXfzdxykj67EEJU5goYJQS7Dyf 2m5bsHrErPcyVj1eeqNbsYYND/sTn2tEuYpqSYPygzGgzb7HH8W9DeBY6iVy0PAjEvvC CI1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=RI4Q6OQvX08XzA+CVSOJCOxHd/0AM0iHQwfhFwGuhZ0=; b=bXM1y5pPwITsbH9tWSNlTGmgoqlNaqIUD1IJja7GFiaBRyDtyU2yXiySpqCi0LYWaH rBiHMG04Us2vNP84gXe0gKSz33pVi5pPiEznlcNcUIfnMFPTPQEAA6GiXkG+Erx36dA6 Mk+K0Lqq/mk6DjJZCrpH2F1ZImwuYtlOzBln3xw089QOQ8VxNAJFd+AXNZLiLaWoFWPy 7Z9qz1S/YqhW5zI5NciWUd1z4cIVmdFX5nlOStX/UTvUcZqw5ryDxrdIuQPGZ1U3wJtA vVd6S4GghTBiRaGrJfWqhbVLXkRkRf0RSQ9hxrCKLbMHeADRhchM1dH6vInM85lCvbPC aJJg== X-Gm-Message-State: AOAM5339Z2mNggVgJY2mVkRduvs6KjqGneM83e2CNxRhPMlC8oazycoz 0I87b22qVvfubI8mL641IxvznIiNf1Q= X-Google-Smtp-Source: ABdhPJzLU24Sc/2GjK+FUpCtcTPYu5ZfKjfS6x1MbXQLGFTllqGKSDwFHNGbbdj0Q6JXRI1q0O7DRg== X-Received: by 2002:a05:6402:64e:: with SMTP id u14mr8602914edx.184.1632843983377; Tue, 28 Sep 2021 08:46:23 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:23 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 1/9] libsepol: ebitmap: mark nodes of const ebitmaps const Date: Tue, 28 Sep 2021 17:46:12 +0200 Message-Id: <20210928154620.11181-1-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Mark pointers to nodes of const ebitmaps also const. C does not enforce a transitive const-ness, but it clarifies the intent and improves maintainability. Follow-up of 390ec54d278a Signed-off-by: Christian Göttsche Acked-by: James Carter --- libsepol/src/ebitmap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c index 4e9acdf8..1de3816a 100644 --- a/libsepol/src/ebitmap.c +++ b/libsepol/src/ebitmap.c @@ -17,7 +17,8 @@ int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2) { - ebitmap_node_t *n1, *n2, *new, *prev; + const ebitmap_node_t *n1, *n2; + ebitmap_node_t *new, *prev; ebitmap_init(dst); @@ -154,7 +155,7 @@ int ebitmap_hamming_distance(const ebitmap_t * e1, const ebitmap_t * e2) int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2) { - ebitmap_node_t *n1, *n2; + const ebitmap_node_t *n1, *n2; if (e1->highbit != e2->highbit) return 0; @@ -175,7 +176,8 @@ int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2) int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src) { - ebitmap_node_t *n, *new, *prev; + const ebitmap_node_t *n; + ebitmap_node_t *new, *prev; ebitmap_init(dst); n = src->node; @@ -204,7 +206,7 @@ int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src) int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2) { - ebitmap_node_t *n1, *n2; + const ebitmap_node_t *n1, *n2; if (e1->highbit < e2->highbit) return 0; @@ -231,8 +233,8 @@ int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2) int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2) { - ebitmap_node_t *n1 = e1->node; - ebitmap_node_t *n2 = e2->node; + const ebitmap_node_t *n1 = e1->node; + const ebitmap_node_t *n2 = e2->node; while (n1 && n2) { if (n1->startbit < n2->startbit) { @@ -253,7 +255,7 @@ int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2) int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit) { - ebitmap_node_t *n; + const ebitmap_node_t *n; if (e->highbit < bit) return 0; From patchwork Tue Sep 28 15:46:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A1FAC433F5 for ; Tue, 28 Sep 2021 15:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31CFA60F44 for ; Tue, 28 Sep 2021 15:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241678AbhI1Psr (ORCPT ); Tue, 28 Sep 2021 11:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1Psq (ORCPT ); Tue, 28 Sep 2021 11:48:46 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F07BCC06161C for ; Tue, 28 Sep 2021 08:47:06 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id y35so33884280ede.3 for ; Tue, 28 Sep 2021 08:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gm5KFpAo0Qlw5HKXLvQfzh0SG1kzoZzUw+QJtG6jHuk=; b=YKaXbIhC/J85BGczlZdW9ODqSedWl1HkKVqtO3CjRL/euv8URSz63hSzxbx12zCbg4 IMsBYHXe9E/PSBOLdq9N/wYlVIjlGqFlMO6heZFUjsD4UNOhU5bC/AwFKnCYW568x77N pl57RAurZub73Jh8JO6rka5D1ALpQjh4kCJIXM0up1IpkDmkQERFervf9jFU46wJA5jN +FphCrxAWRL/yamwZII7qUWMtF6fhcCwUjuonHuboaJe2aUqv1DC5Q3XmH48LdKt6q4Q SQBxdsXrKUn5mgUllr/ITJv6tZuJG5B3O2JW5iXT2ODw0PlWQspGWlo+H1ySn4ygpEUD x4Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gm5KFpAo0Qlw5HKXLvQfzh0SG1kzoZzUw+QJtG6jHuk=; b=EqTjL8jCNm+8li7w6m05UYFR9BzpQkO7yz5iayagnfc1bVkPd/E42EbmD6bMaRyUCf GowAywA+ZznCU8sf+V89kvLNg0YKtNBS1yprC343pH/EE5a1gxXAMXk79jLf6Mip8TqY RucCE8TPXSDzVn/9N1yavBKMLFmZ5WARyXHywVm5K78qw+kRJEFLeVD5VoRkWfOESg3T d5fwjl500vF0O6753m71GRutaP9Xv5ez1+y7blXHUE/sXziOuiuCA5qzRIvZIDBt4Q0A eSM/xmwoKhB43/6C98zF40b6KhYK2Ga8HawBO4KkWlgh/Hvz1YlRJoiaGS/16fw6Hocf Irxw== X-Gm-Message-State: AOAM530thFL9ooUdfxsBLgV+F4mMKMRhTxl/iXjjo6k3pOjxtLv6Bi21 NFF5WyrJOJTIL7T9DT4l97Wdt00xoh4= X-Google-Smtp-Source: ABdhPJxh8a6zrmLAqQ5qoiMo6wHKzAVAGfKzIwHk74AWJeBA8qjEXfDnzfV4u47AbNadYJhNelqzBA== X-Received: by 2002:a17:906:8152:: with SMTP id z18mr7616867ejw.153.1632843983954; Tue, 28 Sep 2021 08:46:23 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:23 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 2/9] libsepol: use correct cast Date: Tue, 28 Sep 2021 17:46:13 +0200 Message-Id: <20210928154620.11181-2-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The function hashtab_insert takes the type hashtab_datum_t (alias void*) as third argument. Do not cast to hashtab_datum_t* alias void**. The casts could be dropped, as explicit casting to void* is unnecessary, but to fit the overall style of this file keep the casts. expand.c:246:41: error: cast from 'perm_datum_t *' (aka 'struct perm_datum *') to 'hashtab_datum_t *' (aka 'void **') increases required alignment from 4 to 8 [-Werror,-Wcast-align] ret = hashtab_insert(s->table, new_id, (hashtab_datum_t *) new_perm); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche --- libsepol/src/expand.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c index aac5b35f..a6a466f7 100644 --- a/libsepol/src/expand.c +++ b/libsepol/src/expand.c @@ -243,7 +243,7 @@ static int perm_copy_callback(hashtab_key_t key, hashtab_datum_t datum, new_perm->s.value = perm->s.value; s->nprim++; - ret = hashtab_insert(s->table, new_id, (hashtab_datum_t *) new_perm); + ret = hashtab_insert(s->table, new_id, (hashtab_datum_t) new_perm); if (ret) { free(new_id); free(new_perm); @@ -294,7 +294,7 @@ static int common_copy_callback(hashtab_key_t key, hashtab_datum_t datum, ret = hashtab_insert(state->out->p_commons.table, new_id, - (hashtab_datum_t *) new_common); + (hashtab_datum_t) new_common); if (ret) { ERR(state->handle, "hashtab overflow"); free(new_common); @@ -492,7 +492,7 @@ static int class_copy_callback(hashtab_key_t key, hashtab_datum_t datum, ret = hashtab_insert(state->out->p_classes.table, new_id, - (hashtab_datum_t *) new_class); + (hashtab_datum_t) new_class); if (ret) { ERR(state->handle, "hashtab overflow"); free(new_class); From patchwork Tue Sep 28 15:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11CB1C433FE for ; Tue, 28 Sep 2021 15:47:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFFE2611BD for ; Tue, 28 Sep 2021 15:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241676AbhI1Psw (ORCPT ); Tue, 28 Sep 2021 11:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1Psw (ORCPT ); Tue, 28 Sep 2021 11:48:52 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 538C3C06161C for ; Tue, 28 Sep 2021 08:47:12 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id g8so85116210edt.7 for ; Tue, 28 Sep 2021 08:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=X8zL2j3g+qXuaPDq9umaJDB7DLVQOzlsMUznEwitkI0=; b=HSqok4NjPy+8EXveE3/En83jiiGcfZlxNAPKOyy14OHWeQ3TpgbEjhF3Mna9aiiFKm KTslyS4aPpEkdGt4Qq2zxlw/DRVQMi5kejDlMNjUjt6BBFNVTmNozWnWxP92p5VU7XxD UZxKhe121QP+MVBSC0UvVBCg6yIFG5tvEpFhbkvSwYIFDrhcEudbMJJevz/EBFtbMS+x 8UfJuPu9G7jpAOcFQFSF2oK0/tmvFUM3doNyfmxARwZc+QEezVq6OivlD+bvIE+aGCeq jg+pIhvlTgGfS7as7ycROYX+YMHF0kx53kgcJMd6xckMVvcbepHYtQR/IL4ZiQbQ5xV/ mUQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X8zL2j3g+qXuaPDq9umaJDB7DLVQOzlsMUznEwitkI0=; b=r9WGslP9XTOf5nxKi4eAhlLYbrh9V5m8O7P0cA9cKGjQbZFsf44iwoTlsg/SAlpmCs +4TLkEzEPvPlvjYrDW1yBVzig87JjQwD5H8ucM4HSjiUCk2GCgDPjHnr0Q6RoaKxjZlu r8kiCTR8+MAkbyea4d5WWNQSBjvCVAayz8FqsOvy2jGgYHqrKTFfeHd9IKcedGv3LOfH nXUl6tJHj6RgmuC4E+0J2uR9yHfq05Zgcq+gJx4bdaQ4rcbMgYaRRRRiiqm6uxuBUKD4 HPev4SKOLKxHAuSRCubWZakBvAChbACnatLOvGX2/MO3F0azrKDcnzyXQFhKe/ekbShx MKoQ== X-Gm-Message-State: AOAM5307QyrswFS1g4+mSzsygbPJ6yNPS0usEFYMvmD2yqhVYILhXe6S m+Bo+2j8mCAU8VV3rb2JBXi2toZdfS8= X-Google-Smtp-Source: ABdhPJxBs8TPRFn1ejmuoAOJ5Wgy1ewQardKQUej3aw82hVq8ajkdgpUNPYcc83caPmITDh+sMCHRg== X-Received: by 2002:a50:da06:: with SMTP id z6mr8291562edj.355.1632843984557; Tue, 28 Sep 2021 08:46:24 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:24 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 3/9] libsepol: resolve GCC warning about null-dereference Date: Tue, 28 Sep 2021 17:46:14 +0200 Message-Id: <20210928154620.11181-3-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org GCC reports a NULL dereference of the return value of stack_peek(). This function explicitly returns NULL in case of 'stack->pos == -1'. Error out on NULL returned. module_to_cil.c: In function ‘block_to_cil’: module_to_cil.c:3357:55: error: potential null pointer dereference [-Werror=null-dereference] 3357 | struct list *alias_list = typealias_lists[decl->decl_id]; | ~~~~^~~~~~~~~ There are more occurrences of unconditionally dereferencing the return value of stack_peek(), but the callers should ensure a valid stack, so just silence this single warning. Signed-off-by: Christian Göttsche --- libsepol/src/module_to_cil.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c index 3c8ba10a..16e4004e 100644 --- a/libsepol/src/module_to_cil.c +++ b/libsepol/src/module_to_cil.c @@ -3354,9 +3354,14 @@ static int typealiases_to_cil(int indent, struct policydb *pdb, struct avrule_bl char *type_name; struct list_node *curr; struct avrule_decl *decl = stack_peek(decl_stack); - struct list *alias_list = typealias_lists[decl->decl_id]; + struct list *alias_list; int rc = -1; + if (decl == NULL) { + return -1; + } + + alias_list = typealias_lists[decl->decl_id]; if (alias_list == NULL) { return 0; } From patchwork Tue Sep 28 15:46:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27A47C4332F for ; Tue, 28 Sep 2021 15:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D412611BD for ; Tue, 28 Sep 2021 15:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241672AbhI1Psx (ORCPT ); Tue, 28 Sep 2021 11:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1Psx (ORCPT ); Tue, 28 Sep 2021 11:48:53 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C037DC06161C for ; Tue, 28 Sep 2021 08:47:13 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id g8so85116317edt.7 for ; Tue, 28 Sep 2021 08:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Abxr88e4AjrbFisjHde26z4wPEeoRwVWpt7DfzPhMAo=; b=cVHWTEjKWhWNJ+eMEFfYZdwyU2s1IcL60ZZOUb/0AmPL5M9Wx57ZIv5JMacCSCKcy0 XlcDXUj2a1i3hbnALXb2wx855gjjZ6P+Ha96byX5ETqU01MGMUO0tzVutV1ojJoUHbs4 7sacPK7kNy5YKjxpi07s6ngpG8m6j6c4TVTZ63qnI4jqw0KXAReQMBr3QY2iIFCi+J3G j5NodKE+xSTv6J+mydsefdx6fF22UfMbYVR2+B7bxW/s+nQ0BogH6dyu9FRq3DStbAu5 OB939ZetE511LddzTNupJKUiNCUaDs7GpomYhWQYg9iRkPakVbfwXrLltEyYjsPPiQoH BRLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Abxr88e4AjrbFisjHde26z4wPEeoRwVWpt7DfzPhMAo=; b=Ws74sEYaDvG7AwIYc6wpM3ZY1ZYjfeTm4EKLVJ2eqBbs2aCTxlHPKhybX0wt1j+Il+ 1+2DWuR5/Z/4sZGDCJo7S45rHGilBt5CAc3KrD51DeFYB/PeoFqjtH/QP7FRtlZ3RWSN KODHZbUWj6+FZnXIg5nAEQxOKcwgdGMedSZK7Zacsg8lMPGwSdTJ5CAcX1fuLCFk7FOr XO90DkoAibRrJr6vuLIk4ZMHn/0dLtaEnqRsl5gEhLbq5FxgebzfAqDzmwCbuuLBdq0h TAvgnyMnCOfo+tb7VFQYib189lbqnfmXfpZwPn5GBO7JOSl2L4SvwJRdCmqMBTxox/ON VLiw== X-Gm-Message-State: AOAM531dHJ1kLlNnxOxuljuouA88ntLUUDHxTue8Z6TADyF8vLpyXd3h udjU9jhuOenytJStE2uOCI/VDxhCXDM= X-Google-Smtp-Source: ABdhPJyvY9f/SXF6OkNuBwJANBSMG183kkIGFSZwQ6TxjCEr5WQDKNRw8kkP+B+AHw1onqe9TrdJjw== X-Received: by 2002:a50:e0c9:: with SMTP id j9mr8121820edl.336.1632843985108; Tue, 28 Sep 2021 08:46:25 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:24 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 4/9] libsepol/cil: silence clang void-pointer-to-enum-cast warning Date: Tue, 28 Sep 2021 17:46:15 +0200 Message-Id: <20210928154620.11181-4-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Add an intermediate cast to uintptr_t to silence the clang specific warning about casting a void pointer to an enum. ../cil/src/cil_verify.c:1749:28: error: cast to smaller integer type 'enum cil_flavor' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast] enum cil_flavor op = (enum cil_flavor)i->data; ^~~~~~~~~~~~~~~~~~~~~~~~ Similar to 32f8ed3d6b0b. Signed-off-by: Christian Göttsche --- libsepol/cil/src/cil_verify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsepol/cil/src/cil_verify.c b/libsepol/cil/src/cil_verify.c index dc29ea66..d994d717 100644 --- a/libsepol/cil/src/cil_verify.c +++ b/libsepol/cil/src/cil_verify.c @@ -1746,7 +1746,7 @@ static int __cil_verify_classperms(struct cil_list *classperms, goto exit; } } else { - enum cil_flavor op = (enum cil_flavor)i->data; + enum cil_flavor op = (enum cil_flavor)(uintptr_t)i->data; if (op == CIL_ALL) { struct cil_class *mc = cp->class; struct cil_list *perm_list; From patchwork Tue Sep 28 15:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30A21C433EF for ; Tue, 28 Sep 2021 15:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16E4860F44 for ; Tue, 28 Sep 2021 15:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241669AbhI1Pst (ORCPT ); Tue, 28 Sep 2021 11:48:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241676AbhI1Pss (ORCPT ); Tue, 28 Sep 2021 11:48:48 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B79C1C06161C for ; Tue, 28 Sep 2021 08:47:08 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id y35so33884669ede.3 for ; Tue, 28 Sep 2021 08:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=k5BYEuDbiZnzXVev7vparjhsdxXtKF0jUnwDdqEM4X8=; b=oczgiRvMPXKxYXQm5SDWsYVXfhds2MnkpFfnaYt3bs231XgNa6YJaSKw2VfyUTsQDg nfKoXGVhBZMsqaFiSrsVOEaL6f7+38bVBha1NuCF4u24IFn/iwtAB8DTxhgYbfOzaSl3 2f4Cyk/q6sPkjiUNJ0LTst1YuJXJ/3hFPAwTDCji8vUhhaDgo6IHAlVXg7APo8XKfpO1 4VG33VLcgrfTGLYly3kW4ELu7d+stDAn4eHXTOuHyTNY0b3EZQQ2I5l/OwOQ4oh/EtPY hG6ciNNQd2NOYotxO+NTbsNw/zaG9JaFPJV8/mVh+sxonA9/jVOArO0rYApkgciCn8wv 3/Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k5BYEuDbiZnzXVev7vparjhsdxXtKF0jUnwDdqEM4X8=; b=Jp6BjYOZvZLC8C0Aw908mRCyIfB8NOUJJDPcL6u0jh//HnggDXyRFtok/AKWcyAmj5 c1dMw2i2dc9FP2bdc5ATboOLktj/bVHbTZE/9Vf5R8rJLTb020NuEr3GNR1Zj8kCRH3r /j798z/pMnkvyj9Gxjhvq7g837wYdguPmEp8EiQ7x3y4rW7udCuHmF5uF3r/+SXBQlxO sWowRs/1WcQdDUh96X9B5S9hGceaiu4JqdDbSzGJifqoSIvlOtzEVmPtjKEI3mMuXMLu pfxv0CmyJgnMK2AzWBseHM++FNyq7QJrA2rWEaBWunMb72dF604PI59S3P1Fe86qBP7c ZOtQ== X-Gm-Message-State: AOAM530GWZPw+Cq9QLp2qqAmPCdcqKvaDJEUqstNiJNdTG+3HQe+RrMe 3yqee1bx5zpe8ZkELuh9HZe+4erGEVo= X-Google-Smtp-Source: ABdhPJx1itGXN5TMgNNbgaYl7rasGUrSVSNmLDcuganGNyBkkOXlZ/NN7H7KBH5PsZAKekkZzMFdxw== X-Received: by 2002:a17:906:8496:: with SMTP id m22mr6243797ejx.357.1632843985713; Tue, 28 Sep 2021 08:46:25 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:25 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 5/9] checkpolicy: policy_define: cleanup declarations Date: Tue, 28 Sep 2021 17:46:16 +0200 Message-Id: <20210928154620.11181-5-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable curfile is nowhere used. Static functions do not need to be forward declared if not used before their definition. The error buffer errormsg can be a simple scoped variable. Also vsnprintf(3) always NUL-terminates the buffer, so the whole length can be passed. Signed-off-by: Christian Göttsche --- checkpolicy/policy_define.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c index 185d5704..cda3337b 100644 --- a/checkpolicy/policy_define.c +++ b/checkpolicy/policy_define.c @@ -67,7 +67,6 @@ extern void yyerror2(const char *fmt, ...); policydb_t *policydbp; queue_t id_queue = 0; unsigned int pass; -char *curfile = 0; int mlspol = 0; extern unsigned long policydb_lineno; @@ -78,12 +77,6 @@ extern char source_file[PATH_MAX]; extern int yywarn(const char *msg); extern int yyerror(const char *msg); -#define ERRORMSG_LEN 255 -static char errormsg[ERRORMSG_LEN + 1] = {0}; - -static int id_has_dot(const char *id); -static int parse_security_context(context_struct_t *c); - /* initialize all of the state variables for the scanner/parser */ void init_parser(int pass_number) { @@ -95,9 +88,10 @@ void init_parser(int pass_number) void yyerror2(const char *fmt, ...) { + char errormsg[256]; va_list ap; va_start(ap, fmt); - vsnprintf(errormsg, ERRORMSG_LEN, fmt, ap); + vsnprintf(errormsg, sizeof(errormsg), fmt, ap); yyerror(errormsg); va_end(ap); } From patchwork Tue Sep 28 15:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00D4FC433F5 for ; Tue, 28 Sep 2021 15:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3730611EF for ; Tue, 28 Sep 2021 15:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241685AbhI1PtA (ORCPT ); Tue, 28 Sep 2021 11:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1PtA (ORCPT ); Tue, 28 Sep 2021 11:49:00 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D4BC06161C for ; Tue, 28 Sep 2021 08:47:20 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id bd28so23413521edb.9 for ; Tue, 28 Sep 2021 08:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PNvuTizLv0cwOxbk8m3l9W44wpXZgEFiGyrOuxwwRBc=; b=P4FumdAl5RrkGbIIeHVkx8UMLVwh0PCc0zLqDI746X+LLM8YY7QDo7TyoKK9jVIAJ3 sbqm5IDeP8IxxAZFm4Dov0n6083Af1YZHzgs10/c31Rb9l/hDY2+tV7kWNux4UvnvXXC OSN23nraC4DT2bpjSlPfP+m5iSrWX7naa3/wsJU/+vT6ou8RVRXpw/yPPIGUgS/wiZBS rsNIav/VMH1oAjldBgxHctaXL+hDO+14qri9G3TmDGn9MXZXAl4o/w1kn3/TAXfsxHgP 22UoByzICDaUUgGLUo+pQ1krRT1N+YKWfDctqcrE+EhDZccLDDU4huHjYOvYoi7R2rVr I2eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PNvuTizLv0cwOxbk8m3l9W44wpXZgEFiGyrOuxwwRBc=; b=FfE6SAwJg364PMH6Lp2ZOINp9Kp9U5V42DrU/uXJsDAskxxj4VRxNDRUxN8wfHwWsZ p2Jrqn3IqBXEGv9xUxrREVgy92zy7GE75PavGIwMCeVvEpTh9hXrVr5b+x4FcalXU0+E KDGkqlTfOimHBSv5Ob+z2zS+Xyik6deLbx3IMGDsGaq5mL1AqLdIBKgy5Y3GrrCxBLlr BG/r8Gxxo+uV95A/ST6stpI8YNZIJ4QFmMU1yMNc1h3dJtn84BJE1Qiz2eHj76Ug4Qj6 HeuYbvZZFc+m6YXMzuL8FyfY3c7mA47/BBbkHNMck/1sZSwIZOecWemmO/siXHSYz/KN RroQ== X-Gm-Message-State: AOAM530oQ17MwHYv9813xEk/tiiuv0+ZQTdGjb/yC7e4qHt8t7IQqRxC XGrPRkU5LjwGZUxzvtxbmQNRuT42pTE= X-Google-Smtp-Source: ABdhPJxdSAshw82xWeXHVJzvckPnQGjQMjB/Bhs3RbPkd5n9hLrJTk/yS0snDyrbV8swuZdMJYQuog== X-Received: by 2002:a17:906:498b:: with SMTP id p11mr7178815eju.295.1632843986340; Tue, 28 Sep 2021 08:46:26 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:26 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 6/9] checkpolicy: print reason of fopen failure Date: Tue, 28 Sep 2021 17:46:17 +0200 Message-Id: <20210928154620.11181-6-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Print the reason why opening a source policy file failed, e.g: checkpolicy: unable to open policy.conf: No such file or directory Signed-off-by: Christian Göttsche --- checkpolicy/parse_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkpolicy/parse_util.c b/checkpolicy/parse_util.c index 1795e93c..8c1f393c 100644 --- a/checkpolicy/parse_util.c +++ b/checkpolicy/parse_util.c @@ -36,7 +36,7 @@ int read_source_policy(policydb_t * p, const char *file, const char *progname) { yyin = fopen(file, "r"); if (!yyin) { - fprintf(stderr, "%s: unable to open %s\n", progname, file); + fprintf(stderr, "%s: unable to open %s: %s\n", progname, file, strerror(errno)); return -1; } set_source_file(file); From patchwork Tue Sep 28 15:46:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B34D1C433EF for ; Tue, 28 Sep 2021 15:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A72B61246 for ; Tue, 28 Sep 2021 15:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241679AbhI1Ps4 (ORCPT ); Tue, 28 Sep 2021 11:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1Psz (ORCPT ); Tue, 28 Sep 2021 11:48:55 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 324FAC06161C for ; Tue, 28 Sep 2021 08:47:16 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id s17so66157745edd.8 for ; Tue, 28 Sep 2021 08:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JKnQuMHaBMfpY/3fWHFejTQul5LVF20aHJanG2kNNXE=; b=OG/bXFko2YOTdeus952N9D1zF5NkQB5CoTBKpc6vQQJZEcAjRdlZNkV0+deItNkvlQ 0XDl310B9R9oggJlTREjYKs65qrJlcntJg/MCVlKpy1gxZR5Iw+zR24fj8/yP8Xu5BjX NF9WsaOVqkkUfABabj2axCEXKU+XW96NYjBNawW4N0bnzUw3EJzsoU8X8ibizo9Av6zi aCHtsYF5Nh4vg4dr8ADnir9YYLpgl93jEIqqm7ttHyT9lWBwoSw4YKFw5BKKDORMuoyj ssC/5smmzH4IVmaRv9zn0wSO8vK5iXgJtf6d6yjDwZ4IlxIk9MByTmQ7y5H9w2SYTgSM iyJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JKnQuMHaBMfpY/3fWHFejTQul5LVF20aHJanG2kNNXE=; b=mHvDGNWv9JJLEQVNKxOTjCmiCgMdpVr5Jh1yJRgHS3LTNqf928StRU/ICyyMnBH30E fGRTd+pOM6KUrlzWi6WdaumOwZj5AmTXTraYc80fz8hnPha4FyeHH3ssbXPjEGlJ0mjE Xmw8NAg18y/oSTW6TJ6xMEg2hsEOJN/acFq/3m1Bn+/H3r9P9KNY94fdF0YxoLgfWG9Q d4R+0A/HOc2aeFJyrWXFHN7eGUxQ6dMriN9nKJHLK394geFJyqo5nuEh0wK5FV2k0iss Wzdjqnan0lCiWpHOhn8fr4IfM/9cl79S1yk7sjVUBwA+03UMcQmxZ26T6Z0EVtlFzhkU XV7A== X-Gm-Message-State: AOAM531Fbnvt09+Tjo5kABkpWzEnH4yI5rnmJtXPDK6xAT3ILZepjPTr K2tNMLpDmo1wlUQ7I7x90+9bJvxRPqI= X-Google-Smtp-Source: ABdhPJzm90xsDzI3WQPSVf6I2QEx7uQYMkU/J+nEyaP07IokUiWHhklw2X1dS8Y+9RnA8oGLFzJrLQ== X-Received: by 2002:a17:906:6b1a:: with SMTP id q26mr7246771ejr.185.1632843986892; Tue, 28 Sep 2021 08:46:26 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:26 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 7/9] checkpolicy: update documentation Date: Tue, 28 Sep 2021 17:46:18 +0200 Message-Id: <20210928154620.11181-7-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Add missing command-line arguments to synopsis and highlight mentions of other tools in man pages. Add missing space between arguments in help message. Signed-off-by: Christian Göttsche --- checkpolicy/checkmodule.8 | 11 +++++++---- checkpolicy/checkpolicy.8 | 8 +++++--- checkpolicy/checkpolicy.c | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/checkpolicy/checkmodule.8 b/checkpolicy/checkmodule.8 index c4b1592b..1061a6f2 100644 --- a/checkpolicy/checkmodule.8 +++ b/checkpolicy/checkmodule.8 @@ -3,7 +3,7 @@ checkmodule \- SELinux policy module compiler .SH SYNOPSIS .B checkmodule -.I "[\-h] [\-b] [\-C] [\-m] [\-M] [\-U handle_unknown ] [\-V] [\-o output_file] [input_file]" +.I "[\-h] [\-b] [\-c policy_version] [\-C] [\-E] [\-m] [\-M] [\-U handle_unknown] [\-V] [\-o output_file] [input_file]" .SH "DESCRIPTION" This manual page describes the .BR checkmodule @@ -15,9 +15,12 @@ into a binary representation. It can generate either a base policy module (default) or a non-base policy module (\-m option); typically, you would build a non-base policy module to add to an existing module store that already has a base module provided by the base policy. Use -semodule_package to combine this module with its optional file -contexts to create a policy package, and then use semodule to install -the module package into the module store and load the resulting policy. +.B semodule_package(8) +to combine this module with its optional file +contexts to create a policy package, and then use +.B semodule(8) +to install the module package into the module store and load the resulting +policy. .SH OPTIONS .TP diff --git a/checkpolicy/checkpolicy.8 b/checkpolicy/checkpolicy.8 index f4e6fb24..2984c238 100644 --- a/checkpolicy/checkpolicy.8 +++ b/checkpolicy/checkpolicy.8 @@ -3,7 +3,7 @@ checkpolicy \- SELinux policy compiler .SH SYNOPSIS .B checkpolicy -.I "[\-b[F]] [\-C] [\-d] [\-U handle_unknown (allow,deny,reject)] [\-M] [\-c policyvers] [\-o output_file|\-] [\-S] [\-t target_platform (selinux,xen)] [\-V] [input_file]" +.I "[\-b[F]] [\-C] [\-d] [\-U handle_unknown (allow,deny,reject)] [\-M] [\-c policyvers] [\-o output_file|\-] [\-S] [\-t target_platform (selinux,xen)] [\-O] [\-E] [\-V] [input_file]" .br .SH "DESCRIPTION" This manual page describes the @@ -13,8 +13,10 @@ command. .B checkpolicy is a program that checks and compiles a SELinux security policy configuration into a binary representation that can be loaded into the kernel. If no -input file name is specified, checkpolicy will attempt to read from -policy.conf or policy, depending on whether the \-b flag is specified. +input file name is specified, +.B checkpolicy +will attempt to read from policy.conf or policy, depending on whether the \-b +flag is specified. .SH OPTIONS .TP diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index 9459486b..6740c6d4 100644 --- a/checkpolicy/checkpolicy.c +++ b/checkpolicy/checkpolicy.c @@ -109,7 +109,7 @@ static __attribute__((__noreturn__)) void usage(const char *progname) { printf ("usage: %s [-b[F]] [-C] [-d] [-U handle_unknown (allow,deny,reject)] [-M] " - "[-c policyvers (%d-%d)] [-o output_file|-] [-S] [-O]" + "[-c policyvers (%d-%d)] [-o output_file|-] [-S] [-O] " "[-t target_platform (selinux,xen)] [-E] [-V] [input_file]\n", progname, POLICYDB_VERSION_MIN, POLICYDB_VERSION_MAX); exit(1); From patchwork Tue Sep 28 15:46:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61F60C43217 for ; Tue, 28 Sep 2021 15:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4549860F44 for ; Tue, 28 Sep 2021 15:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241680AbhI1Ps7 (ORCPT ); Tue, 28 Sep 2021 11:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1Ps6 (ORCPT ); Tue, 28 Sep 2021 11:48:58 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29438C06161C for ; Tue, 28 Sep 2021 08:47:19 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id b26so36812384edt.0 for ; Tue, 28 Sep 2021 08:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BDGnpFOwaxgu4kjpNrN1FgZ1yXTRYcJnX/ad5ij8bQw=; b=Mmp4fOAsUCiI2/nFkltSYielvpPIoJEpFxlo20ya125/H+r5eYcd8mciJfDXtQQ3P0 QciMsSqEHG6BUd0bLXMnUxDHfq4n4HvRcoHNZ1pr/69irkfFgb1d/3XDWGzwlhFNfb3Z z4o3pbxkpqKTFN0Cposii3+Jiq6cigxJ2mV+f/5VYTnRNr5ezHy25qA1YXM8In9HCMEz GUuWBHi7PUz8ClPXtOYAJJ7jZGxfV6Oon2GKcFzdE2l/xUy2C/H749JI4fjpJj2GooEX LvJaaTdGEFzd33mo1qpFIITlI5pElBN+Kw9gAUZZfDPVzK/PZmiAG0o7zeU3ItioiXS9 P8EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BDGnpFOwaxgu4kjpNrN1FgZ1yXTRYcJnX/ad5ij8bQw=; b=Nv3a13UJLNUCeBFak96vBuwTeHp6SB0pruZ93rsU3YcFBojID1BYaSTChykA2ZXE/9 7ka34vKKTWeN5+P+bpGU7kdKXMWbc6RPWuhbxNGGHX8JxOmjxcZtvahWcSYwWp6javNB XN2RSwpdo/t4tm8OlPzQnOst+uWvVHnCZbtkL3NxxYt0sTnzyYP2ernayVLyjWxS82Vd /DtQyAJEkSbpGUn4/iKKvXYDwnRslOIO5i9IAIkxX1w9MqsIdbvKt9VRy3AD34Uw4RX8 WWvoelPe8NtVS/zzx4iSRaF/nSBtXZgII3fAOoPaoPxWYSIEx7s01d0Qxe+GAENIAsFf WvKA== X-Gm-Message-State: AOAM533X9akSk4X8GL6ukhPd1DW/ghv7S/y8b/BY7gM4xy1bEZ3SCLDp fI8Dv7NUf9xy5sOuBoxZz86qDz6rbi0= X-Google-Smtp-Source: ABdhPJw4oLxEyW4N3Qgpj2BgeJdAV+F9IiCujxglC7XgIe2c9ZSwEXW8VfAnon5uRzIxzYq/Xyw5tw== X-Received: by 2002:a17:906:3542:: with SMTP id s2mr7811373eja.379.1632843987459; Tue, 28 Sep 2021 08:46:27 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:27 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 8/9] checkpolicy: drop incorrect cast Date: Tue, 28 Sep 2021 17:46:19 +0200 Message-Id: <20210928154620.11181-8-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The function require_symbol takes the type hashtab_datum_t (alias void*) as third argument. Do not cast to hashtab_datum_t* alias void**. Since explicit casting to void* is unnecessary, drop the casts. module_compiler.c:1002:36: warning: cast from 'cond_bool_datum_t *' (aka 'struct cond_bool_datum *') to 'hashtab_datum_t *' (aka 'void **') increases required alignment from 4 to 8 [-Wcast-align] require_symbol(SYM_BOOLS, id, (hashtab_datum_t *) booldatum, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ module_compiler.c:1092:40: warning: cast from 'cat_datum_t *' (aka 'struct cat_datum *') to 'hashtab_datum_t *' (aka 'void **') increases required alignment from 4 to 8 [-Wcast-align] retval = require_symbol(SYM_CATS, id, (hashtab_datum_t *) cat, ^~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche --- checkpolicy/module_compiler.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/checkpolicy/module_compiler.c b/checkpolicy/module_compiler.c index e8f15f4e..a1cf9fc4 100644 --- a/checkpolicy/module_compiler.c +++ b/checkpolicy/module_compiler.c @@ -999,7 +999,7 @@ static int require_bool_tunable(int pass, int is_tunable) if (is_tunable) booldatum->flags |= COND_BOOL_FLAGS_TUNABLE; retval = - require_symbol(SYM_BOOLS, id, (hashtab_datum_t *) booldatum, + require_symbol(SYM_BOOLS, id, booldatum, &booldatum->s.value, &booldatum->s.value); if (retval != 0) { cond_destroy_bool(id, booldatum, NULL); @@ -1051,7 +1051,7 @@ int require_sens(int pass) return -1; } mls_level_init(level->level); - retval = require_symbol(SYM_LEVELS, id, (hashtab_datum_t *) level, + retval = require_symbol(SYM_LEVELS, id, level, &level->level->sens, &level->level->sens); if (retval != 0) { free(id); @@ -1089,7 +1089,7 @@ int require_cat(int pass) } cat_datum_init(cat); - retval = require_symbol(SYM_CATS, id, (hashtab_datum_t *) cat, + retval = require_symbol(SYM_CATS, id, cat, &cat->s.value, &cat->s.value); if (retval != 0) { free(id); From patchwork Tue Sep 28 15:46:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 12523155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EACEDC433EF for ; Tue, 28 Sep 2021 15:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE09160F44 for ; Tue, 28 Sep 2021 15:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241688AbhI1PtO (ORCPT ); Tue, 28 Sep 2021 11:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241565AbhI1PtO (ORCPT ); Tue, 28 Sep 2021 11:49:14 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6654AC06161C for ; Tue, 28 Sep 2021 08:47:34 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id dn26so8011319edb.13 for ; Tue, 28 Sep 2021 08:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lwPC9qd4TiWmTPTuMtvJNWeHF3d0/n+2LcIsyskvAaM=; b=Boykq6AelQwjFjTJlw++77P7d3EDeXSLnLr/UYAqeA5ozbfWSqbLmzSisur8PTORpn qmoX69fTD0ez1FCvXXZb4jFaH9ORcJZ3YqAZElBnI90M/T9Bbnc3wvwe+X6qN0BHWFPt ZFOv65UdxQ/dhRy7xlf/iihBWaCKRVHq9LrtTVZkhVAyE0QJWsMiOXS04o09qYDww0pp YtEef4eOuSYwfx+aFwjaqDhLW4mif+qtK7SGwXRrPganC2KX3uKi3VegQ8ZqVOpaiVBu UyWX4nanS5HDGlcRI3soYojpAsYM48DwOzF6PPDTvqEWU4ZlBLhxkTWAhWdlpPaKatkV 2/Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lwPC9qd4TiWmTPTuMtvJNWeHF3d0/n+2LcIsyskvAaM=; b=0pv1wPabPAZscX10Nc3PODQGlHf5C+4hDXAqrEbYWTBRpjLzr+1BwOr/+fpk4AdZjC SFU2BehOgDnh1IMyMhoFfmq3S55tIsxNaO1OLIY3+/lTZGXlG6UVMP0KN9KBzhx9TMZP mpGK7uObckgV3wFfZgBq3OlgJOCE5RGhEbNYx9pVJZVblzdmZxHR4Ql3QEHb3YW+3ja9 agfXdeUTHMicy5//N8HcRPCkciWySneneUtRGAZJTPEBJ16jCa1eETx/YSYbDFFsM1VM RPV+A4YBmVNvTtDJjRO7V4y1AwZwawRqNeplaVGUcaCjBZLelGMTXBNBnuz7qxmOy2T7 ZN8g== X-Gm-Message-State: AOAM532npVZZC+zJlUfQLSi0JbhLpTlZ6gdQlpDktgyoHn3KZNw/5YH4 JuGyP41jXnspkyA/lxASA4NMJhSvGOg= X-Google-Smtp-Source: ABdhPJyueXmNwTHfXhzy7o4Vwm6PPLcfNeewhz94+KBgn1fHcdpgS6LuEHrRW4IO+n5IlL2jEltPMQ== X-Received: by 2002:a17:906:dbc9:: with SMTP id yc9mr7627054ejb.439.1632843988032; Tue, 28 Sep 2021 08:46:28 -0700 (PDT) Received: from debianHome.localdomain (dynamic-095-112-152-081.95.112.pool.telefonica.de. [95.112.152.81]) by smtp.gmail.com with ESMTPSA id l18sm13403834edw.78.2021.09.28.08.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 08:46:27 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 9/9] checkpolicy: delay down-cast to avoid align warning Date: Tue, 28 Sep 2021 17:46:20 +0200 Message-Id: <20210928154620.11181-9-cgzones@googlemail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928154620.11181-1-cgzones@googlemail.com> References: <20210928154620.11181-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Delay the down-cast from hashtab_datum_t, alias void*, to the actual type once its kind has been determined. module_compiler.c:174:19: warning: cast from 'symtab_datum_t *' (aka 'struct symtab_datum *') to 'level_datum_t *' (aka 'struct level_datum *') increases required alignment from 4 to 8 [-Wcast-align] *dest_value = ((level_datum_t *)s)->level->sens; ^~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche --- checkpolicy/module_compiler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkpolicy/module_compiler.c b/checkpolicy/module_compiler.c index a1cf9fc4..5f5b0b19 100644 --- a/checkpolicy/module_compiler.c +++ b/checkpolicy/module_compiler.c @@ -165,7 +165,7 @@ static int create_symbol(uint32_t symbol_type, hashtab_key_t key, hashtab_datum_ decl->decl_id, dest_value); if (ret == 1 && dest_value) { - symtab_datum_t *s = + hashtab_datum_t s = hashtab_search(policydbp->symtab[symbol_type].table, key); assert(s != NULL); @@ -173,7 +173,7 @@ static int create_symbol(uint32_t symbol_type, hashtab_key_t key, hashtab_datum_ if (symbol_type == SYM_LEVELS) { *dest_value = ((level_datum_t *)s)->level->sens; } else { - *dest_value = s->value; + *dest_value = ((symtab_datum_t *)s)->value; } } else if (ret == -2) { return -2;