vmWriteBytes writes b to the process's memory starting at ptr. It returns an error if the address range isn't writable or if the notification is invalid.
(n *seccomp.Notif, ptr uintptr, b []byte)
| 167 | // vmWriteBytes writes b to the process's memory starting at ptr. It returns an |
| 168 | // error if the address range isn't writable or if the notification is invalid. |
| 169 | func (p *Process) vmWriteBytes(n *seccomp.Notif, ptr uintptr, b []byte) (syscall.Errno, error) { |
| 170 | if !n.Valid() { |
| 171 | return 0, seccomp.ErrCancelled |
| 172 | } |
| 173 | |
| 174 | if len(b) == 0 { |
| 175 | return 0, nil |
| 176 | } |
| 177 | if ptr == 0 { |
| 178 | return unix.EINVAL, nil |
| 179 | } |
| 180 | |
| 181 | wrote, err := writeMemory(int(p.PID), b, ptr) |
| 182 | if err != nil { |
| 183 | if !n.Valid() { |
| 184 | return 0, seccomp.ErrCancelled |
| 185 | } |
| 186 | var errno syscall.Errno |
| 187 | if errors.As(err, &errno) { |
| 188 | return errno, nil |
| 189 | } |
| 190 | return 0, fmt.Errorf("memory write: unknown error: %w", err) |
| 191 | } |
| 192 | if wrote < len(b) { |
| 193 | if !n.Valid() { |
| 194 | return 0, seccomp.ErrCancelled |
| 195 | } |
| 196 | return 0, fmt.Errorf("memory write: partial write: wrote %d, expected %d", wrote, len(b)) |
| 197 | } |
| 198 | return 0, nil |
| 199 | } |
| 200 | |
| 201 | // vmWriteInt32 writes a uint32 to the process' memory at ptr. |
| 202 | func (p *Process) vmWriteUint32(n *seccomp.Notif, ptr uintptr, val uint32) (syscall.Errno, error) { |
no test coverage detected