Skip to content

Commit

Permalink
selinux: use int arrays for boolean values
Browse files Browse the repository at this point in the history
Do not cast pointers of signed integers to pointers of unsigned integers
and vice versa.

It should currently not be an issue since they hold SELinux boolean
values which should only contain either 0's or 1's, which should have
the same representation.

Reported by sparse:

  .../selinuxfs.c:1485:30: warning: incorrect type in assignment
                                    (different signedness)
  .../selinuxfs.c:1485:30:    expected unsigned int *
  .../selinuxfs.c:1485:30:    got int *[addressable] values
  .../selinuxfs.c:1402:48: warning: incorrect type in argument 3
                                    (different signedness)
  .../selinuxfs.c:1402:48:    expected int *values
  .../selinuxfs.c:1402:48:    got unsigned int *bool_pending_values

Signed-off-by: Christian Göttsche <[email protected]>
[PM: minor whitespace fixes, sparse output cleanup]
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
cgzones authored and pcmoore committed Aug 30, 2022
1 parent 5698f08 commit c3fae2b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions security/selinux/selinuxfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct selinux_fs_info {
struct dentry *bool_dir;
unsigned int bool_num;
char **bool_pending_names;
unsigned int *bool_pending_values;
int *bool_pending_values;
struct dentry *class_dir;
unsigned long last_class_ino;
bool policy_opened;
Expand Down Expand Up @@ -356,7 +356,7 @@ static const struct file_operations sel_policyvers_ops = {
/* declaration for sel_write_load */
static int sel_make_bools(struct selinux_policy *newpolicy, struct dentry *bool_dir,
unsigned int *bool_num, char ***bool_pending_names,
unsigned int **bool_pending_values);
int **bool_pending_values);
static int sel_make_classes(struct selinux_policy *newpolicy,
struct dentry *class_dir,
unsigned long *last_class_ino);
Expand Down Expand Up @@ -527,7 +527,7 @@ static const struct file_operations sel_policy_ops = {
};

static void sel_remove_old_bool_data(unsigned int bool_num, char **bool_names,
unsigned int *bool_values)
int *bool_values)
{
u32 i;

Expand All @@ -545,7 +545,7 @@ static int sel_make_policy_nodes(struct selinux_fs_info *fsi,
struct dentry *tmp_parent, *tmp_bool_dir, *tmp_class_dir, *old_dentry;
unsigned int tmp_bool_num, old_bool_num;
char **tmp_bool_names, **old_bool_names;
unsigned int *tmp_bool_values, *old_bool_values;
int *tmp_bool_values, *old_bool_values;
unsigned long tmp_ino = fsi->last_ino; /* Don't increment last_ino in this function */

tmp_parent = sel_make_disconnected_dir(fsi->sb, &tmp_ino);
Expand Down Expand Up @@ -1423,7 +1423,7 @@ static void sel_remove_entries(struct dentry *de)

static int sel_make_bools(struct selinux_policy *newpolicy, struct dentry *bool_dir,
unsigned int *bool_num, char ***bool_pending_names,
unsigned int **bool_pending_values)
int **bool_pending_values)
{
int ret;
ssize_t len;
Expand Down

0 comments on commit c3fae2b

Please sign in to comment.