summaryrefslogtreecommitdiff
path: root/src/shared/memfd.c
AgeCommit message (Collapse)Author
2014-10-30memfd: rename memfd.h to memfd-util.h to avoid any confusion with any libc ↵Lennart Poettering
provided headers
2014-10-30memfd: drop memfd_get_name() as it is unusedLennart Poettering
2014-10-30memfd: always create our memfds with CLOEXEC setLennart Poettering
We really shouldn't create fds ever that have the flag unset.
2014-10-05build-sys: use linux/memfd.h if availableZbigniew Jędrzejewski-Szmek
linux/memfd.h was added linux 3.17, so it might not be widely available for a while. Also, check if memfd_create is defined, for the HAVE_LINUX_MEMFD_H check to have a chance of succeeding. Also, collapse all ifdefs for memfd-related stuff, because they were all added together so there's no need to check separately.
2014-08-19memfd: escape the comm field we get from PR_GET_NAME, but assume everything ↵Lennart Poettering
else is proper UTF8
2014-08-19memfd: skip utf-8 escaping if we use a name that was passed inDaniel Mack
If a name was passed in as function argument, trust it, and don't do utf-8 encoding for them. Callers are obliged to check the names themselves, and escape them in case they use anything they got from the outside world.
2014-08-19memfd: reduce name escaping logic to utf-8 checksDaniel Mack
As memfds are now created by proper kernel API, and not by our functions, we can't rely on names being escaped/unescaped according to our current logic. Thus, the only safe way is to remove the escaping and when reading names, just escape names that are not properly encoded in UTF-8. Also, remove assert(name) lines from the memfd creation functions, as we explictly allow name to be NULL.
2014-08-19memfd: simplify APILennart Poettering
Now, that the memfd stuff is not exported anymore, we can simplify a few things: Use assert() instead of assert_return(), since this is used internally only, and we should be less permissive then. No need to pass an allocated fd back by call-by-reference, we can just directly return it.
2014-08-18memfd: internalize functions, drop sd_memfd typeDaniel Mack
Remove the sd_ prefix from internal functions and get rid of the sd_memfd type. As a memfd is now just a native file descriptor, we can get rid of our own wrapper type, and also use close() and dup() on them directly.
2014-08-18memfd: use _cleanup_ if applicableDavid Herrmann
We now have a sd_memfd_freep helper, use it if applicable.
2014-08-18memfd: map unsealed files as MAP_SHAREDDavid Herrmann
We need to map sealed files as MAP_PRIVATE so far as the kernel treats MAP_SHARED as writable mapping (you can run mprotect(PROT_WRITE) at any time on those). However, unsealed files must be mapped as MAP_SHARED. Otherwise, we never end up writing to the real file.
2014-08-18memfd: disallow importing memfds without sealingDavid Herrmann
We use memfds for sealing. Lets not bother with memfds created without MFD_ALLOW_SEALING for now. They're equivalent to random shmem files, so don't bother treating them as sealable memfds.
2014-08-18memfd: don't open kdbus for memfdDavid Herrmann
No reason to open /dev/kdbus/control if we want memfds. memfd_create() is always available.
2014-08-18memfd: fix memfd_create() syscall wrapperDaniel Mack
Unlike earlier versions, the syscall only takes 2 arguments in its final version, not 3.
2014-08-18memfd: move code from public library to src/sharedDaniel Mack
Don't expose generic kernel API via libsystemd, but keep the code internal for our own usage.