summaryrefslogtreecommitdiff
path: root/libs/binder/MemoryHeapBase.cpp
Commit message (Collapse)AuthorAgeFilesLines
* File size seal for memory mapped regionKeith Mok2023-08-111-2/+2
| | | | | | | | | | | When using memfd for cross process communication, we always need to seal the file size, otherwise remote process and shrink the size we memory mapped and thus crash the originate process causing a DoS Bug: 294609150 Test: Build Ignore-AOSP-First: security Change-Id: Ibc263c4f78df897e884378e3d984a188ca8772c7
* Fix -Wnullable-to-nonnull-conversion errorzijunzhao2023-05-181-1/+1
| | | | | | | | Fix the build errors like https://android-build.googleplex.com/builds/pending/P56005836/aosp_arm64-userdebug/latest/view/logs/build.log Bugs: b/245972273 Test: mm -j Change-Id: I8edeace5afddc2cf6783899c889a3f2a542156a3
* Update MemoryHeapBase to avoid abortAtneya Nair2022-05-241-7/+4
| | | | | | | | | | | | | | | MemoryHeapBase currently logs fatal on passing invalid flags. Since we control flags combinations as compile time constants within an enum, we can enforce that all the enum values pass valid flag combos in order to remove the fatal flag checks. This avoids aborts in fuzzers consuming the enum value. If a user passes MEMFD_ALLOW_SEALING_FLAG without FORCE_MEMFD set (not possible if using the enum values), then the flag is silently ignored. Test: atest binderUnitTest Bug: 224667194 Change-Id: Iab90c8b0926ac32f01bb1489bf954c136dd2953f
* Add explicit memfd support to MemoryHeapBaseAtneya Nair2022-03-141-8/+56
| | | | | | | | | | | | | | | | | | | The default behavior of MemoryHeapBase is to request memory from ashmem in libcutils. This library is being used to migrate from ashmem to memfd, but on supported devices, memfd is still debug only in order to sanitize expectations of callees of the library. As such, we add a flag to explicitly request memfd files, as well as to opt into file sealing of memfd files. Note: the calling process will have to modify selinux permissions to allow tmpfs access to the domains accessing the shared buffer. This is more secure than ashmem as granular acess can be specified. See audioserver_tmpfs in system/selinux for examples. Test: Expected mappings recieved in Audioflinger for flag combos. atest binderMemoryHeapBaseUnitTest Change-Id: I893f7846f4d16b8ccc7f407fb957dccd9ebe62d7
* MemoryHeapBase: Map as read-only when neededYtai Ben-Tsvi2020-10-261-5/+9
| | | | | | | | | | | | | | | | When creating a MemoryHeapBase around a file descriptor provided by a different process, either via an fd or a device name, the existing code would attempt to map it with PROT_WRITE, unconditionally, which would result in a failure to map. With this change, we omit PROT_WRITE from the mapping whenever the READ_ONLY flag is set, but only when accessing via one of these ctors. The ctor that allocates a new ashmem region continues to work as before, with the caller process having write access, but any other process not having it. Test: atest -p frameworks/native/libs/binder Change-Id: Iab3583d841c3dceed1a7cb61e922a85104b4b00b
* Remove extraneous semicolon.Steven Moreland2019-09-271-1/+1
| | | | | | | Bug: N/A Test: build w/o -Wno-c++98-compat-extra-semi Merged-In: I632d6df9a03485e547a6e7f14df0f1c068066c1e Change-Id: I632d6df9a03485e547a6e7f14df0f1c068066c1e
* Fix binder memory handling for 64 bit devicesAndy Hung2018-10-241-10/+17
| | | | | | | | | Change MemoryHeap offset to use off_t. Always transmit Memory related size and offset as 64 bits. Test: CTS, native binder tests, sanity Bug: 117556990 Change-Id: Icaabf7442f561a53941f9ebebe4029ddc533b0c2
* [binder] Replace NULL/0 with nullptrYi Kong2018-06-071-8/+8
| | | | | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. clang-tidy -checks=modernize-use-nullptr -p compile_commands.json -fix ... Test: m Bug: 68236239 Change-Id: I3181bc5683796423a98b0f9b94daf30880c07bdc
* Replace cutils/log.h and rationalize log/log.h and android/log.hMark Salyzyn2017-01-121-1/+1
| | | | | | | | | | - cutils/log.h treat as deprecated and lead by example - coding standard for header order - include headers that are side effect of others. Test: compile Bug: 34250038 Change-Id: I8d99b24c333578c9b5aa9f2a01324bd0bba268dd
* resolve merge conflicts of a2c2d11f9 to masterMark Salyzyn2017-01-121-3/+2
|\ | | | | | | | | | | | | Test: compile Bug: 26552300 Bug: 31289077 Change-Id: I84d0ffa430df3beca0dcc6ed205ce220d7be1f87
| * Replace cutils/log.h and rationalize log/log.h and android/log.hMark Salyzyn2017-01-111-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | - cutils/log.h treat as deprecated and lead by example - android/log.h to be used instead of log/log.h if possible - add system includes that are assumed as side effects - define LOG_TAG first Test: compile Bug: 31289077 Bug: 30465923 Change-Id: I8d99b24c333578c9b5aa9f2a01324bd0bba268dd
* | resolve merge conflicts of 525a5f2 to masterMark Salyzyn2016-12-281-7/+7
|\| | | | | | | | | Test: build Change-Id: Id1c6d3d9dd158fb086b0d8ab74f7838ef0a51af1
| * Replace cutils/log.h and rationalize log/log.h and android/log.hMark Salyzyn2016-12-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | - cutils/log.h treat as deprecated and lead by example - android/log.h to be used instead of log/log.h if required - add system includes that are assumed as side effects of log.h - modules that use SLOG should use SLOG for all logging (installd) - define LOG_TAG first - remove logging infrastructure if not used Test: build Bug: 31289077 Change-Id: Iea147a0104c7ab7f12451304131d6500f42141e7
* | libbinder: replace dup() with fcntl(F_DUPFD_CLOEXEC)Nick Kralevich2016-12-171-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | Replace calls to dup() with fcntl(F_DUPFD_CLOEXEC). The only difference between the two is that O_CLOEXEC is set on the newly duped file descriptor. This helps address file descriptor leaks crossing an exec() boundary in multi-threaded processes, and potentially fixes the following non-reproducible SELinux denials which may be occurring because of FD leakage from netd to clatd/dnsmasq. avc: denied { use } for comm="clatd" path="socket:[860297]" dev="sockfs" ino=860297 scontext=u:r:clatd:s0 tcontext=u:r:untrusted_app:s0:c512,c768 tclass=fd permissive=0 avc: denied { read write } for comm="clatd" path="socket:[1414454]" dev="sockfs" ino=1414454 scontext=u:r:clatd:s0 tcontext=u:r:system_server:s0 tclass=tcp_socket permissive=0 avc: denied { use } for comm="clatd" path="socket:[681600]" dev="sockfs" ino=681600 scontext=u:r:clatd:s0 tcontext=u:r:priv_app:s0:c512,c768 tclass=fd permissive=0 Test: Device boots and no obvious problems Change-Id: I9dcd9911a093f329c6f12e39d2c49ef3df651ae5
* Remove references to obsolete pmem functionality.Elliott Hughes2013-11-211-17/+3
| | | | Change-Id: I5d3befd075e51614e6801115388a0a9f32fbb6ea
* Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGESteve Block2012-01-081-3/+3
| | | | | | | See https://android-git.corp.google.com/g/#/c/157220 Bug: 5449033 Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
* Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGESteve Block2012-01-031-2/+2
| | | | | | | See https://android-git.corp.google.com/g/156016 Bug: 5449033 Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
* MemoryHeapBase: Save and binderize the offsetAnu Sundararajan2011-06-271-5/+10
| | | | | | | | | | The offset that is used in the creation of the MemoryHeapBase must be saved, so that it can be used to recreate the Heap when an IMemory object is passed across process boundary through the binder. Change-Id: Ie618fb5c0718e6711f55ed9235616fd801e648dc Signed-off-by: Anu Sundararajan <sanuradha@ti.com> Signed-off-by: Iliyan Malchev <malchev@google.com>
* Clean up use of HAVE_ANDROID_OSKenny Root2011-02-161-2/+2
| | | | | | | | HAVE_ANDROID_OS was defined as "1" for targets, but never defined as "0" for non-targets. Changing them to #ifdef should be safe and matches all the other uses of HAVE_ANDROID_OS throughout the system. Change-Id: I82257325a8ae5e4e4371ddfc4dbf51cea8ea0abb
* libbinder: add a NO_CACHING flag to MemoryHeapBaseIliyan Malchev2009-10-301-1/+5
| | | | | | The NO_CACHING flag translates to opening a memory region with O_SYNC. Signed-off-by: Iliyan Malchev <malchev@google.com>
* Add offset handling in MemoryHeapBase classBenny Wong2009-08-201-4/+4
|
* move libbinder's header files under includes/binderMathias Agopian2009-05-201-1/+1
|
* checkpoint: split libutils into libutils + libbinderMathias Agopian2009-05-201-0/+183