From 9a2d40c12d00ead1b1a3ac8383d2d66e35674fdb Mon Sep 17 00:00:00 2001 From: John Johansen Date: Mon, 16 Jan 2017 00:42:22 -0800 Subject: apparmor: add strn version of aa_find_ns Signed-off-by: John Johansen --- security/apparmor/policy_ns.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'security/apparmor/policy_ns.c') diff --git a/security/apparmor/policy_ns.c b/security/apparmor/policy_ns.c index 71fbd14e3b37..9746643cbab2 100644 --- a/security/apparmor/policy_ns.c +++ b/security/apparmor/policy_ns.c @@ -139,26 +139,42 @@ void aa_free_ns(struct aa_ns *ns) } /** - * aa_find_ns - look up a profile namespace on the namespace list + * aa_findn_ns - look up a profile namespace on the namespace list * @root: namespace to search in (NOT NULL) * @name: name of namespace to find (NOT NULL) + * @n: length of @name * * Returns: a refcounted namespace on the list, or NULL if no namespace * called @name exists. * * refcount released by caller */ -struct aa_ns *aa_find_ns(struct aa_ns *root, const char *name) +struct aa_ns *aa_findn_ns(struct aa_ns *root, const char *name, size_t n) { struct aa_ns *ns = NULL; rcu_read_lock(); - ns = aa_get_ns(__aa_find_ns(&root->sub_ns, name)); + ns = aa_get_ns(__aa_findn_ns(&root->sub_ns, name, n)); rcu_read_unlock(); return ns; } +/** + * aa_find_ns - look up a profile namespace on the namespace list + * @root: namespace to search in (NOT NULL) + * @name: name of namespace to find (NOT NULL) + * + * Returns: a refcounted namespace on the list, or NULL if no namespace + * called @name exists. + * + * refcount released by caller + */ +struct aa_ns *aa_find_ns(struct aa_ns *root, const char *name) +{ + return aa_findn_ns(root, name, strlen(name)); +} + /** * aa_prepare_ns - find an existing or create a new namespace of @name * @name: the namespace to find or add (MAYBE NULL) -- cgit 1.4.1