diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2018-05-01 16:19:01 +0900 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2018-05-11 00:56:51 +0900 |
commit | 5089e875599dabf51c0ddc18889fcd1515355c5c (patch) | |
tree | 964c0e656f4148e010f401cef2bb32d531918277 | |
parent | 775fb0962173f07aeb46c8ae764a35a85e00a3f0 (diff) | |
download | bionic-5089e875599dabf51c0ddc18889fcd1515355c5c.tar.gz |
fchown DNS lookup sockets to AID_DNS.
Currently DNS lookups are all sent as UID 0. In N we added an
AID_DNS user, but we never used it. A separate UID allows us to
account for and route DNS traffic differently from other UID 0
traffic such as kernel-originated traffic.
(cherry picked from commit 5f02720c880de23c053d6054fe8a3165f23ed749)
Fix: 29420831
Bug: 70673901
Test: DNS lookups continue to work
Test: netd_{unit,integration}_test pass
Change-Id: Ife3ca7df45de51b92437d2cfe627fb4703b672fb
Merged-In: I1c76fac51bdd4804620fe8a8567c9a650b8734d9
-rw-r--r-- | libc/dns/resolv/res_send.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libc/dns/resolv/res_send.c b/libc/dns/resolv/res_send.c index 3b94fcf78..18bb75279 100644 --- a/libc/dns/resolv/res_send.c +++ b/libc/dns/resolv/res_send.c @@ -100,6 +100,7 @@ __RCSID("$NetBSD: res_send.c,v 1.9 2006/01/24 17:41:25 christos Exp $"); #ifdef ANDROID_CHANGES #include "resolv_netid.h" #include "resolv_private.h" +#include "private/android_filesystem_config.h" #else #include <resolv.h> #endif @@ -820,6 +821,7 @@ send_vc(res_state statp, return (-1); } } + fchown(statp->_vcsock, AID_DNS, -1); if (statp->_mark != MARK_UNSET) { if (setsockopt(statp->_vcsock, SOL_SOCKET, SO_MARK, &statp->_mark, sizeof(statp->_mark)) < 0) { @@ -1122,6 +1124,7 @@ send_dg(res_state statp, } } + fchown(EXT(statp).nssocks[ns], AID_DNS, -1); if (statp->_mark != MARK_UNSET) { if (setsockopt(EXT(statp).nssocks[ns], SOL_SOCKET, SO_MARK, &(statp->_mark), sizeof(statp->_mark)) < 0) { |