From patchwork Fri Jul 28 15:54:54 2023 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: 127766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp578599vqg; Fri, 28 Jul 2023 10:13:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlyc1O4an4ekI6ZsL3KPXh5DwlBwQmyE/rYpu9kEPIgklxC6c1YuOPm852wJu4fX283grZ X-Received: by 2002:a17:90a:4a03:b0:264:a14:ce19 with SMTP id e3-20020a17090a4a0300b002640a14ce19mr1838944pjh.20.1690564416883; Fri, 28 Jul 2023 10:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690564416; cv=none; d=google.com; s=arc-20160816; b=V/wdvRrGy1WoWJTVSmRHE88Tre9tFmWvBiws57xI7N0dzJdfS/5VEdVCir8uhcot1h BI2MGaJinOhKzSumkBLgeVURM60KPqM7d6O5O9JrL6+9SBqOEfYZAdsn0JJ2NNY31MXB 59biHwu6QNhkl57KfymMLlYtEtgN3HfQfmNvdY6KP6pxyZ7mblr1cmeYUozzcsjS6DqA pDBZMwJf3N9GuhCPC/3qpRI1dTg4hm8mE+A9n4kf2stilfL08fMK0CJ+pGSDtycecZG/ Z3UXzT6O6RzOem8pV21pkj4b2Ee1JLy8r4BnW54OBxVx1jTojqtoYDKgbfuBNUAy9RpY cFKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Hj8EXANVUnt9bxQH+/nx3iBETrgoqthp/pWZeVRl9D8=; fh=QKur2PFwoLuCt27JzfZM4LabS9ldoGoSAJNPH9t/KWI=; b=qXnc+Jbcu9P+eADy0MA3DRIwnLoWav6fo+4tboSswrijs0SHWm2aHwajzsDv/+Px+i vnFJQ02O6macWmXElvrjJwVkR5xLhBTOSXqaqAzuR3WfTJ4dhFUi7su8Sl8N+tw79z+S 7lkRPGKAJj5x2WAFunFyS1ngWz579+Y/cpHEm2zqOA/tLLhUQ6Arzmd7aIxgaL2LJ6qW kZVBrB5G+1J8Efyb8dVS/Y5K/nY8sL//vX8vjHvu17dWyWjhfd9CC46au32zrUSpQEkC 715jen5fZbJCslIibQF9HD8h35UojpGA/EPT7qARoYskHnv7GKY/idSC+ZN2j7qP1e4k juUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20221208 header.b=lJEotxX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a17090abc0800b002685065230asi4285399pjr.37.2023.07.28.10.13.23; Fri, 28 Jul 2023 10:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20221208 header.b=lJEotxX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236919AbjG1Pzq (ORCPT + 99 others); Fri, 28 Jul 2023 11:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235836AbjG1Pza (ORCPT ); Fri, 28 Jul 2023 11:55:30 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDAF444B1; Fri, 28 Jul 2023 08:55:14 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fe2503e3easo641871e87.2; Fri, 28 Jul 2023 08:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20221208; t=1690559713; x=1691164513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hj8EXANVUnt9bxQH+/nx3iBETrgoqthp/pWZeVRl9D8=; b=lJEotxX4ThykyTKoZQKZCBYw/acPZZ4atSdyoRuShZW2/I43mCDRmqkeglAanKpIEt 5MF9aBJM/t4X+/bcmUHnhzJ5MG36wDlLuYSiqgB71dPp1/ipxcp8w+sz83iMb2uuUOuc FwYcM8KxC4EBTRGkUgcFZVZo5bYQMjemYzMmw0fgSNNGr6CnhWzVfNOeaaT756gAM31m 85VZxhu/MTx2mxVzxFT/79zMBTSQpZMWxL5WFuClAxvjZ2/GgKSRWKyUqV6QTDmCzUWH 0JqbhdjgZp73AsnE94Sz3kVw2fIYpGOi82E/3cWhgIvhEkyT3eRb2PtibfZ8ZAI3/Wtm CgYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690559713; x=1691164513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hj8EXANVUnt9bxQH+/nx3iBETrgoqthp/pWZeVRl9D8=; b=jQnpun6OMkjwNUye76r5PMmVRUGhnAlVokQQR21Fw9LA1dy+bxpUTZ+M21UnBw/jV8 Ao1nNfbId08f83VzBVR+kqA5bZ35/patGT2EKNP1KZM4KpZs+0grAP7pK8O2DRsWUT2k lALsbWp7S+KOIBVpFK7gNT2oGMyRYPuWQhOLP2dM9WhLMpSy6qkYafDwJ/889g7QdhZA +rWVA8/5IDzrGeJNmaNxPZt7Vm7d2XpCyEjiw4LZ8hcGT0RhW6yQNUiH+8bPiiGVY/v3 5LwZ3FfZNI8i91AzmV6BSe+JZ5PgFZo7CvottT+rmFbyEt+NecB+3HbfME/xQFHzIuk1 ucuA== X-Gm-Message-State: ABy/qLbwkLEelXiTFjXUijo34TwWbsfmLA9xbt7vYpU5NuO+BueawwDM QlTksjNfKc+vyNeK+kJgDMl2uwDseNy+hmpv X-Received: by 2002:a19:2d49:0:b0:4f9:7aee:8dc5 with SMTP id t9-20020a192d49000000b004f97aee8dc5mr1989307lft.19.1690559712679; Fri, 28 Jul 2023 08:55:12 -0700 (PDT) Received: from debian_development.DebianHome (dynamic-077-000-157-016.77.0.pool.telefonica.de. [77.0.157.16]) by smtp.gmail.com with ESMTPSA id f5-20020a1709064dc500b0098669cc16b2sm2198345ejw.83.2023.07.28.08.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:55:12 -0700 (PDT) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Cc: Paul Moore , Stephen Smalley , Eric Paris , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/9] selinux: avoid implicit conversions in mls code Date: Fri, 28 Jul 2023 17:54:54 +0200 Message-Id: <20230728155501.39632-3-cgzones@googlemail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728155501.39632-1-cgzones@googlemail.com> References: <20230728155501.39632-1-cgzones@googlemail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772685274093054216 X-GMAIL-MSGID: 1772685274093054216 Use u32 for ebitmap bits. Use char for the default range of a class. Signed-off-by: Christian Göttsche --- v2: avoid declarations in init-clauses of for loops --- security/selinux/ss/mls.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c index b2c6c846ea03..cd38f5913b63 100644 --- a/security/selinux/ss/mls.c +++ b/security/selinux/ss/mls.c @@ -45,7 +45,7 @@ int mls_compute_context_len(struct policydb *p, struct context *context) len = 1; /* for the beginning ":" */ for (l = 0; l < 2; l++) { - int index_sens = context->range.level[l].sens; + u32 index_sens = context->range.level[l].sens; len += strlen(sym_name(p, SYM_LEVELS, index_sens - 1)); /* categories */ @@ -240,7 +240,8 @@ int mls_context_to_sid(struct policydb *pol, char *sensitivity, *cur_cat, *next_cat, *rngptr; struct level_datum *levdatum; struct cat_datum *catdatum, *rngdatum; - int l, rc, i; + u32 i; + int l, rc; char *rangep[2]; if (!pol->mls_enabled) { @@ -451,7 +452,8 @@ int mls_convert_context(struct policydb *oldp, struct level_datum *levdatum; struct cat_datum *catdatum; struct ebitmap_node *node; - int l, i; + u32 i; + int l; if (!oldp->mls_enabled || !newp->mls_enabled) return 0; @@ -495,7 +497,7 @@ int mls_compute_sid(struct policydb *p, struct range_trans rtr; struct mls_range *r; struct class_datum *cladatum; - int default_range = 0; + char default_range = 0; if (!p->mls_enabled) return 0;