|
| 1 | +From 38e3c0f2a9d289afd1cf83f7def2e42823084c58 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Kevin Lockwood <v-klockwood@microsoft.com> |
| 3 | +Date: Wed, 26 Feb 2025 14:12:06 -0800 |
| 4 | +Subject: [PATCH] Patch llvm16 for CVE-2023-29933 [Medium] |
| 5 | + |
| 6 | +Link: https://github.com/llvm/llvm-project/commit/ae8cb6437294ca99ba203607c0dd522db4dbf6b6.patch |
| 7 | +--- |
| 8 | + .../SCF/Transforms/BufferizableOpInterfaceImpl.cpp | 12 ++++++++---- |
| 9 | + .../one-shot-module-bufferize-invalid.mlir | 14 ++++++++++++++ |
| 10 | + 2 files changed, 22 insertions(+), 4 deletions(-) |
| 11 | + |
| 12 | +diff --git a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp |
| 13 | +index 630edd300..ad621e50c 100644 |
| 14 | +--- a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp |
| 15 | ++++ b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp |
| 16 | +@@ -954,10 +954,12 @@ struct WhileOpInterface |
| 17 | + |
| 18 | + auto conditionOp = whileOp.getConditionOp(); |
| 19 | + for (const auto &it : llvm::enumerate(conditionOp.getArgs())) { |
| 20 | ++ Block *block = conditionOp->getBlock(); |
| 21 | + if (!it.value().getType().isa<TensorType>()) |
| 22 | + continue; |
| 23 | +- if (!state.areEquivalentBufferizedValues( |
| 24 | +- it.value(), conditionOp->getBlock()->getArgument(it.index()))) |
| 25 | ++ if (it.index() >= block->getNumArguments() || |
| 26 | ++ !state.areEquivalentBufferizedValues(it.value(), |
| 27 | ++ block->getArgument(it.index()))) |
| 28 | + return conditionOp->emitError() |
| 29 | + << "Condition arg #" << it.index() |
| 30 | + << " is not equivalent to the corresponding iter bbArg"; |
| 31 | +@@ -965,10 +967,12 @@ struct WhileOpInterface |
| 32 | + |
| 33 | + auto yieldOp = whileOp.getYieldOp(); |
| 34 | + for (const auto &it : llvm::enumerate(yieldOp.getResults())) { |
| 35 | ++ Block *block = yieldOp->getBlock(); |
| 36 | + if (!it.value().getType().isa<TensorType>()) |
| 37 | + continue; |
| 38 | +- if (!state.areEquivalentBufferizedValues( |
| 39 | +- it.value(), yieldOp->getBlock()->getArgument(it.index()))) |
| 40 | ++ if (it.index() >= block->getNumArguments() || |
| 41 | ++ !state.areEquivalentBufferizedValues(it.value(), |
| 42 | ++ block->getArgument(it.index()))) |
| 43 | + return yieldOp->emitError() |
| 44 | + << "Yield operand #" << it.index() |
| 45 | + << " is not equivalent to the corresponding iter bbArg"; |
| 46 | +diff --git a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir |
| 47 | +index da0fe74db..10075fc8a 100644 |
| 48 | +--- a/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir |
| 49 | ++++ b/mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir |
| 50 | +@@ -315,3 +315,17 @@ func.func @yield_alloc_dominance_test_2(%cst : f32, %idx : index, |
| 51 | + %r = tensor.extract %2[%idx2] : tensor<?xf32> |
| 52 | + return %r : f32 |
| 53 | + } |
| 54 | ++ |
| 55 | ++// ----- |
| 56 | ++ |
| 57 | ++func.func @regression_scf_while() { |
| 58 | ++ %false = arith.constant false |
| 59 | ++ %8 = bufferization.alloc_tensor() : tensor<10x10xf32> |
| 60 | ++ scf.while (%arg0 = %8) : (tensor<10x10xf32>) -> () { |
| 61 | ++ scf.condition(%false) |
| 62 | ++ } do { |
| 63 | ++ // expected-error @+1 {{Yield operand #0 is not equivalent to the corresponding iter bbArg}} |
| 64 | ++ scf.yield %8 : tensor<10x10xf32> |
| 65 | ++ } |
| 66 | ++ return |
| 67 | ++} |
| 68 | +-- |
| 69 | +2.34.1 |
| 70 | + |
0 commit comments