Skip to content

Commit ff55dbc

Browse files
committed
fix(symbolizer,stackwalk): Always obtain callstack from real parent process
The callstack should be obtained from the real parent process regardless of which process initiated the creation. The symbolizer now searches the process state the belongs to the real parent if the process creation event is originating from the brokered process.
1 parent a000a1d commit ff55dbc

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

pkg/event/event_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ func (e *Event) StackID() uint64 {
267267
// parent, not the process being created.
268268
func (e *Event) StackPID() uint32 {
269269
if e.IsCreateProcess() {
270+
if e.IsSurrogateProcess() {
271+
return e.Params.MustGetUint32(params.ProcessRealParentID)
272+
}
270273
return e.Params.MustGetPpid()
271274
}
272275
return e.PID

pkg/event/stackwalk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ func (s *StackwalkDecorator) Pop(e *Event) *Event {
140140
evt.AppendParam(params.Callstack, params.Slice, callstack)
141141

142142
// obtain the callstack from the CreateThread event
143-
// generated by the surrogate process, such as Seclogon.
143+
// generated by the surrogate/brokered process, such as
144+
// Secondary Logon.
144145
// If the remote process id is present in the procs map
145146
// the stack is attached to the cached event and then
146147
// pushed to the queue immediately
147-
if (evt.IsCreateRemoteThread() && evt.PS != nil) &&
148-
(evt.PS.IsSeclogonSvc() || evt.PS.IsAppinfoSvc()) {
148+
if evt.IsCreateRemoteThread() {
149149
pid := evt.Params.MustGetPid()
150150
ev, ok := s.procs[pid]
151151
if ok {

pkg/symbolize/symbolizer.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,24 @@ func (s *Symbolizer) produceFrame(addr va.Address, e *event.Event) callstack.Fra
442442
}
443443
}
444444

445-
if e.PS != nil {
446-
mod := e.PS.FindModuleByVa(addr)
445+
ps := e.PS
446+
447+
// for process creation events initiated by
448+
// brokered processes, obtain the real parent
449+
// process state
450+
if e.IsSurrogateProcess() {
451+
var ok bool
452+
ok, ps = s.psnap.Find(e.Params.MustGetUint32(params.ProcessRealParentID))
453+
if !ok {
454+
ps = e.PS
455+
}
456+
}
457+
458+
if ps != nil {
459+
mod := ps.FindModuleByVa(addr)
447460
// perform lookup against parent modules
448-
if mod == nil && e.PS.Parent != nil {
449-
mod = e.PS.Parent.FindModuleByVa(addr)
461+
if mod == nil && ps.Parent != nil {
462+
mod = ps.Parent.FindModuleByVa(addr)
450463
}
451464
if mod == nil {
452465
// our last resort is to enumerate process modules

0 commit comments

Comments
 (0)