Enable RTM_GETLINK restrictions on all apps
Extend existing restrictions targeting only apps with API level >= 30 to
all apps.
Actual enforcement happens in SELinux. This change just prevents
logspam.
To be merged when automerge to sc-dev ends.
Bug: 170188668
Test: atest bionic-unit-tests-static
Test: atest NetworkInterfaceTest
Test: Connect to Wi-Fi network
Test: atest CtsSelinuxTargetSdk27TestCases
Test: atest CtsSelinuxTargetSdk28TestCasesTest: atest
CtsSelinuxTargetSdk29TestCases
Test: atest CtsSelinuxTargetSdkCurrentTestCases
Change-Id: If1761354216b23a1e55e6b9606de452899afff0c
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 =