syzbot


DATA RACE in safemem.Copy (3)

Status: fixed on 2021/09/28 10:18
Fix commit: 1fe0a6691ff5 Prevent PacketData from being modified.
First crash: 1160d, last: 1160d
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
gvisor DATA RACE in safemem.Copy C 4 1403d 1403d 14/26 fixed on 2021/01/26 10:37
gvisor DATA RACE in safemem.Copy (7) C 4 336d 336d 26/26 fixed on 2023/12/29 10:22
gvisor DATA RACE in safemem.Copy (6) C 121 727d 728d 26/26 fixed on 2023/10/05 23:05
gvisor DATA RACE in safemem.Copy (2) C 9 1208d 1208d 14/26 fixed on 2021/08/16 21:45
gvisor DATA RACE in safemem.Copy (4) C 1019 837d 840d 14/26 fixed on 2022/11/18 03:22
gvisor DATA RACE in safemem.Copy (5) C 3153 728d 738d 14/26 fixed on 2022/11/29 11:04

Sample crash report:
WARNING: DATA RACE
Read at 0x00c0003e41e2 by goroutine 230:
  runtime.slicecopy()
      GOROOT/src/runtime/slice.go:247 +0x0
  gvisor.dev/gvisor/pkg/safemem.Copy()
      pkg/safemem/block_unsafe.go:199 +0x4e6
  gvisor.dev/gvisor/pkg/safemem.CopySeq()
      pkg/safemem/seq_unsafe.go:282 +0x296
  gvisor.dev/gvisor/pkg/sentry/mm.(*MemoryManager).CopyOut.func1()
      pkg/sentry/mm/io.go:121 +0xaf
  gvisor.dev/gvisor/pkg/sentry/mm.(*MemoryManager).withInternalMappings()
      pkg/sentry/mm/io.go:507 +0xb63
  gvisor.dev/gvisor/pkg/sentry/mm.(*MemoryManager).CopyOut()
      pkg/sentry/mm/io.go:120 +0x256
  gvisor.dev/gvisor/pkg/usermem.CopyOutVec()
      pkg/usermem/usermem.go:263 +0x1f2
  gvisor.dev/gvisor/pkg/usermem.IOSequence.CopyOut()
      pkg/usermem/usermem.go:481 +0x15b
  gvisor.dev/gvisor/pkg/usermem.(*IOSequenceReadWriter).Write()
      pkg/usermem/usermem.go:559 +0x45
  gvisor.dev/gvisor/pkg/tcpip/buffer.(*VectorisedView).ReadTo()
      pkg/tcpip/buffer/view.go:156 +0xe8
  gvisor.dev/gvisor/pkg/tcpip/transport/raw.(*endpoint).Read()
      pkg/tcpip/transport/raw/endpoint.go:212 +0x344
  gvisor.dev/gvisor/pkg/sentry/socket/netstack.(*socketOpsCommon).nonBlockingRead()
      pkg/sentry/socket/netstack/netstack.go:2687 +0x313
  gvisor.dev/gvisor/pkg/sentry/socket/netstack.(*SocketVFS2).Read()
      pkg/sentry/socket/netstack/netstack_vfs2.go:113 +0x156
  gvisor.dev/gvisor/pkg/sentry/vfs.(*FileDescription).Read()
      pkg/sentry/vfs/file_description.go:626 +0x16d
  gvisor.dev/gvisor/pkg/sentry/syscalls/linux/vfs2.read()
      pkg/sentry/syscalls/linux/vfs2/read_write.go:94 +0xed
  gvisor.dev/gvisor/pkg/sentry/syscalls/linux/vfs2.Readv()
      pkg/sentry/syscalls/linux/vfs2/read_write.go:88 +0x2fe
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).executeSyscall()
      pkg/sentry/kernel/task_syscall.go:103 +0x452
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallInvoke()
      pkg/sentry/kernel/task_syscall.go:238 +0xb3
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallEnter()
      pkg/sentry/kernel/task_syscall.go:198 +0x10e
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscall()
      pkg/sentry/kernel/task_syscall.go:173 +0x213
  gvisor.dev/gvisor/pkg/sentry/kernel.(*runApp).execute()
      pkg/sentry/kernel/task_run.go:282 +0x12c6
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).run()
      pkg/sentry/kernel/task_run.go:97 +0x392

