Lines Matching refs:ns
416 loff_t *pos, struct aa_ns *ns) in policy_update() argument
427 error = aa_may_manage_policy(label, ns, mask); in policy_update()
434 error = aa_replace_profiles(ns, label, mask, data); in policy_update()
446 struct aa_ns *ns = aa_get_ns(f->f_inode->i_private); in profile_load() local
447 int error = policy_update(AA_MAY_LOAD_POLICY, buf, size, pos, ns); in profile_load()
449 aa_put_ns(ns); in profile_load()
463 struct aa_ns *ns = aa_get_ns(f->f_inode->i_private); in profile_replace() local
465 buf, size, pos, ns); in profile_replace()
466 aa_put_ns(ns); in profile_replace()
483 struct aa_ns *ns = aa_get_ns(f->f_inode->i_private); in profile_remove() local
489 error = aa_may_manage_policy(label, ns, AA_MAY_REMOVE_POLICY); in profile_remove()
502 error = aa_remove_profiles(ns, label, data->data, size); in profile_remove()
507 aa_put_ns(ns); in profile_remove()
517 struct aa_ns *ns; member
527 aa_put_ns(rev->ns); in ns_revision_release()
542 mutex_lock(&rev->ns->lock); in ns_revision_read()
544 if (last_read == rev->ns->revision) { in ns_revision_read()
545 mutex_unlock(&rev->ns->lock); in ns_revision_read()
548 if (wait_event_interruptible(rev->ns->wait, in ns_revision_read()
550 READ_ONCE(rev->ns->revision))) in ns_revision_read()
552 mutex_lock(&rev->ns->lock); in ns_revision_read()
555 avail = sprintf(buffer, "%ld\n", rev->ns->revision); in ns_revision_read()
557 rev->last_read = rev->ns->revision; in ns_revision_read()
560 mutex_unlock(&rev->ns->lock); in ns_revision_read()
572 rev->ns = aa_get_ns(inode->i_private); in ns_revision_open()
573 if (!rev->ns) in ns_revision_open()
574 rev->ns = aa_get_current_ns(); in ns_revision_open()
586 mutex_lock(&rev->ns->lock); in ns_revision_poll()
587 poll_wait(file, &rev->ns->wait, pt); in ns_revision_poll()
588 if (rev->last_read < rev->ns->revision) in ns_revision_poll()
590 mutex_unlock(&rev->ns->lock); in ns_revision_poll()
596 void __aa_bump_ns_revision(struct aa_ns *ns) in __aa_bump_ns_revision() argument
598 ns->revision++; in __aa_bump_ns_revision()
599 wake_up_interruptible(&ns->wait); in __aa_bump_ns_revision()
1172 if (profile->ns != labels_ns(label)) { in seq_ns_nsstacked_show()
1342 AA_BUG(rawdata->ns && !mutex_is_locked(&rawdata->ns->lock)); in __aa_fs_remove_rawdata()
1344 if (rawdata->ns) { in __aa_fs_remove_rawdata()
1347 aa_put_ns(rawdata->ns); in __aa_fs_remove_rawdata()
1348 rawdata->ns = NULL; in __aa_fs_remove_rawdata()
1352 int __aa_fs_create_rawdata(struct aa_ns *ns, struct aa_loaddata *rawdata) in __aa_fs_create_rawdata() argument
1356 AA_BUG(!ns); in __aa_fs_create_rawdata()
1358 AA_BUG(!mutex_is_locked(&ns->lock)); in __aa_fs_create_rawdata()
1359 AA_BUG(!ns_subdata_dir(ns)); in __aa_fs_create_rawdata()
1366 rawdata->name = kasprintf(GFP_KERNEL, "%ld", ns->revision); in __aa_fs_create_rawdata()
1370 dir = aafs_create_dir(rawdata->name, ns_subdata_dir(ns)); in __aa_fs_create_rawdata()
1403 rawdata->ns = aa_get_ns(ns); in __aa_fs_create_rawdata()
1404 list_add(&rawdata->list, &ns->rawdata_list); in __aa_fs_create_rawdata()
1537 id_len = snprintf(NULL, 0, ".%ld", profile->ns->uniq_id); in __aafs_profile_mkdir()
1546 sprintf(profile->dirname + len, ".%ld", profile->ns->uniq_id++); in __aafs_profile_mkdir()
1631 struct aa_ns *ns, *parent; in ns_mkdir_op() local
1660 ns = __aa_find_or_create_ns(parent, READ_ONCE(dentry->d_name.name), in ns_mkdir_op()
1662 if (IS_ERR(ns)) { in ns_mkdir_op()
1663 error = PTR_ERR(ns); in ns_mkdir_op()
1664 ns = NULL; in ns_mkdir_op()
1667 aa_put_ns(ns); /* list ref remains */ in ns_mkdir_op()
1680 struct aa_ns *ns, *parent; in ns_rmdir_op() local
1700 ns = aa_get_ns(__aa_findn_ns(&parent->sub_ns, dentry->d_name.name, in ns_rmdir_op()
1702 if (!ns) { in ns_rmdir_op()
1706 AA_BUG(ns_dir(ns) != dentry); in ns_rmdir_op()
1708 __aa_remove_ns(ns); in ns_rmdir_op()
1709 aa_put_ns(ns); in ns_rmdir_op()
1726 static void __aa_fs_list_remove_rawdata(struct aa_ns *ns) in __aa_fs_list_remove_rawdata() argument
1730 AA_BUG(!mutex_is_locked(&ns->lock)); in __aa_fs_list_remove_rawdata()
1732 list_for_each_entry_safe(ent, tmp, &ns->rawdata_list, list) in __aa_fs_list_remove_rawdata()
1740 void __aafs_ns_rmdir(struct aa_ns *ns) in __aafs_ns_rmdir() argument
1746 if (!ns) in __aafs_ns_rmdir()
1748 AA_BUG(!mutex_is_locked(&ns->lock)); in __aafs_ns_rmdir()
1750 list_for_each_entry(child, &ns->base.profiles, base.list) in __aafs_ns_rmdir()
1753 list_for_each_entry(sub, &ns->sub_ns, base.list) { in __aafs_ns_rmdir()
1759 __aa_fs_list_remove_rawdata(ns); in __aafs_ns_rmdir()
1761 if (ns_subns_dir(ns)) { in __aafs_ns_rmdir()
1762 sub = d_inode(ns_subns_dir(ns))->i_private; in __aafs_ns_rmdir()
1765 if (ns_subload(ns)) { in __aafs_ns_rmdir()
1766 sub = d_inode(ns_subload(ns))->i_private; in __aafs_ns_rmdir()
1769 if (ns_subreplace(ns)) { in __aafs_ns_rmdir()
1770 sub = d_inode(ns_subreplace(ns))->i_private; in __aafs_ns_rmdir()
1773 if (ns_subremove(ns)) { in __aafs_ns_rmdir()
1774 sub = d_inode(ns_subremove(ns))->i_private; in __aafs_ns_rmdir()
1777 if (ns_subrevision(ns)) { in __aafs_ns_rmdir()
1778 sub = d_inode(ns_subrevision(ns))->i_private; in __aafs_ns_rmdir()
1783 aafs_remove(ns->dents[i]); in __aafs_ns_rmdir()
1784 ns->dents[i] = NULL; in __aafs_ns_rmdir()
1789 static int __aafs_ns_mkdir_entries(struct aa_ns *ns, struct dentry *dir) in __aafs_ns_mkdir_entries() argument
1793 AA_BUG(!ns); in __aafs_ns_mkdir_entries()
1799 ns_subprofs_dir(ns) = dent; in __aafs_ns_mkdir_entries()
1804 ns_subdata_dir(ns) = dent; in __aafs_ns_mkdir_entries()
1806 dent = aafs_create_file("revision", 0444, dir, ns, in __aafs_ns_mkdir_entries()
1810 aa_get_ns(ns); in __aafs_ns_mkdir_entries()
1811 ns_subrevision(ns) = dent; in __aafs_ns_mkdir_entries()
1813 dent = aafs_create_file(".load", 0640, dir, ns, in __aafs_ns_mkdir_entries()
1817 aa_get_ns(ns); in __aafs_ns_mkdir_entries()
1818 ns_subload(ns) = dent; in __aafs_ns_mkdir_entries()
1820 dent = aafs_create_file(".replace", 0640, dir, ns, in __aafs_ns_mkdir_entries()
1824 aa_get_ns(ns); in __aafs_ns_mkdir_entries()
1825 ns_subreplace(ns) = dent; in __aafs_ns_mkdir_entries()
1827 dent = aafs_create_file(".remove", 0640, dir, ns, in __aafs_ns_mkdir_entries()
1831 aa_get_ns(ns); in __aafs_ns_mkdir_entries()
1832 ns_subremove(ns) = dent; in __aafs_ns_mkdir_entries()
1835 dent = aafs_create("namespaces", S_IFDIR | 0755, dir, ns, NULL, NULL, in __aafs_ns_mkdir_entries()
1839 aa_get_ns(ns); in __aafs_ns_mkdir_entries()
1840 ns_subns_dir(ns) = dent; in __aafs_ns_mkdir_entries()
1848 int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name, in __aafs_ns_mkdir() argument
1856 AA_BUG(!ns); in __aafs_ns_mkdir()
1858 AA_BUG(!mutex_is_locked(&ns->lock)); in __aafs_ns_mkdir()
1861 name = ns->base.name; in __aafs_ns_mkdir()
1870 ns_dir(ns) = dir = dent; in __aafs_ns_mkdir()
1871 error = __aafs_ns_mkdir_entries(ns, dir); in __aafs_ns_mkdir()
1876 list_for_each_entry(child, &ns->base.profiles, base.list) { in __aafs_ns_mkdir()
1877 error = __aafs_profile_mkdir(child, ns_subprofs_dir(ns)); in __aafs_ns_mkdir()
1883 list_for_each_entry(sub, &ns->sub_ns, base.list) { in __aafs_ns_mkdir()
1885 error = __aafs_ns_mkdir(sub, ns_subns_dir(ns), NULL, NULL); in __aafs_ns_mkdir()
1897 __aafs_ns_rmdir(ns); in __aafs_ns_mkdir()
1917 static struct aa_ns *__next_ns(struct aa_ns *root, struct aa_ns *ns) in __next_ns() argument
1922 AA_BUG(!ns); in __next_ns()
1923 AA_BUG(ns != root && !mutex_is_locked(&ns->parent->lock)); in __next_ns()
1926 if (!list_empty(&ns->sub_ns)) { in __next_ns()
1927 next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list); in __next_ns()
1933 parent = ns->parent; in __next_ns()
1934 while (ns != root) { in __next_ns()
1935 mutex_unlock(&ns->lock); in __next_ns()
1936 next = list_next_entry(ns, base.list); in __next_ns()
1941 ns = parent; in __next_ns()
1957 struct aa_ns *ns) in __first_profile() argument
1960 AA_BUG(ns && !mutex_is_locked(&ns->lock)); in __first_profile()
1962 for (; ns; ns = __next_ns(root, ns)) { in __first_profile()
1963 if (!list_empty(&ns->base.profiles)) in __first_profile()
1964 return list_first_entry(&ns->base.profiles, in __first_profile()
1982 struct aa_ns *ns = p->ns; in __next_profile() local
1993 mutex_is_locked(&p->ns->lock)); in __next_profile()
2000 mutex_is_locked(&parent->ns->lock)); in __next_profile()
2005 if (!list_entry_is_head(p, &ns->base.profiles, base.list)) in __next_profile()
2026 return __first_profile(root, __next_ns(root, profile->ns)); in next_profile()
2069 struct aa_ns *ns = f->private; in p_next() local
2072 return next_profile(ns, profile); in p_next()
2085 struct aa_ns *root = f->private, *ns; in p_stop() local
2088 for (ns = profile->ns; ns && ns != root; ns = ns->parent) in p_stop()
2089 mutex_unlock(&ns->lock); in p_stop()
2387 struct aa_ns *ns; in policy_get_link() local
2392 ns = aa_get_current_ns(); in policy_get_link()
2394 path.dentry = dget(ns_dir(ns)); in policy_get_link()
2396 aa_put_ns(ns); in policy_get_link()
2401 static int ns_get_name(char *buf, size_t size, struct aa_ns *ns, in ns_get_name() argument
2415 struct aa_ns *ns; in policy_readlink() local
2419 ns = aa_get_current_ns(); in policy_readlink()
2420 res = ns_get_name(name, sizeof(name), ns, d_inode(dentry)); in policy_readlink()
2423 aa_put_ns(ns); in policy_readlink()