Commit graph

10 commits

Author SHA1 Message Date
Elliott Hughes
790ef05793 ashmem: ensure ashmem fds are CLOEXEC.
Fix the memfd_create(2) path and add the missing unit test.

Bug: https://issuetracker.google.com/165667331
Test: treehugger
Change-Id: Ibb5c1d0f9d7caba1df04d1f03e82e55026d9f86a
2020-09-03 10:54:20 -07:00
Hridya Valsaraju
9a147033f8 Add failure logs in __ashmem_open_locked()
Bug: 160984921
Test: build, boot
Change-Id: I754c961289828463af6de905d8b057b4350f5f07
2020-08-10 14:14:13 -07:00
Dan Albert
ac4500e67d Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: http://b/161896447
Test: None
Change-Id: I9e5a37a20012b2f7a8eac55701df03f7b7a9ab6c
2020-07-28 15:58:25 -07:00
Steven Moreland
4f99dd3af1 libcutils: fallback to /dev/ashmem
For a Q APEX built with use_vendor, rather than using AIDL to talk to
ashmemd, it would directly open /dev/ashmem. R libcutils does ashmem
differently, but in order to allow R-built APEXes to replace this
category of APEXes, falling back to /dev/ashmem.

Fixes: 147363115
Test: tested on Q in swcodec APEX
Change-Id: I625e46b15fee6649251ab9be7a1bbe11c5427525
2020-01-14 18:19:10 +00:00
Tri Vo
92fd3caff7 libcutils: route to /dev/ashmem<boot_id> instead of ashmemd
Having libcutils ask ashmemd for ashmem fds results in unsatisfactory
performance/memory overhead. Introduce a duplicate of /dev/ashmem and
route to it instead.

Our goal remains as before, namely, use SELinux to phase out usage of
ashmem that doesn't go through libcutils.

Bug: 139855428
Test: boot aosp_crosshatch, browse internet, use camera
Change-Id: I02260a9042acb412571b11f1f4c1d8608483064a
2019-09-25 12:50:16 -07:00
Tim Murray
8879ed7f2a cutils: add ashmem_init
Add a new ashmem_init function that only dlopens libashmemd_client.
This allows the library to be preloaded in the zygote.

Test: boots, works
Bug: 129543489

Change-Id: Ie106791edf381654f085203c266c9f9c0df35cfc
2019-04-04 17:30:25 -07:00
Joel Fernandes
519440468b Add support for memfd
This patch adds support to make libcutils create and use memfd where
possible, instead of ashmem.

The libcutils library is made dynamic, since apps are still sending over
ashmem FDs to processes and we are working on moving those apps away
from ashmem. The best we can do for that is make the library work, and
force apps in the long run to move away from directly using ashmem.

Due to further complications mentioned in the 'NOTE' section of the
patch, memfd is kept disabled for now, so nothing changes yet. To enable
it, set the sys.use_memfd property (check user_debug build).

Bug: 113362644
Change-Id: I491cb7841b664db5b1c26b3e07a440a14810e182
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-02-07 00:40:13 +00:00
Tri Vo
2891ba09d5 libcutils: route to ashmemd
If libcutils is not a VNDK version and /dev/ashmem is not available,
then ask ashmemd for opened fd to /dev/ashmem.

We rely on SELinux policy to determine what's allowed to open
/dev/ashmem directly.

Bug: 113362644
Test: device boots (in selinux permissive mode)
Change-Id: I93c4fa6044b0bfa5282097c6c32139a8d8f67deb
2019-02-04 10:30:24 -08:00
Joel Fernandes
56cd651e7a libcutils: ashmem: Avoid doing fd checks for ashmem calls
Callers already verify that they are calling ashmem API on a valid fd by
calling ashmem_valid first. Lets make the fstat syscall only if the
ioctl returns -ENOTTY. This means in the regular case, only 1 syscall is
needed (ioctl) vs the current 2 (fstat+ioctl).

Some data to show improvements in reduction of vfs_getattr calls in the
kernel by 10x when doing a camera.

Test: Boot and camera CTS
Bug: 111418894
Change-Id: I992620bbe44355e54ba19eeac81da586c5e5a6e0
Signed-off-by: Joel Fernandes <joelaf@google.com>
2018-07-17 17:02:44 -07:00
Elliott Hughes
8e9aeb9053 Move libcutils source to C++.
Just the minimial changes to get this to actually build, because otherwise
we always bog down trying to rewrite everything (when the real answer
is usually "stop using libcutils, it's awful").

This doesn't move a handful of files: two are basically just BSD libc
source, a couple have outstanding code reviews, and one can be deleted
(but I'll do that in a separate change).

I'm also skipping the presubmit hooks because otherwise clang-format
wants to reformat everything. I'll follow up with that...

Bug: N/A
Test: builds
Change-Id: I06403f465b67c8e493bad466dd76b1151eed5993
2017-11-10 13:18:10 -08:00
Renamed from libcutils/ashmem-dev.c (Browse further)