From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795015083; b=Yz4tPVZOywdlpMOS3ZCa7tCKsQN+9efp31o8iWbhhu4eda3vLwpm79yxY6muzvGGosQ/ a6bbI9qbV2hDEpJ8p6pAtmly/Dh46Hg8eSLFCwNvRHQusO/njspg+ffVpJIQbLGa3Bh6g k+FueCG38mz9u3vLfTW4p9IBxv29NC8D8QLAS0jdCQmGUO6tWS15JtwY2pTRNPoe2AZVp rZUrPF/ggZkGy69zcyHMzaIhq+5AveAZAhoQa/1J8RHS750vOGzp5axyny15GAgfivkd8 eGqT+feW8SNAUB42ySqLUWYUAwfMYP86MxvTNviqawt+/HS7pT9k0mI+taX+bd2yT6A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795015083; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=sJMT0Qav99b9wQkm2NYEGKd+ikNpAl2ffFKhrMBDE48=; b=c0wU4ylwcKD/LFButXyUTL4hzOqIgfZxbm7PdhREQ9OYCFujHoG8c7HwmwD8VP4jivcJ GDdN5o2tdKQoceV0oiDWO1eOj+FJXAtYz/CqtE+yBgtNZ4EloHYK9R1ruqfhfIg21/AmK 4fcc7+jjdHbZER0MN1R/vVxwkukZMwBL/DA7Hcm1Li2hhIyCB1cNFYJGjOP/fUZ8R/93c a43/w3HFAv0UaB7r7w8YdSFd3G8TBAHj4HxS6VwRWdiOeL1gACmwDuTErKGpGKGx/Lpzr z1zUThHvR6KJF4AYzeK4nqH46XiZ5Ar3x85zJReGF0nghwjie3r1l1M5HBdQehNybxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=pWmRyWGl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0058D60A2609; Wed, 18 Nov 2026 15:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=pWmRyWGl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D0AC1F000C7; Wed, 18 Nov 2026 15:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795015082; bh=sJMT0Qav99b9wQkm2NYEGKd+ikNpAl2ffFKhrMBDE48=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pWmRyWGlLszHKznpp6Nq5crflqtqFEXATjQeBj4oNn2pXZrE8PIDiz/ZGjJ57PIbT 1LkMgqgPwGPpqxOXfLehO+P5TnbfXHORK1zXE0jcl6YLp4xGimk52KHwRVO7sb8k+8 YXjKO5FN1c0FscC+mSMRSq4TbT3Db7ORIe1qSWvo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dylan Johnson , YouYou Yu , Gunnar Kudrjavets , Jan Kara , Sasha Levin Subject: [PATCH 7.3 0046/2651] quota: initialize dquot cache before mounting rootfs Date: Wed, 18 Nov 2026 15:21:26 +0100 Message-ID: <20261118150249.616583513@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: YouYou Yu [ Upstream commit e21a6f39aa6d0336ffbf5f34e5fa20ff8de36773 ] 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 Signed-off-by: Dylan Johnson Signed-off-by: YouYou Yu Reviewed-by: Gunnar Kudrjavets Link: https://patch.msgid.link/20261021181217.20171-1-youyouyu@amazon.com Signed-off-by: Jan Kara [ sashal: Adjusted include-list context because the neighboring namei header is absent. ] Signed-off-by: Sasha Levin --- fs/dcache.c | 2 ++ fs/quota/dquot.c | 10 ++++++---- include/linux/quotaops.h | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index f9c9f3b1ba807..7d7d96a098d78 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "internal.h" #include "mount.h" @@ -3537,6 +3538,7 @@ void __init vfs_caches_init(void) inode_init(); files_init(); files_maxfiles_init(); + dquot_cache_init(); mnt_init(); bdev_cache_init(); chrdev_init(); diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 1c78c695d0ddf..cd142c9cc7e0c 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2942,7 +2942,7 @@ static const struct ctl_table fs_dqstats_table[] = { }, }; -static int __init dquot_init(void) +void __init dquot_cache_init(void) { int i, ret; unsigned long nr_hash; @@ -2950,8 +2950,6 @@ static int __init dquot_init(void) printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__); - register_sysctl_init("fs/quota", fs_dqstats_table); - dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), sizeof(unsigned long) * 4, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| @@ -2992,7 +2990,11 @@ static int __init dquot_init(void) WQ_UNBOUND | WQ_MEM_RECLAIM, WQ_MAX_ACTIVE); if (!quota_unbound_wq) panic("Cannot create quota_unbound_wq\n"); +} +static int __init init_fs_dquot_sysctls(void) +{ + register_sysctl_init("fs/quota", fs_dqstats_table); return 0; } -fs_initcall(dquot_init); +fs_initcall(init_fs_dquot_sysctls); diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index f9c0f9d7c9d93..bbe22c22439ed 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; -- 2.53.0