Previous write at 0x00c0003e41e2 by goroutine 258:
  runtime.slicecopy()
      GOROOT/src/runtime/slice.go:247 +0x0
  gvisor.dev/gvisor/pkg/buffer.(*buffer).Remove()
      pkg/buffer/buffer.go:64 +0x29d
  gvisor.dev/gvisor/pkg/buffer.(*View).Remove()
      pkg/buffer/view.go:63 +0x1b0
  gvisor.dev/gvisor/pkg/tcpip/stack.PacketData.DeleteFront()
      pkg/tcpip/stack/packet_buffer.go:396 +0x7f5
  gvisor.dev/gvisor/pkg/tcpip/network/ipv4.(*endpoint).handleICMP()
      pkg/tcpip/network/ipv4/icmp.go:341 +0x757
  gvisor.dev/gvisor/pkg/tcpip/network/ipv4.(*endpoint).handleValidatedPacket()
      pkg/tcpip/network/ipv4/ipv4.go:1014 +0xb59
  gvisor.dev/gvisor/pkg/tcpip/network/ipv4.(*endpoint).HandlePacket()
      pkg/tcpip/network/ipv4/ipv4.go:836 +0x1e9
  gvisor.dev/gvisor/pkg/tcpip/stack.(*nic).DeliverNetworkPacket()
      pkg/tcpip/stack/nic.go:781 +0x444
  gvisor.dev/gvisor/pkg/tcpip/link/channel.(*Endpoint).InjectLinkAddr()
      pkg/tcpip/link/channel/channel.go:195 +0x48e
  gvisor.dev/gvisor/pkg/tcpip/link/tun.(*Device).Write()
      pkg/tcpip/link/tun/device.go:235 +0x2b2
  gvisor.dev/gvisor/pkg/sentry/devices/tundev.(*tunFD).Write()
      pkg/sentry/devices/tundev/tundev.go:146 +0x236
  gvisor.dev/gvisor/pkg/sentry/vfs.(*FileDescription).Write()
      pkg/sentry/vfs/file_description.go:657 +0x130
  gvisor.dev/gvisor/pkg/sentry/syscalls/linux/vfs2.write()
      pkg/sentry/syscalls/linux/vfs2/read_write.go:345 +0xed
  gvisor.dev/gvisor/pkg/sentry/syscalls/linux/vfs2.Write()
      pkg/sentry/syscalls/linux/vfs2/read_write.go:314 +0x307
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).executeSyscall()
      pkg/sentry/kernel/task_syscall.go:103 +0x452
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallInvoke()
      pkg/sentry/kernel/task_syscall.go:238 +0xb3
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallEnter()
      pkg/sentry/kernel/task_syscall.go:198 +0x10e
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscall()
      pkg/sentry/kernel/task_syscall.go:173 +0x213
  gvisor.dev/gvisor/pkg/sentry/kernel.(*runApp).execute()
      pkg/sentry/kernel/task_run.go:282 +0x12c6
  gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).run()
      pkg/sentry/kernel/task_run.go:97 +0x392

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/09/22 18:56 gvisor 0ed53e5e92a0 8cac236e .config console log report syz C ci-gvisor-ptrace-2-race DATA RACE in safemem.Copy
2021/09/22 18:25 gvisor 0ed53e5e92a0 8cac236e .config console log report syz C ci-gvisor-ptrace-1-race DATA RACE in safemem.Copy
2021/09/22 17:45 gvisor 0ed53e5e92a0 8cac236e .config console log report info ci-gvisor-ptrace-1-race DATA RACE in safemem.Copy
* Struck through repros no longer work on HEAD.