summaryrefslogtreecommitdiff
path: root/resolv/res_cache.cpp
diff options
context:
space:
mode:
authorLuke Huang <huangluke@google.com>2020-07-07 23:11:05 +0800
committermosimchah <mosimchah@gmail.com>2020-12-15 02:32:52 -0500
commit4d5ab4290b20bcaa873aaaacc0264615e9e4f65d (patch)
tree7f460d0e0b572abe0411d72aefbd735431201fcb /resolv/res_cache.cpp
parentb4939e066230e96fc0637b8f48c8c0ddef6a4ccc (diff)
Backport: Fix the side channel attack by using async DnsResolver API with FLAG_NO_CACHE_STOREq10.0
Before this CL, FLAG_NO_CACHE_STORE could be used to perform side channel attack. Because this flag ensures the result is never added to the cache, but will return a cached response if one exists. So make FLAG_NO_CACHE_STORE imply FLAG_NO_CACHE_LOOKUP to block the possibility of side channel attacking. Bug: 150371903 Test: atest Because DnsResolver had been moved to another git project in R, use aosp/1302595 as Merged-In tag to avoid conflict. Merged-In: I1ff2dc09f41f76973c5f066b07b15388e722b375 Change-Id: Ic0ef9b22bb5992b083bebc4f530acd63a02ac31c (cherry picked from commit 91945c82ec4e8eda4cdd85b77029cceccfa11769)
Diffstat (limited to 'resolv/res_cache.cpp')
-rw-r--r--resolv/res_cache.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/resolv/res_cache.cpp b/resolv/res_cache.cpp
index d6f0cd80..879ddbb4 100644
--- a/resolv/res_cache.cpp
+++ b/resolv/res_cache.cpp
@@ -1423,7 +1423,9 @@ ResolvCacheStatus _resolv_cache_lookup(unsigned netid, const void* query, int qu
// possible to cache the answer of this query.
// If ANDROID_RESOLV_NO_CACHE_STORE is set, return RESOLV_CACHE_SKIP to skip possible cache
// storing.
- if (flags & ANDROID_RESOLV_NO_CACHE_LOOKUP) {
+ // (b/150371903): ANDROID_RESOLV_NO_CACHE_STORE should imply ANDROID_RESOLV_NO_CACHE_LOOKUP
+ // to avoid side channel attack.
+ if (flags & (ANDROID_RESOLV_NO_CACHE_LOOKUP | ANDROID_RESOLV_NO_CACHE_STORE)) {
return flags & ANDROID_RESOLV_NO_CACHE_STORE ? RESOLV_CACHE_SKIP : RESOLV_CACHE_NOTFOUND;
}
Entry key;
@@ -1456,11 +1458,6 @@ ResolvCacheStatus _resolv_cache_lookup(unsigned netid, const void* query, int qu
if (e == NULL) {
LOG(INFO) << __func__ << ": NOT IN CACHE";
- // If it is no-cache-store mode, we won't wait for possible query.
- if (flags & ANDROID_RESOLV_NO_CACHE_STORE) {
- return RESOLV_CACHE_SKIP;
- }
-
if (!cache_has_pending_request_locked(cache, &key, true)) {
return RESOLV_CACHE_NOTFOUND;