Skip to content

Commit 2e43ca1

Browse files
committed
Merge patch series "vfs: follow-on fixes for i_ino widening"
Jeff Layton <jlayton@kernel.org> says: Just some patches to fix follow-on issues reported after the inode->i_ino widening series. * patches from https://patch.msgid.link/20260316-iino-u64-v3-0-d1076b8f7a20@kernel.org: nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group() EVM: add comment describing why ino field is still unsigned long Link: https://patch.msgid.link/20260316-iino-u64-v3-0-d1076b8f7a20@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 9840bb6 + 81359c1 commit 2e43ca1

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

fs/nilfs2/bmap.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,25 @@ __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key)
450450
return NILFS_BMAP_INVALID_PTR;
451451
}
452452

453-
#define NILFS_BMAP_GROUP_DIV 8
453+
#define NILFS_BMAP_GROUP_DIV 8 /* must be power of 2 */
454+
454455
__u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *bmap)
455456
{
456457
struct inode *dat = nilfs_bmap_get_dat(bmap);
457458
unsigned long entries_per_group = nilfs_palloc_entries_per_group(dat);
458-
unsigned long group = bmap->b_inode->i_ino / entries_per_group;
459+
unsigned long group;
460+
u32 index;
461+
462+
BUILD_BUG_ON_NOT_POWER_OF_2(NILFS_BMAP_GROUP_DIV);
463+
464+
group = div_u64(bmap->b_inode->i_ino, entries_per_group);
465+
index = bmap->b_inode->i_ino & (NILFS_BMAP_GROUP_DIV - 1);
459466

460467
return group * entries_per_group +
461-
(bmap->b_inode->i_ino % NILFS_BMAP_GROUP_DIV) *
462-
(entries_per_group / NILFS_BMAP_GROUP_DIV);
468+
index * (entries_per_group / NILFS_BMAP_GROUP_DIV);
463469
}
464470

471+
465472
static struct lock_class_key nilfs_bmap_dat_lock_key;
466473
static struct lock_class_key nilfs_bmap_mdt_lock_key;
467474

security/integrity/evm/evm_crypto.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
144144
char type, char *digest)
145145
{
146146
struct h_misc {
147+
/*
148+
* Although inode->i_ino is now u64, this field remains
149+
* unsigned long to allow existing HMAC and signatures from
150+
* 32-bit hosts to continue working when i_ino hasn't changed
151+
* and fits in a u32.
152+
*/
147153
unsigned long ino;
148154
__u32 generation;
149155
uid_t uid;

0 commit comments

Comments
 (0)