diff options
| -rw-r--r-- | include/android/multinetwork.h | 55 | ||||
| -rw-r--r-- | libs/binder/ndk/include_cpp/android/binder_auto_utils.h | 9 | ||||
| -rw-r--r-- | libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp | 23 | ||||
| -rw-r--r-- | libs/binder/rust/src/parcel.rs | 2 | ||||
| -rw-r--r-- | libs/binder/tests/binderRpcTest.cpp | 7 | ||||
| -rw-r--r-- | services/gpuservice/OWNERS | 4 | ||||
| -rw-r--r-- | services/gpuservice/vts/OWNERS | 7 |
7 files changed, 103 insertions, 4 deletions
diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h index 509ee0e49b..4c83a14728 100644 --- a/include/android/multinetwork.h +++ b/include/android/multinetwork.h @@ -216,6 +216,61 @@ int android_res_nresult(int fd, */ void android_res_cancel(int nsend_fd) __INTRODUCED_IN(29); +/* + * Set the socket tag and owning UID for traffic statistics on the specified + * socket. + * + * Subsequent calls always replace any existing parameters. The socket tag and + * uid (if set) are kept when the socket is sent to another process using binder + * IPCs or other mechanisms such as UNIX socket fd passing. Any app can accept + * blame for future traffic performed on a socket originally created by another + * app by calling this method with its own UID (or calling + * android_tag_socket(int sockfd, int tag)). However, only apps holding the + * android.Manifest.permission#UPDATE_DEVICE_STATS permission may assign blame + * to another UIDs. If unset (default) the socket tag is 0, and the uid is the + * socket creator's uid. + * + * Returns 0 on success, or a negative POSIX error code (see errno.h) on + * failure. + * + * Available since API level 33. + */ +int android_tag_socket_with_uid(int sockfd, int tag, uid_t uid) __INTRODUCED_IN(33); + +/* + * Set the socket tag for traffic statistics on the specified socket. + * + * This function tags the socket with the caller's UID (accepting blame for + * future traffic performed on this socket) even if the socket was originally + * opened by another UID or was previously tagged by another UID. Subsequent + * calls always replace any existing parameters. The socket tag is kept when the + * socket is sent to another process using binder IPCs or other mechanisms such + * as UNIX socket fd passing. + * + * Returns 0 on success, or a negative POSIX error code (see errno.h) on + * failure. + * + * Available since API level 33. + */ +int android_tag_socket(int sockfd, int tag) __INTRODUCED_IN(33); + +/* + * Untag a network socket. + * + * Future traffic on this socket will no longer be associated with any + * previously configured tag and uid. If the socket was created by another UID + * or was previously tagged by another UID, calling this function will clear the + * statistics parameters, and thus the UID blamed for traffic on the socket will + * be the UID that originally created the socket, even if the socket was + * subsequently tagged by a different UID. + * + * Returns 0 on success, or a negative POSIX error code (see errno.h) on + * failure. + * + * Available since API level 33. + */ +int android_untag_socket(int sockfd) __INTRODUCED_IN(33); + __END_DECLS #endif // ANDROID_MULTINETWORK_H diff --git a/libs/binder/ndk/include_cpp/android/binder_auto_utils.h b/libs/binder/ndk/include_cpp/android/binder_auto_utils.h index c903998021..2c471c6e8f 100644 --- a/libs/binder/ndk/include_cpp/android/binder_auto_utils.h +++ b/libs/binder/ndk/include_cpp/android/binder_auto_utils.h @@ -163,6 +163,15 @@ class ScopedAResource { const T get() const { return mT; } /** + * Release the underlying resource. + */ + [[nodiscard]] T release() { + T a = mT; + mT = DEFAULT; + return a; + } + + /** * This allows the value in this class to be set from beneath it. If you call this method and * then change the value of T*, you must take ownership of the value you are replacing and add * ownership to the object that is put in here. diff --git a/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp b/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp index 58fa13afe5..357b454f7f 100644 --- a/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp +++ b/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp @@ -752,6 +752,29 @@ TEST(NdkBinder, GetClassInterfaceDescriptor) { ASSERT_STREQ(IFoo::kIFooDescriptor, AIBinder_Class_getDescriptor(IFoo::kClass)); } +static void addOne(int* to) { + if (!to) return; + ++(*to); +} +struct FakeResource : public ndk::impl::ScopedAResource<int*, addOne, nullptr> { + explicit FakeResource(int* a) : ScopedAResource(a) {} +}; + +TEST(NdkBinder_ScopedAResource, GetDelete) { + int deleteCount = 0; + { FakeResource resource(&deleteCount); } + EXPECT_EQ(deleteCount, 1); +} + +TEST(NdkBinder_ScopedAResource, Release) { + int deleteCount = 0; + { + FakeResource resource(&deleteCount); + (void)resource.release(); + } + EXPECT_EQ(deleteCount, 0); +} + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); diff --git a/libs/binder/rust/src/parcel.rs b/libs/binder/rust/src/parcel.rs index 206b90c807..256fa8bea6 100644 --- a/libs/binder/rust/src/parcel.rs +++ b/libs/binder/rust/src/parcel.rs @@ -496,7 +496,7 @@ impl<'a> BorrowedParcel<'a> { { let start = self.get_data_position(); let parcelable_size: i32 = self.read()?; - if parcelable_size < 0 { + if parcelable_size < 4 { return Err(StatusCode::BAD_VALUE); } diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index ca68b99e35..c2639e7c67 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -1517,10 +1517,11 @@ TEST(BinderRpc, Java) { auto keepAlive = sp<BBinder>::make(); auto setRpcClientDebugStatus = binder->setRpcClientDebug(std::move(socket), keepAlive); - if (!android::base::GetBoolProperty("ro.debuggable", false)) { + if (!android::base::GetBoolProperty("ro.debuggable", false) || + android::base::GetProperty("ro.build.type", "") == "user") { ASSERT_EQ(INVALID_OPERATION, setRpcClientDebugStatus) - << "setRpcClientDebug should return INVALID_OPERATION on non-debuggable builds, " - "but get " + << "setRpcClientDebug should return INVALID_OPERATION on non-debuggable or user " + "builds, but get " << statusToString(setRpcClientDebugStatus); GTEST_SKIP(); } diff --git a/services/gpuservice/OWNERS b/services/gpuservice/OWNERS index ac300d009e..0ff65bf4ae 100644 --- a/services/gpuservice/OWNERS +++ b/services/gpuservice/OWNERS @@ -1,2 +1,6 @@ chrisforbes@google.com lpy@google.com +alecmouri@google.com +lfy@google.com +paulthomson@google.com +pbaiget@google.com diff --git a/services/gpuservice/vts/OWNERS b/services/gpuservice/vts/OWNERS new file mode 100644 index 0000000000..e789052fa3 --- /dev/null +++ b/services/gpuservice/vts/OWNERS @@ -0,0 +1,7 @@ +# Bug component: 653544 +paulthomson@google.com +pbaiget@google.com +lfy@google.com +chrisforbes@google.com +lpy@google.com +alecmouri@google.com |