Revert^2 "Soft-enables new MAC address restrictions."
259776d8ffcb64679e9c8d3459c2ec3a68a9e061
The original change was reverted due to InterfaceParamsTest failing.
This test has now been fixed in r.android.com/1498525.
The original change message is below.
Updates getifaddrs() to behave as if RTM_GETLINK requests are not
allowed for non-system apps. This is different from previous behavior,
where apps targeting an API level < 30 were exempted from this
restriction.
Actual enforcement happens in SELinux. This change:
- Soft-enables the behavior until SELinux changes are in place
- Prevents logspam from SELinux denials after they are in place
Bug: 170188668
Test: atest bionic-unit-tests-static
Test: atest NetworkInterfaceTest
Test: Connect to Wi-Fi network
Test: Call getifaddrs() directly from within an app.
Test: Call NetworkInterface#getNetworkInterfaces() from within an app.
Change-Id: Ia9f61819f8fdf878c0e67e57de7e893fb3b1c233
diff --git a/libc/bionic/ifaddrs.cpp b/libc/bionic/ifaddrs.cpp
index 1536333..0c80f4e 100644
--- a/libc/bionic/ifaddrs.cpp
+++ b/libc/bionic/ifaddrs.cpp
@@ -306,12 +306,9 @@
// Open the netlink socket and ask for all the links and addresses.
NetlinkConnection nc;
- // SELinux policy only allows RTM_GETLINK messages to be sent by:
- // - System apps
- // - Apps with a target SDK version lower than R
+ // SELinux policy only allows RTM_GETLINK messages to be sent by system apps.
bool getlink_success = false;
- if (getuid() < FIRST_APPLICATION_UID ||
- android_get_application_target_sdk_version() < __ANDROID_API_R__) {
+ if (getuid() < FIRST_APPLICATION_UID) {
getlink_success = nc.SendRequest(RTM_GETLINK) && nc.ReadResponses(__getifaddrs_callback, out);
}
bool getaddr_success =