mirror of
https://github.com/torvalds/linux.git
synced 2026-05-13 00:28:54 +02:00
On 32-bit architectures, unsigned long is only 32 bits wide, which causes 64-bit inode numbers to be silently truncated. Several filesystems (NFS, XFS, BTRFS, etc.) can generate inode numbers that exceed 32 bits, and this truncation can lead to inode number collisions and other subtle bugs on 32-bit systems. Change the type of inode->i_ino from unsigned long to u64 to ensure that inode numbers are always represented as 64-bit values regardless of architecture. Update all format specifiers treewide from %lu/%lx to %llu/%llx to match the new type, along with corresponding local variable types. This is the bulk treewide conversion. Earlier patches in this series handled trace events separately to allow trace field reordering for better struct packing on 32-bit. Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260304-iino-u64-v3-12-2257ad83d372@kernel.org Acked-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* fs-verity module initialization and logging
|
|
*
|
|
* Copyright 2019 Google LLC
|
|
*/
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
#include "fsverity_private.h"
|
|
|
|
#include <linux/ratelimit.h>
|
|
|
|
#ifdef CONFIG_SYSCTL
|
|
static const struct ctl_table fsverity_sysctl_table[] = {
|
|
#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
|
|
{
|
|
.procname = "require_signatures",
|
|
.data = &fsverity_require_signatures,
|
|
.maxlen = sizeof(int),
|
|
.mode = 0644,
|
|
.proc_handler = proc_dointvec_minmax,
|
|
.extra1 = SYSCTL_ZERO,
|
|
.extra2 = SYSCTL_ONE,
|
|
},
|
|
#endif
|
|
};
|
|
|
|
static void __init fsverity_init_sysctl(void)
|
|
{
|
|
register_sysctl_init("fs/verity", fsverity_sysctl_table);
|
|
}
|
|
#else /* CONFIG_SYSCTL */
|
|
static inline void fsverity_init_sysctl(void)
|
|
{
|
|
}
|
|
#endif /* !CONFIG_SYSCTL */
|
|
|
|
void fsverity_msg(const struct inode *inode, const char *level,
|
|
const char *fmt, ...)
|
|
{
|
|
static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
|
|
DEFAULT_RATELIMIT_BURST);
|
|
struct va_format vaf;
|
|
va_list args;
|
|
|
|
if (!__ratelimit(&rs))
|
|
return;
|
|
|
|
va_start(args, fmt);
|
|
vaf.fmt = fmt;
|
|
vaf.va = &args;
|
|
if (inode)
|
|
printk("%sfs-verity (%s, inode %llu): %pV\n",
|
|
level, inode->i_sb->s_id, inode->i_ino, &vaf);
|
|
else
|
|
printk("%sfs-verity: %pV\n", level, &vaf);
|
|
va_end(args);
|
|
}
|
|
|
|
static int __init fsverity_init(void)
|
|
{
|
|
fsverity_check_hash_algs();
|
|
fsverity_init_info_cache();
|
|
fsverity_init_workqueue();
|
|
fsverity_init_sysctl();
|
|
fsverity_init_signature();
|
|
fsverity_init_bpf();
|
|
return 0;
|
|
}
|
|
late_initcall(fsverity_init)
|