[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230706132337.15924-20-cgzones@googlemail.com>
Date: Thu, 6 Jul 2023 15:23:35 +0200
From: Christian Göttsche <cgzones@...glemail.com>
To: selinux@...r.kernel.org
Cc: Paul Moore <paul@...l-moore.com>,
Stephen Smalley <stephen.smalley.work@...il.com>,
Eric Paris <eparis@...isplace.org>,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 20/20] selinux: selinuxfs: avoid implicit conversions
Use unsigned loop counters where the upper bound is of unsigned
type.
Signed-off-by: Christian Göttsche <cgzones@...glemail.com>
---
security/selinux/selinuxfs.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 88d856f5c6bc..a2dc415779ae 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1074,7 +1074,7 @@ 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;
+ int rc;
u32 len, nsids;
length = avc_has_perm(current_sid(), SECINITSID_SECURITY,
@@ -1107,7 +1107,7 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
length = sprintf(buf, "%u", nsids) + 1;
ptr = buf + length;
- for (i = 0; i < nsids; i++) {
+ for (u32 i = 0; i < nsids; i++) {
rc = security_sid_to_context(sids[i], &newcon, &len);
if (rc) {
length = rc;
@@ -1612,7 +1612,6 @@ 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;
static const struct tree_descr files[] = {
{ "cache_threshold",
&sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR },
@@ -1622,7 +1621,7 @@ static int sel_make_avc_files(struct dentry *dir)
#endif
};
- for (i = 0; i < ARRAY_SIZE(files); i++) {
+ for (u32 i = 0; i < ARRAY_SIZE(files); i++) {
struct inode *inode;
struct dentry *dentry;
@@ -1648,12 +1647,11 @@ 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;
static const struct tree_descr files[] = {
{ "sidtab_hash_stats", &sel_sidtab_hash_stats_ops, S_IRUGO },
};
- for (i = 0; i < ARRAY_SIZE(files); i++) {
+ for (u32 i = 0; i < ARRAY_SIZE(files); i++) {
struct inode *inode;
struct dentry *dentry;
@@ -1699,9 +1697,7 @@ static const struct file_operations sel_initcon_ops = {
static int sel_make_initcon_files(struct dentry *dir)
{
- int i;
-
- for (i = 1; i <= SECINITSID_NUM; i++) {
+ for (u32 i = 1; i <= SECINITSID_NUM; i++) {
struct inode *inode;
struct dentry *dentry;
const char *s = security_get_initial_sid_context(i);
--
2.40.1
Powered by blists - more mailing lists