Skip to content

Commit

Permalink
Update net from Chromium 114.0.5735.358
Browse files Browse the repository at this point in the history
Issue: 326748668
Reviewed-on: #3042
  • Loading branch information
dahlstrom-g committed Apr 23, 2024
2 parents dcc4175 + 712a421 commit d7aed9e
Show file tree
Hide file tree
Showing 23 changed files with 380 additions and 126 deletions.
17 changes: 7 additions & 10 deletions net/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,6 @@ component("net") {
sources += [
"base/network_change_notifier_linux.cc",
"base/network_change_notifier_linux.h",
"base/network_interfaces_linux.cc",
"base/platform_mime_util_linux.cc",
"proxy_resolution/proxy_config_service_linux.cc",
"proxy_resolution/proxy_config_service_linux.h",
]
Expand Down Expand Up @@ -1710,7 +1708,6 @@ source_set("net_deps") {
":cronet_buildflags",
":isolation_info_proto",
":net_export_header",

":net_resources",
":preload_decoder",
"//base",
Expand All @@ -1719,7 +1716,6 @@ source_set("net_deps") {
"//third_party/protobuf:protobuf_lite",
"//third_party/zlib",
"//url:buildflags",

"//third_party/boringssl",
]

Expand Down Expand Up @@ -2146,7 +2142,7 @@ static_library("test_support") {
]
if (is_win) {
sources += [ "test/spawned_test_server/local_test_server_win.cc" ]
} else if (is_posix) {
} else if (is_posix || is_fuchsia) {
sources += [ "test/spawned_test_server/local_test_server_posix.cc" ]
}
}
Expand Down Expand Up @@ -2216,7 +2212,10 @@ if (!is_ios && !is_android && !use_cobalt_customizations) {

proto_library("cert_verify_comparison_tool_proto") {
sources = [ "tools/cert_verify_tool/dumper.proto" ]
# visibility = [ ":cert_verify_comparison_tool" ]

if (!use_cobalt_customizations) {
visibility = [ ":cert_verify_comparison_tool" ]
}
}

executable("cert_verify_comparison_tool") {
Expand Down Expand Up @@ -5398,8 +5397,7 @@ if (!use_cobalt_customizations) {
proto_library("backoff_entry_serializer_fuzzer_input") {
proto_in_dir = "//"
sources = [ "base/backoff_entry_serializer_fuzzer_input.proto" ]

# link_deps = [ "//testing/libfuzzer/proto:json_proto" ]
link_deps = [ "//testing/libfuzzer/proto:json_proto" ]
}

fuzzer_test("net_backoff_entry_serializer_fuzzer") {
Expand Down Expand Up @@ -6005,8 +6003,7 @@ if (!use_cobalt_customizations) {
proto_library("reporting_policy_proto") {
proto_in_dir = "//"
sources = [ "reporting/reporting_policy.proto" ]

# link_deps = [ "//testing/libfuzzer/proto:json_proto" ]
link_deps = [ "//testing/libfuzzer/proto:json_proto" ]
}
}

Expand Down
16 changes: 12 additions & 4 deletions net/METADATA
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ description:
"Subtree at net."

third_party {
url {
type: GIT
value: "https://chromium.googlesource.com/chromium/src"
identifier {
type: "ChromiumVersion"
value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html
}
identifier {
type: "Git"
value: "https://chromium.googlesource.com/chromium/src.git"
version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02"
}
identifier {
type: "UpstreamSubdir"
value: "net"
}
version: "114.0.5735.331"
last_upgrade_date {
year: 2023
month: 9
Expand Down
4 changes: 2 additions & 2 deletions net/base/io_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ void GrowableIOBuffer::SetCapacity(int capacity) {
free(real_data_.release());
real_data_.reset();
} else {
real_data_.reset(
static_cast<char*>(realloc(real_data_.release(), capacity)));
real_data_.reset(static_cast<char*>(realloc(real_data_.release(), capacity)));
}

capacity_ = capacity;
if (offset_ > capacity)
set_offset(capacity);
Expand Down
29 changes: 28 additions & 1 deletion net/base/network_change_notifier_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ class NetworkChangeNotifierLinux::BlockingThreadObjects {
// Plumbing for NetworkChangeNotifier::GetCurrentConnectionType.
// Safe to call from any thread.
NetworkChangeNotifier::ConnectionType GetCurrentConnectionType() {
/* Cobalt
return address_tracker_.GetCurrentConnectionType();
Cobalt */
return NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN;
}

/* Cobalt
internal::AddressTrackerLinux* address_tracker() { return &address_tracker_; }
Cobalt */
internal::AddressTrackerLinux* address_tracker() { return nullptr; }

// Begin watching for netlink changes.
Expand All @@ -44,20 +50,41 @@ class NetworkChangeNotifierLinux::BlockingThreadObjects {
void OnIPAddressChanged();
void OnLinkChanged();
// Used to detect online/offline state and IP address changes.
/* Cobalt
internal::AddressTrackerLinux address_tracker_;
Cobalt */
NetworkChangeNotifier::ConnectionType last_type_ =
NetworkChangeNotifier::CONNECTION_NONE;
};

NetworkChangeNotifierLinux::BlockingThreadObjects::BlockingThreadObjects(
const std::unordered_set<std::string>& ignored_interfaces,
scoped_refptr<base::SequencedTaskRunner> blocking_thread_runner) {}
scoped_refptr<base::SequencedTaskRunner> blocking_thread_runner)
/* Cobalt
: address_tracker_(
base::BindRepeating(&NetworkChangeNotifierLinux::
BlockingThreadObjects::OnIPAddressChanged,
base::Unretained(this)),
base::BindRepeating(
&NetworkChangeNotifierLinux::BlockingThreadObjects::OnLinkChanged,
base::Unretained(this)),
base::DoNothing(),
ignored_interfaces,
std::move(blocking_thread_runner)) {}
Cobalt */ {}

void NetworkChangeNotifierLinux::BlockingThreadObjects::Init() {
/* Cobalt
address_tracker_.Init();
Cobalt */
last_type_ = GetCurrentConnectionType();
}

void NetworkChangeNotifierLinux::BlockingThreadObjects::InitForTesting(
base::ScopedFD netlink_fd) {
/* Cobalt
address_tracker_.InitWithFdForTesting(std::move(netlink_fd)); // IN-TEST
Cobalt */
last_type_ = GetCurrentConnectionType();
}

Expand Down
114 changes: 110 additions & 4 deletions net/base/network_interfaces_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,46 @@ namespace internal {
// or ethtool extensions.
NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType(
const std::string& ifname) {
/* Cobalt
base::ScopedFD s = GetSocketForIoctl();
if (!s.is_valid())
return NetworkChangeNotifier::CONNECTION_UNKNOWN;
// Test wireless extensions for CONNECTION_WIFI
struct iwreq pwrq = {};
strncpy(pwrq.ifr_name, ifname.c_str(), IFNAMSIZ - 1);
if (ioctl(s.get(), SIOCGIWNAME, &pwrq) != -1)
return NetworkChangeNotifier::CONNECTION_WIFI;
#if !BUILDFLAG(IS_ANDROID)
// Test ethtool for CONNECTION_ETHERNET
struct ethtool_cmd ecmd = {};
ecmd.cmd = ETHTOOL_GSET;
struct ifreq ifr = {};
ifr.ifr_data = &ecmd;
strncpy(ifr.ifr_name, ifname.c_str(), IFNAMSIZ - 1);
if (ioctl(s.get(), SIOCETHTOOL, &ifr) != -1)
return NetworkChangeNotifier::CONNECTION_ETHERNET;
#endif // !BUILDFLAG(IS_ANDROID)
Cobalt */

return NetworkChangeNotifier::CONNECTION_UNKNOWN;
}

std::string GetInterfaceSSID(const std::string& ifname) {
/* Cobalt
base::ScopedFD ioctl_socket = GetSocketForIoctl();
if (!ioctl_socket.is_valid())
return std::string();
struct iwreq wreq = {};
strncpy(wreq.ifr_name, ifname.c_str(), IFNAMSIZ - 1);
char ssid[IW_ESSID_MAX_SIZE + 1] = {0};
wreq.u.essid.pointer = ssid;
wreq.u.essid.length = IW_ESSID_MAX_SIZE;
if (ioctl(ioctl_socket.get(), SIOCGIWESSID, &wreq) != -1)
return ssid;
Cobalt */
return std::string();
}

Expand All @@ -98,6 +134,66 @@ bool GetNetworkListImpl(
const std::unordered_set<int>& online_links,
const internal::AddressTrackerLinux::AddressMap& address_map,
GetInterfaceNameFunction get_interface_name) {
/* Cobalt
std::map<int, std::string> ifnames;
for (const auto& it : address_map) {
// Ignore addresses whose links are not online.
if (online_links.find(it.second.ifa_index) == online_links.end())
continue;
sockaddr_storage sock_addr;
socklen_t sock_len = sizeof(sockaddr_storage);
// Convert to sockaddr for next check.
if (!IPEndPoint(it.first, 0)
.ToSockAddr(reinterpret_cast<sockaddr*>(&sock_addr), &sock_len)) {
continue;
}
// Skip unspecified addresses (i.e. made of zeroes) and loopback addresses
if (IsLoopbackOrUnspecifiedAddress(reinterpret_cast<sockaddr*>(&sock_addr)))
continue;
int ip_attributes = IP_ADDRESS_ATTRIBUTE_NONE;
if (it.second.ifa_family == AF_INET6) {
// Ignore addresses whose attributes are not actionable by
// the application layer.
if (!TryConvertNativeToNetIPAttributes(it.second.ifa_flags,
&ip_attributes))
continue;
}
// Find the name of this link.
std::map<int, std::string>::const_iterator itname =
ifnames.find(it.second.ifa_index);
std::string ifname;
if (itname == ifnames.end()) {
char buffer[IFNAMSIZ] = {0};
ifname.assign(get_interface_name(it.second.ifa_index, buffer));
// Ignore addresses whose interface name can't be retrieved.
if (ifname.empty())
continue;
ifnames[it.second.ifa_index] = ifname;
} else {
ifname = itname->second;
}
// Based on the interface name and policy, determine whether we
// should ignore it.
if (ShouldIgnoreInterface(ifname, policy))
continue;
NetworkChangeNotifier::ConnectionType type =
GetInterfaceConnectionType(ifname);
networks->push_back(
NetworkInterface(ifname, ifname, it.second.ifa_index, type, it.first,
it.second.ifa_prefixlen, ip_attributes));
}
Cobalt */

return true;
}

Expand All @@ -119,6 +215,12 @@ std::string GetWifiSSIDFromInterfaceListInternal(
}

base::ScopedFD GetSocketForIoctl() {
/* Cobalt
base::ScopedFD ioctl_socket(socket(AF_INET6, SOCK_DGRAM, 0));
if (ioctl_socket.is_valid())
return ioctl_socket;
return base::ScopedFD(socket(AF_INET, SOCK_DGRAM, 0));
Cobalt */
return base::ScopedFD();
}

Expand Down Expand Up @@ -152,7 +254,9 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
#endif // BUILDFLAG(IS_ANDROID)

const AddressMapOwnerLinux* map_owner = nullptr;
// absl::optional<internal::AddressTrackerLinux> temp_tracker;
/* Cobalt
absl::optional<internal::AddressTrackerLinux> temp_tracker;
Cobalt */
#if BUILDFLAG(IS_LINUX)
// If NetworkChangeNotifier already maintains a map owner in this process, use
// it.
Expand All @@ -161,11 +265,13 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
}
#endif // BUILDFLAG(IS_LINUX)
if (!map_owner) {
/* Cobalt
// If there is no existing map_owner, create an AdressTrackerLinux and
// initialize it.
// temp_tracker.emplace();
// temp_tracker->Init();
// map_owner = &temp_tracker.value();
temp_tracker.emplace();
temp_tracker->Init();
map_owner = &temp_tracker.value();
Cobalt */
}

return internal::GetNetworkListImpl(
Expand Down
32 changes: 17 additions & 15 deletions net/base/platform_mime_util_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,26 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
const base::FilePath::StringType& ext,
std::string* result) const {
return false;
// base::FilePath dummy_path("foo." + ext);
// std::string out = base::nix::GetFileMimeType(dummy_path);
/* Cobalt
base::FilePath dummy_path("foo." + ext);
std::string out = base::nix::GetFileMimeType(dummy_path);
// // GetFileMimeType likes to return application/octet-stream
// // for everything it doesn't know - ignore that.
// if (out == "application/octet-stream" || out.empty())
// return false;
// GetFileMimeType likes to return application/octet-stream
// for everything it doesn't know - ignore that.
if (out == "application/octet-stream" || out.empty())
return false;
// // GetFileMimeType returns image/x-ico because that's what's in the XDG
// // mime database. That database is the merger of the Gnome and KDE mime
// // databases. Apparently someone working on KDE in 2001 decided .ico
// // resolves to image/x-ico, whereas the rest of the world uses image/x-icon.
// // FWIW, image/vnd.microsoft.icon is the official IANA assignment.
// if (out == "image/x-ico")
// out = "image/x-icon";
// GetFileMimeType returns image/x-ico because that's what's in the XDG
// mime database. That database is the merger of the Gnome and KDE mime
// databases. Apparently someone working on KDE in 2001 decided .ico
// resolves to image/x-ico, whereas the rest of the world uses image/x-icon.
// FWIW, image/vnd.microsoft.icon is the official IANA assignment.
if (out == "image/x-ico")
out = "image/x-icon";
// *result = out;
// return true;
*result = out;
return true;
Cobalt */
}

#endif // BUILDFLAG(IS_ANDROID)
Expand Down
20 changes: 11 additions & 9 deletions net/cert/pki/ocsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,20 +765,22 @@ OCSPRevocationStatus GetRevocationStatusForCert(
if (!CheckCertIDMatchesCertificate(cert_id, cert, issuer_certificate))
continue;

/* Cobalt
// The SingleResponse matches the certificate, but may be out of date. Out
// of date responses are noted seperate from responses with mismatched
// serial numbers. If an OCSP responder provides both an up to date
// response and an expired response, the up to date response takes
// precedence (PROVIDED > INVALID_DATE).
// if (!CheckRevocationDateValid(single_response.this_update,
// single_response.has_next_update
// ? &single_response.next_update
// : nullptr,
// verify_time_epoch_seconds, max_age_seconds)) {
// if (*response_details != OCSPVerifyResult::PROVIDED)
// *response_details = OCSPVerifyResult::INVALID_DATE;
// continue;
// }
if (!CheckRevocationDateValid(single_response.this_update,
single_response.has_next_update
? &single_response.next_update
: nullptr,
verify_time_epoch_seconds, max_age_seconds)) {
if (*response_details != OCSPVerifyResult::PROVIDED)
*response_details = OCSPVerifyResult::INVALID_DATE;
continue;
}
Cobalt */

// In the case with multiple matching and up to date responses, keep only
// the strictest status (REVOKED > UNKNOWN > GOOD).
Expand Down
3 changes: 3 additions & 0 deletions net/cookies/cookie_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ bool GetCookieDomainWithString(const GURL& url,
// a sequence of individual domain name labels"; a label can only be empty if
// it is the last label in the name, but a name ending in `..` would have an
// empty label in the penultimate position and is thus invalid.
/* Cobalt
if (url_host.ends_with("..")) {
Cobalt */
if (base::EndsWith(url_host, "..")) {
return false;
}
Expand Down
Loading

0 comments on commit d7aed9e

Please sign in to comment.