diff options
| author | YouYou Yu <youyouyu@amazon.com> | 2026-10-21 18:12:17 +0000 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2026-10-26 14:19:20 +0100 |
| commit | e21a6f39aa6d0336ffbf5f34e5fa20ff8de36773 (patch) | |
| tree | 789b44fd43622b93ca58750e577e4b683da2220e /include | |
| parent | 49f771d14578733a350c45e34e1bc6ad14f56952 (diff) | |
quota: initialize dquot cache before mounting rootfs
On some systems, a tmpfs backed rootfs is extensively used throughout
system's lifecycle. tmpfs quotas are needed to limit per user rootfs
usage. However, booting with CONFIG_TMPFS_QUOTA=y, an initramfs, no root=
and "initramfs_options=usrquota" panics at boot:
BUG: kernel NULL pointer dereference, address: 0000000000000000
RIP: 0010:dqget+0x1ac/0x490
Call Trace:
__dquot_initialize
dquot_initialize
shmem_get_inode
shmem_fill_super
...
mnt_init
vfs_caches_init
start_kernel
The rootfs is mounted from mnt_init(), but the dquot hash table and
cache are only set up later by dquot_init(), an fs_initcall. Creating
the root inode of a quota enabled rootfs thus dereferences the NULL
dquot_hash in dqget().
Rename dquot_init() to dquot_cache_init() and call it from
vfs_caches_init() before mnt_init(). The slab, percpu and early
workqueue code it relies on is available there, and the workqueue
rescuer and shrinker debugfs entries are set up later by their own
subsystems. Keep the sysctl registration in an fs_initcall, as done
for the dcache, inode and mount sysctls. This only moves existing
allocations earlier in boot.
Fixes: 278033a225e1 ("fs: Add 'initramfs_options' to set initramfs mount options")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Co-developed-by: Dylan Johnson <dgj@amazon.com>
Signed-off-by: Dylan Johnson <dgj@amazon.com>
Signed-off-by: YouYou Yu <youyouyu@amazon.com>
Reviewed-by: Gunnar Kudrjavets <gunnarku@amazon.com>
Link: https://patch.msgid.link/20261021181217.20171-1-youyouyu@amazon.com
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/quotaops.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 0c64ca674e77..7346efc85d43 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -40,6 +40,7 @@ void __quota_error(struct super_block *sb, const char *func, /* * declaration of quota_function calls in kernel. */ +void dquot_cache_init(void); int dquot_initialize(struct inode *inode); bool dquot_initialize_needed(struct inode *inode); void dquot_drop(struct inode *inode); @@ -206,6 +207,10 @@ static inline int sb_has_quota_active(struct super_block *sb, int type) return 0; } +static inline void dquot_cache_init(void) +{ +} + static inline int dquot_initialize(struct inode *inode) { return 0; |
