Backed out changeset 1c2af90126ee (bug 1787321) for causing bp-hybrid build bustages in netwerk/base/ARefBase.h CLOSED TREE

This commit is contained in:
Sandor Molnar 2022-08-30 02:01:11 +03:00
parent 1dbf416fc2
commit f05a07c983
12 changed files with 154 additions and 111 deletions

View file

@ -566,8 +566,9 @@ bool AltSvcTransaction<Validator>::MaybeValidate(nsresult reason) {
return false;
}
nsCOMPtr<nsISSLSocketControl> socketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(socketControl));
nsCOMPtr<nsISupports> secInfo;
mConnection->GetSecurityInfo(getter_AddRefs(secInfo));
nsCOMPtr<nsISSLSocketControl> socketControl = do_QueryInterface(secInfo);
LOG(("AltSvcTransaction::MaybeValidate() %p socketControl=%p\n", this,
socketControl.get()));

View file

@ -2558,8 +2558,9 @@ nsresult Http2Session::RecvAltSvc(Http2Session* self) {
if (!impliedOrigin) {
bool okToReroute = true;
nsCOMPtr<nsISSLSocketControl> ssl;
self->mConnection->GetTLSSocketControl(getter_AddRefs(ssl));
nsCOMPtr<nsISupports> securityInfo;
self->mConnection->GetSecurityInfo(getter_AddRefs(securityInfo));
nsCOMPtr<nsISSLSocketControl> ssl = do_QueryInterface(securityInfo);
if (!ssl) {
okToReroute = false;
}
@ -2594,15 +2595,12 @@ nsresult Http2Session::RecvAltSvc(Http2Session* self) {
}
}
nsCOMPtr<nsISSLSocketControl> tlsSocketControl;
self->mConnection->GetTLSSocketControl(getter_AddRefs(tlsSocketControl));
nsCOMPtr<nsIInterfaceRequestor> callbacks;
if (tlsSocketControl) {
tlsSocketControl->GetNotificationCallbacks(getter_AddRefs(callbacks));
}
nsCOMPtr<nsISupports> callbacks;
self->mConnection->GetSecurityInfo(getter_AddRefs(callbacks));
nsCOMPtr<nsIInterfaceRequestor> irCallbacks = do_QueryInterface(callbacks);
RefPtr<UpdateAltSvcEvent> event =
new UpdateAltSvcEvent(altSvcFieldValue, origin, ci, callbacks);
new UpdateAltSvcEvent(altSvcFieldValue, origin, ci, irCallbacks);
NS_DispatchToMainThread(event);
self->ResetDownstreamState();
return NS_OK;
@ -4140,8 +4138,9 @@ nsresult Http2Session::ConfirmTLSProfile() {
if (!mConnection) return NS_ERROR_FAILURE;
nsCOMPtr<nsISSLSocketControl> ssl;
mConnection->GetTLSSocketControl(getter_AddRefs(ssl));
nsCOMPtr<nsISupports> securityInfo;
mConnection->GetSecurityInfo(getter_AddRefs(securityInfo));
nsCOMPtr<nsISSLSocketControl> ssl = do_QueryInterface(securityInfo);
LOG3(("Http2Session::ConfirmTLSProfile %p sslsocketcontrol=%p\n", this,
ssl.get()));
if (!ssl) return NS_ERROR_FAILURE;
@ -4464,9 +4463,12 @@ bool Http2Session::RealJoinConnection(const nsACString& hostname, int32_t port,
nsresult rv;
bool isJoined = false;
nsCOMPtr<nsISupports> securityInfo;
nsCOMPtr<nsISSLSocketControl> sslSocketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(sslSocketControl));
if (!sslSocketControl) {
mConnection->GetSecurityInfo(getter_AddRefs(securityInfo));
sslSocketControl = do_QueryInterface(securityInfo, &rv);
if (NS_FAILED(rv) || !sslSocketControl) {
return false;
}

View file

@ -1543,9 +1543,12 @@ bool Http3Session::RealJoinConnection(const nsACString& hostname, int32_t port,
nsresult rv;
bool isJoined = false;
nsCOMPtr<nsISupports> securityInfo;
nsCOMPtr<nsISSLSocketControl> sslSocketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(sslSocketControl));
if (!sslSocketControl) {
mConnection->GetSecurityInfo(getter_AddRefs(securityInfo));
sslSocketControl = do_QueryInterface(securityInfo, &rv);
if (NS_FAILED(rv) || !sslSocketControl) {
return false;
}
@ -1885,9 +1888,10 @@ void Http3Session::ZeroRttTelemetry(ZeroRttOutcome aOutcome) {
}
}
nsresult Http3Session::GetTransactionTLSSocketControl(
nsISSLSocketControl** tlsSocketControl) {
NS_IF_ADDREF(*tlsSocketControl = mSocketControl);
nsresult Http3Session::GetTransactionSecurityInfo(nsISupports** secinfo) {
nsCOMPtr<nsISupports> info;
mSocketControl->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(info));
info.forget(secinfo);
return NS_OK;
}

View file

@ -82,8 +82,7 @@ class Http3Session final : public nsAHttpTransaction, public nsAHttpConnection {
void TransactionHasDataToWrite(nsAHttpTransaction* caller) override;
void TransactionHasDataToRecv(nsAHttpTransaction* caller) override;
[[nodiscard]] nsresult GetTransactionTLSSocketControl(
nsISSLSocketControl**) override;
[[nodiscard]] nsresult GetTransactionSecurityInfo(nsISupports**) override;
// This function will be called by QuicSocketControl when the certificate
// verification is done.

View file

@ -107,7 +107,7 @@ class HttpConnectionBase : public nsSupportsWeakReference {
void GetConnectionInfo(nsHttpConnectionInfo** ci) {
*ci = do_AddRef(mConnInfo).take();
}
virtual void GetTLSSocketControl(nsISSLSocketControl** result) = 0;
virtual void GetSecurityInfo(nsISupports** result) = 0;
[[nodiscard]] virtual nsresult ResumeSend() = 0;
[[nodiscard]] virtual nsresult ResumeRecv() = 0;
@ -177,7 +177,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(HttpConnectionBase, HTTPCONNECTIONBASE_IID)
void PrintDiagnostics(nsCString&) override; \
bool TestJoinConnection(const nsACString&, int32_t) override; \
bool JoinConnection(const nsACString&, int32_t) override; \
void GetTLSSocketControl(nsISSLSocketControl** result) override; \
void GetSecurityInfo(nsISupports** result) override; \
[[nodiscard]] nsresult ResumeSend() override; \
[[nodiscard]] nsresult ResumeRecv() override; \
[[nodiscard]] nsresult ForceSend() override; \

View file

@ -346,13 +346,13 @@ nsresult HttpConnectionUDP::TakeTransport(
return NS_ERROR_FAILURE;
}
void HttpConnectionUDP::GetTLSSocketControl(nsISSLSocketControl** secinfo) {
void HttpConnectionUDP::GetSecurityInfo(nsISupports** secinfo) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("HttpConnectionUDP::GetTLSSocketControl http3Session=%p\n",
LOG(("HttpConnectionUDP::GetSecurityInfo http3Session=%p\n",
mHttp3Session.get()));
if (mHttp3Session &&
NS_SUCCEEDED(mHttp3Session->GetTransactionTLSSocketControl(secinfo))) {
NS_SUCCEEDED(mHttp3Session->GetTransactionSecurityInfo(secinfo))) {
return;
}

View file

@ -97,19 +97,25 @@ nsresult TlsHandshaker::InitSSLParams(bool connectingToProxy,
return NS_ERROR_ABORT;
}
nsCOMPtr<nsISSLSocketControl> ssl;
mOwner->GetTLSSocketControl(getter_AddRefs(ssl));
if (!ssl) {
nsresult rv;
nsCOMPtr<nsISupports> securityInfo;
mOwner->GetSecurityInfo(getter_AddRefs(securityInfo));
if (!securityInfo) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsISSLSocketControl> ssl = do_QueryInterface(securityInfo, &rv);
if (NS_FAILED(rv)) {
return rv;
}
// If proxy is use or 0RTT is excluded for a origin, don't use early-data.
if (mConnInfo->UsingProxy() || gHttpHandler->Is0RttTcpExcluded(mConnInfo)) {
ssl->DisableEarlyData();
}
if (proxyStartSSL) {
nsresult rv = ssl->ProxyStartSSL();
rv = ssl->ProxyStartSSL();
if (NS_FAILED(rv)) {
return rv;
}
@ -179,9 +185,16 @@ bool TlsHandshaker::EnsureNPNComplete() {
return false;
}
nsCOMPtr<nsISSLSocketControl> ssl;
mOwner->GetTLSSocketControl(getter_AddRefs(ssl));
if (!ssl) {
nsresult rv = NS_OK;
nsCOMPtr<nsISupports> securityInfo;
mOwner->GetSecurityInfo(getter_AddRefs(securityInfo));
if (!securityInfo) {
FinishNPNSetup(false, false);
return true;
}
nsCOMPtr<nsISSLSocketControl> ssl = do_QueryInterface(securityInfo, &rv);
if (NS_FAILED(rv)) {
FinishNPNSetup(false, false);
return true;
}
@ -198,7 +211,7 @@ bool TlsHandshaker::EnsureNPNComplete() {
LOG(("TlsHandshaker::EnsureNPNComplete [mOwner=%p] drive TLS handshake",
mOwner.get()));
nsresult rv = ssl->DriveHandshake();
rv = ssl->DriveHandshake();
if (NS_FAILED(rv) && rv != NS_BASE_STREAM_WOULD_BLOCK) {
FinishNPNSetup(false, true);
return true;

View file

@ -11,10 +11,9 @@
#include "nsAHttpTransaction.h"
#include "HttpTrafficAnalyzer.h"
class nsISocketTransport;
class nsIAsyncInputStream;
class nsIAsyncOutputStream;
class nsISSLSocketControl;
class nsISocketTransport;
namespace mozilla {
namespace net {
@ -106,8 +105,8 @@ class nsAHttpConnection : public nsISupports {
nsIAsyncInputStream**,
nsIAsyncOutputStream**) = 0;
// called by a transaction to get the TLS socket control from the socket.
virtual void GetTLSSocketControl(nsISSLSocketControl**) = 0;
// called by a transaction to get the security info from the socket.
virtual void GetSecurityInfo(nsISupports**) = 0;
// called by a transaction to determine whether or not the connection is
// persistent... important in determining the end of a response.
@ -196,12 +195,12 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpConnection, NS_AHTTPCONNECTION_IID)
} \
return (fwdObject)->GetConnectionInfo(result); \
} \
void GetTLSSocketControl(nsISSLSocketControl** result) override { \
void GetSecurityInfo(nsISupports** result) override { \
if (!(fwdObject)) { \
*result = nullptr; \
return; \
} \
return (fwdObject)->GetTLSSocketControl(result); \
return (fwdObject)->GetSecurityInfo(result); \
} \
[[nodiscard]] nsresult ResumeSend() override { \
if (!(fwdObject)) return NS_ERROR_FAILURE; \

View file

@ -5,6 +5,7 @@
#ifndef nsAHttpTransaction_h__
#define nsAHttpTransaction_h__
#include "nsISupports.h"
#include "nsTArray.h"
#include "nsWeakReference.h"
@ -18,10 +19,9 @@ typedef __StatusTmp Status;
class nsIDNSHTTPSSVCRecord;
class nsIInterfaceRequestor;
class nsIRequestContext;
class nsISSLSocketControl;
class nsISVCBRecord;
class nsITransport;
class nsIRequestContext;
namespace mozilla {
namespace net {
@ -167,14 +167,13 @@ class nsAHttpTransaction : public nsSupportsWeakReference {
virtual bool ResponseTimeoutEnabled() const;
virtual PRIntervalTime ResponseTimeout();
// conceptually the socket control is part of the connection, but sometimes
// conceptually the security info is part of the connection, but sometimes
// in the case of TLS tunneled within TLS the transaction might present
// a more specific socket control that cannot be represented as a layer in
// a more specific security info that cannot be represented as a layer in
// the connection due to multiplexing. This interface represents such an
// overload. If it returns NS_FAILURE the connection should be considered
// authoritative.
[[nodiscard]] virtual nsresult GetTransactionTLSSocketControl(
nsISSLSocketControl**) {
[[nodiscard]] virtual nsresult GetTransactionSecurityInfo(nsISupports**) {
return NS_ERROR_NOT_IMPLEMENTED;
}

View file

@ -33,6 +33,7 @@
#include "nsProxyRelease.h"
#include "nsSocketTransport2.h"
#include "nsStringStream.h"
#include "nsITransportSecurityInfo.h"
#include "mozpkix/pkixnss.h"
#include "sslerr.h"
#include "sslt.h"
@ -643,10 +644,14 @@ void nsHttpConnection::Close(nsresult reason, bool aIsShutdown) {
}
}
nsCOMPtr<nsISSLSocketControl> ssl;
GetTLSSocketControl(getter_AddRefs(ssl));
if (ssl) {
ssl->SetHandshakeCallbackListener(nullptr);
nsCOMPtr<nsISupports> securityInfo;
GetSecurityInfo(getter_AddRefs(securityInfo));
if (securityInfo) {
nsresult rv;
nsCOMPtr<nsISSLSocketControl> ssl = do_QueryInterface(securityInfo, &rv);
if (NS_SUCCEEDED(rv)) {
ssl->SetHandshakeCallbackListener(nullptr);
}
}
if (NS_FAILED(reason)) {
@ -1184,23 +1189,26 @@ void nsHttpConnection::UpdateTCPKeepalive(nsITimer* aTimer, void* aClosure) {
}
}
void nsHttpConnection::GetTLSSocketControl(
nsISSLSocketControl** tlsSocketControl) {
void nsHttpConnection::GetSecurityInfo(nsISupports** secinfo) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnection::GetSecurityInfo trans=%p socket=%p\n",
mTransaction.get(), mSocketTransport.get()));
*tlsSocketControl = nullptr;
if (mTransaction && NS_SUCCEEDED(mTransaction->GetTransactionTLSSocketControl(
tlsSocketControl))) {
if (mTransaction &&
NS_SUCCEEDED(mTransaction->GetTransactionSecurityInfo(secinfo))) {
return;
}
if (mSocketTransport &&
NS_SUCCEEDED(mSocketTransport->GetTlsSocketControl(tlsSocketControl))) {
return;
if (mSocketTransport) {
nsCOMPtr<nsISSLSocketControl> tlsSocketControl;
if (NS_SUCCEEDED(mSocketTransport->GetTlsSocketControl(
getter_AddRefs(tlsSocketControl)))) {
tlsSocketControl.forget(secinfo);
return;
}
}
*secinfo = nullptr;
}
nsresult nsHttpConnection::PushBack(const char* data, uint32_t length) {
@ -1416,12 +1424,13 @@ void nsHttpConnection::CloseTransaction(nsAHttpTransaction* trans,
bool nsHttpConnection::CheckCanWrite0RTTData() {
MOZ_ASSERT(mTlsHandshaker->EarlyDataAvailable());
nsCOMPtr<nsISSLSocketControl> ssl;
GetTLSSocketControl(getter_AddRefs(ssl));
if (!ssl) {
nsCOMPtr<nsISupports> securityInfo;
GetSecurityInfo(getter_AddRefs(securityInfo));
if (!securityInfo) {
return false;
}
nsCOMPtr<nsITransportSecurityInfo> info(do_QueryInterface(ssl));
nsCOMPtr<nsITransportSecurityInfo> info;
info = do_QueryInterface(securityInfo);
if (!info) {
return false;
}
@ -1432,6 +1441,11 @@ bool nsHttpConnection::CheckCanWrite0RTTData() {
if (NS_FAILED(rv)) {
return true;
}
nsCOMPtr<nsISSLSocketControl> ssl;
ssl = do_QueryInterface(securityInfo);
if (!ssl) {
return false;
}
bool earlyDataAccepted = false;
rv = ssl->GetEarlyDataAccepted(&earlyDataAccepted);
// If 0RTT data is accepted we can continue writing data,
@ -2253,21 +2267,30 @@ void nsHttpConnection::HandshakeDoneInternal() {
if (mTlsHandshaker->NPNComplete()) {
return;
}
nsresult rv = NS_OK;
nsCOMPtr<nsISupports> securityInfo;
nsCOMPtr<nsITransportSecurityInfo> info;
nsCOMPtr<nsISSLSocketControl> ssl;
GetTLSSocketControl(getter_AddRefs(ssl));
if (!ssl) {
mTlsHandshaker->FinishNPNSetup(false, false);
return;
}
nsCOMPtr<nsITransportSecurityInfo> info(do_QueryInterface(ssl));
if (!info) {
mTlsHandshaker->FinishNPNSetup(false, false);
return;
}
nsAutoCString negotiatedNPN;
GetSecurityInfo(getter_AddRefs(securityInfo));
if (!securityInfo) {
mTlsHandshaker->FinishNPNSetup(false, false);
return;
}
ssl = do_QueryInterface(securityInfo, &rv);
if (NS_FAILED(rv)) {
mTlsHandshaker->FinishNPNSetup(false, false);
return;
}
info = do_QueryInterface(securityInfo, &rv);
if (NS_FAILED(rv)) {
mTlsHandshaker->FinishNPNSetup(false, false);
return;
}
DebugOnly<nsresult> rvDebug = info->GetNegotiatedNPN(negotiatedNPN);
MOZ_ASSERT(NS_SUCCEEDED(rvDebug));
@ -2279,7 +2302,7 @@ void nsHttpConnection::HandshakeDoneInternal() {
("nsHttpConnection::HandshakeDone [this=%p] - early data "
"that was sent during 0RTT %s been accepted [rv=%" PRIx32 "].",
this, earlyDataAccepted ? "has" : "has not",
static_cast<uint32_t>(rvEarlyData)));
static_cast<uint32_t>(rv)));
if (NS_FAILED(rvEarlyData) ||
(mTransaction &&

View file

@ -735,10 +735,10 @@ nsresult nsHttpTransaction::ReadSegments(nsAHttpSegmentReader* reader,
if (!mConnected && !m0RTTInProgress) {
mConnected = true;
nsCOMPtr<nsISSLSocketControl> tlsSocketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(tlsSocketControl));
nsCOMPtr<nsISupports> info;
mConnection->GetSecurityInfo(getter_AddRefs(info));
MutexAutoLock lock(mLock);
mTLSSocketControl = tlsSocketControl;
mSecurityInfo = info;
}
mDeferredSendProgress = false;
@ -979,7 +979,7 @@ bool nsHttpTransaction::DataSentToChildProcess() { return false; }
already_AddRefed<nsISupports> nsHttpTransaction::SecurityInfo() {
MutexAutoLock lock(mLock);
return do_AddRef(mTLSSocketControl);
return do_AddRef(mSecurityInfo);
}
bool nsHttpTransaction::HasStickyConnection() const {
@ -1220,10 +1220,12 @@ void nsHttpTransaction::PrepareConnInfoForRetry(nsresult aReason) {
LOG((" Got SSL_ERROR_ECH_RETRY_WITH_ECH, use retry echConfig"));
MOZ_ASSERT(mConnection);
nsCOMPtr<nsISSLSocketControl> socketControl;
nsCOMPtr<nsISupports> secInfo;
if (mConnection) {
mConnection->GetTLSSocketControl(getter_AddRefs(socketControl));
mConnection->GetSecurityInfo(getter_AddRefs(secInfo));
}
nsCOMPtr<nsISSLSocketControl> socketControl = do_QueryInterface(secInfo);
MOZ_ASSERT(socketControl);
nsAutoCString retryEchConfig;
@ -1381,11 +1383,11 @@ void nsHttpTransaction::Close(nsresult reason) {
connReused = mConnection->IsReused();
isHttp2or3 = mConnection->Version() >= HttpVersion::v2_0;
if (!mConnected) {
// Try to get TLSSocketControl for this transaction.
nsCOMPtr<nsISSLSocketControl> tlsSocketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(tlsSocketControl));
// Try to get SecurityInfo for this transaction.
nsCOMPtr<nsISupports> info;
mConnection->GetSecurityInfo(getter_AddRefs(info));
MutexAutoLock lock(mLock);
mTLSSocketControl = tlsSocketControl;
mSecurityInfo = info;
}
}
mConnected = false;
@ -1751,7 +1753,7 @@ nsresult nsHttpTransaction::Restart() {
// clear old connection state...
{
MutexAutoLock lock(mLock);
mTLSSocketControl = nullptr;
mSecurityInfo = nullptr;
}
if (mConnection) {
@ -2918,10 +2920,10 @@ nsresult nsHttpTransaction::Finish0RTT(bool aRestart,
} else if (!mConnected) {
// this is code that was skipped in ::ReadSegments while in 0RTT
mConnected = true;
nsCOMPtr<nsISSLSocketControl> tlsSocketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(tlsSocketControl));
nsCOMPtr<nsISupports> info;
mConnection->GetSecurityInfo(getter_AddRefs(info));
MutexAutoLock lock(mLock);
mTLSSocketControl = tlsSocketControl;
mSecurityInfo = info;
}
return NS_OK;
}
@ -3043,8 +3045,9 @@ void nsHttpTransaction::NotifyTransactionObserver(nsresult reason) {
((mConnection->Version() == HttpVersion::v2_0) ||
(mConnection->Version() == HttpVersion::v3_0)));
nsCOMPtr<nsISSLSocketControl> socketControl;
mConnection->GetTLSSocketControl(getter_AddRefs(socketControl));
nsCOMPtr<nsISupports> secInfo;
mConnection->GetSecurityInfo(getter_AddRefs(secInfo));
nsCOMPtr<nsISSLSocketControl> socketControl = do_QueryInterface(secInfo);
LOG(
("nsHttpTransaction::NotifyTransactionObserver"
" version %u socketControl %p\n",

View file

@ -6,26 +6,26 @@
#ifndef nsHttpTransaction_h__
#define nsHttpTransaction_h__
#include "ARefBase.h"
#include "EventTokenBucket.h"
#include "Http2Push.h"
#include "nsHttp.h"
#include "nsAHttpTransaction.h"
#include "HttpTransactionShell.h"
#include "nsAHttpConnection.h"
#include "EventTokenBucket.h"
#include "nsCOMPtr.h"
#include "nsIAsyncOutputStream.h"
#include "nsThreadUtils.h"
#include "nsIInterfaceRequestor.h"
#include "nsIAsyncOutputStream.h"
#include "nsITimer.h"
#include "nsIEarlyHintObserver.h"
#include "nsTHashMap.h"
#include "nsIClassOfService.h"
#include "TimingStruct.h"
#include "mozilla/StaticPrefs_security.h"
#include "Http2Push.h"
#include "mozilla/net/DNS.h"
#include "mozilla/net/NeckoChannelParams.h"
#include "nsAHttpConnection.h"
#include "nsAHttpTransaction.h"
#include "nsCOMPtr.h"
#include "nsHttp.h"
#include "nsIAsyncOutputStream.h"
#include "nsIClassOfService.h"
#include "nsIEarlyHintObserver.h"
#include "nsIInterfaceRequestor.h"
#include "nsISSLSocketControl.h"
#include "nsITimer.h"
#include "nsTHashMap.h"
#include "nsThreadUtils.h"
#include "mozilla/StaticPrefs_security.h"
#include "ARefBase.h"
//-----------------------------------------------------------------------------
@ -306,7 +306,7 @@ class nsHttpTransaction final : public nsAHttpTransaction,
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsITransportEventSink> mTransportSink;
nsCOMPtr<nsIEventTarget> mConsumerTarget;
nsCOMPtr<nsISSLSocketControl> mTLSSocketControl;
nsCOMPtr<nsISupports> mSecurityInfo;
nsCOMPtr<nsIAsyncInputStream> mPipeIn;
nsCOMPtr<nsIAsyncOutputStream> mPipeOut;
nsCOMPtr<nsIRequestContext> mRequestContext;