From patchwork Mon May 3 17:53:26 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: 12236649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E174C433ED for ; Mon, 3 May 2021 17:53:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 682586121D for ; Mon, 3 May 2021 17:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbhECRyv (ORCPT ); Mon, 3 May 2021 13:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbhECRyu (ORCPT ); Mon, 3 May 2021 13:54:50 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596D8C06138B for ; Mon, 3 May 2021 10:53:57 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id n25so7317960edr.5 for ; Mon, 03 May 2021 10:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=i+AX9Fkiq+kBYkU8B5ajVJ41iLmCTWfcP89Zz6lYb0o=; b=rSIU8dNmNdl1HxEW3+9wlImh8q2s/twx7zaFO8udPt8XGRe2CkzC3BuVDijGIpQHog OZGC00vmMYQbz9LaW1dP/qOmOlcNPDbaOF1SwiMxnBNYyKaDFTtpz+GVhJECzPohe2nV eBHU1mlEHkxvcKXGztIkqGfEgbLqqB4+PkvsGnpftTf2ylLyHnbcu9LvFfwtnavYaFHc zyf084w0YwlOVLv2l8C7uuXEM3ixAaP9ovsIj/Kvw2+YMuErLFSZdJSHSkOw18520GYV 16/uzOYxctM6aFvz/z0ReEvKg2a1l/7px8Pe3x+vmmRKtJhOqsQUau+kF10WTL7eGcQ4 acsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i+AX9Fkiq+kBYkU8B5ajVJ41iLmCTWfcP89Zz6lYb0o=; b=D+7Mp3u0NpHln7jBydRNnNwXrVc9sCmrv75yDqcbelKqvWc2jkGJymOdVRjZhJzNx5 51Dse/51EnyzR6gkEht5Sno1fWVKIe1UC0ywb6s01TK2Zd2GoxRswICDgSLnlQ2wHpTX r7skTrLF73TZOABzcnrPV9eAVCfnK66ASGquvwbkjD5Wc/9SDx7vwSW+ge9Bw4Cp1dmi /cNRN4LjHeB1ff3v1C6Ko/r5EFkPijhxJIhR7yUBR6E4JG0jSSSKEo0597FVKH35qIL2 wsMYIUVj1elQySKyADU8/ewkMIxnWUc/SI+LwZfByiOzoJLGffW23GwSJ4lBsFi4OkYt 2qdA== X-Gm-Message-State: AOAM531OjLDkn3/DPk4fargX0dJA8pwonGkDFKiLU4yjDuR+wcaEOjAY BwmmuABNu+rbUELfAhJZxRlR88dU1NDf9w== X-Google-Smtp-Source: ABdhPJzm4wdAfeQ5BW4enHuIP0wJEd1kp612s+O7yggmKtQZu2Uawc7TqaVAwyQ5m4SUcL8dT5gDrw== X-Received: by 2002:a05:6402:8d3:: with SMTP id d19mr21273907edz.302.1620064436128; Mon, 03 May 2021 10:53:56 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:55 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 01/25] libselinux: sidtab_hash(): do not discard const qualifier Date: Mon, 3 May 2021 19:53:26 +0200 Message-Id: <20210503175350.55954-2-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Do not discard the const qualifier of the function argument, and drop the redundant local variable `keyp`. avc_sidtab.c: In function ‘sidtab_hash’: avc_sidtab.c:23:9: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 23 | keyp = (char *)key; | ^ Signed-off-by: Christian Göttsche --- libselinux/src/avc_sidtab.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libselinux/src/avc_sidtab.c b/libselinux/src/avc_sidtab.c index 9669264d..8dc87560 100644 --- a/libselinux/src/avc_sidtab.c +++ b/libselinux/src/avc_sidtab.c @@ -15,14 +15,13 @@ static inline unsigned sidtab_hash(const char * key) { - char *p, *keyp; + const char *p; unsigned int size; unsigned int val; val = 0; - keyp = (char *)key; - size = strlen(keyp); - for (p = keyp; (unsigned int)(p - keyp) < size; p++) + size = strlen(key); + for (p = key; (unsigned int)(p - key) < size; p++) val = (val << 4 | (val >> (8 * sizeof(unsigned int) - 4))) ^ (*p); return val & (SIDTAB_SIZE - 1); From patchwork Mon May 3 17:53:27 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: 12236657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BBFAC43460 for ; Mon, 3 May 2021 17:54:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FCFC6121D for ; Mon, 3 May 2021 17:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbhECRyx (ORCPT ); Mon, 3 May 2021 13:54:53 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2880C06174A for ; Mon, 3 May 2021 10:53:57 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id h10so7264584edt.13 for ; Mon, 03 May 2021 10:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FSFNkp3zfDVlCOXZVNpd6NENdAAQgbrDoDyhNlN4s5c=; b=Guo0ensQPAsQ+vFqxPAo1zCjsBsjWnEHYNfzpcjID6kU+OeCj95SeMJGmG9CJvjZNs 4TKuXlFo6K2iMElDiTT8DjFhYsBkRxjV+u3yzQgF7VeZkJ+SJb7L/jj5kcqQOp9ijFGG be4rOFhWW9EjQn5cGtUOvMzWMikkmbt82mpMj3iwIU66rqOoMbY3q3EMk4qRiG03fX9g q8XG0ePJ4NtmDXGw2OTTDRW/yVTm7Lk6WgLL8AQJaU+IA8UGDqr/pR8wNfYRHh78PkDj 35ISdYemD6/4tc3GkX6f0OsveIzGbvrpDYIK9Ct3qWSlqIp+0NKziOhu7tR8C9Xz2R58 +1iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FSFNkp3zfDVlCOXZVNpd6NENdAAQgbrDoDyhNlN4s5c=; b=TY0WFOaVhH66jpOvCtrBZpjtRXQI/LjtZXFhGC5m0YuKeXV9SnMC8dWoLvl2IvIIBb PQX9oEsIzIFRmUDfVEPt8oL4gEJ2Xs3AyLUfQENTJxwkzOIOIBNm7jmnf804oOKsxogW r6vo5C/Oimf/ki90ueXf1tP+zkeVGQ0pMGOYjn85VYBLlE01UyNjLwormdzQBBQgfu+D ImKSpjNRgNc+8Z++Oa4aLPl5sGrCrOf6Kfwq7U31xd70eeit5o8nLmtchB7YLX5TLsFL ZJ5g975iRp21cLGqOi1yv8CUsJSsez15sYpfcxkE74TwuFwapKsx+1qASSwQQ41q06qE woOg== X-Gm-Message-State: AOAM531J39npxefk3v48yK0Ws8U6U6G0tgRBCIsHH5ZlWFYURGbtnJY7 94f5WoQg2VNicizZoueRfrnFuIdFt51Ldw== X-Google-Smtp-Source: ABdhPJzrWIaPRjx3Xhw9Z1Cgn7uSgykdY9UubdofOVjGbliV6TRSU3ETJrPm9rf+2UxoTRfwOUeghA== X-Received: by 2002:aa7:d408:: with SMTP id z8mr7101376edq.286.1620064436452; Mon, 03 May 2021 10:53:56 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:56 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 02/25] libselinux: selinux_file_context_cmp(): do not discard const qualifier Date: Mon, 3 May 2021 19:53:27 +0200 Message-Id: <20210503175350.55954-3-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org matchpathcon.c: In function ‘selinux_file_context_cmp’: matchpathcon.c:487:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 487 | rest_a = strchr((char *)a, ':'); | ^ matchpathcon.c:488:18: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 488 | rest_b = strchr((char *)b, ':'); | ^ Signed-off-by: Christian Göttsche --- libselinux/src/matchpathcon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libselinux/src/matchpathcon.c b/libselinux/src/matchpathcon.c index 2ec66650..9e1fab59 100644 --- a/libselinux/src/matchpathcon.c +++ b/libselinux/src/matchpathcon.c @@ -477,15 +477,15 @@ void matchpathcon_checkmatches(char *str __attribute__((unused))) int selinux_file_context_cmp(const char * a, const char * b) { - char *rest_a, *rest_b; /* Rest of the context after the user */ + const char *rest_a, *rest_b; /* Rest of the context after the user */ if (!a && !b) return 0; if (!a) return -1; if (!b) return 1; - rest_a = strchr((char *)a, ':'); - rest_b = strchr((char *)b, ':'); + rest_a = strchr(a, ':'); + rest_b = strchr(b, ':'); if (!rest_a && !rest_b) return 0; if (!rest_a) From patchwork Mon May 3 17:53:28 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: 12236653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B720C433ED for ; Mon, 3 May 2021 17:54:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1D3961244 for ; Mon, 3 May 2021 17:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231665AbhECRy4 (ORCPT ); Mon, 3 May 2021 13:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbhECRyv (ORCPT ); Mon, 3 May 2021 13:54:51 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D4B9C061761 for ; Mon, 3 May 2021 10:53:58 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id b17so4292580ede.0 for ; Mon, 03 May 2021 10:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PR3K+awGkRMcy1+IeKglsEg2qWTUDuhLCNwgWilDMRo=; b=as827ohyJWAofLh5pe4iYSU38rzdLO2L5p611+Xmrgvc8WI7MsA8QMoBQVcer4BRnd hVAtcoEYCqdmayayFO3rF2ef7coNXTZook/U0EkvjXUt+5IG3WYk+NsQz3531QqBCqCW 7Uzt+HUVYn6CJkl+bu8RTSUAUBxkvt4xS3f/Iu0ixI176+f0rRdiLG9szsuY3/orvs1a HRgbbZF8hlKqXGHkd63JDldKk6HMSA5GD/aDaCN+N1DCEARP+CfANYhg2iwQYlNiGzKg tGwDt7IKwX/pKRPxFFIYtwrjoeSPrtjaT9rB9xhawF4aomFStpazmW+WHaVJSYc8lm7P nTdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PR3K+awGkRMcy1+IeKglsEg2qWTUDuhLCNwgWilDMRo=; b=R8GoNOdTAOp5TQ+oiPbFLD7TaM0YUCvI4iKrPvekdfEYXPAXBi+avc1NEah7jImfUY irWOFriDj865qTjtTPU9jwsFS5ycCoWOVipv79j6FERNxOr8pkUJ8fRRMkR35ln1F/Tr 3xiSV3crO6AjO3q3iCmrXUXVPvSrxaeUL/kfTFVccSeWp2HzRhStQJjmu580lazpCb/t nh1jlOiejlz5YhxZOadH1KTwroWhIQaIctH1x5oglE65tjGuCjWUyS2ctzcXIj4Z+ADM fQHOQ7bQIBNW9vC6rBlYa9G1W2RLoZf5AJdBjgtOgQnchm88j34ZZgF89Uh/7O6FDHYC zFgQ== X-Gm-Message-State: AOAM533coioeGF1PHaPA6P0u1kUwmYPAQMUrqcF+mfJKAy7fj1Vu7xBQ kcm2jPkguClA8BcikHRlRleYb3wD29THyA== X-Google-Smtp-Source: ABdhPJzIRefKrDGAZ4+gKHC56cpAZEEzWygUnQy9ZyYKTtjGB4DYUYQVg/Y0TX5fglfsTjAGVRzydg== X-Received: by 2002:aa7:dc10:: with SMTP id b16mr21791318edu.258.1620064436726; Mon, 03 May 2021 10:53:56 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:56 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 03/25] libselinux: label_common(): do not discard const qualifier Date: Mon, 3 May 2021 19:53:28 +0200 Message-Id: <20210503175350.55954-4-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org As the const qualifier is discarded in label_common(), do not return a const qualified pointer pointer from the local function `lookup_all()`. label_file.c: In function ‘lookup_common’: label_file.c:994:24: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 994 | struct spec *result = (struct spec*)matches[0]; | ^ Signed-off-by: Christian Göttsche --- libselinux/src/label_file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c index 726394ca..4d4e3a76 100644 --- a/libselinux/src/label_file.c +++ b/libselinux/src/label_file.c @@ -845,7 +845,7 @@ static void closef(struct selabel_handle *rec) // Finds all the matches of |key| in the given context. Returns the result in // the allocated array and updates the match count. If match_count is NULL, // stops early once the 1st match is found. -static const struct spec **lookup_all(struct selabel_handle *rec, +static struct spec **lookup_all(struct selabel_handle *rec, const char *key, int type, bool partial, @@ -861,7 +861,7 @@ static const struct spec **lookup_all(struct selabel_handle *rec, unsigned int sofar = 0; char *sub = NULL; - const struct spec **result = NULL; + struct spec **result = NULL; if (match_count) { *match_count = 0; result = calloc(data->nspec, sizeof(struct spec*)); @@ -987,11 +987,11 @@ static struct spec *lookup_common(struct selabel_handle *rec, const char *key, int type, bool partial) { - const struct spec **matches = lookup_all(rec, key, type, partial, NULL); + struct spec **matches = lookup_all(rec, key, type, partial, NULL); if (!matches) { return NULL; } - struct spec *result = (struct spec*)matches[0]; + struct spec *result = matches[0]; free(matches); return result; } @@ -1054,7 +1054,7 @@ static bool hash_all_partial_matches(struct selabel_handle *rec, const char *key assert(digest); size_t total_matches; - const struct spec **matches = lookup_all(rec, key, 0, true, &total_matches); + struct spec **matches = lookup_all(rec, key, 0, true, &total_matches); if (!matches) { return false; } From patchwork Mon May 3 17:53:29 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: 12236655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFEC3C433B4 for ; Mon, 3 May 2021 17:54:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A198E6121D for ; Mon, 3 May 2021 17:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231684AbhECRy4 (ORCPT ); Mon, 3 May 2021 13:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbhECRyw (ORCPT ); Mon, 3 May 2021 13:54:52 -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 4BBA9C061763 for ; Mon, 3 May 2021 10:53:58 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id d14so7284100edc.12 for ; Mon, 03 May 2021 10:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5oO0YCOLyVYMxcN3MBjbY9NAjoy33/7LxOpC2BU2HAs=; b=PB68QvO5CGUtWiipEjYVvZWR0iWNIS5ywTwAd9Jt0JN/4nDsz4E70FcmLnG4ZdRBvq J5lk4icvGO5oYn2Vhf5jMvTFZwuVx5jW353YijaKCU8IO/2L7HvtXGUBh7J3nhRh+DzZ X4ktdQUGuvdTfbvbX+5UWGDWiOifPSFWOitxU4SI5MTN7G6L/Z4dzLhm5oqUGr5cLTmx cLn5zOzSa/W3sFap13JYu4alEmnr4OKLXpO0djb1zMpGB1qpYoY3ck60ooVUCaoXB1lA T0radV4v9OMTDOuO72ohKAPlsGzD860pkTf52UdmodEmUmi+6qzPhzR2kcm+0IvchTRP 05Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5oO0YCOLyVYMxcN3MBjbY9NAjoy33/7LxOpC2BU2HAs=; b=un1mHk9zctZetmjKWq+XwnlOillO2XhtgMbVbY17Hq0gYNU/eH7kXo+eUziyIWTXUv uRtZGlNNBjvkaP1ArP6k7vTMeOSXr/PYu6uH+Hxx1kWtak/+4T7X6AmkGOtKrK9mbgOg v4UiTv1nBMOd1IE90VdYADJNFKOT8A1y+kEJwfGgHw+PAA1nt+IMdMi4i69rdWPPhLJz b6I10ty34BM/ajcqvnh3NsbT9SoeLbtcyKv0v84Y3qt9Ou/1JSO9r+kC1Vjx7G9CA1kY MJQ/Yl87njPKxdTNRbqTBqi5C17iWLoCLl/wkYAuR060wjU1w/cG4V3y2GR+2QYji1XX 4IHQ== X-Gm-Message-State: AOAM5302rOA2EDwvrw8EIBk8zdrMFYN6KG+RQjsOruPtJz1nmPDh9yuY XVOc3gMqjS6Pn47fM0gL7tl8C4SNbHQ0oQ== X-Google-Smtp-Source: ABdhPJwmkhh0KDFjN1ZYJrj6fuefSXEnTNjsmFAzJA/85LpFANRcjKHUg93U1tYaJJcKfOwrfoEbOg== X-Received: by 2002:aa7:d30b:: with SMTP id p11mr21109507edq.325.1620064437061; Mon, 03 May 2021 10:53:57 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:56 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 04/25] libselinux: Sha1Finalise(): do not discard const qualifier Date: Mon, 3 May 2021 19:53:29 +0200 Message-Id: <20210503175350.55954-5-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Mark the argument `Buffer` of `Sha1Update()` const, since it is not modified. sha1.c: In function ‘Sha1Finalise’: sha1.c:208:25: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 208 | Sha1Update(Context, (uint8_t*)"\x80", 1); | ^ sha1.c:211:29: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 211 | Sha1Update(Context, (uint8_t*)"\0", 1); | ^ Signed-off-by: Christian Göttsche --- libselinux/src/sha1.c | 10 +++++----- libselinux/src/sha1.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libselinux/src/sha1.c b/libselinux/src/sha1.c index 9a8ce01d..664bbcf2 100644 --- a/libselinux/src/sha1.c +++ b/libselinux/src/sha1.c @@ -151,7 +151,7 @@ void Sha1Update ( Sha1Context* Context, - void* Buffer, + const void* Buffer, uint32_t BufferSize ) { @@ -172,7 +172,7 @@ void TransformFunction(Context->State, Context->Buffer); for (; i + 63 < BufferSize; i += 64) { - TransformFunction(Context->State, (uint8_t*)Buffer + i); + TransformFunction(Context->State, (const uint8_t*)Buffer + i); } j = 0; } @@ -181,7 +181,7 @@ void i = 0; } - memcpy(&Context->Buffer[j], &((uint8_t*)Buffer)[i], BufferSize - i); + memcpy(&Context->Buffer[j], &((const uint8_t*)Buffer)[i], BufferSize - i); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -205,10 +205,10 @@ void finalcount[i] = (unsigned char)((Context->Count[(i >= 4 ? 0 : 1)] >> ((3-(i & 3)) * 8) ) & 255); // Endian independent } - Sha1Update(Context, (uint8_t*)"\x80", 1); + Sha1Update(Context, (const uint8_t*)"\x80", 1); while ((Context->Count[0] & 504) != 448) { - Sha1Update(Context, (uint8_t*)"\0", 1); + Sha1Update(Context, (const uint8_t*)"\0", 1); } Sha1Update(Context, finalcount, 8); // Should cause a Sha1TransformFunction() diff --git a/libselinux/src/sha1.h b/libselinux/src/sha1.h index eac3c195..f83a6e7e 100644 --- a/libselinux/src/sha1.h +++ b/libselinux/src/sha1.h @@ -64,7 +64,7 @@ void Sha1Update ( Sha1Context* Context, - void* Buffer, + const void* Buffer, uint32_t BufferSize ); From patchwork Mon May 3 17:53:30 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: 12236661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69882C43461 for ; Mon, 3 May 2021 17:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D11A61244 for ; Mon, 3 May 2021 17:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231735AbhECRy6 (ORCPT ); Mon, 3 May 2021 13:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbhECRyx (ORCPT ); Mon, 3 May 2021 13:54:53 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01DADC06138C for ; Mon, 3 May 2021 10:53:59 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id m12so9215292eja.2 for ; Mon, 03 May 2021 10:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8a+ODB1LNoDtrvnUe/G+OpgSlNOTGtjaWoaMUWoLAfg=; b=oV0kE8T2LWYtaGvHAyFsWnr2BEg2AC7Q2Th7/W9gYEsYARrkBQ5oKpcCHq7X6H64jF fm51JGLsljF/bJKXvMl50qndEv1bP9ZBsY59vfzPABF0+8vgWpOH5Ycj/41g9Hm/SALT xMpDI5VJ7WADrGAZ6JnvM+rLO5amx3tA9XVzbIQjnFlO+brWJVUK+jrwACgOETJcl6f1 8CKkZywEbFJG9/IkQ8hbbBxxeQYBvLiG/9csP0Q2antaly5pOotKkYu4/WQjN3PoxPej y+Tdw8rc5A7BUzbZzvM5+wh2fdh9DRkr/MmKksG28BwMwqY7auxnGZeo3AicBE5xgkMy OtDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8a+ODB1LNoDtrvnUe/G+OpgSlNOTGtjaWoaMUWoLAfg=; b=CgW7z3VYWfLjz5YE/0cHzDXG+M3uHrddhmdntFeEC84yfMx4p1wZbRNyyDspx3aAf4 CtGyTY3tWoJvzJp6kVqBZZEdJ81E3xOOx7qrCSJUyS6tvGMwzO0dOLnFRb/Nakz3hBmi WzsuVmQwhDaekK/LpHHIzTt18w9kSiM8s3xL7KD+rPvcu0SWBuiggPb090dYpBYWOVYO 5hR9eorParbvbao+z2Rc7amE6DdtS3tKI6Lb0+33hFIve6xWESGngHntNJRuYJgXVt19 bj3O5zkgvzJ0UF4bzhtSs4zRaqajDfBnUVECntJDJjjSGmBpTRNBqWblYbh9FBiD8+vT heiw== X-Gm-Message-State: AOAM531ICNDu8IXUqj6c/wV45Lr+3tTL+s0etctUjDdwFaQlunyeYm6g gKfgX9iY1cpBqh1Pt3i7Omq8yHW08Q90fQ== X-Google-Smtp-Source: ABdhPJxAksrNkn/FbGjs2R0fDQz/bSjKfaXSOKM/SKqJNanfaiJvKtPq/p2JCwhNLTiYmiw61YDY+g== X-Received: by 2002:a17:906:17ca:: with SMTP id u10mr17393611eje.124.1620064437330; Mon, 03 May 2021 10:53:57 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:57 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 05/25] libselinux: sefcontext_compile: mark local variable static Date: Mon, 3 May 2021 19:53:30 +0200 Message-Id: <20210503175350.55954-6-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `policy_file` is only used in sefcontext_compile.c. Signed-off-by: Christian Göttsche --- libselinux/utils/sefcontext_compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libselinux/utils/sefcontext_compile.c b/libselinux/utils/sefcontext_compile.c index dcb0085a..6c32172d 100644 --- a/libselinux/utils/sefcontext_compile.c +++ b/libselinux/utils/sefcontext_compile.c @@ -14,7 +14,7 @@ #include "../src/label_file.h" #include "../src/regex.h" -const char *policy_file; +static const char *policy_file; static int ctx_err; static int validate_context(char **ctxp) From patchwork Mon May 3 17:53:31 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: 12236659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00B1CC43462 for ; Mon, 3 May 2021 17:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0B866121D for ; Mon, 3 May 2021 17:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231733AbhECRy6 (ORCPT ); Mon, 3 May 2021 13:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbhECRyx (ORCPT ); Mon, 3 May 2021 13:54:53 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5793C06138B for ; Mon, 3 May 2021 10:53:58 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id b25so9187567eju.5 for ; Mon, 03 May 2021 10:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1JhlCsiGRXtSRbdAAlrHwjRODmg8T/Akun+p7ZCPbQg=; b=n0vPmMKNYd4COy9wIxVVMC+Z9/iiwr23bMQHm5p0grzsWvkAb2605AlcJoPEabNVFO XFlln3IsjIr/+cQEwPkoqHUXHseaYfr0k1oXWgpoVtLqjgbkMP+kExQ2ouAuWqStLzZ0 gwTU5F4hGd92xyBldlsQkY7bnJK0UPIW7wH7o7rQRwB9wvS57p4DlRETdm+XuI/EqDr0 BgQGe3K0i+ww7AxcfQhkxmcHaODW66GaopMArxNeS0NtaK4yDgOz0SV9O2XXjVd5FWTW zXh1tKVjWBofn1qI/i3QPS57R7T+tBAaD6CHBa9J8JhfDVgM1n434lZojaR9CewZ/tDN ER+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1JhlCsiGRXtSRbdAAlrHwjRODmg8T/Akun+p7ZCPbQg=; b=tmtKnehES8xwFJ4iHAoS1bNVoZ4vETJj+SSYkxV+1RT6rjbnlvQ5kgKLavU55I4/lE bVrw3PiFZ2RCdWSOtJJUOMdL3qdDJPopw6+YEfoTidhD5L/brlPugPYcg5g/dTBVqVg5 pYA1W46DyB5bWylJ6I6EsePYDoJCagnAaPEhwpKrHinqqRDQzUkZZY9u5HiPF8S5qUk1 qDJW6iiSnl724TMjgnpnLjz4C5Sf5wMAZIOQeMFroj8BYSyo23a8bbJJ8QE6GHY5u0CA Pv9xaQy8H/+JCln1k2ejbP6EOH8MhVq+5SMs7TiTPLLsyw7U+060v7b9xse6LrOrkqs0 69cA== X-Gm-Message-State: AOAM532S/cquvqymy0nVe00NUV4Au4tboPuPTMNtJ7kbM5XXp+Ir7I8c fA38K2lK/UrLQPaScIzcr01CQP298/JViA== X-Google-Smtp-Source: ABdhPJz3l+fgidxQTlG79BtrnLBVC6hT3HKOLxZMWRYMVSDJ9+MqMGpUyyxWTv5LZIaHb920sdJY6A== X-Received: by 2002:a17:906:2482:: with SMTP id e2mr6622734ejb.212.1620064437597; Mon, 03 May 2021 10:53:57 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:57 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 06/25] libselinux: avcstat: use standard length modifier for unsigned long long Date: Mon, 3 May 2021 19:53:31 +0200 Message-Id: <20210503175350.55954-7-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The format width specifier `L` is only standardized for floating point types. Use `ll` for fixed-width data types. Signed-off-by: Christian Göttsche --- libselinux/utils/avcstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libselinux/utils/avcstat.c b/libselinux/utils/avcstat.c index da239287..cc9a48dd 100644 --- a/libselinux/utils/avcstat.c +++ b/libselinux/utils/avcstat.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) die("unable to parse \'%s\': no data", avcstatfile); if (cumulative || !i) - printf("%10Lu %10Lu %10Lu %10Lu %10Lu %10Lu\n", + printf("%10llu %10llu %10llu %10llu %10llu %10llu\n", tot.lookups, tot.hits, tot.misses, tot.allocations, tot.reclaims, tot.frees); else { @@ -215,7 +215,7 @@ int main(int argc, char **argv) rel.allocations = tot.allocations - last.allocations; rel.reclaims = tot.reclaims - last.reclaims; rel.frees = tot.frees - last.frees; - printf("%10Lu %10Lu %10Lu %10Lu %10Lu %10Lu\n", + printf("%10llu %10llu %10llu %10llu %10llu %10llu\n", rel.lookups, rel.hits, rel.misses, rel.allocations, rel.reclaims, rel.frees); } From patchwork Mon May 3 17:53:32 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: 12236665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 491DDC43470 for ; Mon, 3 May 2021 17:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26A4F61278 for ; Mon, 3 May 2021 17:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbhECRy7 (ORCPT ); Mon, 3 May 2021 13:54:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbhECRyz (ORCPT ); Mon, 3 May 2021 13:54:55 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48792C06138D for ; Mon, 3 May 2021 10:53:59 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id u13so4616068edd.3 for ; Mon, 03 May 2021 10:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/8YTM1x8f18VNrTJdlKur6vh0lfbOCklkMl5jzvLQ+c=; b=WF8vzFxfqyDvoDayyBBVdGnymY9yZSIBYwwa4wmkKdOT5u3hhCb6XJEo9F8876pOWV HiBqp2qsqxr8cAejKNwA/9sKiMgeaM5K6VA2euEMw/vorHSd+mhszx9kr99ukYWjpeHo /mqLXxj06iWs74G3qyaajFWk2gbGMXbucauERkLcKOe/mJcNglUzepas68fxuifZRRvn NbwQpdu6kgANBet4WmoZ9yL5o4AHbia7PI3xu1DAlwEQ/3Y4SdAQig4zboUwFDjlH57g h+YPfU61eVYwu/CnoqbR08Sx2Mt0lc+TxLrc2I1ge+l0Gf1tXfK8z/FQPiWRh2ckNK0w 9SNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/8YTM1x8f18VNrTJdlKur6vh0lfbOCklkMl5jzvLQ+c=; b=Cy0JA55xuwg7GqY7SQTSqxEQLSlHP4ydczJkja8BQqFpi0b60ydxrnhHjvIWoGMAk5 FunC5o1Gy56vT865CQ6j8sSbji7Q1ONPCynjP6xe4yTOMl6ynSBvlD5+UQViWRoMLFhG +8L9IolIC2/PNtF7X8E58MbpLZ1HKZuAkCWayVh3V7Df6DTIu53m6ZDXv6e6RvG7uxif +pIGqagROmnMHTcXdUxgvl60EhNlrugCQktVFSdza/1IvpFDu0cHJVxiw3wlkdFbcBCu Cb0e6za1s4szTvcOY3ghKrHpFuTz7amG48oXghnO8St9+884BzKPT9HSWWCVaRm/wxau XJFg== X-Gm-Message-State: AOAM532s4QWXw6nq3LY15NdZmqD1rIoWhYAeeiPyDXbERiDWJoHGlh2R 5DTMNhogJJuCcvHxPGhDcmHrarAPimnD0w== X-Google-Smtp-Source: ABdhPJyUjgnxY/DBSMkN0Sh7xpyjazBBaeXvCzQaozOWD+2iDJXx11WvfzMjTx+Q/JXwgRBTDRQWcw== X-Received: by 2002:a05:6402:3553:: with SMTP id f19mr12415866edd.167.1620064437863; Mon, 03 May 2021 10:53:57 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:57 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 07/25] libselinux: selinux_restorecon: mark local variable static Date: Mon, 3 May 2021 19:53:32 +0200 Message-Id: <20210503175350.55954-8-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `dir_xattr_list` is only used inside `selinux_restorecon.c`. selinux_restorecon.c:65:19: warning: no previous extern declaration for non-static variable 'dir_xattr_list' [-Wmissing-variable-declarations] struct dir_xattr *dir_xattr_list; ^ selinux_restorecon.c:65:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit struct dir_xattr *dir_xattr_list; ^ Signed-off-by: Christian Göttsche --- libselinux/src/selinux_restorecon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c index 63fb8dc5..249c361f 100644 --- a/libselinux/src/selinux_restorecon.c +++ b/libselinux/src/selinux_restorecon.c @@ -62,7 +62,7 @@ static uint64_t fc_count = 0; /* Number of files processed so far */ static uint64_t efile_count; /* Estimated total number of files */ /* Store information on directories with xattr's. */ -struct dir_xattr *dir_xattr_list; +static struct dir_xattr *dir_xattr_list; static struct dir_xattr *dir_xattr_last; /* restorecon_flags for passing to restorecon_sb() */ From patchwork Mon May 3 17:53:33 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: 12236663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E94AC433ED for ; Mon, 3 May 2021 17:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E413B61244 for ; Mon, 3 May 2021 17:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbhECRy7 (ORCPT ); Mon, 3 May 2021 13:54:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231643AbhECRyz (ORCPT ); Mon, 3 May 2021 13:54:55 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFA5C06138E for ; Mon, 3 May 2021 10:53:59 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id e7so7286210edu.10 for ; Mon, 03 May 2021 10:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=55Z2maoL2CIyHa7EJp6X9pn7o8/HQjP9mgit2hwOMZY=; b=sW8lA4TytbjVIb371EA1SgJXQTZ+zepO8j30GEVluei5HWwigOu26dvDY9VWZ05jrW blfZXVhNitg4AUi7Zvh42H5OSMHgfSswTZu5HoT3KBEiT+7ui0ZEpBZF9j4lPfUxOsdc uFnEt8AbPfJJS+0xdadpg1aFwdA86VppL/2ZhunYOSAzg73bXTGvfkcZ6Kc1rTkW2+4r K5KxxVpW15Dqe2ojz6yyTmh16K4NbUDsaWsA0wfo0w59VwUJhW68QuJJmzGMXeFebqQP rgyfpyG0pYcOw3XUbHKGdFLA/W7PAb8TSKmc7S/dWwoGOfUvhYNz3yaaa3yzZeHLnzLy THDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=55Z2maoL2CIyHa7EJp6X9pn7o8/HQjP9mgit2hwOMZY=; b=gl1H+66Ye8GU0Pmi9ho4AMv9L6gASwFdTAelHNq5LY2BJxF7HL3Rhq5bBDOfXnjV+A 4QqnlL47JnQ3MCYHs2moaZwpzTn7rzrpJH/+OerT5mJ1793tgc4+0OZMutjZPqXr7e4q VwC3wGMQOPjI6vGlRK6NXnMD8FeGjxn35F8lSTBKMRgQCoCvCdAj+G9B5LWf/6QL9ikE vwhOS4rkzvD64vpkPpiz6Wj/o5Oz2n75SHHqbaQ5FCbrk8/BlYSuoYFnvxq0N65t+tAk TgKpj4CVBuYIlI49r4yTiZy1c3rHufB9DZpmhNis3/wFoO0ylPh/YAKHto57vyhYliJ+ kmIg== X-Gm-Message-State: AOAM530uw1JJ/JFVTv9lKbNyKTIuzS8GwD2s7sobmZPIdFGR3IOTvb3+ NJ0cacvs/6myoXppUAAggFp8LMOVR338Kw== X-Google-Smtp-Source: ABdhPJyjcRMFkHVauDyMjUAPEucYVI5YsvZdVVNWZHRo0GLhoYDk/T45KESuE3VaxL8gQ1uFgQEOjw== X-Received: by 2002:aa7:d955:: with SMTP id l21mr12525330eds.118.1620064438147; Mon, 03 May 2021 10:53:58 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:57 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 08/25] libselinux: selabel_get_digests_all_partial_matches: free memory after FTS_D block Date: Mon, 3 May 2021 19:53:33 +0200 Message-Id: <20210503175350.55954-9-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Free all memory from `selabel_get_digests_all_partial_matches()` in case of success and failure. Found by clang-analyzer. Signed-off-by: Christian Göttsche --- .../utils/selabel_get_digests_all_partial_matches.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libselinux/utils/selabel_get_digests_all_partial_matches.c b/libselinux/utils/selabel_get_digests_all_partial_matches.c index 0c2edc67..e28833d2 100644 --- a/libselinux/utils/selabel_get_digests_all_partial_matches.c +++ b/libselinux/utils/selabel_get_digests_all_partial_matches.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) printf("No SHA1 digest available for: %s\n", ftsent->fts_path); printf("as file_context entry is \"<>\"\n"); - break; + goto cleanup; } printf("The file_context entries for: %s\n", @@ -149,11 +149,11 @@ int main(int argc, char **argv) xattr_digest[i]); printf("%s\n", sha1_buf); } - - free(xattr_digest); - free(calculated_digest); - free(sha1_buf); } + cleanup: + free(xattr_digest); + free(calculated_digest); + free(sha1_buf); break; } default: From patchwork Mon May 3 17:53:34 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: 12236667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE213C433B4 for ; Mon, 3 May 2021 17:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 976B461244 for ; Mon, 3 May 2021 17:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbhECRzA (ORCPT ); Mon, 3 May 2021 13:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbhECRyz (ORCPT ); Mon, 3 May 2021 13:54:55 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC87C061343 for ; Mon, 3 May 2021 10:53:59 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id d14so7284195edc.12 for ; Mon, 03 May 2021 10:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MFtCCqwgvbVttNpGX4eKRO2mNR7gMa014+Tni4SwScw=; b=QMt+Z/JxMqFg28fLE5YGnw6rABSgErAinBWelaYbYbD6LN6jPkKqy3NzKqkpsPs90R Hz02A2mCiBt6ieck6QNn6tBFoA9Vc2oYKUBESNWepGc4IQ6YCwBpx9qbajpJ5DcfZmUb ElHbxuquD3IQpntXuV5mNs+UCy85qBPFZuMdfvy8ucdNAngOD3XXBBOIRyvqfmDv+YK1 0W7nycKjsDCw6ilmicHiXDIx5Cyx5NrNUydJYG0lB0O5kK3HGF5mvZ71zdhJzNSE3IXP Dq6xHerqJ4Y6Bt2pmJqN/Lx+yAUNrfEKvxdhGA88r6/Hlt1luRUnOJACpEhBcoEStkhG PuLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MFtCCqwgvbVttNpGX4eKRO2mNR7gMa014+Tni4SwScw=; b=dFMhmbqEO27ERrPPWeLE6Vi9iI3EPLKZDW7V/O7Ab6wCD7blUwcNn3IzKwJPII4Pet BuWazPrHRBooFk3+9MV3qFadmLLdmd8xlPSSgULJe5MR94qyLfhNS9LLpgMqk71exVVa oQ6t2CeJELns8EV7yNIi+vcEsNFT3l4PVDUSBhw0RWrmBiPsLjXZa66OwLM/oy61A7Ti Rk5s3j4kgIhWl/ycLwVL4csrOBzTLqjNYcomzzsMImTbiTvDLlu4I1L6CzleVhG/lCHZ KCuS5l4MagPjJeb8g4DgpMSBRGdL9PRi9d3N68kzoJVX2OzauG+y7fcy7c0tu1ssHXR6 y28A== X-Gm-Message-State: AOAM530wyvP/aqJ898B6hgO44SV2j84IfalwZpcoJ8tTBCT8wDgYT0ds Ygo58KSCgZx2PopffzMzLD7Soz8zCv/mxQ== X-Google-Smtp-Source: ABdhPJzBQQiIW8mrPJnoJkHOFi112pg7QkGfRLQKX1E5fuRlhidvL+v5Cias6GsGQ6C/l+NTbsUQdw== X-Received: by 2002:aa7:c495:: with SMTP id m21mr8393629edq.123.1620064438454; Mon, 03 May 2021 10:53:58 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:58 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 09/25] libselinux: getconlist: free memory on multiple level arguments Date: Mon, 3 May 2021 19:53:34 +0200 Message-Id: <20210503175350.55954-10-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Do not leak memory if the program argument `l` got passed more than once. Found by clang-analyzer. Signed-off-by: Christian Göttsche --- libselinux/utils/getconlist.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libselinux/utils/getconlist.c b/libselinux/utils/getconlist.c index 76654b75..0bb28469 100644 --- a/libselinux/utils/getconlist.c +++ b/libselinux/utils/getconlist.c @@ -26,6 +26,7 @@ int main(int argc, char **argv) while ((opt = getopt(argc, argv, "l:")) > 0) { switch (opt) { case 'l': + free(level); level = strdup(optarg); if (!level) { fprintf(stderr, "memory allocation failure: %d(%s)\n", From patchwork Mon May 3 17:53:35 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: 12236669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79F28C43460 for ; Mon, 3 May 2021 17:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 484CF61244 for ; Mon, 3 May 2021 17:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbhECRzA (ORCPT ); Mon, 3 May 2021 13:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbhECRy4 (ORCPT ); Mon, 3 May 2021 13:54:56 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04877C061342 for ; Mon, 3 May 2021 10:53:59 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id gx5so9154030ejb.11 for ; Mon, 03 May 2021 10:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LbwZlbBVV6DpLBBhseCMZpwc2EMISvQSBHBs+9MbTM4=; b=irB2tP8dDORuIOExOh8vb6S1H7eHJN+uQ+uf+ABSq9JKzpZrk/HHLpAt6su3mLkoAU 6TT67efcmLh06dnyB+f6/VblooLRslGqOdhG95sdeHEZyTjVK+wOcJDxiLN8IjAihcJP w3YKgmGq+UxjBZbwxcyLIUBLIkRVEE3i3BsY2uqcogHMqbeyFoxec4HDiU4ZZfLjsp6I BBb5W+pL1+/y17FpHfxDA/n3bzKhR6jTIhR1hoQD60PD/VhHYbZuogbRJrQ4RD+AZ6kr g7jY0nHKZZHpNsHpJYC/MYVdkBhiIdtyDbijh+FqDF0cLuHaRQoNBXKhgEbU9p8JDbo/ uJtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LbwZlbBVV6DpLBBhseCMZpwc2EMISvQSBHBs+9MbTM4=; b=B01KjSGlQyxMfwJUBXaan7PgEBddTw7UrnykANWx4Zg2XnpUSwk1IH1aIz7UksmlL3 sFE6WZJ0+EiqxtLcOcI/Ygz2fhqEW7r9sOOoGn5Nj5njb6uBu7LYgLkSHd3L8SyCDRjT iyI58w0mrgxdQGfrz93nR1feCOnrWeyx7dtdAUEWGhe8djX8gvQctGb+WKz7n8GyMJK3 CrCrRggWpsm0uwtHfB3f4mLZfeC252Tz4hey3y79xg/a8jjoXkKidWeaTtuajmIKGvQC LScTgzvLaz/RLAAxqmIb/1Cht0/Bre+k9v7ysOMExUncPQG7dgKwyxM/QEB61MsUAJXk VZmw== X-Gm-Message-State: AOAM530dgQdlF9qBH+zrcichU2w47WudF8jgMU/6Xdhs1/Cj+rmiU2l6 /9V//4TYb8HbDLntVnT+DYGosmDxORt1gA== X-Google-Smtp-Source: ABdhPJy2L4CWIGHDwPtQHRUScTRL2/BaXZaqbVvXvuphImDK9Y0aqAPyZ4r6iYxVn1NERozoglLetQ== X-Received: by 2002:a17:906:1185:: with SMTP id n5mr18230153eja.468.1620064438724; Mon, 03 May 2021 10:53:58 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:58 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 10/25] libselinux: exclude_non_seclabel_mounts(): drop unused variable Date: Mon, 3 May 2021 19:53:35 +0200 Message-Id: <20210503175350.55954-11-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `num` is never read from. Found by clang-analyer. Signed-off-by: Christian Göttsche --- libselinux/src/selinux_restorecon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c index 249c361f..6fb9e1ff 100644 --- a/libselinux/src/selinux_restorecon.c +++ b/libselinux/src/selinux_restorecon.c @@ -230,7 +230,6 @@ static int exclude_non_seclabel_mounts(void) struct utsname uts; FILE *fp; size_t len; - ssize_t num; int index = 0, found = 0, nfile = 0; char *mount_info[4]; char *buf = NULL, *item; @@ -245,7 +244,7 @@ static int exclude_non_seclabel_mounts(void) if (!fp) return 0; - while ((num = getline(&buf, &len, fp)) != -1) { + while (getline(&buf, &len, fp) != -1) { found = 0; index = 0; item = strtok(buf, " "); From patchwork Mon May 3 17:53:36 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: 12236677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 168B0C43470 for ; Mon, 3 May 2021 17:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1C8861278 for ; Mon, 3 May 2021 17:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231664AbhECRzC (ORCPT ); Mon, 3 May 2021 13:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231685AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ABF9C06138F for ; Mon, 3 May 2021 10:54:00 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id y26so7323616eds.4 for ; Mon, 03 May 2021 10:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fIogwTVFYjCmaSZ6TY103+kSKHXedn5m6sgVOECNPfM=; b=WIOuTKcj8TkHBKROSItE+/S+4JEjS08kwLmXz9ftEbOPUMhMgTnP3+NzFNmI9bOemk u7XNgBxLiUa4xxL2GhrXtfqxuHTWYtwOKQchB532qcpThJ1rIqF6h2AhjcfpyKx4WfCq Z8LCPQIpQ1IJQL/LLfPjGEou0pdacjlTDgi54Vc+CSq63pwvtADpWFxJbKdkZ3OnXVHf roWV30JYtZWgQoKkvUTqsE3/0N96FIbE5gnwhmlSk8Eg4Z2cvR04uwL2I8zSRQQtDJDl ioup3t2skPKWvY4lAksKTmdljRJ2RsKxRcHnycp2HkU5Kp8Ef6NJJIe+67i2okCuvSG8 nsQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fIogwTVFYjCmaSZ6TY103+kSKHXedn5m6sgVOECNPfM=; b=JHP7n6WZaAJABAA1hF1k9F335soIc9Y58j1212+65VtPMiB76q6u1K5XNhCR8MN54w +sjCpm/JMQl5RL9Ef4FMqqJbOr7OH9Z5ZWUtDDJP4mQ+R7pBDq5sycInSZd+Cb9TfR62 679nMBZ/UHA1mvPq/RFLbiyTkjFV1q6OiW9F800cMERvb3lh35Xu4CAs54UJ5X7ZDGLe cukZwTRSHxRBsUIH/HrDrDpfU2sPum45VTqXlY/u2RphzZvo2kgqmHRTmgFQ8DJBKthr pXuZkfS8AieEEVmiGoQ7tmhre8izRdA/AkxK6Pi29gahz5QW52DrIOekIhIRw8ak77f1 bMBA== X-Gm-Message-State: AOAM533lyW8XiyTPZdbp9U0CifseEUxmMY2TH8xnFugdRVGzml1SGELE TSzNgEWMYxr34fgnAKaZgkmEtE+XZFeG6A== X-Google-Smtp-Source: ABdhPJzze1Rb7E2qmssIn5ibT922W0tkuXkUxN51dH5msy+CmJsJxfw7dElPstwykto6Uma0WHbKGw== X-Received: by 2002:aa7:c413:: with SMTP id j19mr21358945edq.206.1620064439020; Mon, 03 May 2021 10:53:59 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:58 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 11/25] libselinux: context_new(): drop dead assignment Date: Mon, 3 May 2021 19:53:36 +0200 Message-Id: <20210503175350.55954-12-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `i` is not used inside this loop, and it later unconditionally set to 0. Found by clang-analyzer. Signed-off-by: Christian Göttsche --- libselinux/src/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libselinux/src/context.c b/libselinux/src/context.c index ce425880..b2144c7c 100644 --- a/libselinux/src/context.c +++ b/libselinux/src/context.c @@ -37,7 +37,7 @@ context_t context_new(const char *str) } n->current_str = n->component[0] = n->component[1] = n->component[2] = n->component[3] = 0; - for (i = count = 0, p = str; *p; p++) { + for (count = 0, p = str; *p; p++) { switch (*p) { case ':': count++; From patchwork Mon May 3 17:53:37 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: 12236671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0B1AC43462 for ; Mon, 3 May 2021 17:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5E196121D for ; Mon, 3 May 2021 17:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbhECRzB (ORCPT ); Mon, 3 May 2021 13:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231604AbhECRy4 (ORCPT ); Mon, 3 May 2021 13:54:56 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86847C061344 for ; Mon, 3 May 2021 10:54:00 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id c22so7313261edn.7 for ; Mon, 03 May 2021 10:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OaHh7NFTPHxZgNaeYXwcDNkow2ilHSnWR7ngZniqiKE=; b=rAvm9nRAOHl126trajCq0EmJ6g8BSb/kJS4XK4w3lWmOTBV7fFLyDZC+w9Bf0JaBAS D/CT9qOELBXB516ANyfSRQQikb7T4nyUBhBHql2pK+QhyH1VSM4MKCWTC+++f5RQkBT5 ztQu/GS3NSBkwEEcps+lMLzyZP2+CVOVSnRIHwSUw007pYRPduVFG2+YTPgDiuvqhSig 7LB243PHy6i7Uzck6tDmCE9QRb4+RlQD+Bu/ybOdlj+ECRBqUdReJXBNVdAGRI0dy6Ea cDFI5FqsqvK32jeSzR4DqEb6qQhpk0eG5HTeKmrRj7HohXDQCHbl6DeeckrRGvHtT0Ca +hDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OaHh7NFTPHxZgNaeYXwcDNkow2ilHSnWR7ngZniqiKE=; b=hJ2vQ3wbhYVZyTD4cuGuoOjNoC9FC5wqxwPiOSl1eDzjUQPrXsUKibuDaNiPgHW3sV pgG6XdorlsD78hZbwfSt3U6UDt45+I+mPS/moSOUaS73WGQiOkiLPB51JaGOnp1A/4cn bjBrYmsJMpigt/gxnxqaC8Jz4kQ5fCAaldBBX6MO105tJhMizySTijYqod1p9RSopZjW nP6T0fOAQtArfHsVmdv3+TDmi4z9JMsp3iZovViOxGQUvef/W/HEIL2HmfO3FClXwIyI b0lmAr2PLcuMubuyoU+ELo71J64qKojY/hYC0F7iFhU4VI/88NDYvcFCAT8LW9+ICugr M79A== X-Gm-Message-State: AOAM530IJAJhXBqHOP9EgjUFGa+88SN066kUvFPN6y/IMJ9tiEJxCovg rIsNeauN2ZvaybuuCakbSCnMmyW07wWqYQ== X-Google-Smtp-Source: ABdhPJwvb5sWN4RG3nx47HfD/nw6PnRd0v7uXYDtbydblnyHuvONqaFPHatN8VshOExCHxFq/8bv5g== X-Received: by 2002:aa7:c3c2:: with SMTP id l2mr21903758edr.41.1620064439302; Mon, 03 May 2021 10:53:59 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:59 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 12/25] libselinux: label_x::init(): drop dead assignment Date: Mon, 3 May 2021 19:53:37 +0200 Message-Id: <20210503175350.55954-13-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `lineno` is only used in the preceding loop and is always set prior that to 0. Found by clang-analyzer. Signed-off-by: Christian Göttsche --- libselinux/src/label_x.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libselinux/src/label_x.c b/libselinux/src/label_x.c index 96745299..e9fa063f 100644 --- a/libselinux/src/label_x.c +++ b/libselinux/src/label_x.c @@ -146,7 +146,6 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, if (process_line(path, line_buf, pass, ++lineno, rec)) goto finish; } - lineno = 0; if (pass == 0) { if (data->nspec == 0) { From patchwork Mon May 3 17:53:38 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: 12236687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C571C43603 for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4F776121D for ; Mon, 3 May 2021 17:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231397AbhECRzD (ORCPT ); Mon, 3 May 2021 13:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231710AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E2DC061348 for ; Mon, 3 May 2021 10:54:01 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id u13so4616194edd.3 for ; Mon, 03 May 2021 10:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jVYXLFnlnhsHhy8UnZrHesfEI+ARavA9rlkGZkAsv94=; b=YjyTceZaLHmMvibU8PMOeOuxJ3XG/CwLc5FxFF6Eo8UDYLPzN5dS2jTlu8B0G+2VPe YxRsvL2O6SFgYjwF4y0xyQVR4u2kBz2+iFP4cmiRAWZewEu9Gr3fa/m3rG7Bkxp342TN tbmPHA5plNfe/2AdPAKxCRURW0fsHMR1YhO4pU5vAwdFzgWZz28hNa13SuqzbuoWNHyi qITaY0lQCrs4cAYhTbFRCeHM/y9Xz1vKc/2JvzWWr3IPBBwyD+i4IkUbZgZY2YmIja/6 W7wYlQ4qnDIr/cdwA0+AswD80ESkg3KL5lapyWgeOfwgR2EC+FL4vjZ1luoue7LB44X9 G0WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jVYXLFnlnhsHhy8UnZrHesfEI+ARavA9rlkGZkAsv94=; b=TkPMy22rxJU0c9KqPVJLcy4EZTN7l3bDWEce9X3ysXiULc9u9/Xnte1Dk6EgWKOaeD E821iKN5ykITmP+OfjXbAvaLPdr0gkAxp6Toj1oHKipQGd3Y39DPE2w2WfiZ7YEcbsR/ NkeDSKZNxJuHpVDA0na5o3Vo/L7dSVG8+hf5YxJAK7lQORNdeOS1uoc4r7ztNAoaQV7A Wr+zaYkguYAXRsed1eIRX97Kvp3ylWJ94/rcFBgUrFS8UcMEUb+4B+Yy1i57esaY1V2M ngu7qecNZM7mGdUnGYWvZ7x21VBp6DHKQ/Gc0PLmqUMwopWbz5nYggYrod+9ncFwy9K0 B1fA== X-Gm-Message-State: AOAM533uPT4TJKZOKJX35Y92rKQwHsxkHHGV9D4Y2IgYA0IvjRB0ATvX 27NdfGkECveeknfmWQyHLMyuV4ZaNggi+w== X-Google-Smtp-Source: ABdhPJyN/AgIPSd1uXuss4pdvK4NCDnDCeewmsx0LCH3SOvY4yl+XpzjZCRmuce2ZwdR5jDDf047Rw== X-Received: by 2002:a50:ee85:: with SMTP id f5mr21767656edr.8.1620064439644; Mon, 03 May 2021 10:53:59 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:59 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 13/25] libselinux: label_media::init(): drop dead assignment Date: Mon, 3 May 2021 19:53:38 +0200 Message-Id: <20210503175350.55954-14-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `lineno` is only used in the preceding loop and it always set prior that to 0. Found by clang-analyzer. Signed-off-by: Christian Göttsche --- libselinux/src/label_media.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libselinux/src/label_media.c b/libselinux/src/label_media.c index d202e5d5..eb27deaf 100644 --- a/libselinux/src/label_media.c +++ b/libselinux/src/label_media.c @@ -119,7 +119,6 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, if (process_line(path, line_buf, pass, ++lineno, rec)) goto finish; } - lineno = 0; if (pass == 0) { if (data->nspec == 0) { From patchwork Mon May 3 17:53:39 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: 12236673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56AE4C43461 for ; Mon, 3 May 2021 17:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 271536121D for ; Mon, 3 May 2021 17:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231604AbhECRzB (ORCPT ); Mon, 3 May 2021 13:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbhECRy4 (ORCPT ); Mon, 3 May 2021 13:54:56 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D748C061345 for ; Mon, 3 May 2021 10:54:01 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id w3so9193666ejc.4 for ; Mon, 03 May 2021 10:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+l5WaM/XLDKsSixonjdGaNfRI3ejaxla3T48dQ0Gp48=; b=l0nfxgjv9uw0KKZLbm4Z20tgz73geAJJpLx3eFNkPxngU3fURL3lduzqt/FSg381hP xnxCuMHl1W/s9CM1ZKqL2gZjNWlOgM5owTmMQXBL/d4TMeQbZ9T9yYVxqk25Klkcfww1 WfmkE0PGc/wqLxbu6D/Xyn0lJLs+fyVHYlo9OEwgyjgoIjvDX2k9r0OuSrVPzQf6CuG/ bgoGxeGwXsi7eLTYTT51o4kIh9wABGsQ4YxEHDVgUytyBI3EWwwOA1Tf+FbW55UeLZHO xgqOpIuuGmw2iv+DQT2bTpzZgBhy3diS3jv6HPG9Y70IF5DWach3GlDC22vLH5QdiUKM eQQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+l5WaM/XLDKsSixonjdGaNfRI3ejaxla3T48dQ0Gp48=; b=OKnSuGEDbO4JfvLJo6sFhOVC22QObhVn8m+sRy7Gr4VFpccHZqYS8GOiuDBpI9ZnJN Sq5Z4CpYKzGIUqNA60edwAndexNZj+IwkBECL7go2AVgJ3a2/LTf4EBn3icUwrffnBtN H/Wz+Jngyg0OZl3F7z8PHXA+vD6DGXGqrKZtpmhUdGsDJ2ZU5W/FqFbAN3pG5YYMteF+ eRl1GIWI5LmKkhMK/2YcZOVJNbJgn4VcczVkBoEgRzlQE5y7ZoCdOvr2p4n8I+qdXtGI FE0lZBZWr09OWtUP7csB2WwS5jS3ayuV25VnUYdpoJQI0z67QwkIRQ8BXM4t4z4ofUsr QcwQ== X-Gm-Message-State: AOAM530uLRyFq8ee8cVrco3QwbWh9IkWJserflPdQXrXK5bgTtxYOPyZ zx49bknefquVSQZAgys6C2xjtA/Eer1vPw== X-Google-Smtp-Source: ABdhPJwJzU5QHnSa+3MLtPi5+7ODMEAlELVQ9rbEJw6gCQShju/O+R8RjpTzeWJSYLgC2gat9bD/BA== X-Received: by 2002:a17:906:608a:: with SMTP id t10mr18225787ejj.374.1620064439945; Mon, 03 May 2021 10:53:59 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:53:59 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 14/25] libselinux: setexecfilecon(): drop dead assignment Date: Mon, 3 May 2021 19:53:39 +0200 Message-Id: <20210503175350.55954-15-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The variable `rc` is always unconditionally assigned by the next call of `setexeccon()` and never read in between. Found by clang-analyzer. Signed-off-by: Christian Göttsche --- libselinux/src/setexecfilecon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libselinux/src/setexecfilecon.c b/libselinux/src/setexecfilecon.c index e72ba0d9..2c6505a9 100644 --- a/libselinux/src/setexecfilecon.c +++ b/libselinux/src/setexecfilecon.c @@ -37,7 +37,6 @@ int setexecfilecon(const char *filename, const char *fallback_type) newcon = strdup(context_str(con)); if (!newcon) goto out; - rc = 0; } rc = setexeccon(newcon); From patchwork Mon May 3 17:53:40 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: 12236675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA5D7C43600 for ; Mon, 3 May 2021 17:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CD7461278 for ; Mon, 3 May 2021 17:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbhECRzC (ORCPT ); Mon, 3 May 2021 13:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbhECRy4 (ORCPT ); Mon, 3 May 2021 13:54:56 -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 7C6F3C061346 for ; Mon, 3 May 2021 10:54:01 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id j28so7295309edy.9 for ; Mon, 03 May 2021 10:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RO441n4/VIEk7ehh6qb3RnHBVuLrEYuAYiYFb0xNGt4=; b=TVK/Nf5+1cIY4X9pRRVLUdNC/ZEBkKwrWnf5APJ/ZAYKPtMhTC698Kc3SB+TX1Noal z/ChnKE6jiZanWtQiQYYUeWjCyt6b07gU9uxtMrcIls0Bw3Wr+x9BU+1poOe0MseX8X8 49AdWdNT/QKNOvD+23J3NbSz42Uw3JvEZlqRHEpopRJnoa9P91ULMEiF830qcMCtyPQe 1K3ue95jkvykwP+Axu6+RIW1ChO3WgN7zRXMmP2XZJkyHQnIGUgc5+EteRH2TedXwh1c Y+Cmm1x+RqAyiAkl8ocECdscr2wR61pIddqNG+msRuSBXpeeI7WFrJf/fr5lDM2iSH8e UqWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RO441n4/VIEk7ehh6qb3RnHBVuLrEYuAYiYFb0xNGt4=; b=PYD8qVrNIljT0YqISuLd5KxXSNQq//hEwaBreRdRJPoaJ090YDxRN2T1inrnz5aVTD 7CIgMzNG7y3Y3NZh+FG9kFjUeu+SH2NK12FX0dnB/XlDXhA216uQTcrofecsTjKcd1Si GdQyb8fJpBSTKnEiFZ1oljb9VCGSpyeemYYImLtayhXuQKe2c/H2FP1iOvp4IhDutRfK Yd8GMqYJ/5KJ4UrEa8DEmUrSL2laS848on41sjO5HI14VRhP+7yiNJzK6KCvXRUXK7Db dolNu+JpZP3Z3msl/yGrPFkXDc74nSLp/d6mPq45tl6+C/vSs8RNa0v+v627GKXSA5y5 PgcQ== X-Gm-Message-State: AOAM5332qST3qYF8R92JzEi0AuyykN5UV3uGTyuEB7vv83Vk/GvnWcno dzXVO24QH5WTXvhFTaB+/9fa1HrEnA/ffQ== X-Google-Smtp-Source: ABdhPJzxKoYs9V4PD/KzBwYJxMySdwzSt+9LUVEKi4Gszzs34p4YKPZWvp/4jnoSndcly4oSHAvHeQ== X-Received: by 2002:aa7:cc98:: with SMTP id p24mr21232235edt.187.1620064440231; Mon, 03 May 2021 10:54:00 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:00 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 15/25] libselinux: getdefaultcon: free memory on multiple same arguments Date: Mon, 3 May 2021 19:53:40 +0200 Message-Id: <20210503175350.55954-16-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Do not leak memory if program arguments get specified more than once. Found by clang-anlyzer. getdefaultcon.c:52:3: warning: Potential leak of memory pointed to by 'level' [unix.Malloc] fprintf(stderr, ^~~~~~~~~~~~~~~ getdefaultcon.c:52:3: warning: Potential leak of memory pointed to by 'role' [unix.Malloc] fprintf(stderr, ^~~~~~~~~~~~~~~ getdefaultcon.c:52:3: warning: Potential leak of memory pointed to by 'service' [unix.Malloc] fprintf(stderr, ^~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche --- libselinux/utils/getdefaultcon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libselinux/utils/getdefaultcon.c b/libselinux/utils/getdefaultcon.c index 96a5a8c2..957c1cb2 100644 --- a/libselinux/utils/getdefaultcon.c +++ b/libselinux/utils/getdefaultcon.c @@ -28,12 +28,15 @@ int main(int argc, char **argv) while ((opt = getopt(argc, argv, "l:r:s:v")) > 0) { switch (opt) { case 'l': + free(level); level = strdup(optarg); break; case 'r': + free(role); role = strdup(optarg); break; case 's': + free(service); service = strdup(optarg); break; case 'v': From patchwork Mon May 3 17:53:41 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: 12236685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AA59C43460 for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1751F61244 for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbhECRzD (ORCPT ); Mon, 3 May 2021 13:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9BAC061347 for ; Mon, 3 May 2021 10:54:01 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id j28so7295333edy.9 for ; Mon, 03 May 2021 10:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YJonApMKNzdL/cbI0eBHeOHnjKGop1qXt55KgjZnRuk=; b=bE6ha8XeSYcCdNnIoT28T7LKD54kUUIudZrH/nHywKMJQSsEveLUPx9yGfN7xiT3Xm pD3lvN3cpZriyY5SY6ROAOO9dx+oe8qEsu9bR1nMgWW1O4yleSq8lyxbyZ2fv1cD+mmc +czfbtWnHT1ZkhTAGhgn3kq0Qr5bgQmI1FQNZOz6I22JrmSFIrbXQExm1DgUVa5Y92e4 vPQD6OpXpndPvkOO+1ThjEJ+RZPs58BBnf2h0BfpotpSOYcJ/mo/lSO7XyHHiA5MM6jf eue1TnBmjW5EknjTK67GD5qpxAvyoSZ82pRn7s1fq85RlB643GOb4l1Z30QTuw2DA8uv 1Rng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YJonApMKNzdL/cbI0eBHeOHnjKGop1qXt55KgjZnRuk=; b=rrGIlxx9voLREsyB0W1IlA/SnKd4Ejn86utMIPDh5iENpOkwviR1S2lG57gVzHhCHw 90KikhSmM2ar0o7XrnzNRkcwP1dfkjXd4iNF3Bv+dH2s8rWCHSgStg0GdUPAoiOUspA0 WmGw9ilXe8/NmIP1bXlbp9CEhvkZnij1N6PuiYKoPJ/6U2azqXFxpHnIl3A0hZU7jy/E J3IWUWeNtyQxAb08PGffl3ngyNvEANLnY0U0e4BbCO6pSL+kke9Am7YaYLz/6Iwuslg5 bfhzSefFYFDnvea/M/5J4SNIw+mVibUzMdOLpQwb55nsvZGfOYSRLeWCO3iTv2Hn5BuZ vMBA== X-Gm-Message-State: AOAM5306YZWUYzwDbfFUCyxVXYGek+ztzw1gtU+8gyEGwvJF6PiPxcIF Hk407sUt9AMEfGSrqXRZExyc4y6CLAELbw== X-Google-Smtp-Source: ABdhPJwO+5Iwkr0xtZwImySFdT+T7vzQKi+qvDV/tmhRhBM6Du3aXRPBbuZgbkMA2SjwSb34l/LdUQ== X-Received: by 2002:aa7:c4d0:: with SMTP id p16mr22097203edr.102.1620064440538; Mon, 03 May 2021 10:54:00 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:00 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 16/25] libselinux: store_stem(): do not free possible non-heap object Date: Mon, 3 May 2021 19:53:41 +0200 Message-Id: <20210503175350.55954-17-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org GCC 11 complains: In file included from label_file.c:24: In function ‘store_stem’, inlined from ‘load_mmap’ at label_file.c:277:12, inlined from ‘process_file’ at label_file.c:551:5: label_file.h:289:25: error: ‘free’ called on pointer ‘*mmap_area.next_addr’ with nonzero offset 4 [-Werror=free-nonheap-object] 289 | free(buf); | ^~~~~~~~~ Free the pointer on failure at the caller instead of inside `store_stem()`. Signed-off-by: Christian Göttsche --- libselinux/src/label_file.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h index baed3341..9f633701 100644 --- a/libselinux/src/label_file.h +++ b/libselinux/src/label_file.h @@ -286,7 +286,6 @@ static inline int store_stem(struct saved_data *data, char *buf, int stem_len) tmp_arr = realloc(data->stem_arr, sizeof(*tmp_arr) * alloc_stems); if (!tmp_arr) { - free(buf); return -1; } data->alloc_stems = alloc_stems; @@ -308,6 +307,7 @@ static inline int find_stem_from_spec(struct saved_data *data, const char *buf) int stem_len = get_stem_from_spec(buf); int stemid; char *stem; + int r; if (!stem_len) return -1; @@ -321,7 +321,11 @@ static inline int find_stem_from_spec(struct saved_data *data, const char *buf) if (!stem) return -1; - return store_stem(data, stem, stem_len); + r = store_stem(data, stem, stem_len); + if (r < 0) + free(stem); + + return r; } /* This will always check for buffer over-runs and either read the next entry From patchwork Mon May 3 17:53:42 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: 12236689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1DA4C433B4 for ; Mon, 3 May 2021 17:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 992906121D for ; Mon, 3 May 2021 17:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbhECRzD (ORCPT ); Mon, 3 May 2021 13:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231397AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -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 117A5C06134A for ; Mon, 3 May 2021 10:54:02 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id u13so4616284edd.3 for ; Mon, 03 May 2021 10:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MDAhyImfxXfHrVqJSjeGJs6q7MSayY6jD5V7i6hIELE=; b=uby0xI4d2puC0D0pXUPz73kfxDXYzKV4QNqNJVkfhK9abrJw+urLVmFL2qvekh+wtn lR7w76LREACJ+ynLQUIBPhv99b/ReHm9onjKL0etT3PGnYzuTR4iFVcJtCQLDuy7X4Kg qg64Nc90+uUoRc1KGWMFkHQLntLIt0sjTwBu78g35czt1mW0onoJfkBRpMITOpRXgXVr /zHg9s13UzTBSV0WgzIJ+v1anaOa2XQGth9pqFhg2neTpxV4cyhXS1X/D6oGPQx3OgkS /ak1+qyRmIJeNgGSpS+migKYSCM1KF8diEwWFd/72SiUQ2I3UQWbo4PbEoU7c/UUMo9L vkLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MDAhyImfxXfHrVqJSjeGJs6q7MSayY6jD5V7i6hIELE=; b=Dm4ZBUJvloAENtJvtdJV0lmEm5R/CgaWxieaZDwyWb3kacWwgzFtyi5i0ZQkQlbyOd rRHZcgtKY2hB8mFprdZTXWSLiU+ATum4mYikSPcOtkRbzK63KJUIKhBng4yZdyY2pDKS PQMwgFLPsl358Zur4ANxUrXHg+cTz4CwmhVUE//GcmTblr/tAAaQcjQXZS+2kc2Tm6ih ya76mpE1kUD4c/EMFf5lfShNdaCPS+t8YkQetDFsr9Z3PkoAfQha299PDyeVlxfOeh7M X6K93zxaILLcUuyuum3tbACUWQrQYOaLaeYVWKZcfiwNHISWtf7/wVjeHhvN9swg2A56 MYSw== X-Gm-Message-State: AOAM5322oiDoaGkYJoHInT+m/PcIQJ8XBt7djk4bd5sSulDe6y/i4zlv qIP6W/Hna4Xb/Zxeg2WYAmq7QGFjmBdxdw== X-Google-Smtp-Source: ABdhPJyIXj0gmYDKHFfqMOBS7iDdFT5ANCdj4nL4yZ3oPh3iv9Y1bVCLdukEa7ifJGABJ+laOFI1XA== X-Received: by 2002:a50:fc0b:: with SMTP id i11mr22086046edr.259.1620064440863; Mon, 03 May 2021 10:54:00 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:00 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 17/25] libselinux: matchmediacon(): close file on error Date: Mon, 3 May 2021 19:53:42 +0200 Message-Id: <20210503175350.55954-18-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Found by Infer. matchmediacon.c:25: error: Resource Leak resource of type `_IO_FILE` acquired to `return` by call to `fopen()` at line 21, column 16 is not released after line 25, column 4. 23. while (!feof_unlocked(infile)) { 24. if (!fgets_unlocked(current_line, sizeof(current_line), infile)) { 25. return -1; ^ 26. } 27. if (current_line[strlen(current_line) - 1]) Signed-off-by: Christian Göttsche --- libselinux/src/matchmediacon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libselinux/src/matchmediacon.c b/libselinux/src/matchmediacon.c index 23d01af4..d3d95043 100644 --- a/libselinux/src/matchmediacon.c +++ b/libselinux/src/matchmediacon.c @@ -22,6 +22,7 @@ int matchmediacon(const char *media, char ** con) return -1; while (!feof_unlocked(infile)) { if (!fgets_unlocked(current_line, sizeof(current_line), infile)) { + fclose(infile); return -1; } if (current_line[strlen(current_line) - 1]) From patchwork Mon May 3 17:53:43 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: 12236679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77D26C433ED for ; Mon, 3 May 2021 17:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DB936121D for ; Mon, 3 May 2021 17:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbhECRzC (ORCPT ); Mon, 3 May 2021 13:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231573AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E29EC061349 for ; Mon, 3 May 2021 10:54:02 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id zg3so9165256ejb.8 for ; Mon, 03 May 2021 10:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6uSO+VAXsI68QiGIglToPcJmQwH6vpV52Zwf88xDxpY=; b=SwGB2wsmGPDyre+2q+1gLPqxIQR0siJFRXle9BKhCc6UnD0uE3AcwTqfm7Eymj3nVR c2m+OTjDK6XMnNMjgim9X3K24zQm7JWQT3h+fMMKNmolVi1bw4p7DYt33PgD9WnwCthp 9xoxfI9Y5h7Al0TXDPS6yhaeJdQdr4Ij91G60pi5pc5Cp0gZLUj0OoWwJU8FG4hCqvU8 1dmomnwrL3npX1gL54DjQaIQU/CvdlP/kxwAC5wrJnOEFdCSl83XISe3J/OZNm7DFzg1 TKy4rr1qex/DFLRyJ2mvkpBh1ukOcHE+RcpFEjGOYdCbFnL75j1O6bVoL+5kZNr4H7lJ ytJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6uSO+VAXsI68QiGIglToPcJmQwH6vpV52Zwf88xDxpY=; b=U/IiBCPrVP6hzSljiUh7qhvYQQlk8DutkUUmnAhkuwDtcH4Ca451VIIkDrTX/kV1wh y6rMo0ScXrdaN4DBbhoFZP7ng+Gf8VAp89HqDgzUCmzDaHc+wriaQoiburIBNCWYCV7o Rzt9XouxB4No08IPtMgQ7cgZdilu9vHiMgO2iXKV2nnQiFCoNaUWpib1eNjC4165vrRG djRuUnKKjT0zdngBwxrH8UJX1h3rYtdvRmRj9X6okPA7vbw5I7DkGClDWJ8HF0wk5646 Qnzc2dANMo4KVB3gV9Bwj5cnTZZjAPWYQxa0yLKWnL6/XPlO4zibXEvmwUTRYuWvAVM9 9FoA== X-Gm-Message-State: AOAM533qN5tyZqQ7XZRzvkFL9i1WJmwVzQUT8f9uMr1fKgxK/vzD+PUv bqTDiZD1S9EPgh/Jev5IBC7PN7pI1bLJMg== X-Google-Smtp-Source: ABdhPJyoP3cxYPrSrOTpQ7w8qO49wG7FWwUpi9twaJpPQNAYN4e0P5ppA1zVOBru3e7njk4lwFWjFg== X-Received: by 2002:a17:907:2176:: with SMTP id rl22mr13551785ejb.155.1620064441141; Mon, 03 May 2021 10:54:01 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:00 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 18/25] libselinux: init_selinux_config(): free resources on error Date: Mon, 3 May 2021 19:53:43 +0200 Message-Id: <20210503175350.55954-19-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Found by Infer. selinux_config.c:181: error: Resource Leak resource of type `_IO_FILE` acquired by call to `fopen()` at line 165, column 7 is not released after line 181, column 6. 179. type = strdup(buf_p + sizeof(SELINUXTYPETAG) - 1); 180. if (!type) 181. return; ^ 182. end = type + strlen(type) - 1; 183. while ((end > type) && Signed-off-by: Christian Göttsche --- libselinux/src/selinux_config.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libselinux/src/selinux_config.c b/libselinux/src/selinux_config.c index 6c523895..97f81a8b 100644 --- a/libselinux/src/selinux_config.c +++ b/libselinux/src/selinux_config.c @@ -177,8 +177,11 @@ static void init_selinux_config(void) if (!strncasecmp(buf_p, SELINUXTYPETAG, sizeof(SELINUXTYPETAG) - 1)) { type = strdup(buf_p + sizeof(SELINUXTYPETAG) - 1); - if (!type) + if (!type) { + free(line_buf); + fclose(fp); return; + } end = type + strlen(type) - 1; while ((end > type) && (isspace(*end) || iscntrl(*end))) { @@ -187,6 +190,8 @@ static void init_selinux_config(void) } if (setpolicytype(type) != 0) { free(type); + free(line_buf); + fclose(fp); return; } free(type); From patchwork Mon May 3 17:53:44 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: 12236681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 811C5C4360C for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50A5A6121D for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbhECRzE (ORCPT ); Mon, 3 May 2021 13:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E9DC061761 for ; Mon, 3 May 2021 10:54:02 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id u3so9148769eja.12 for ; Mon, 03 May 2021 10:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mdTJWbH5fYeX8RUN2psmigQmLOEaN7onfXdrssOTbl8=; b=DefnVkgvUFb6yNYkv3qPK5KG7descNdJTUWrchyR2SSDl0CxLkCv1c50+MRT9z1DC1 HY8uyXNPxUfxduIBqc7vH6cOrkBGVmmFSgio2WRZKuesJ/u3AvYe3Q/Z4gPoRBR6yhiK Ls6wnHo9MlFXbDFhHfAm2g838j3I+dUQQoLpdjbwqPwq7BvUrjhgFqLJkFDn1YnJm9CU GfWrB8jHkoaTsNTqVTVUSY6jZCmUGD7wdfrC8chNJbywpcgUY3QWZ74T0+4XlEMBVzWR uJmXRq59vsa3rOuHek+6I9cKLpQFJ0pkoTZIJBmiZyPcA31kK+jzoopu3mOCgnORzxIE twqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mdTJWbH5fYeX8RUN2psmigQmLOEaN7onfXdrssOTbl8=; b=QYWdhBoMBn+QVV0RleGOZFkexBVFrP0FtNNm+hb+03UF5M5ecm1alZCyqWWTDDR2EH AeIG3ncSNW3Xci1tHPbgbqvjEY7yMMj9mUEUVAKoRf/XOrOTxKIQaeStj7HeaXav1Mja m2g1o1lUJF0Likh5zjXXf25tWdSslyU4kxdieOfFRWPtAzrdnFRp7Is09EqOJUfPLqkv BUcAkt8BrY/PklHh43iDreywNObERKDqwYzdaW4IYcXIEKNPL1fuKLXm940hNAmOLBNn p4U7ZEa/OtP1xGkKrcpYVcLjBJSs4huiRsBl/i6/YJJdkCmueHuId9RtcIL2biTufB9c +lsg== X-Gm-Message-State: AOAM533aGk3HkBPyDgTV0griG6/crYyEzxHKZq0vbmVfUAccPA7Vfq45 sBnjNIPuH/HfNdC3Uhc5kWRQjcnElryBIw== X-Google-Smtp-Source: ABdhPJzk7Up7qYkBJoW7hvAIhu8IvdTKdVvDcgiMbyOteQYINKK/hvYR97IYKtIcfFopcTKEwmg+9w== X-Received: by 2002:a17:907:3f99:: with SMTP id hr25mr14987660ejc.231.1620064441415; Mon, 03 May 2021 10:54:01 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:01 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 19/25] libselinux: label_file::init(): do not pass NULL to strdup Date: Mon, 3 May 2021 19:53:44 +0200 Message-Id: <20210503175350.55954-20-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org If any of the build flags `BUILD_HOST` or `ANDROID` is set and the caller did not pass an option of type `SELABEL_OPT_PATH`, the variable `path` might be not set. Add a check to avoid calling `strdup()` with a NULL pointer. Found by cppcheck. src/label_file.c:759:26: warning: Possible null pointer dereference: path [nullPointer] rec->spec_file = strdup(path); ^ src/label_file.c:713:21: note: Assignment 'path=NULL', assigned value is 0 const char *path = NULL; ^ src/label_file.c:759:26: note: Null pointer dereference rec->spec_file = strdup(path); ^ Signed-off-by: Christian Göttsche --- libselinux/src/label_file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c index 4d4e3a76..39a56133 100644 --- a/libselinux/src/label_file.c +++ b/libselinux/src/label_file.c @@ -756,6 +756,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, } #endif + + if (!path) + goto finish; + rec->spec_file = strdup(path); /* From patchwork Mon May 3 17:53:45 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: 12236691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A719FC43616 for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7619A61244 for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231649AbhECRzE (ORCPT ); Mon, 3 May 2021 13:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231718AbhECRy5 (ORCPT ); Mon, 3 May 2021 13:54:57 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0645EC06174A for ; Mon, 3 May 2021 10:54:03 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id u3so9148787eja.12 for ; Mon, 03 May 2021 10:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=q1c+dSkGvb+QkY/rA9tywMX6zTIRP1JVcE26G5ixBJY=; b=QuafPaT7k/34b0IClduS4aejQlUgQwugA/P39+4cNoqi5wY0kgReeL+jHTwvIEBrzm TxDTsOV7707yURYUxmi3Cfjvq3XSW1x5sSCX3zEND69iFxkvU+omhPWWAHz629OUmqnM 3yXC9Mdkxs+QyBHHr1Wu81QkMUa47D5eP1ob/+SNOae82ZCgJh3FsezRBDL26iadaDxS wN2CbhnJg0m3DrItCpNmbwFj5aO/4QLqpWAM2NahDddOmBnNVKtw32vyYhI9++4iMpNi PZWfXmZs4gspSja7SxsCQYMOOdzAYqG5ZL2oomP25GntBXDFoJwN5JYs+kyi51RdDDZp GurQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q1c+dSkGvb+QkY/rA9tywMX6zTIRP1JVcE26G5ixBJY=; b=E19DGapMuHma92P4r1V5YQ6vuhfVavq5k8raHN9bmOWnOL2EM2VX+3xQjCNutrFmtn eYlpAQ+iLnS41eczdwpXL5kUBHzfqshZHidqS8/hMtO0EDPKdGK28FYlUJCReggwHECg Ujk8v3doPMiAA/4Hz4SOnI+MZKTvoKztYaVqJDwVQPRlgLzBL1DXpmpNi+hKunl/2K1w d1gQC+h/BimGLFlSoHNArt6OTpBMP3Dzb9qJT85UwuGkiJKweMs1FrBL+Cl+DkhEycx2 YpS/3UjXT582c+TwmAbje3S6N62fmBNZjt+yLfNAuJ7qgumKIemevFdF59uHA17CmW7d DhDw== X-Gm-Message-State: AOAM5330UZF6PDh6r4a1ruxdF1LW71RCFQc9BpgO76HUE5dZbKes3s1c evUrR68wJxcnzdq0wdOV8869IO4jSwORHg== X-Google-Smtp-Source: ABdhPJw46mkbeBi12dwFkmbpQVj2HiRc2+02ic7EiKjgagytNWkAj6P3W2aU3ABDraeK0ensECXQ6w== X-Received: by 2002:a17:906:6544:: with SMTP id u4mr17828181ejn.455.1620064441746; Mon, 03 May 2021 10:54:01 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:01 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 20/25] libselinux: matchpathcon: free memory on realloc failure Date: Mon, 3 May 2021 19:53:45 +0200 Message-Id: <20210503175350.55954-21-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org In case `realloc()` fails and returns NULL, free the passed array, instead of just setting the size helper variables to 0. Also free the string contents in `free_array_elts()` of the array `con_array`, instead of just the array of pointers. Found by cppcheck. src/matchpathcon.c:86:4: error: Common realloc mistake: 'con_array' nulled but not freed upon failure [memleakOnRealloc] con_array = (char **)realloc(con_array, sizeof(char*) * ^ Signed-off-by: Christian Göttsche --- libselinux/src/matchpathcon.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libselinux/src/matchpathcon.c b/libselinux/src/matchpathcon.c index 9e1fab59..075a3fb3 100644 --- a/libselinux/src/matchpathcon.c +++ b/libselinux/src/matchpathcon.c @@ -78,17 +78,30 @@ static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_key_t destructor_key; static int destructor_key_initialized = 0; +static void free_array_elts(void) +{ + int i; + for (i = 0; i < con_array_used; i++) + free(con_array[i]); + free(con_array); + + con_array_size = con_array_used = 0; + con_array = NULL; +} + static int add_array_elt(char *con) { + char **tmp; if (con_array_size) { while (con_array_used >= con_array_size) { con_array_size *= 2; - con_array = (char **)realloc(con_array, sizeof(char*) * + tmp = (char **)realloc(con_array, sizeof(char*) * con_array_size); - if (!con_array) { - con_array_size = con_array_used = 0; + if (!tmp) { + free_array_elts(); return -1; } + con_array = tmp; } } else { con_array_size = 1000; @@ -105,13 +118,6 @@ static int add_array_elt(char *con) return con_array_used++; } -static void free_array_elts(void) -{ - con_array_size = con_array_used = 0; - free(con_array); - con_array = NULL; -} - void set_matchpathcon_invalidcon(int (*f) (const char *p, unsigned l, char *c)) { myinvalidcon = f; From patchwork Mon May 3 17:53:46 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: 12236699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE3FBC43619 for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87F8B6121D for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231609AbhECRzF (ORCPT ); Mon, 3 May 2021 13:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231738AbhECRy7 (ORCPT ); Mon, 3 May 2021 13:54:59 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DEB8C061763 for ; Mon, 3 May 2021 10:54:03 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id g14so7299147edy.6 for ; Mon, 03 May 2021 10:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2qeqi96IaIbzo+rnEBgHFQ1xj4F2X71Y0Eph2jKqL2s=; b=mLfbEd1MlvS95Qd9R6wTmXQh1iIXaOlHLyK2jeVvnOX2GhKs29L5pfdoPb2DnmH9jn tmKtdMkESzDvnVGfWHQ9HbPWrQUgr9ux25CcnUhPGtb9JGMlRPAUnQokMLT5ZLrE4zXz 10tjpou9qvn8Ilf/aAb7rxIeKcx/jMTXtPhMrKsfZX9BkNQbLKPfCAGhcm4hSo3dqnow Jwug1MJRB297vYqU+NQ0XhtChqUXHprEXL827Cg3/YX9cnbIUDf+gsuoldzjKDHoy6Pq 2Rob9dvhK45YlPnXqAgS3hpRHVuXfSwHmOhowt/+E8iK75/6mcgYGB3Za6IJjvnl7MFo kceQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2qeqi96IaIbzo+rnEBgHFQ1xj4F2X71Y0Eph2jKqL2s=; b=lONavvrRNkx6H1iCN9GwrLBa4ZG3bEzCcllmL/EizDpzCdaPiBbh7N9oyXBzo0fwKV a1+qZEWaemX3G2++nLOUjHMmV2+SeHt68dJdWyKimkkEy59OlD+8CUqS46hPdulWR/9T QoaEJGH/5eLtdb+OVyOQCdK0OEIwYgdCJWH2Lu9RAorkYcasluj0m4pjnRoJoVb0RhFn OyBm92jM41C+1OisL5tbgUKjdgmXdFLMGydWlBdr/Y8h6ANEIBb7uJyeQROnMVUv8vJG Gt1uE84LlJO+YxD8i2jjAW9HzinH6GpBf9JbZgHJI6a9HrzzbLvK5Qf3ymPehH9ItTSL 2xWQ== X-Gm-Message-State: AOAM531qFompPWyf9753o9y8of6ke1Jj0Rt3p/Fo5Yh5udvRVSTi3Gqs mQ06IQbQChLxnAin6xfcldx6NFZc7PdDcg== X-Google-Smtp-Source: ABdhPJzl55fxmO7lY9W8Zr4+o7cW/m5xB4Pn7JaPl+xft/wgfvn7Bg/7riOGNRoIkpp2tJq20p5QMg== X-Received: by 2002:a05:6402:51d4:: with SMTP id r20mr21255933edd.112.1620064442006; Mon, 03 May 2021 10:54:02 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:01 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 21/25] libselinux: label_db::db_init(): open file with CLOEXEC mode Date: Mon, 3 May 2021 19:53:46 +0200 Message-Id: <20210503175350.55954-22-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Open the file stream with the `e` flag, so that the underlying file descriptor gets closed on an exec in a potential sibling thread. Also drop the flag `b`, since it is ignored on POSIX systems. Found by clang-tidy. Signed-off-by: Christian Göttsche --- libselinux/src/label_db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libselinux/src/label_db.c b/libselinux/src/label_db.c index fba96c92..94c05c6d 100644 --- a/libselinux/src/label_db.c +++ b/libselinux/src/label_db.c @@ -277,7 +277,7 @@ db_init(const struct selinux_opt *opts, unsigned nopts, if (!path) path = selinux_sepgsql_context_path(); - if ((filp = fopen(path, "rb")) == NULL) { + if ((filp = fopen(path, "re")) == NULL) { free(catalog); return NULL; } From patchwork Mon May 3 17:53:47 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: 12236683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0EF8C43611 for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A97646121D for ; Mon, 3 May 2021 17:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231685AbhECRzE (ORCPT ); Mon, 3 May 2021 13:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbhECRy6 (ORCPT ); Mon, 3 May 2021 13:54:58 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FAE0C06138B for ; Mon, 3 May 2021 10:54:03 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id u21so9140829ejo.13 for ; Mon, 03 May 2021 10:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=nqrTybfraTNAjTXLC1JUZdvrh3NNq0lOqSzGBA1zkYk=; b=rWPsl+50lk3URvD9E9zTNLeR+K8S9re4FitTBsqeLfu/chU1wPqNPZhfOzleq/0lRi 4cngOhlSNxXGWDuAVRUcQLEi4hdVFCEfhUndLpntN8JCXJokP/ZwLX4gMArsN4Su5h3g zzsp+UXnmhnA26vTXuI/VsrAkowpd3jAR+ut4KVhoFdm1DPpMwnw5NDvzklJm+qqkNI6 FPq3+uM+E/ecJRDM801UaFqV5K+dcxsaoOUAQQudDY4VWtxBlLbbQn2RQP7qIIVN4gNg yiZs3TLjJHoVrApfBu7O30E5p5uKZT6HjauDyctZRO1Ce83WqkTe3FKOCm5xUlhmR/Vs 4CBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nqrTybfraTNAjTXLC1JUZdvrh3NNq0lOqSzGBA1zkYk=; b=MoYWKhcbOtUGG7UAv0JCdUzpFsZaOGXXv1g5TTYb4IpsmPQ+Lhyi15uCb7PKF92GKy T8ZXQNhSO2KSyKL2Glk6oEbao8ee8MR0wGf02pjXIEV40EH5+hul82XOytNwVMkeejaG d0seZ7MpxaVWuoftEcdBMOEO3wt8LyOWai75M1l/eO66MJHCWBNjKY/nhDVdIOOD+n6Y llFdP6hVpabgUy/Rx7YSFlT7iEhej7/QCcQcajwqnd1Axw94XA/QcmXZNdBvIg1oTWxq jjgGrru1mI9maaQBrHe1yVV6WQ0Kc3N+V6tDceG/Dsey1/kP854HURHU5m99otR77tob 2CfQ== X-Gm-Message-State: AOAM532Fo8Ieg60J2okaKvx72Dcn2HkE24U8fUA0E6o5M7VtYiLDRpSw oWqOP1GpTsj8BKeLU2u5Qtu8q/bGq9TQ/g== X-Google-Smtp-Source: ABdhPJxcMJgjPbxGORr8hNXnRK5ifrJA4i56X95jWNs5g3454ieQgC/CPi/4bXFx0TZdrLbjBVbucA== X-Received: by 2002:a17:907:11d1:: with SMTP id va17mr17700402ejb.485.1620064442315; Mon, 03 May 2021 10:54:02 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:02 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 22/25] libselinux: drop redundant casts to the same type Date: Mon, 3 May 2021 19:53:47 +0200 Message-Id: <20210503175350.55954-23-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Found by clang-tidy. Signed-off-by: Christian Göttsche --- libselinux/src/audit2why.c | 2 +- libselinux/src/avc_sidtab.c | 2 +- libselinux/src/is_customizable_type.c | 2 +- libselinux/src/selinux_restorecon.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libselinux/src/audit2why.c b/libselinux/src/audit2why.c index d56b56eb..029f874f 100644 --- a/libselinux/src/audit2why.c +++ b/libselinux/src/audit2why.c @@ -275,7 +275,7 @@ static int __policy_init(const char *init_path) } sepol_bool_iterate(avc->handle, avc->policydb, - load_booleans, (void *)NULL); + load_booleans, NULL); /* Initialize the sidtab for subsequent use by sepol_context_to_sid and sepol_compute_av_reason. */ diff --git a/libselinux/src/avc_sidtab.c b/libselinux/src/avc_sidtab.c index 8dc87560..8c81cf65 100644 --- a/libselinux/src/avc_sidtab.c +++ b/libselinux/src/avc_sidtab.c @@ -56,7 +56,7 @@ int sidtab_insert(struct sidtab *s, const char * ctx) rc = -1; goto out; } - newctx = (char *) strdup(ctx); + newctx = strdup(ctx); if (!newctx) { rc = -1; avc_free(newnode); diff --git a/libselinux/src/is_customizable_type.c b/libselinux/src/is_customizable_type.c index 92876f4d..1b17860c 100644 --- a/libselinux/src/is_customizable_type.c +++ b/libselinux/src/is_customizable_type.c @@ -38,7 +38,7 @@ static int get_customizable_type_list(char *** retlist) while (fgets_unlocked(buf, selinux_page_size, fp) && i < ctr) { buf[strlen(buf) - 1] = 0; - list[i] = (char *) strdup(buf); + list[i] = strdup(buf); if (!list[i]) { unsigned int j; for (j = 0; j < i; j++) diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c index 6fb9e1ff..999aa924 100644 --- a/libselinux/src/selinux_restorecon.c +++ b/libselinux/src/selinux_restorecon.c @@ -1152,7 +1152,7 @@ void selinux_restorecon_set_sehandle(struct selabel_handle *hndl) unsigned char *fc_digest; size_t num_specfiles, fc_digest_len; - fc_sehandle = (struct selabel_handle *) hndl; + fc_sehandle = hndl; if (!fc_sehandle) return; From patchwork Mon May 3 17:53:48 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: 12236695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 346E7C43617 for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10E6E6121D for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231622AbhECRzE (ORCPT ); Mon, 3 May 2021 13:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbhECRy6 (ORCPT ); Mon, 3 May 2021 13:54:58 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 419EEC06134B for ; Mon, 3 May 2021 10:54:04 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id u3so9148837eja.12 for ; Mon, 03 May 2021 10:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QzQumgOJmDZxWmsBJ+ObYe9igAM8BCQXhoezYQw89vI=; b=L1RW0onlI7NIRF1IucZ7QxZhqULN3+W+MIoAlXfeD6eVJ+Pkw5anYbCx62aFLATi2F JxLK42s14LEcSFhHukkbYoDhm+ZgsHCkXXVJUcvtZuQmm3yLpHNWr6CATJf+Lj8XFC0d aGg/k5oH23BChWr6itzaulRdPSGfkGjwJUq8M9JfizOUEaTJlKyBu967iM/ZbOJz7AEd 1q4ZjDVl6CbyJ6SPM9Zn4VwMkaDKz+Y6rlzKRICrm7H89Duqfvo06APq1gR1YuydJFyX D562PzsfW16M2x986V3i4pDePnYUEIFw6LrdJkW2+OvoRBNGWnLWjcFxWm3Uu2h4DIzv dnFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QzQumgOJmDZxWmsBJ+ObYe9igAM8BCQXhoezYQw89vI=; b=D8Wqc1mGo2ntFG0ywV0uw+qwRDivpbT66Sy0oGPk9otiGQ6HgeRKV+r6f5+BtHupbm 3A7k08SlcrkxMklZUaF8WYAZjtvwNf8GpKMq+HHt7ZdYlwx1KU8gHY+NhcxodSVugkPz g9Ul99KtwXW0QgalrYNA+7xPhytf4XGIEuAwlejAMzlckAopR1fKzeFxm4u4HpJdpmes ios/y2yw6NBE5ETUACtNilrTMMfqp/5z/7mHB9YjlmzMIhd87STNwQogLdubiggwvKNx hv86XLoEaY8uGyrHyMzvrMzthByUHdRJlkVUIHRcWSpIPiYIOiP7n3XLDYhixBZ2KbqI L2Bg== X-Gm-Message-State: AOAM530vAPbu6/ZBGl3Sf/EjOVz+Yz8zAgjE3AjXy6TLU+irJC0CeTzr VrPfPc2yzWU/XGfe07qhHi3kYhN1/Me6MA== X-Google-Smtp-Source: ABdhPJyXhj9Hf6wH4UaSUkmGKnMlL1o+xXolKAPVDzUrZSxdYH/HsZ6Xu8B49U6aVlLJUhX/jQxlTg== X-Received: by 2002:a17:906:13c9:: with SMTP id g9mr18106296ejc.69.1620064442604; Mon, 03 May 2021 10:54:02 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:02 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 23/25] libselinux: sidtab_sid_stats(): unify parameter name Date: Mon, 3 May 2021 19:53:48 +0200 Message-Id: <20210503175350.55954-24-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Found by clang-tidy. libselinux/src/avc_sidtab.h:32:6: warning: function 'sidtab_sid_stats' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name] void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) ; ^ libselinux/src/avc_sidtab.c:103:6: note: the definition seen here void sidtab_sid_stats(struct sidtab *h, char *buf, int buflen) ^ libselinux/src/avc_sidtab.h:32:6: note: differing parameters are named here: ('s'), in definition: ('h') void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) ; ^ ~ h Signed-off-by: Christian Göttsche --- libselinux/src/avc_sidtab.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libselinux/src/avc_sidtab.c b/libselinux/src/avc_sidtab.c index 8c81cf65..f179d855 100644 --- a/libselinux/src/avc_sidtab.c +++ b/libselinux/src/avc_sidtab.c @@ -100,7 +100,7 @@ sidtab_context_to_sid(struct sidtab *s, return rc; } -void sidtab_sid_stats(struct sidtab *h, char *buf, int buflen) +void sidtab_sid_stats(struct sidtab *s, char *buf, int buflen) { int i, chain_len, slots_used, max_chain_len; struct sidtab_node *cur; @@ -108,7 +108,7 @@ void sidtab_sid_stats(struct sidtab *h, char *buf, int buflen) slots_used = 0; max_chain_len = 0; for (i = 0; i < SIDTAB_SIZE; i++) { - cur = h->htable[i]; + cur = s->htable[i]; if (cur) { slots_used++; chain_len = 0; @@ -124,7 +124,7 @@ void sidtab_sid_stats(struct sidtab *h, char *buf, int buflen) snprintf(buf, buflen, "%s: %u SID entries and %d/%d buckets used, longest " - "chain length %d\n", avc_prefix, h->nel, slots_used, + "chain length %d\n", avc_prefix, s->nel, slots_used, SIDTAB_SIZE, max_chain_len); } From patchwork Mon May 3 17:53:49 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: 12236697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9F69C4361A for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE68961244 for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231594AbhECRzF (ORCPT ); Mon, 3 May 2021 13:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231736AbhECRy7 (ORCPT ); Mon, 3 May 2021 13:54:59 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13097C06138C for ; Mon, 3 May 2021 10:54:04 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id gx5so9154377ejb.11 for ; Mon, 03 May 2021 10:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vio2xh7NH/IqS63KvGAdagJdOQONzhZvJd0dIjpP+hw=; b=fCN3WE9/hLzXS3bQp3S0jh6N68vTZ+VvBXDCt/+Ub6SkxwsGh6XMrVnz3aclIOQULe Vm1/claM7wpc6nG4P2f4ttNnFG++fqZ6/jyN6urbR73aYwxXwm/cYt5mjCXKai6TYdgo 0x2twvEqotBy3GwfileIt4Zp1VJ2P2p2brAfmNNSas6/KlhiF19DEfk7urg6R2VSynh2 XKbytFcUSbu4ZUw9CShnPYtCHmayErJFTJptwOAs0bJNBdsmIsXEOwW142Q7zhszS16P tcurHzDs4wREB+AsWqxzIRvUZ3+joYYczuEn7vYIxytUxqbge3zN6nF/Zaq4UXnkHi6t hJXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vio2xh7NH/IqS63KvGAdagJdOQONzhZvJd0dIjpP+hw=; b=un855IAV7ysBfjJ3iZhDoO/RRZG9XMahNT24+2KWDc5CFLT1oDytDaKXvjjCjz9zPU 0IRmOzQQfkmj4fAx8X/G0PoGeNC5X2aDDLzINa6qclMyDbji+TVoMn4MSDwG00671vYJ GHH4gKcNep3ZN5gL2unWbc9Rk8ZOThITDqls399jYsaK6VtdKmyx3XbQIJo/a0LUrkVC amnebCEddU1oTUpsLBQdbWduOG0cFYo+RjXxCsYgyVV7Pb6tyznWAoRN9fKCn4x/QT/e tsicFnHg6sKdg3camgBQGCYYEJq0NgVfKh0knaNeIOHEzLOmpBXvmFHcsjUmlwO0s9hN w0eQ== X-Gm-Message-State: AOAM530N7qZoTGqoayV7+OJ8zrf8rtqjPqhjZij2Ux5EfpaZhyuQVPzQ YYmaNRJmfWuUiwUc9nTGS1+13IF+vWPIPw== X-Google-Smtp-Source: ABdhPJx6aLcrym+AcoSNYSM7lRTZg2k0u7vWA2tURQ/5WPLvDmvWPjQlhXV+bJHrmWTkDDtjD4k5Jg== X-Received: by 2002:a17:906:e88:: with SMTP id p8mr16984584ejf.31.1620064442865; Mon, 03 May 2021 10:54:02 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:02 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 24/25] libselinux: regex: unify parameter names Date: Mon, 3 May 2021 19:53:49 +0200 Message-Id: <20210503175350.55954-25-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Use the same parameter names as in the header `regex.h`. Found by clang-tidy. Signed-off-by: Christian Göttsche --- libselinux/src/regex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libselinux/src/regex.c b/libselinux/src/regex.c index 770bc3ea..73987d9f 100644 --- a/libselinux/src/regex.c +++ b/libselinux/src/regex.c @@ -319,7 +319,7 @@ char const *regex_version(void) } int regex_load_mmap(struct mmap_area *mmap_area, struct regex_data **regex, - int unused __attribute__((unused)), bool *regex_compiled) + int do_load_precompregex __attribute__((unused)), bool *regex_compiled) { int rc; uint32_t entry_len; @@ -387,7 +387,7 @@ static inline pcre_extra *get_pcre_extra(struct regex_data *regex) } int regex_writef(struct regex_data *regex, FILE *fp, - int unused __attribute__((unused))) + int do_write_precompregex __attribute__((unused))) { int rc; size_t len; From patchwork Mon May 3 17:53:50 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: 12236693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F56BC43618 for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A1EF61244 for ; Mon, 3 May 2021 17:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbhECRzF (ORCPT ); Mon, 3 May 2021 13:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbhECRy6 (ORCPT ); Mon, 3 May 2021 13:54:58 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63363C06138E for ; Mon, 3 May 2021 10:54:04 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id t4so9234689ejo.0 for ; Mon, 03 May 2021 10:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=osNyx1FIPkAa/wFyAagZJAoLCmCuby1zL1yHhVFkfCs=; b=gsXqDDEFNKBAVxaFOgzGZrkd0qe/K7CP/tO7YMBdzAv5Ul1OxrOHXP4FQjIzxILU0N txtzxKmNBApvkAiEgffdUJMZ6SEe42sheF+291Ng2pqcv324SoAmowqRJQFpB0d/LsCS q1zynCFkxw3yJsClP4cu0v/QKhbpXRGWpK4Y21bKeSp/LmX/Quf7Hhyer+QGe+eKBTkX EDXL4WMwSBlYgY6p7kRdEW+SUwSKSFxMQYgRjPWaiGOGqBzZ3EncR7SzvyiiqzgDV2sN NZF7oSHld+QwnZ6aRBjt4KewJ7sbXTS6hqUc4BnKzc/hmyLSSY/ay+rtXL97KIMvt00Y /tkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=osNyx1FIPkAa/wFyAagZJAoLCmCuby1zL1yHhVFkfCs=; b=It4n4prDsrSlh35XAmJ3sWVnJWbtnAWKcOUCH5FmQmqRqXIiDQGhxA8bUc+4uGW187 0jQ6RiVXxVsc1sNpICzt6f8OirfLsx2QB2gv6I6odyYsxlA4hlF5HSsMJvo7Iunkiz/W aKDjVHYDJiD88xwO+aOkePkHUsvUUuGQuKkRRljUnPliPnnQUX9Emkdf/kqbyPRbFdX7 yckvTVo+R4M077FfTDAqzJN4MoWI1PHNC8j3W4brow0/sAOayWd+2mXJH1TLp3pOylGf qGDjYWj3qXgy4sSpmc6cDnSXlRHOsnl6GiOuvpMS6+iN0N2D/ha/yKjNey89+lC56Sxj kBPA== X-Gm-Message-State: AOAM532fCFX7PyfrPF88zNObSMkzlnxw09k5BzhjlBwC1kW59uYfTm6H c7oioN1GGqQna8wuWgrXtnx26CGS6lFQtg== X-Google-Smtp-Source: ABdhPJxrpzPK/jYeD00MY/B5EC640O4PyixwZe7fj7W0TgnP6B6IsAO0xmIZ33yIskKZChJtm3eHYA== X-Received: by 2002:a17:907:3342:: with SMTP id yr2mr18133267ejb.325.1620064443137; Mon, 03 May 2021 10:54:03 -0700 (PDT) Received: from debianHome.localdomain (dynamic-077-000-172-037.77.0.pool.telefonica.de. [77.0.172.37]) by smtp.gmail.com with ESMTPSA id b17sm1830165edr.80.2021.05.03.10.54.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 10:54:03 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [PATCH 25/25] libselinux: label_file.c: fix indent Date: Mon, 3 May 2021 19:53:50 +0200 Message-Id: <20210503175350.55954-26-cgzones@googlemail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503175350.55954-1-cgzones@googlemail.com> References: <20210503175350.55954-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Found by clang-tidy. libselinux/src/label_file.c:374:4: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation] else ^ Signed-off-by: Christian Göttsche --- libselinux/src/label_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c index 39a56133..8139b38c 100644 --- a/libselinux/src/label_file.c +++ b/libselinux/src/label_file.c @@ -371,7 +371,7 @@ end_arch_check: if (stem_id < 0 || stem_id >= (int32_t)stem_map_len) spec->stem_id = -1; - else + else spec->stem_id = stem_map[stem_id]; /* retrieve the hasMetaChars bit */