fs.c (a68916eaedcd01f254ac4c09ca12b5065d710fd0) fs.c (ba199dc909a20fe62270ae4e93f263987bb9d119)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved.
4 */
5
6#include <linux/dcache.h>
7#include <linux/security.h>
8

--- 176 unchanged lines hidden (view full) ---

185 * ipe_init_securityfs() - Initialize IPE's securityfs tree at fsinit.
186 *
187 * Return: %0 on success. If an error occurs, the function will return
188 * the -errno.
189 */
190static int __init ipe_init_securityfs(void)
191{
192 int rc = 0;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved.
4 */
5
6#include <linux/dcache.h>
7#include <linux/security.h>
8

--- 176 unchanged lines hidden (view full) ---

185 * ipe_init_securityfs() - Initialize IPE's securityfs tree at fsinit.
186 *
187 * Return: %0 on success. If an error occurs, the function will return
188 * the -errno.
189 */
190static int __init ipe_init_securityfs(void)
191{
192 int rc = 0;
193 struct ipe_policy *ap;
193
194 if (!ipe_enabled)
195 return -EOPNOTSUPP;
196
197 root = securityfs_create_dir("ipe", NULL);
198 if (IS_ERR(root)) {
199 rc = PTR_ERR(root);
200 goto err;

--- 14 unchanged lines hidden (view full) ---

215 }
216
217 policy_root = securityfs_create_dir("policies", root);
218 if (IS_ERR(policy_root)) {
219 rc = PTR_ERR(policy_root);
220 goto err;
221 }
222
194
195 if (!ipe_enabled)
196 return -EOPNOTSUPP;
197
198 root = securityfs_create_dir("ipe", NULL);
199 if (IS_ERR(root)) {
200 rc = PTR_ERR(root);
201 goto err;

--- 14 unchanged lines hidden (view full) ---

216 }
217
218 policy_root = securityfs_create_dir("policies", root);
219 if (IS_ERR(policy_root)) {
220 rc = PTR_ERR(policy_root);
221 goto err;
222 }
223
224 ap = rcu_access_pointer(ipe_active_policy);
225 if (ap) {
226 rc = ipe_new_policyfs_node(ap);
227 if (rc)
228 goto err;
229 }
230
223 np = securityfs_create_file("new_policy", 0200, root, NULL, &np_fops);
224 if (IS_ERR(np)) {
225 rc = PTR_ERR(np);
226 goto err;
227 }
228
229 return 0;
230err:
231 securityfs_remove(np);
232 securityfs_remove(policy_root);
233 securityfs_remove(enforce_node);
234 securityfs_remove(audit_node);
235 securityfs_remove(root);
236 return rc;
237}
238
239fs_initcall(ipe_init_securityfs);
231 np = securityfs_create_file("new_policy", 0200, root, NULL, &np_fops);
232 if (IS_ERR(np)) {
233 rc = PTR_ERR(np);
234 goto err;
235 }
236
237 return 0;
238err:
239 securityfs_remove(np);
240 securityfs_remove(policy_root);
241 securityfs_remove(enforce_node);
242 securityfs_remove(audit_node);
243 securityfs_remove(root);
244 return rc;
245}
246
247fs_initcall(ipe_init_securityfs);