mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-08-08 07:40:39 -09:00
GP-0 Fix for trust write memory flag ignored, don't disassemble in
non-executable memory on computed references
This commit is contained in:
@@ -23,8 +23,7 @@ import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
import ghidra.program.model.mem.MemoryBufferImpl;
|
||||
import ghidra.program.model.mem.*;
|
||||
import ghidra.program.model.pcode.PcodeOp;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
@@ -220,8 +219,10 @@ public class ConstantPropagationContextEvaluator extends ContextEvaluatorAdapter
|
||||
}
|
||||
|
||||
// if flowing to an address, disassemble it
|
||||
// only disassemble in executable memory
|
||||
Memory memory = program.getMemory();
|
||||
if (refType.isFlow() && !refType.isIndirect() &&
|
||||
!program.getMemory().isExternalBlockAddress(address)) {
|
||||
!memory.isExternalBlockAddress(address) && memory.getExecuteSet().contains(address)) {
|
||||
Data udata = program.getListing().getUndefinedDataAt(address);
|
||||
if (udata != null) {
|
||||
DisassembleCommand cmd = new DisassembleCommand(address, null, true);
|
||||
|
||||
@@ -530,7 +530,8 @@ public class VarnodeContext implements ProcessorContext {
|
||||
}
|
||||
|
||||
// If the memory is Writeable, then maybe don't trust it
|
||||
if (!isReadOnly(addr)) {
|
||||
boolean isReadOnly = isReadOnly(addr);
|
||||
if (!isReadOnly) {
|
||||
// don't try to see how far away if it is in a different space.
|
||||
if (addr.getAddressSpace()
|
||||
.equals(this.spaceContext.getAddress().getAddressSpace())) {
|
||||
@@ -572,8 +573,10 @@ public class VarnodeContext implements ProcessorContext {
|
||||
value = (value << 8 * (8 - size)) >> 8 * (8 - size);
|
||||
}
|
||||
|
||||
// constants pulled from memory are always suspect
|
||||
return createVarnode(value, SUSPECT_OFFSET_SPACEID, size);
|
||||
// constants pulled from memory are suspec
|
||||
// unless memory is readonly, or given access from evaluator (trustWriteAccess)
|
||||
int spaceId = (isReadOnly || evaluator.allowAccess(this, addr)) ? 0 : SUSPECT_OFFSET_SPACEID;
|
||||
return createVarnode(value, spaceId, size);
|
||||
|
||||
}
|
||||
catch (MemoryAccessException e) {
|
||||
|
||||
Reference in New Issue
Block a user