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

Method handleGetsockopt

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

handleGetsockopt handles the getsockopt(2) syscall to emulate SO_ERROR.

(n *seccomp.Notif, fd int, level int, name int, valPtr uintptr, valSizePtr uintptr)

Source from the content-addressed store, hash-verified

458
459// handleGetsockopt handles the getsockopt(2) syscall to emulate SO_ERROR.
460func (p *Process) handleGetsockopt(n *seccomp.Notif, fd int, level int, name int, valPtr uintptr, valSizePtr uintptr) error {
461 if level != unix.SOL_SOCKET || name != unix.SO_ERROR {
462 return n.Skip()
463 }
464
465 s, ok := p.getSocket(fd)
466 if !ok {
467 return n.Skip()
468 }
469
470 valSize, errno, err := p.vmReadUint32(n, valSizePtr)
471 if err != nil {
472 return fmt.Errorf("read value size pointer: %w", err)
473 }
474 if errno != 0 {
475 return n.Return(0, errno)
476 }
477 if valSize != 4 {
478 return n.Return(0, unix.EINVAL)
479 }
480
481 errno, err = p.vmWriteUint32(n, valPtr, uint32(s.Errno()))
482 if err != nil {
483 return fmt.Errorf("write value: %w", err)
484 }
485 return n.Return(0, errno)
486}
487
488// handleSetsockopt handles the setsockopt(2) syscall to allow ignoring
489// TCP_DEFER_ACCEPT.

Callers 1

initFunction · 0.80

Calls 6

getSocketMethod · 0.95
vmReadUint32Method · 0.95
vmWriteUint32Method · 0.95
SkipMethod · 0.80
ReturnMethod · 0.80
ErrnoMethod · 0.80

Tested by

no test coverage detected