summaryrefslogtreecommitdiffstats
path: root/sys/security/mac
diff options
context:
space:
mode:
Diffstat (limited to 'sys/security/mac')
-rw-r--r--sys/security/mac/mac_framework.c30
-rw-r--r--sys/security/mac/mac_framework.h2
-rw-r--r--sys/security/mac/mac_internal.h30
-rw-r--r--sys/security/mac/mac_net.c30
-rw-r--r--sys/security/mac/mac_pipe.c30
-rw-r--r--sys/security/mac/mac_policy.h4
-rw-r--r--sys/security/mac/mac_process.c30
-rw-r--r--sys/security/mac/mac_syscalls.c30
-rw-r--r--sys/security/mac/mac_system.c30
-rw-r--r--sys/security/mac/mac_vfs.c30
10 files changed, 246 insertions, 0 deletions
diff --git a/sys/security/mac/mac_framework.c b/sys/security/mac/mac_framework.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_framework.c
+++ b/sys/security/mac/mac_framework.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_framework.h b/sys/security/mac/mac_framework.h
index ebb65cb..a646ad3 100644
--- a/sys/security/mac/mac_framework.h
+++ b/sys/security/mac/mac_framework.h
@@ -333,6 +333,8 @@ int mac_check_vnode_getacl(struct ucred *cred, struct vnode *vp,
acl_type_t type);
int mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
int attrnamespace, const char *name, struct uio *uio);
+int mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp);
int mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp);
/* XXX This u_char should be vm_prot_t! */
diff --git a/sys/security/mac/mac_internal.h b/sys/security/mac/mac_internal.h
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_internal.h
+++ b/sys/security/mac/mac_internal.h
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_net.c b/sys/security/mac/mac_net.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_net.c
+++ b/sys/security/mac/mac_net.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_pipe.c b/sys/security/mac/mac_pipe.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_pipe.c
+++ b/sys/security/mac/mac_pipe.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_policy.h b/sys/security/mac/mac_policy.h
index a54e925..d9f1a8e 100644
--- a/sys/security/mac/mac_policy.h
+++ b/sys/security/mac/mac_policy.h
@@ -294,6 +294,9 @@ struct mac_policy_ops {
int (*mpo_check_vnode_getextattr)(struct ucred *cred,
struct vnode *vp, struct label *label, int attrnamespace,
const char *name, struct uio *uio);
+ int (*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
+ struct label *dlabel, struct vnode *vp,
+ struct label *label, struct componentname *cnp);
int (*mpo_check_vnode_lookup)(struct ucred *cred,
struct vnode *dvp, struct label *dlabel,
struct componentname *cnp);
@@ -454,6 +457,7 @@ enum mac_op_constant {
MAC_CHECK_VNODE_EXEC,
MAC_CHECK_VNODE_GETACL,
MAC_CHECK_VNODE_GETEXTATTR,
+ MAC_CHECK_VNODE_LINK,
MAC_CHECK_VNODE_LOOKUP,
MAC_CHECK_VNODE_MMAP_PERMS,
MAC_CHECK_VNODE_OPEN,
diff --git a/sys/security/mac/mac_process.c b/sys/security/mac/mac_process.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_process.c
+++ b/sys/security/mac/mac_process.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_syscalls.c b/sys/security/mac/mac_syscalls.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_syscalls.c
+++ b/sys/security/mac/mac_syscalls.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_system.c b/sys/security/mac/mac_system.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_system.c
+++ b/sys/security/mac/mac_system.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
diff --git a/sys/security/mac/mac_vfs.c b/sys/security/mac/mac_vfs.c
index d21d5df..5719b01f 100644
--- a/sys/security/mac/mac_vfs.c
+++ b/sys/security/mac/mac_vfs.c
@@ -799,6 +799,10 @@ mac_policy_register(struct mac_policy_conf *mpc)
mpc->mpc_ops->mpo_check_vnode_getextattr =
mpe->mpe_function;
break;
+ case MAC_CHECK_VNODE_LINK:
+ mpc->mpc_ops->mpo_check_vnode_link =
+ mpe->mpe_function;
+ break;
case MAC_CHECK_VNODE_LOOKUP:
mpc->mpc_ops->mpo_check_vnode_lookup =
mpe->mpe_function;
@@ -1832,6 +1836,32 @@ mac_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
}
int
+mac_check_vnode_link(struct ucred *cred, struct vnode *dvp,
+ struct vnode *vp, struct componentname *cnp)
+{
+
+ int error;
+
+ ASSERT_VOP_LOCKED(dvp, "mac_check_vnode_link");
+ ASSERT_VOP_LOCKED(vp, "mac_check_vnode_link");
+
+ if (!mac_enforce_fs)
+ return (0);
+
+ error = vn_refreshlabel(dvp, cred);
+ if (error)
+ return (error);
+
+ error = vn_refreshlabel(vp, cred);
+ if (error)
+ return (error);
+
+ MAC_CHECK(check_vnode_link, cred, dvp, &dvp->v_label, vp,
+ &vp->v_label, cnp);
+ return (error);
+}
+
+int
mac_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
struct componentname *cnp)
{
OpenPOWER on IntegriCloud