From 918bd7222505a28219076ffff45fa16adb580d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bram=20Bonn=C3=A9?= Date: Thu, 27 Feb 2020 16:02:30 +0100 Subject: [PATCH] Cleans up logging and comments in ifaddrs. To prevent unnecessary SELinux denials, the check referred to by the comment is kept in place. This allows us to keep auditing the SELinux denial in order to catch apps that intentionally send RTM_GETLINK messages. Fix: 141455849 Test: atest bionic-unit-tests-static Test: atest NetworkInterfaceTest Change-Id: I41e5ad6f071c820a8246177a0c629b3be788a942 --- libc/bionic/ifaddrs.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libc/bionic/ifaddrs.cpp b/libc/bionic/ifaddrs.cpp index 0e9b544f7..e89b0bf11 100644 --- a/libc/bionic/ifaddrs.cpp +++ b/libc/bionic/ifaddrs.cpp @@ -28,7 +28,6 @@ #include -#include #include // FIRST_APPLICATION_UID #include #include @@ -282,11 +281,9 @@ int getifaddrs(ifaddrs** out) { // Open the netlink socket and ask for all the links and addresses. NetlinkConnection nc; - // Simulate kernel behavior on R and above: RTM_GETLINK messages can only be - // sent by: + // SELinux policy only allows RTM_GETLINK messages to be sent by: // - System apps // - Apps with a target SDK version lower than R - // TODO(b/141455849): Remove this check when kernel changes are merged. bool getlink_success = false; if (getuid() < FIRST_APPLICATION_UID || android_get_application_target_sdk_version() < __ANDROID_API_R__) { @@ -303,7 +300,6 @@ int getifaddrs(ifaddrs** out) { } if (!getlink_success) { - async_safe_format_log(ANDROID_LOG_INFO, "ifaddrs", "Failed to send RTM_GETLINK request"); // If we weren't able to depend on GETLINK messages, it's possible some // interfaces never got their name set. Resolve them using if_indextoname or remove them. resolve_or_remove_nameless_interfaces(out);