Commit e4e071ba authored by Stefan Berger's avatar Stefan Berger Committed by Mimi Zohar

ima: Return error code obtained from securityfs functions

If an error occurs when creating a securityfs file, return the exact
error code to the caller.
Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
parent 18848c71
...@@ -452,47 +452,61 @@ static const struct file_operations ima_measure_policy_ops = { ...@@ -452,47 +452,61 @@ static const struct file_operations ima_measure_policy_ops = {
int __init ima_fs_init(void) int __init ima_fs_init(void)
{ {
int ret;
ima_dir = securityfs_create_dir("ima", integrity_dir); ima_dir = securityfs_create_dir("ima", integrity_dir);
if (IS_ERR(ima_dir)) if (IS_ERR(ima_dir))
return -1; return PTR_ERR(ima_dir);
ima_symlink = securityfs_create_symlink("ima", NULL, "integrity/ima", ima_symlink = securityfs_create_symlink("ima", NULL, "integrity/ima",
NULL); NULL);
if (IS_ERR(ima_symlink)) if (IS_ERR(ima_symlink)) {
ret = PTR_ERR(ima_symlink);
goto out; goto out;
}
binary_runtime_measurements = binary_runtime_measurements =
securityfs_create_file("binary_runtime_measurements", securityfs_create_file("binary_runtime_measurements",
S_IRUSR | S_IRGRP, ima_dir, NULL, S_IRUSR | S_IRGRP, ima_dir, NULL,
&ima_measurements_ops); &ima_measurements_ops);
if (IS_ERR(binary_runtime_measurements)) if (IS_ERR(binary_runtime_measurements)) {
ret = PTR_ERR(binary_runtime_measurements);
goto out; goto out;
}
ascii_runtime_measurements = ascii_runtime_measurements =
securityfs_create_file("ascii_runtime_measurements", securityfs_create_file("ascii_runtime_measurements",
S_IRUSR | S_IRGRP, ima_dir, NULL, S_IRUSR | S_IRGRP, ima_dir, NULL,
&ima_ascii_measurements_ops); &ima_ascii_measurements_ops);
if (IS_ERR(ascii_runtime_measurements)) if (IS_ERR(ascii_runtime_measurements)) {
ret = PTR_ERR(ascii_runtime_measurements);
goto out; goto out;
}
runtime_measurements_count = runtime_measurements_count =
securityfs_create_file("runtime_measurements_count", securityfs_create_file("runtime_measurements_count",
S_IRUSR | S_IRGRP, ima_dir, NULL, S_IRUSR | S_IRGRP, ima_dir, NULL,
&ima_measurements_count_ops); &ima_measurements_count_ops);
if (IS_ERR(runtime_measurements_count)) if (IS_ERR(runtime_measurements_count)) {
ret = PTR_ERR(runtime_measurements_count);
goto out; goto out;
}
violations = violations =
securityfs_create_file("violations", S_IRUSR | S_IRGRP, securityfs_create_file("violations", S_IRUSR | S_IRGRP,
ima_dir, NULL, &ima_htable_violations_ops); ima_dir, NULL, &ima_htable_violations_ops);
if (IS_ERR(violations)) if (IS_ERR(violations)) {
ret = PTR_ERR(violations);
goto out; goto out;
}
ima_policy = securityfs_create_file("policy", POLICY_FILE_FLAGS, ima_policy = securityfs_create_file("policy", POLICY_FILE_FLAGS,
ima_dir, NULL, ima_dir, NULL,
&ima_measure_policy_ops); &ima_measure_policy_ops);
if (IS_ERR(ima_policy)) if (IS_ERR(ima_policy)) {
ret = PTR_ERR(ima_policy);
goto out; goto out;
}
return 0; return 0;
out: out:
...@@ -503,5 +517,6 @@ int __init ima_fs_init(void) ...@@ -503,5 +517,6 @@ int __init ima_fs_init(void)
securityfs_remove(binary_runtime_measurements); securityfs_remove(binary_runtime_measurements);
securityfs_remove(ima_symlink); securityfs_remove(ima_symlink);
securityfs_remove(ima_dir); securityfs_remove(ima_dir);
return -1;
return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment