-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect ACLFilledChecklist heap allocations from leaking #1870
Changes from 13 commits
5229b55
ff6fb73
769e66b
e252105
ed12451
08aa0ee
f8d024e
3c6612c
faead84
c99385f
f95d411
664008b
43419b9
948fb09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2484,7 +2484,7 @@ ConnStateData::postHttpsAccept() | |||||||||
CodeContext::Reset(connectAle); | ||||||||||
// TODO: Use these request/ALE when waiting for new bumped transactions. | ||||||||||
|
||||||||||
const auto acl_checklist = new ACLFilledChecklist(Config.accessList.ssl_bump, request); | ||||||||||
auto acl_checklist = ACLFilledChecklist::Make(Config.accessList.ssl_bump, request); | ||||||||||
fillChecklist(*acl_checklist); | ||||||||||
// Build a local AccessLogEntry to allow requiresAle() acls work | ||||||||||
acl_checklist->al = connectAle; | ||||||||||
|
@@ -2501,7 +2501,7 @@ ConnStateData::postHttpsAccept() | |||||||||
ClientHttpRequest *http = context ? context->http : nullptr; | ||||||||||
const char *log_uri = http ? http->log_uri : nullptr; | ||||||||||
acl_checklist->syncAle(request, log_uri); | ||||||||||
acl_checklist->nonBlockingCheck(httpsSslBumpAccessCheckDone, this); | ||||||||||
ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), httpsSslBumpAccessCheckDone, this); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This explicit std::move() call (and similar calls added in this PR) is one of those exceptional cases where forcing developer to write (and code reader to see) this explicit std::move call is desirable: We want to emphasize that acl_checklist may be gone after this NonBlockingCheck() call returns. BTW, GCC and clang do not do that for us automatically, but we plan to enhance our CI tests to automatically check Squid code for use-after-move errors. This comment does not request any PR changes. |
||||||||||
#else | ||||||||||
fatal("FATAL: SSL-Bump requires --with-openssl"); | ||||||||||
#endif | ||||||||||
|
@@ -2967,12 +2967,12 @@ ConnStateData::startPeekAndSplice() | |||||||||
sslServerBump->step = XactionStep::tlsBump2; | ||||||||||
// Run a accessList check to check if want to splice or continue bumping | ||||||||||
|
||||||||||
const auto acl_checklist = new ACLFilledChecklist(Config.accessList.ssl_bump, sslServerBump->request.getRaw()); | ||||||||||
auto acl_checklist = ACLFilledChecklist::Make(Config.accessList.ssl_bump, sslServerBump->request.getRaw()); | ||||||||||
acl_checklist->banAction(Acl::Answer(ACCESS_ALLOWED, Ssl::bumpNone)); | ||||||||||
acl_checklist->banAction(Acl::Answer(ACCESS_ALLOWED, Ssl::bumpClientFirst)); | ||||||||||
acl_checklist->banAction(Acl::Answer(ACCESS_ALLOWED, Ssl::bumpServerFirst)); | ||||||||||
fillChecklist(*acl_checklist); | ||||||||||
acl_checklist->nonBlockingCheck(httpsSslBumpStep2AccessCheckDone, this); | ||||||||||
ACLFilledChecklist::NonBlockingCheck(std::move(acl_checklist), httpsSslBumpStep2AccessCheckDone, this); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If others prefer, we can simplify this to remove ACLFilledChecklist prefix by making NonBlockingCheck() into a global function:
Suggested change
or
Suggested change
Due to fairly unique parameter types, such a global function is unlikely to clash with other non-blocking check functions. Please add a comment if you want to see this kind of change (at the cost of adding a corresponding This comment, byt itself, does not request any PR changes. |
||||||||||
return; | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -3111,7 +3111,7 @@ ConnStateData::initiateTunneledRequest(HttpRequest::Pointer const &cause, const | |||||||||
// TLS handshakes on non-bumping https_port. TODO: Discover these | ||||||||||
// problems earlier so that they can be classified/detailed better. | ||||||||||
debugs(33, 2, "Not able to compute URL, abort request tunneling for " << reason); | ||||||||||
// TODO: throw when nonBlockingCheck() callbacks gain job protections | ||||||||||
// TODO: throw when NonBlockingCheck() callbacks gain job protections | ||||||||||
static const auto d = MakeNamedErrorDetail("TUNNEL_TARGET"); | ||||||||||
updateError(ERR_INVALID_REQ, d); | ||||||||||
return false; | ||||||||||
|
@@ -3448,10 +3448,10 @@ varyEvaluateMatch(StoreEntry * entry, HttpRequest * request) | |||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
ACLFilledChecklist * | ||||||||||
ACLFilledChecklist::MakingPointer | ||||||||||
clientAclChecklistCreate(const acl_access * acl, ClientHttpRequest * http) | ||||||||||
{ | ||||||||||
const auto checklist = new ACLFilledChecklist(acl, nullptr); | ||||||||||
auto checklist = ACLFilledChecklist::Make(acl, nullptr); | ||||||||||
clientAclChecklistFill(*checklist, http); | ||||||||||
return checklist; | ||||||||||
} | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possible type name that still addresses the documented "this is not our regular Pointer" concern is UniquePointer:
I prefer MakingPointer because it is more specific to this smart pointer primary purpose, but I acknowledge that "making pointer" is ambiguous.
This comment does not request any PR changes.