[Serialization] Restrict loading all swiftmodules by compiler tag

Swiftmodule loading was previously restricted by compiler tag only for
resilient modules. This left room for resilient modules with a corrupted
control block to pass as non-resilient modules.

Apply the same check for non-resilient modules (so all modules) when
read from a tagged compiler.

rdar://88081456
This commit is contained in:
Alexis Laferrière
2022-01-27 10:44:45 -08:00
parent 493a8c52cd
commit 39c3fc01a8
3 changed files with 16 additions and 21 deletions

View File

@@ -308,8 +308,8 @@ static ValidationInfo validateControlBlock(
break;
}
case control_block::REVISION: {
// Tagged compilers should load only resilient modules if they were
// produced by the exact same version.
// Tagged compilers should only load modules if they were
// produced by the exact same compiler tag.
// Disable this restriction for compiler testing by setting this
// env var to any value.
@@ -328,7 +328,7 @@ static ValidationInfo validateControlBlock(
!version::Version::getCurrentCompilerVersion().empty();
StringRef moduleRevision = blobData;
if (isCompilerTagged && !moduleRevision.empty()) {
if (isCompilerTagged) {
StringRef compilerRevision = forcedDebugRevision ?
forcedDebugRevision : version::getSwiftRevision();
if (moduleRevision != compilerRevision)