From patchwork Mon Aug 7 17:11:39 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: 132322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1644291vqr; Mon, 7 Aug 2023 11:53:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnmwyWLR7RBY67znCJJ1nIlhCI80pJuvewmiOminOBm1fJ0+GEH/sEJEfoZB+3m7bIb5tU X-Received: by 2002:a17:906:76d4:b0:99c:75f7:19c1 with SMTP id q20-20020a17090676d400b0099c75f719c1mr8012134ejn.39.1691434430374; Mon, 07 Aug 2023 11:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691434430; cv=none; d=google.com; s=arc-20160816; b=QaQ70iEDvgUTsNQCGH6BqnzMgpsGjg6BYdtKR3rNIo87DN01DCqSXrhrwyRgDDvzDm QM5AA+5TfMPhp9jyiG9yt4nDw+DhR4PhTdLuQcWHbLE520TzkTJir3vMVSdmxqYwT9Jn hhcPw7VjQ4fqpWLvgkYQoofXroA4nzRMaGM2tE3bIA8xxnxjypBYvJIon9p90hJn1E/Z w3K7EuaN55JM4pe+4HFzDNoTsGM+PTePrx9NOxtqt8Fho8baFjUs77MFuExcUHKDgzuh tgeDv1DNDecaYys7DaFWgQ58iQFr9rDjB5hnPfZcekg80R+XxoevBlWfGQUW/uixUNTI /ceQ== 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=n++x1VyupiNA1jLZvucgYL91izWJdNor+dndheNguCo=; fh=QKur2PFwoLuCt27JzfZM4LabS9ldoGoSAJNPH9t/KWI=; b=WBieyc4wE48tgrpNvvr+Hd3h3kHLp4Jwg5gOq6lA5iUC8QugiYBXcSYNjjNs8Yu79+ LiBSQ9uNc8s6DFsY3M3FWeFYrWgv6CjgObshbgfQoJjZQBXytW6dc66GhSrLxfq8PxUJ p3fj7H59IgVSt9BrOFuE8vaVdRRr8iRF4A06vU8dyccg/v5ztq0VaDwLDDKPL6omLNiO hscZvSVAX96MIq4ozwbh2fDPwDR6Zcg96uch2lBECBzZRvASMzMGxmAmJdSjf3H9ghu7 6J47HmPKgpEzFrn6lI7g/0g5bMAxfEs81BEcggdq0FKpRRqV3suZ7Chb3ksF+RoGFBj3 7C/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20221208 header.b=W9Rx6Eoz; 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 t22-20020a17090605d600b00992c3b85acbsi6270558ejt.128.2023.08.07.11.53.26; Mon, 07 Aug 2023 11:53:50 -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=W9Rx6Eoz; 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 S231971AbjHGRMD (ORCPT + 99 others); Mon, 7 Aug 2023 13:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbjHGRL6 (ORCPT ); Mon, 7 Aug 2023 13:11:58 -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 071821A3; Mon, 7 Aug 2023 10:11:57 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-52222562f1eso6588859a12.3; Mon, 07 Aug 2023 10:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20221208; t=1691428315; x=1692033115; 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=n++x1VyupiNA1jLZvucgYL91izWJdNor+dndheNguCo=; b=W9Rx6EozIRNL2uZal/Q25+X+xyX9WQ88IheKymL4vdDvOWHBLHyCkkkDKq/+5tZXh1 fY24hvgjUggAzq1XcWKgw3U97gJMnxgmWA9mIU6hGlu0RP+QDyeB2S7ZjDA8p4PVg4Ab PZYvBukK2p5Qqfio/Wj1oiS1+moack1GwTjQ2liT8a2ygSlFANPEZxxGKPyeJIxfDrnT YC83t9RRrUoIBe+BBLSZExpmufDAw/So2rEVMkpHNEnBjqGTnAtheiYwRQHZBtZysBK1 3L8EbDc8YyJfLVKPmUctI0TEDv/k8AwEBxmUcTuBTZe/C74vQ5hq7DznahUfvRUYxmbP i8hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691428315; x=1692033115; 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=n++x1VyupiNA1jLZvucgYL91izWJdNor+dndheNguCo=; b=D5Y9jquOp0qYqJlom1ZzqQvcLZfJBd3nhRWF0y5XzdMX2MsHVWiFaKbgn4NoQmxe4p N1xZvv178Hr+bBzbFSdoYnyQWYo5pB0spqth2ZWoo4BiWsen+tw6qdzXL+532ndiN5E8 JO3KuAbgCOt5yNk+XwF6Z1U9ftzeCqKcPcsj5opENpK40eZaQ3AosiCf9IOLRWIRT6Nk 16D31IzCUU0Qs8CzL4bdgHPytI+VRvlMw67/tajTCletahGRuxOGqco/+tyHYHMbOBD1 LaxE/FNn61Y6TpGf1xXKZFoFAs5r69ZMhwkM9oyfzNo90JyxjlmaMQ/p2GojwHzoHv7K RKvg== X-Gm-Message-State: AOJu0YwDBgceInAhiFjABBcskjil11S/SrO2/fwro74zHqOpZ5aSH2+V Q/M8g/iaJOTMnvYEtXMkkBjl5JH7F69t2Q== X-Received: by 2002:aa7:da96:0:b0:523:38eb:395f with SMTP id q22-20020aa7da96000000b0052338eb395fmr2338743eds.2.1691428315338; Mon, 07 Aug 2023 10:11:55 -0700 (PDT) Received: from debian_development.DebianHome (dynamic-095-112-033-028.95.112.pool.telefonica.de. [95.112.33.28]) by smtp.gmail.com with ESMTPSA id e10-20020a056402148a00b005224d960e66sm5420814edv.96.2023.08.07.10.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 10:11:55 -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 v3 5/7] selinux: avoid implicit conversions in selinuxfs code Date: Mon, 7 Aug 2023 19:11:39 +0200 Message-Id: <20230807171143.208481-4-cgzones@googlemail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230807171143.208481-1-cgzones@googlemail.com> References: <20230807171143.208481-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 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: 1773597549054447690 X-GMAIL-MSGID: 1773597549054447690 Use umode_t as parameter type for sel_make_inode(), which assigns the value to the member i_mode of struct inode. Use identical and unsigned types for loop iterators. Signed-off-by: Christian Göttsche --- v3: - drop leftover declaration in init-clauses of for loops - use unsigned int instead of u32 for loop iterator with loop bounds known at compile time to be small (<100) v2: avoid declarations in init-clauses of for loops --- security/selinux/selinuxfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index b969e87fd870..107b028d5e40 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -97,7 +97,7 @@ static int selinux_fs_info_create(struct super_block *sb) static void selinux_fs_info_free(struct super_block *sb) { struct selinux_fs_info *fsi = sb->s_fs_info; - int i; + unsigned int i; if (fsi) { for (i = 0; i < fsi->bool_num; i++) @@ -1075,8 +1075,8 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size) u32 sid, *sids = NULL; ssize_t length; char *newcon; - int i, rc; - u32 len, nsids; + int rc; + u32 i, len, nsids; length = avc_has_perm(current_sid(), SECINITSID_SECURITY, SECCLASS_SECURITY, SECURITY__COMPUTE_USER, @@ -1192,7 +1192,7 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size) return length; } -static struct inode *sel_make_inode(struct super_block *sb, int mode) +static struct inode *sel_make_inode(struct super_block *sb, umode_t mode) { struct inode *ret = new_inode(sb); @@ -1613,7 +1613,7 @@ static int sel_make_avc_files(struct dentry *dir) { struct super_block *sb = dir->d_sb; struct selinux_fs_info *fsi = sb->s_fs_info; - int i; + unsigned int i; static const struct tree_descr files[] = { { "cache_threshold", &sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR }, @@ -1649,7 +1649,7 @@ static int sel_make_ss_files(struct dentry *dir) { struct super_block *sb = dir->d_sb; struct selinux_fs_info *fsi = sb->s_fs_info; - int i; + unsigned int i; static const struct tree_descr files[] = { { "sidtab_hash_stats", &sel_sidtab_hash_stats_ops, S_IRUGO }, }; @@ -1700,7 +1700,7 @@ static const struct file_operations sel_initcon_ops = { static int sel_make_initcon_files(struct dentry *dir) { - int i; + unsigned int i; for (i = 1; i <= SECINITSID_NUM; i++) { struct inode *inode;