MCPcopy
hub / github.com/google/gvisor / executeSyscall

Method executeSyscall

pkg/sentry/kernel/task_syscall.go:84–207  ·  view source on GitHub ↗
(sysno uintptr, args arch.SyscallArguments)

Source from the content-addressed store, hash-verified

82}
83
84func (t *Task) executeSyscall(sysno uintptr, args arch.SyscallArguments) (rval uintptr, ctrl *SyscallControl, err error) {
85 s := t.SyscallTable()
86
87 fe := s.FeatureEnable.Word(sysno)
88
89 var straceContext any
90 if bits.IsAnyOn(fe, StraceEnableBits) {
91 straceContext = s.Stracer.SyscallEnter(t, sysno, args, fe)
92 }
93
94 if bits.IsAnyOn(fe, SecCheckRawEnter) {
95 info := pb.Syscall{
96 Sysno: uint64(sysno),
97 Arg1: args[0].Uint64(),
98 Arg2: args[1].Uint64(),
99 Arg3: args[2].Uint64(),
100 Arg4: args[3].Uint64(),
101 Arg5: args[4].Uint64(),
102 Arg6: args[5].Uint64(),
103 }
104 fields := seccheck.Global.GetFieldSet(seccheck.GetPointForSyscall(seccheck.SyscallRawEnter, sysno))
105 if !fields.Context.Empty() {
106 info.ContextData = &pb.ContextData{}
107 LoadSeccheckData(t, fields.Context, info.ContextData)
108 }
109 seccheck.Global.SentToSinks(func(c seccheck.Sink) error {
110 return c.RawSyscall(t, fields, &info)
111 })
112 }
113 if bits.IsAnyOn(fe, SecCheckEnter) {
114 fields := seccheck.Global.GetFieldSet(seccheck.GetPointForSyscall(seccheck.SyscallEnter, sysno))
115 var ctxData *pb.ContextData
116 if !fields.Context.Empty() {
117 ctxData = &pb.ContextData{}
118 LoadSeccheckData(t, fields.Context, ctxData)
119 }
120 info := SyscallInfo{
121 Sysno: sysno,
122 Args: args,
123 }
124 cb := s.LookupSyscallToProto(sysno)
125 msg, msgType := cb(t, fields, ctxData, info)
126 seccheck.Global.SentToSinks(func(c seccheck.Sink) error {
127 return c.Syscall(t, fields, ctxData, msgType, msg)
128 })
129 }
130
131 if bits.IsOn(fe, ExternalBeforeEnable) && (s.ExternalFilterBefore == nil || s.ExternalFilterBefore(t, sysno, args)) {
132 t.invokeExternal()
133 // Ensure we check for stops, then invoke the syscall again.
134 ctrl = ctrlStopAndReinvokeSyscall
135 } else {
136 fn := s.Lookup(sysno)
137 var region *trace.Region // Only non-nil if tracing == true.
138 if trace.IsEnabled() {
139 region = trace.StartRegion(t.traceContext, s.LookupName(sysno))
140 }
141 if fn != nil {

Callers 2

doSyscallInvokeMethod · 0.95
doVsyscallInvokeMethod · 0.95

Calls 15

SyscallTableMethod · 0.95
invokeExternalMethod · 0.95
IsAnyOnFunction · 0.92
GetPointForSyscallFunction · 0.92
IsOnFunction · 0.92
LoadSeccheckDataFunction · 0.85
WordMethod · 0.80
GetFieldSetMethod · 0.80
SentToSinksMethod · 0.80
LookupSyscallToProtoMethod · 0.80
IsEnabledMethod · 0.80
ExtractErrnoFunction · 0.70

Tested by

no test coverage detected