]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tomoyo: use u64 for holding inode->i_ino value
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tue, 14 Apr 2026 15:00:10 +0000 (00:00 +0900)
committerTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tue, 14 Apr 2026 15:00:10 +0000 (00:00 +0900)
TOMOYO is treating numeric fields (including inode->i_ino) as "unsigned
long". Now that commit 0b2600f81cef ("treewide: change inode->i_ino from
unsigned long to u64") went upstream, update affected portions in TOMOYO.

While an administrator might write a rule that compares inode->i_ino with
an immediate value, this patch changes type of variable for inode->i_ino
to "u64" but does not change type of variable for the corresponding
immediate value to "u64" due to the following reasons.

  It is likely that rules that compare inode->i_ino are for testing whether
  the directories involved in e.g. rename() operation are the same (i.e.
  comparison between two inode->i_ino values rather than one inode->i_ino
  value and one immediate value).

  It unlikely makes sense to compare inode->i_ino with an immediate value
  larger than UINT_MAX.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
security/tomoyo/audit.c
security/tomoyo/common.h
security/tomoyo/condition.c

index bfacb3f2e2ed84cc5eccdaa2f3252d59b0a75ff0..1fba46aa357a7b2b3171a4fcf7383a8dc8895ab5 100644 (file)
@@ -195,21 +195,19 @@ static char *tomoyo_print_header(struct tomoyo_request_info *r)
                if (i & 1) {
                        pos += snprintf(buffer + pos,
                                        tomoyo_buffer_len - 1 - pos,
-                                       " path%u.parent={ uid=%u gid=%u ino=%lu perm=0%o }",
+                                       " path%u.parent={ uid=%u gid=%u ino=%llu perm=0%o }",
                                        (i >> 1) + 1,
                                        from_kuid(&init_user_ns, stat->uid),
                                        from_kgid(&init_user_ns, stat->gid),
-                                       (unsigned long)stat->ino,
-                                       stat->mode & S_IALLUGO);
+                                       stat->ino, stat->mode & S_IALLUGO);
                        continue;
                }
                pos += snprintf(buffer + pos, tomoyo_buffer_len - 1 - pos,
-                               " path%u={ uid=%u gid=%u ino=%lu major=%u minor=%u perm=0%o type=%s",
+                               " path%u={ uid=%u gid=%u ino=%llu major=%u minor=%u perm=0%o type=%s",
                                (i >> 1) + 1,
                                from_kuid(&init_user_ns, stat->uid),
                                from_kgid(&init_user_ns, stat->gid),
-                               (unsigned long)stat->ino,
-                               MAJOR(dev), MINOR(dev),
+                               stat->ino, MAJOR(dev), MINOR(dev),
                                mode & S_IALLUGO, tomoyo_filetype(mode));
                if (S_ISCHR(mode) || S_ISBLK(mode)) {
                        dev = stat->rdev;
index 4f1704c911ef4597fea4ba2cc61a3401b673ae8f..d098cf8aae610900be44110877534b5309d0e771 100644 (file)
@@ -567,7 +567,7 @@ struct tomoyo_address_group {
 struct tomoyo_mini_stat {
        kuid_t uid;
        kgid_t gid;
-       ino_t ino;
+       u64 ino;
        umode_t mode;
        dev_t dev;
        dev_t rdev;
index f8bcc083bb0deca628904ced658febffa73f9014..8b107b1ffdab3a13998ab50bdd8a9b5dadcdff22 100644 (file)
@@ -766,8 +766,8 @@ bool tomoyo_condition(struct tomoyo_request_info *r,
                      const struct tomoyo_condition *cond)
 {
        u32 i;
-       unsigned long min_v[2] = { 0, 0 };
-       unsigned long max_v[2] = { 0, 0 };
+       u64 min_v[2] = { 0, 0 };
+       u64 max_v[2] = { 0, 0 };
        const struct tomoyo_condition_element *condp;
        const struct tomoyo_number_union *numbers_p;
        const struct tomoyo_name_union *names_p;
@@ -834,7 +834,7 @@ bool tomoyo_condition(struct tomoyo_request_info *r,
                /* Check numeric or bit-op expressions. */
                for (j = 0; j < 2; j++) {
                        const u8 index = j ? right : left;
-                       unsigned long value = 0;
+                       u64 value = 0;
 
                        switch (index) {
                        case TOMOYO_TASK_UID: