MCPcopy Index your code
hub / github.com/subtrace/subtrace / handleStatx

Method handleStatx

cmd/run/engine/process/handle.go:216–249  ·  view source on GitHub ↗

handleStatx handles the statx(2) syscall.

(n *seccomp.Notif, dirfd int, pathAddr uintptr, flags int, mask int, bufAddr uintptr)

Source from the content-addressed store, hash-verified

214
215// handleStatx handles the statx(2) syscall.
216func (p *Process) handleStatx(n *seccomp.Notif, dirfd int, pathAddr uintptr, flags int, mask int, bufAddr uintptr) error {
217 path, errno, err := p.resolvePath(n, dirfd, pathAddr)
218 if err != nil {
219 return fmt.Errorf("resolve path: %w", err)
220 }
221 if errno != 0 {
222 return n.Return(0, errno)
223 }
224 if !tls.Enabled || !tls.IsKnownPath(path) {
225 return n.Skip()
226 }
227
228 ephemeralPEM := tls.GetEphemeralCAPEM()
229
230 pathb := []byte(path)
231
232 var orig linux.Statx
233 b := make([]byte, orig.SizeBytes(), orig.SizeBytes())
234 if _, _, errno := unix.Syscall6(unix.SYS_STATX, uintptr(dirfd), uintptr(unsafe.Pointer(&pathb[0])), uintptr(flags), uintptr(mask), uintptr(unsafe.Pointer(&b[0])), 0); errno != 0 {
235 return n.Skip()
236 }
237 orig.UnmarshalBytes(b)
238
239 repl := orig
240 repl.Size += uint64(len(ephemeralPEM))
241 b = make([]byte, repl.SizeBytes(), repl.SizeBytes())
242 repl.MarshalBytes(b)
243
244 errno, err = p.vmWriteBytes(n, bufAddr, b)
245 if err != nil {
246 return fmt.Errorf("write statx to process memory: %w", err)
247 }
248 return n.Return(0, errno)
249}
250
251// handleClose handles the close(2) syscall.
252func (p *Process) handleClose(n *seccomp.Notif, fd int) error {

Callers 1

initFunction · 0.80

Calls 8

resolvePathMethod · 0.95
vmWriteBytesMethod · 0.95
IsKnownPathFunction · 0.92
GetEphemeralCAPEMFunction · 0.92
ReturnMethod · 0.80
SkipMethod · 0.80
UnmarshalBytesMethod · 0.80
SizeBytesMethod · 0.45

Tested by

no test coverage detected