Skip to contentSkip to conversation

quota: check for register_sysctl() failure

PATCH In review Yangtao Li 2 participants 4 messages Mar 18, 2023 – Mar 20, 2023 Diskquota

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 quota: check for register_sysctl() failure

register_sysctl() might fail, call panic() as with other failure checks in this function if register_sysctl() failed.

---
 fs/quota/dquot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/quota/dquot.c +2 -1
index 90cb70c82012..1483af271368 100644
@@ -2955,7 +2955,8 @@ static int __init dquot_init(void)
 
 	printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
 
-	register_sysctl("fs/quota", fs_dqstats_table);
+	if (!register_sysctl("fs/quota", fs_dqstats_table))
+		panic("Cannot register dquot sysctl");
 
 	dquot_cachep = kmem_cache_create("dquot",
 			sizeof(struct dquot), sizeof(unsigned long) * 4,
Signature · 1 line
2.35.1
#1 lore raw
Quoted 4 lines · Yangtao Li

register_sysctl() might fail, call panic() as with other failure checks in this function if register_sysctl() failed.

...

fs/quota/dquot.c static int __init dquot_init(void) · line 2959

Quoted 7 lines
fs/quota/dquot.c +2 -1
@@ -2955,7 +2955,8 @@ static int __init dquot_init(void)
 
 	printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
 
-	register_sysctl("fs/quota", fs_dqstats_table);
+	if (!register_sysctl("fs/quota", fs_dqstats_table))
+		panic("Cannot register dquot sysctl");

Well, but this is going to make system unbootable with CONFIG_QUOTA && !CONFIG_SYSCTL. Quota functionality actually does not depend on sysctl being available so just continuing without sysctl is perfectly fine.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#2 lore raw
Quoted 4 lines

Well, but this is going to make system unbootable with CONFIG_QUOTA && !CONFIG_SYSCTL.
Quota functionality actually does not depend on sysctl being available so just continuing without sysctl is perfectly fine.

To be honest, I'm a little confused. Should we panic if quota registration fails, or should it depend on the user's cmdline parameters? Just like in the filesystem where we can choose whether to panic in case of exceptions.

Or, should we panic if registration fails when
CONFIG_QUOTA && CONFIG_SYSCTL are enabled?

BTW, kindly ping for:
https://lore.kernel.org/lkml/20230228103515.sb6qpvnmbvenvq73@quack3/

Not sure if you have forgotten to pick these two commits.

Thx,
Yangtao

#3 lore raw
Quoted 5 lines · Yangtao Li
Quoted 4 lines

Well, but this is going to make system unbootable with CONFIG_QUOTA && !CONFIG_SYSCTL.
Quota functionality actually does not depend on sysctl being available so just continuing without sysctl is perfectly fine.

Quoted 7 lines

To be honest, I'm a little confused. Should we panic if quota registration fails, or should it depend on the user's cmdline parameters? Just like in the filesystem where we can choose whether to panic in case of exceptions.

Or, should we panic if registration fails when
CONFIG_QUOTA && CONFIG_SYSCTL are enabled?

So I think that just ignoring the failure to register sysctl (as is currently happening) is fine. Honestly, in practice this is not a likely scenario so I don't think it matters much but if we wanted, we could print a message that sysctl registration failed if CONFIG_SYSCTL is enabled.

Quoted 4 lines

BTW, kindly ping for:
https://lore.kernel.org/lkml/20230228103515.sb6qpvnmbvenvq73@quack3/

Not sure if you have forgotten to pick these two commits.

Yeah, sorry. Now picked up and pushed.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR