Skip to content

Commit 8fc1ad9

Browse files
Tetsuo HandaTetsuo Handa
authored andcommitted
tomoyo: use u64 for holding inode->i_ino value
TOMOYO is treating numeric fields (including inode->i_ino) as "unsigned long". Now that commit 0b2600f ("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 <[email protected]>
1 parent 028ef9c commit 8fc1ad9

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

security/tomoyo/audit.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,19 @@ static char *tomoyo_print_header(struct tomoyo_request_info *r)
195195
if (i & 1) {
196196
pos += snprintf(buffer + pos,
197197
tomoyo_buffer_len - 1 - pos,
198-
" path%u.parent={ uid=%u gid=%u ino=%lu perm=0%o }",
198+
" path%u.parent={ uid=%u gid=%u ino=%llu perm=0%o }",
199199
(i >> 1) + 1,
200200
from_kuid(&init_user_ns, stat->uid),
201201
from_kgid(&init_user_ns, stat->gid),
202-
(unsigned long)stat->ino,
203-
stat->mode & S_IALLUGO);
202+
stat->ino, stat->mode & S_IALLUGO);
204203
continue;
205204
}
206205
pos += snprintf(buffer + pos, tomoyo_buffer_len - 1 - pos,
207-
" path%u={ uid=%u gid=%u ino=%lu major=%u minor=%u perm=0%o type=%s",
206+
" path%u={ uid=%u gid=%u ino=%llu major=%u minor=%u perm=0%o type=%s",
208207
(i >> 1) + 1,
209208
from_kuid(&init_user_ns, stat->uid),
210209
from_kgid(&init_user_ns, stat->gid),
211-
(unsigned long)stat->ino,
212-
MAJOR(dev), MINOR(dev),
210+
stat->ino, MAJOR(dev), MINOR(dev),
213211
mode & S_IALLUGO, tomoyo_filetype(mode));
214212
if (S_ISCHR(mode) || S_ISBLK(mode)) {
215213
dev = stat->rdev;

security/tomoyo/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ struct tomoyo_address_group {
567567
struct tomoyo_mini_stat {
568568
kuid_t uid;
569569
kgid_t gid;
570-
ino_t ino;
570+
u64 ino;
571571
umode_t mode;
572572
dev_t dev;
573573
dev_t rdev;

security/tomoyo/condition.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ bool tomoyo_condition(struct tomoyo_request_info *r,
766766
const struct tomoyo_condition *cond)
767767
{
768768
u32 i;
769-
unsigned long min_v[2] = { 0, 0 };
770-
unsigned long max_v[2] = { 0, 0 };
769+
u64 min_v[2] = { 0, 0 };
770+
u64 max_v[2] = { 0, 0 };
771771
const struct tomoyo_condition_element *condp;
772772
const struct tomoyo_number_union *numbers_p;
773773
const struct tomoyo_name_union *names_p;
@@ -834,7 +834,7 @@ bool tomoyo_condition(struct tomoyo_request_info *r,
834834
/* Check numeric or bit-op expressions. */
835835
for (j = 0; j < 2; j++) {
836836
const u8 index = j ? right : left;
837-
unsigned long value = 0;
837+
u64 value = 0;
838838

839839
switch (index) {
840840
case TOMOYO_TASK_UID:

0 commit comments

Comments
 (0)