https://github.com/google/gvisor/issues/1397
#include <sys/socket.h> #include <sys/un.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #define MY_SOCK_PATH "/tmp/hello" #define LISTEN_BACKLOG 50 #define handle_error(msg) do { perror(msg); /*exit(EXIT_FAILURE);*/ } while (0) int main(int argc, char *argv[]) { unsigned char buff[32]; int sfd, cfd, idx; struct sockaddr_un my_addr, peer_addr; socklen_t peer_addr_size; for (idx=0;idx<60000;idx++) { sfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sfd == -1) handle_error("socket"); memset(buff,0,32); sprintf(buff,"%s%d",MY_SOCK_PATH,idx); memset(&my_addr, 0, sizeof(struct sockaddr_un)); /* Clear structure */ my_addr.sun_family = AF_UNIX; strncpy(my_addr.sun_path, buff, sizeof(my_addr.sun_path) - 1); if (bind(sfd, (struct sockaddr *) &my_addr, sizeof(struct sockaddr_un)) == -1) handle_error("bind"); close(sfd); unlink(buff); } }
$cat /home/script/taskmnts.sh #!/bin/sh while true do cat /proc/self/mounts > /dev/null done
root@cloud:~# docker run -it --runtime=runsc-kvm --rm debian /bin/bash root@f2b9fb2551cd:/# ls bin boot dev etc gov home lib media mnt opt proc root run sbin srv sys tmp usr var root@f2b9fb2551cd:/# ./gov root@f2b9fb2551cd:/# ./gov root@f2b9fb2551cd:/# while true > do > cat /proc/self/mounts > /dev/null > done
root@cloud:~# dlv attach 942458 Type 'help' for list of commands. (dlv) b pkg/sentry/fs/mounts.go:418 Breakpoint 1 set at 0x32e8f0 for gvisor.dev/gvisor/pkg/sentry/fs.(*MountNamespace).findMountLocked() pkg/sentry/fs/mounts.go:418 (dlv) c > gvisor.dev/gvisor/pkg/sentry/fs.(*MountNamespace).findMountLocked() pkg/sentry/fs/mounts.go:418 (hits goroutine(278):1 total:1) (PC: 0x32e8f0) Warning: debugging optimized function (dlv) bt 0 0x000000000032e8f0 in gvisor.dev/gvisor/pkg/sentry/fs.(*MountNamespace).findMountLocked at pkg/sentry/fs/mounts.go:418 1 0x000000000032e874 in gvisor.dev/gvisor/pkg/sentry/fs.(*MountNamespace).FindMount at pkg/sentry/fs/mounts.go:415 2 0x00000000007c326c in gvisor.dev/gvisor/pkg/sentry/fs/proc.forEachMount at pkg/sentry/fs/proc/mounts.go:52 3 0x00000000007c38dc in gvisor.dev/gvisor/pkg/sentry/fs/proc.(*mountsFile).ReadSeqFileData at pkg/sentry/fs/proc/mounts.go:204 4 0x00000000003c792c in gvisor.dev/gvisor/pkg/sentry/fs/proc/seqfile.(*SeqFile).updateSourceLocked at pkg/sentry/fs/proc/seqfile/seqfile.go:180 5 0x00000000003c82f4 in gvisor.dev/gvisor/pkg/sentry/fs/proc/seqfile.(*seqFileOperations).Read at pkg/sentry/fs/proc/seqfile/seqfile.go:229 6 0x000000000031f234 in gvisor.dev/gvisor/pkg/sentry/fs.(*File).Readv at pkg/sentry/fs/file.go:245 7 0x00000000005813a8 in gvisor.dev/gvisor/pkg/sentry/syscalls/linux.readv at pkg/sentry/syscalls/linux/sys_read.go:292 8 0x000000000057fae0 in gvisor.dev/gvisor/pkg/sentry/syscalls/linux.Read at pkg/sentry/syscalls/linux/sys_read.go:72 9 0x0000000000522ea4 in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).executeSyscall at pkg/sentry/kernel/task_syscall.go:104 10 0x0000000000523c5c in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallInvoke at pkg/sentry/kernel/task_syscall.go:239 11 0x00000000005238dc in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallEnter at pkg/sentry/kernel/task_syscall.go:199 12 0x00000000005233e0 in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscall at pkg/sentry/kernel/task_syscall.go:174 13 0x0000000000518e00 in gvisor.dev/gvisor/pkg/sentry/kernel.(*runApp).execute at pkg/sentry/kernel/task_run.go:282 14 0x0000000000517d9c in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).run at pkg/sentry/kernel/task_run.go:97 15 0x0000000000077c84 in runtime.goexit at src/runtime/asm_arm64.s:1136 (dlv) clearall Breakpoint 1 cleared at 0x32e8f0 for gvisor.dev/gvisor/pkg/sentry/fs.(*MountNamespace).findMountLocked() pkg/sentry/fs/mounts.go:418 (dlv) quit Would you like to kill the process? [Y/n] n root@cloud:~#