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
This commit is contained in:
parent
6cf75230d9
commit
918bd72225
1 changed files with 1 additions and 5 deletions
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#include <async_safe/log.h>
|
||||
#include <cutils/misc.h> // FIRST_APPLICATION_UID
|
||||
#include <errno.h>
|
||||
#include <linux/if_packet.h>
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue