aboutsummaryrefslogtreecommitdiff
path: root/sys/security/mac_stub
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2008-01-08 21:58:16 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2008-01-08 21:58:16 +0000
commit8e38aeff17c9cbe66a65d8ef8c66d9f100ddfd90 (patch)
tree49b07dc757aae71e0a64eb4939cde4037af60a24 /sys/security/mac_stub
parent3b2262e4880961209a00ca33d713cf6c8b0073f0 (diff)
downloadsrc-8e38aeff17c9cbe66a65d8ef8c66d9f100ddfd90.tar.gz
src-8e38aeff17c9cbe66a65d8ef8c66d9f100ddfd90.zip
Add a new file descriptor type for IPC shared memory objects and use it to
implement shm_open(2) and shm_unlink(2) in the kernel: - Each shared memory file descriptor is associated with a swap-backed vm object which provides the backing store. Each descriptor starts off with a size of zero, but the size can be altered via ftruncate(2). The shared memory file descriptors also support fstat(2). read(2), write(2), ioctl(2), select(2), poll(2), and kevent(2) are not supported on shared memory file descriptors. - shm_open(2) and shm_unlink(2) are now implemented as system calls that manage shared memory file descriptors. The virtual namespace that maps pathnames to shared memory file descriptors is implemented as a hash table where the hash key is generated via the 32-bit Fowler/Noll/Vo hash of the pathname. - As an extension, the constant 'SHM_ANON' may be specified in place of the path argument to shm_open(2). In this case, an unnamed shared memory file descriptor will be created similar to the IPC_PRIVATE key for shmget(2). Note that the shared memory object can still be shared among processes by sharing the file descriptor via fork(2) or sendmsg(2), but it is unnamed. This effectively serves to implement the getmemfd() idea bandied about the lists several times over the years. - The backing store for shared memory file descriptors are garbage collected when they are not referenced by any open file descriptors or the shm_open(2) virtual namespace. Submitted by: dillon, peter (previous versions) Submitted by: rwatson (I based this on his version) Reviewed by: alc (suggested converting getmemfd() to shm_open())
Notes
Notes: svn path=/head/; revision=175164
Diffstat (limited to 'sys/security/mac_stub')
-rw-r--r--sys/security/mac_stub/mac_stub.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/sys/security/mac_stub/mac_stub.c b/sys/security/mac_stub/mac_stub.c
index 50463a054217..165e7bbb540e 100644
--- a/sys/security/mac_stub/mac_stub.c
+++ b/sys/security/mac_stub/mac_stub.c
@@ -578,6 +578,53 @@ stub_posixsem_create(struct ucred *cred, struct ksem *ks,
}
static int
+stub_posixshm_check_mmap(struct ucred *cred, struct shmfd *shmfd,
+ struct label *shmlabel, int prot, int flags)
+{
+
+ return (0);
+}
+
+static int
+stub_posixshm_check_open(struct ucred *cred, struct shmfd *shmfd,
+ struct label *shmlabel)
+{
+
+ return (0);
+}
+
+static int
+stub_posixshm_check_stat(struct ucred *active_cred, struct ucred *file_cred,
+ struct shmfd *shmfd, struct label *shmlabel)
+{
+
+ return (0);
+}
+
+static int
+stub_posixshm_check_truncate(struct ucred *active_cred,
+ struct ucred *file_cred, struct shmfd *shmfd, struct label *shmlabel)
+{
+
+ return (0);
+}
+
+static int
+stub_posixshm_check_unlink(struct ucred *cred, struct shmfd *shmfd,
+ struct label *shmlabel)
+{
+
+ return (0);
+}
+
+static void
+stub_posixshm_create(struct ucred *cred, struct shmfd *shmfd,
+ struct label *shmlabel)
+{
+
+}
+
+static int
stub_priv_check(struct ucred *cred, int priv)
{
@@ -1550,6 +1597,15 @@ static struct mac_policy_ops stub_ops =
.mpo_posixsem_destroy_label = stub_destroy_label,
.mpo_posixsem_init_label = stub_init_label,
+ .mpo_posixshm_check_mmap = stub_posixshm_check_mmap,
+ .mpo_posixshm_check_open = stub_posixshm_check_open,
+ .mpo_posixshm_check_stat = stub_posixshm_check_stat,
+ .mpo_posixshm_check_truncate = stub_posixshm_check_truncate,
+ .mpo_posixshm_check_unlink = stub_posixshm_check_unlink,
+ .mpo_posixshm_create = stub_posixshm_create,
+ .mpo_posixshm_destroy_label = stub_destroy_label,
+ .mpo_posixshm_init_label = stub_init_label,
+
.mpo_priv_check = stub_priv_check,
.mpo_priv_grant = stub_priv_grant,