summaryrefslogtreecommitdiff
path: root/fs/verity/signature.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2023-07-06 00:27:42 +0300
committerEric Biggers <ebiggers@google.com>2023-07-12 08:49:18 +0300
commite77000ccc531088c486fe5fbd13416fd5e3d2714 (patch)
treecc75f2c75caa4054a06635125884bf67210aa066 /fs/verity/signature.c
parent5d37a1198068b099de47073411efc087d1b555ca (diff)
downloadlinux-e77000ccc531088c486fe5fbd13416fd5e3d2714.tar.xz
fsverity: simplify handling of errors during initcall
Since CONFIG_FS_VERITY is a bool, not a tristate, fs/verity/ can only be builtin or absent entirely; it can't be a loadable module. Therefore, the error code that gets returned from the fsverity_init() initcall is never used. If any part of the initcall does fail, which should never happen, the kernel will be left in a bad state. Following the usual convention for builtin code, just panic the kernel if any of part of the initcall fails. Link: https://lore.kernel.org/r/20230705212743.42180-2-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com>
Diffstat (limited to 'fs/verity/signature.c')
-rw-r--r--fs/verity/signature.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/fs/verity/signature.c b/fs/verity/signature.c
index 72034bc71c9d..ec75ffec069e 100644
--- a/fs/verity/signature.c
+++ b/fs/verity/signature.c
@@ -109,43 +109,29 @@ static struct ctl_table fsverity_sysctl_table[] = {
{ }
};
-static int __init fsverity_sysctl_init(void)
+static void __init fsverity_sysctl_init(void)
{
- fsverity_sysctl_header = register_sysctl("fs/verity", fsverity_sysctl_table);
- if (!fsverity_sysctl_header) {
- pr_err("sysctl registration failed!\n");
- return -ENOMEM;
- }
- return 0;
+ fsverity_sysctl_header = register_sysctl("fs/verity",
+ fsverity_sysctl_table);
+ if (!fsverity_sysctl_header)
+ panic("fsverity sysctl registration failed");
}
#else /* !CONFIG_SYSCTL */
-static inline int __init fsverity_sysctl_init(void)
+static inline void fsverity_sysctl_init(void)
{
- return 0;
}
#endif /* !CONFIG_SYSCTL */
-int __init fsverity_init_signature(void)
+void __init fsverity_init_signature(void)
{
- struct key *ring;
- int err;
-
- ring = keyring_alloc(".fs-verity", KUIDT_INIT(0), KGIDT_INIT(0),
- current_cred(), KEY_POS_SEARCH |
+ fsverity_keyring =
+ keyring_alloc(".fs-verity", KUIDT_INIT(0), KGIDT_INIT(0),
+ current_cred(), KEY_POS_SEARCH |
KEY_USR_VIEW | KEY_USR_READ | KEY_USR_WRITE |
KEY_USR_SEARCH | KEY_USR_SETATTR,
- KEY_ALLOC_NOT_IN_QUOTA, NULL, NULL);
- if (IS_ERR(ring))
- return PTR_ERR(ring);
-
- err = fsverity_sysctl_init();
- if (err)
- goto err_put_ring;
-
- fsverity_keyring = ring;
- return 0;
+ KEY_ALLOC_NOT_IN_QUOTA, NULL, NULL);
+ if (IS_ERR(fsverity_keyring))
+ panic("failed to allocate \".fs-verity\" keyring");
-err_put_ring:
- key_put(ring);
- return err;
+ fsverity_sysctl_init();
}