Commit graph

15 commits

Author SHA1 Message Date
Treehugger Robot
19c054cc4f Merge "Do not check with vendor vndk version" into main am: 6d01651ab9 am: 9062abf0e5 am: fcdbce7f33 am: 3147ebc654 am: b94f5ee99f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2758806

Change-Id: I6380bec21baec416a9e9bd53b8e88610447d5db7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-23 17:50:46 +00:00
Kiyoung Kim
45d88d496e Do not check with vendor vndk version
Current libcutils checks if memfd is supported with vendor VNDK version,
but this is no longer valid if VNDK is deprecated. As we can assume that
any vendor using this code is supported as long as it is treblelized,
simplify logic to check if memfd is valid to vendor only with
'ro.treble.enabled' property.

Bug: 290159430
Test: Cuttlefish with VNDK deprecated worked without error from
libcutils

Change-Id: I351f0798da99cb4827bc3e424b63a2eaee5c7461
2023-09-23 21:06:57 +09:00
Treehugger Robot
d4eca869d6 Merge "Remove redefinition of uapi constant added in R." into main am: d5b09b4b97 am: c3bbf8237a am: 7a1d3efb41 am: 5c30491a99 am: 73f83e22f9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2760268

Change-Id: I784e9d263d970a94f3305776bb9505aba7c4cab0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-22 22:41:25 +00:00
Elliott Hughes
1faedd02a3 Remove redefinition of uapi constant added in R.
Test: treehugger
Change-Id: If0ef9c36b2f54eb59d222dedc6bf575d46c9db1d
2023-09-22 14:45:20 +00:00
Keith Mok
f83c5c8fec Add seal if ashmem-dev is backed by memfd
Need to seal the buffer size in align with ashmem if set to PROT_READ
only to prevent untrusted remote process to shrink the buffer size and
crash it.

Bug: 294609150
Test: build
Ignore-AOSP-First: Security
Change-Id: I9288cf30b41e84ad8d3247c204e20482912bff69
2023-09-05 22:06:21 +00:00
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)