CVS commit: src/sys/arch/i386/include
Module Name:src Committed By: kamil Date: Sat Apr 8 02:02:30 UTC 2017 Modified Files: src/sys/arch/i386/include: ptrace.h Log Message: Define PT_SETSTEP and PT_CLEARSTEP for i386 (ptrace(2)) Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/include/ptrace.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/include/ptrace.h diff -u src/sys/arch/i386/include/ptrace.h:1.18 src/sys/arch/i386/include/ptrace.h:1.19 --- src/sys/arch/i386/include/ptrace.h:1.18 Thu Feb 23 03:34:22 2017 +++ src/sys/arch/i386/include/ptrace.h Sat Apr 8 02:02:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.18 2017/02/23 03:34:22 kamil Exp $ */ +/* $NetBSD: ptrace.h,v 1.19 2017/04/08 02:02:30 kamil Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -88,6 +88,8 @@ #define PT_SETXMMREGS (PT_FIRSTMACH + 6) #define PT_GETDBREGS (PT_FIRSTMACH + 7) #define PT_SETDBREGS (PT_FIRSTMACH + 8) +#define PT_SETSTEP (PT_FIRSTMACH + 9) +#define PT_CLEARSTEP (PT_FIRSTMACH + 10) #define PT_MACHDEP_STRINGS \ "PT_STEP", \ @@ -98,7 +100,9 @@ "PT_GETXMMREGS", \ "PT_SETXMMREGS", \ "PT_GETDBREGS", \ - "PT_SETDBREGS", + "PT_SETDBREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", #include
CVS commit: src/doc
Module Name:src Committed By: kamil Date: Sat Apr 8 01:29:31 UTC 2017 Modified Files: src/doc: CHANGES Log Message: ptrace(2): Add operations to single step specified threads: PT_SETSTEP and PT_CLEARSTEP Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.2268 -r1.2269 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2268 src/doc/CHANGES:1.2269 --- src/doc/CHANGES:1.2268 Sun Apr 2 19:37:03 2017 +++ src/doc/CHANGES Sat Apr 8 01:29:31 2017 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2268 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2269 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -493,3 +493,5 @@ Changes from NetBSD 7.0 to NetBSD 8.0: as being smaller and faster. [kre 20170320] zoneinfo: Import tzdata2017b. [kre 20170321] dhcpcd(8): Import dhcpcd-7.0.0-beta2 [roy 20170402] + ptrace(2): Add operations to single step specified threads: + PT_SETSTEP and PT_CLEARSTEP [kamil 20170408]
CVS commit: src/doc
Module Name:src Committed By: kamil Date: Sat Apr 8 01:08:36 UTC 2017 Modified Files: src/doc: TODO.ptrace Log Message: Update TODO.ptrace Remove entries: - research support PT_SYSCALL & PT_STEP combined like in Linux - GDB Remote Protocol expects a case with a step with a signal to be sent, this is currently unsupported on NetBSD Implemented as PT_SETSTEP and PT_CLEARSTEP. Remove: - support QPassSignals (PT_SET_SIGPASS/PT_GET_SIGPASS) in the kernel, a way to stop routing a set of signals to tracer as they are uninteresting - GDB and LLDB expect this feature This interface has been abandoned and will be handled on the debugger level. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/doc/TODO.ptrace Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/TODO.ptrace diff -u src/doc/TODO.ptrace:1.27 src/doc/TODO.ptrace:1.28 --- src/doc/TODO.ptrace:1.27 Fri Mar 3 07:11:49 2017 +++ src/doc/TODO.ptrace Sat Apr 8 01:08:36 2017 @@ -1,4 +1,4 @@ -$NetBSD: TODO.ptrace,v 1.27 2017/03/03 07:11:49 kamil Exp $ +$NetBSD: TODO.ptrace,v 1.28 2017/04/08 01:08:36 kamil Exp $ Items we (currently) plan to finish in the ptrace(2) field: @@ -23,16 +23,10 @@ Items we (currently) plan to finish in t in all ports - add proper implementation of PTRACE_VFORK for vfork(2)-like events - add ATF tests for SIGCHLD - - research support PT_SYSCALL & PT_STEP combined like in Linux - fix more calls for netbsd32 compat - research ipkdb(4) - research kgdb(4) - check 64-bit debugger on 64-bit kernel tracing capabilities of 32-bit tracee - - GDB Remote Protocol expects a case with a step with a signal to be sent, - this is currently unsupported on NetBSD - - support QPassSignals (PT_SET_SIGPASS/PT_GET_SIGPASS) in the kernel, a way to - stop routing a set of signals to tracer as they are uninteresting - GDB and - LLDB expect this feature and of course: fix as many bugs as possible.
CVS commit: src/lib/libc/sys
Module Name:src Committed By: kamil Date: Sat Apr 8 00:58:35 UTC 2017 Modified Files: src/lib/libc/sys: ptrace.2 Log Message: Fix typo in previous (ptrace(2)) To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/lib/libc/sys/ptrace.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/ptrace.2 diff -u src/lib/libc/sys/ptrace.2:1.65 src/lib/libc/sys/ptrace.2:1.66 --- src/lib/libc/sys/ptrace.2:1.65 Sat Apr 8 00:56:38 2017 +++ src/lib/libc/sys/ptrace.2 Sat Apr 8 00:58:35 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: ptrace.2,v 1.65 2017/04/08 00:56:38 kamil Exp $ +.\" $NetBSD: ptrace.2,v 1.66 2017/04/08 00:58:35 kamil Exp $ .\" .\" This file is in the public domain. .Dd April 7, 2017 @@ -410,7 +410,7 @@ Otherwise this operation is the same as Intercept and ignore a system call before it has been executed, for use with .Dv PT_SYSCALL . This operation shall be called for syscall entry trap from -.Dv PT_STSCALL . +.Dv PT_SYSCALL . To resume execution after intercepting the system call, another .Dv PT_SYSCALL
CVS commit: src/lib/libc/sys
Module Name:src Committed By: kamil Date: Sat Apr 8 00:56:38 UTC 2017 Modified Files: src/lib/libc/sys: ptrace.2 Log Message: Document new calls and be more clear about PT_SYSCALL* in ptrace(2) Document PT_SETSTEP and PT_CLEARSTEP in ptrace(2). Try to explain more details of PT_SYSCALL and PT_SYSCALLEMU. The description of PT_*STEP has been obtained from FreeBSD. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/lib/libc/sys/ptrace.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/ptrace.2 diff -u src/lib/libc/sys/ptrace.2:1.64 src/lib/libc/sys/ptrace.2:1.65 --- src/lib/libc/sys/ptrace.2:1.64 Fri Apr 7 07:21:58 2017 +++ src/lib/libc/sys/ptrace.2 Sat Apr 8 00:56:38 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: ptrace.2,v 1.64 2017/04/07 07:21:58 pgoyette Exp $ +.\" $NetBSD: ptrace.2,v 1.65 2017/04/08 00:56:38 kamil Exp $ .\" .\" This file is in the public domain. .Dd April 7, 2017 @@ -404,9 +404,17 @@ argument should contain .Dq Li "sizeof(struct ptrace_lwpinfo)" . .It Dv PT_SYSCALL Stops a process before and after executing each system call. +Otherwise this operation is the same as +.Dv PT_CONTINUE . .It Dv PT_SYSCALLEMU Intercept and ignore a system call before it has been executed, for use with .Dv PT_SYSCALL . +This operation shall be called for syscall entry trap from +.Dv PT_STSCALL . +To resume execution after intercepting the system call, +another +.Dv PT_SYSCALL +shall be used. .It Dv PT_SET_EVENT_MASK This request can be used to specify which events in the traced process should be reported to the tracing process. @@ -626,6 +634,10 @@ If the .Fa data argument is less than zero, it contains the negative of the LWP ID of the thread to be stepped, and only that thread executes. +.It Dv PT_SETSTEP +This request will turn on single stepping of the specified process. +.It Dv PT_CLEARSTEP +This request will turn off single stepping of the specified process. .It Dv PT_GETREGS This request reads the traced process' machine registers into the .Dq Li "struct reg"
CVS commit: src
Module Name:src Committed By: kamil Date: Sat Apr 8 00:25:50 UTC 2017 Modified Files: src/sys/arch/amd64/include: ptrace.h src/sys/arch/arc/include: ptrace.h src/sys/arch/arm/include: ptrace.h src/sys/arch/hppa/include: ptrace.h src/sys/arch/ia64/include: ptrace.h src/sys/arch/m68k/include: ptrace.h src/sys/arch/mips/include: ptrace.h src/sys/arch/powerpc/include: ptrace.h src/sys/arch/sh3/include: ptrace.h src/sys/arch/vax/include: ptrace.h src/sys/kern: sys_ptrace_common.c src/sys/sys: lwp.h src/tests/lib/libc/sys: t_ptrace_wait.c Log Message: Add new ptrace(2) API: PT_SETSTEP & PT_CLEARSTEP These operations allow to mark thread as a single-stepping one. This allows to i.a.: - single step and emit a signal (PT_SETSTEP & PT_CONTINUE) - single step and trace syscall entry and exit (PT_SETSTEP & PT_SYSCALL) The former is useful for debuggers like GDB or LLDB. The latter can be used to singlestep a usermode kernel. These examples don't limit use-cases of this interface. Define PT_*STEP only for platforms defining PT_STEP. Add new ATF tests setstep[1234]. These ptrace(2) operations first appeared in FreeBSD. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/include/ptrace.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arc/include/ptrace.h cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/ptrace.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/include/ptrace.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/include/ptrace.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/include/ptrace.h cvs rdiff -u -r1.14 -r1.15 src/sys/arch/mips/include/ptrace.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/include/ptrace.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sh3/include/ptrace.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/ptrace.h cvs rdiff -u -r1.20 -r1.21 src/sys/kern/sys_ptrace_common.c cvs rdiff -u -r1.172 -r1.173 src/sys/sys/lwp.h cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_wait.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/include/ptrace.h diff -u src/sys/arch/amd64/include/ptrace.h:1.10 src/sys/arch/amd64/include/ptrace.h:1.11 --- src/sys/arch/amd64/include/ptrace.h:1.10 Thu Feb 23 03:34:22 2017 +++ src/sys/arch/amd64/include/ptrace.h Sat Apr 8 00:25:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.10 2017/02/23 03:34:22 kamil Exp $ */ +/* $NetBSD: ptrace.h,v 1.11 2017/04/08 00:25:49 kamil Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -43,6 +43,8 @@ #define PT_SETFPREGS (PT_FIRSTMACH + 4) #define PT_GETDBREGS (PT_FIRSTMACH + 5) #define PT_SETDBREGS (PT_FIRSTMACH + 6) +#define PT_SETSTEP (PT_FIRSTMACH + 7) +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) #define PT_MACHDEP_STRINGS \ "PT_STEP", \ @@ -51,7 +53,9 @@ "PT_GETFPREGS", \ "PT_SETFPREGS", \ "PT_GETDBREGS", \ - "PT_SETDBREGS", + "PT_SETDBREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", #include #define PTRACE_REG_PC(r) (r)->regs[_REG_RIP] Index: src/sys/arch/arc/include/ptrace.h diff -u src/sys/arch/arc/include/ptrace.h:1.4 src/sys/arch/arc/include/ptrace.h:1.5 --- src/sys/arch/arc/include/ptrace.h:1.4 Sun Jan 23 21:01:58 2000 +++ src/sys/arch/arc/include/ptrace.h Sat Apr 8 00:25:49 2017 @@ -1,6 +1,6 @@ -/* $NetBSD: ptrace.h,v 1.4 2000/01/23 21:01:58 soda Exp $ */ +/* $NetBSD: ptrace.h,v 1.5 2017/04/08 00:25:49 kamil Exp $ */ /* $OpenBSD: ptrace.h,v 1.1.1.1 1996/06/24 09:07:18 pefo Exp $ */ -#include - #define PT_STEP (PT_FIRSTMACH + 0) + +#include Index: src/sys/arch/arm/include/ptrace.h diff -u src/sys/arch/arm/include/ptrace.h:1.9 src/sys/arch/arm/include/ptrace.h:1.10 --- src/sys/arch/arm/include/ptrace.h:1.9 Fri Nov 25 02:19:19 2016 +++ src/sys/arch/arm/include/ptrace.h Sat Apr 8 00:25:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.9 2016/11/25 02:19:19 christos Exp $ */ +/* $NetBSD: ptrace.h,v 1.10 2017/04/08 00:25:49 kamil Exp $ */ /* * Copyright (c) 1995 Frank Lancaster @@ -42,15 +42,21 @@ /* 3 and 4 are for FPE registers */ #define PT_GETFPREGS (PT_FIRSTMACH + 5) #define PT_SETFPREGS (PT_FIRSTMACH + 6) +#ifndef _KERNEL +#define PT_SETSTEP (PT_FIRSTMACH + 7) /* Not implemented */ +#define PT_CLEARSTEP (PT_FIRSTMACH + 8) /* Not implemented */ +#endif #define PT_MACHDEP_STRINGS \ - "(unused)", \ + "PT_STEP", \ "PT_GETREGS", \ "PT_SETREGS", \ "old PT_GETFPREGS", \ "old PT_SETFPREGS", \ "PT_GETFPREGS", \ - "PT_SETFPREGS", + "PT_SETFPREGS", \ + "PT_SETSTEP", \ + "PT_CLEARSTEP", #include #define PTRACE_REG_PC(_r) (_r)->r_pc Index: src/sys/arch/hppa/include/ptrace.h diff -u src/sys/arch/hppa/include/ptrace.h:1.6 src/sys/arch/hppa/include/ptrace.h:1.7 --- src/sys/arch/hppa/include/ptrace.h:1.6 Fri Nov 25 02:27:43 2016 +++ src/sys/arch/hppa/include/ptrace.h Sat Apr 8 00:25:49 2017 @@
CVS commit: src/lib/libc/sys
Module Name:src Committed By: pgoyette Date: Fri Apr 7 07:21:58 UTC 2017 Modified Files: src/lib/libc/sys: ptrace.2 Log Message: Fix typos and some grammar To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/lib/libc/sys/ptrace.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/ptrace.2 diff -u src/lib/libc/sys/ptrace.2:1.63 src/lib/libc/sys/ptrace.2:1.64 --- src/lib/libc/sys/ptrace.2:1.63 Fri Apr 7 00:56:14 2017 +++ src/lib/libc/sys/ptrace.2 Fri Apr 7 07:21:58 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: ptrace.2,v 1.63 2017/04/07 00:56:14 kamil Exp $ +.\" $NetBSD: ptrace.2,v 1.64 2017/04/07 07:21:58 pgoyette Exp $ .\" .\" This file is in the public domain. .Dd April 7, 2017 @@ -51,7 +51,7 @@ such as .Xr execv 3 .Pc , it will stop before executing the first instruction of the new image and emit -.Dv SIGRAP +.Dv SIGTRAP with .Dv si_code set to @@ -145,7 +145,7 @@ debug registers must not be exposed in m userland must not be allowed to set a trap on the kernel .El .Pp -A debugger might reuse a port specific symbols, +A debugger might reuse port specific symbols, to help writing portable code as described in the port specific part of the .In sys/ptrace.h header. @@ -419,7 +419,6 @@ typedef struct ptrace_event { } ptrace_event_t; .Ed .Pp -Where .Fa pe_set_event is the set of events to be reported. This set is formed by OR'ing together the following values:
CVS commit: src/sys/arch/ia64/conf
Module Name:src Committed By: scole Date: Fri Apr 7 17:07:09 UTC 2017 Modified Files: src/sys/arch/ia64/conf: GENERIC GENERIC.SKI Log Message: Add more options, mainly want "options INET" and "pseudo-device loop" so context bug occurs To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/ia64/conf/GENERIC cvs rdiff -u -r1.12 -r1.13 src/sys/arch/ia64/conf/GENERIC.SKI Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/ia64/conf/GENERIC diff -u src/sys/arch/ia64/conf/GENERIC:1.8 src/sys/arch/ia64/conf/GENERIC:1.9 --- src/sys/arch/ia64/conf/GENERIC:1.8 Fri Aug 21 01:52:08 2015 +++ src/sys/arch/ia64/conf/GENERIC Fri Apr 7 17:07:09 2017 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.8 2015/08/21 01:52:08 uebayasi Exp $ +# $NetBSD: GENERIC,v 1.9 2017/04/07 17:07:09 scole Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/ia64/conf/std.ia64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.8 $" +#ident "GENERIC-$Revision: 1.9 $" maxusers 32 # estimated number of users @@ -32,6 +32,18 @@ maxusers 32 # estimated number of users # CPU-related options. # Standard system options +options INSECURE # disable kernel security levels - X needs this +options NTP # NTP phase/frequency locked loop + +options KTRACE # system call tracing via ktrace(1) + +# Note: SysV IPC parameters can be changed dynamically; see sysctl(8). +options SYSVMSG # System V-like message queues +options SYSVSEM # System V-like semaphores +options SYSVSHM # System V-like memory sharing + +#options MODULAR # new style module(7) framework +#options MODULAR_DEFAULT_AUTOLOAD options USERCONF # userconf(4) support @@ -47,18 +59,36 @@ options DDB_HISTORY_SIZE=512 # enable h #options KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600 makeoptions DEBUG="-g" # compile full symbol table +#options UVMHIST +#options UVMHIST_PRINT + # File systems file-system FFS # UFS +file-system NFS # Network File System client file-system MFS # memory file system +#file-system LFS # log-structured file system +#file-system NTFS # Windows/NT file system (experimental) +file-system CD9660 # ISO 9660 + Rock Ridge file system +file-system MSDOSFS # MS-DOS file system +file-system FDESC # /dev/fd +file-system KERNFS # /kern +file-system NULLFS # loopback file system +file-system OVERLAY # overlay file system +#file-system PROCFS # /proc file-system TMPFS # Efficient memory file-system # These options enable verbose messages for several subsystems. # Warning, these may compile large string tables into the kernel! options ACPIVERBOSE # verbose ACPI device autoconfig messages +#options GATEWAY # packet forwarding +options INET # IP + ICMP + TCP + UDP +#options INET6 # IPv6 +#options IPSEC # IP security # Kernel root file system and dump configuration. config netbsd root on ? type ? +#config netbsd root on md0a type ffs # # Device configuration @@ -79,5 +109,26 @@ com* at acpi? # Serial communications # PCI bus support #pci* at mainbus? bus ? +#puc* at pci? dev ? function ? +#com* at puc? port ? + # Pull in optional local configuration cinclude "arch/ia64/conf/GENERIC.local" + +# Pseudo-Devices + +# Enable the hooks used for initializing the root memory-disk. +#pseudo-device md # memory disk device (ramdisk) +#options MEMORY_DISK_DYNAMIC # loaded via kernel module(7) +##options MEMORY_DISK_HOOKS # enable root ramdisk +##options MEMORY_DISK_IS_ROOT # force md RAM disk to be the root device +#optionsMEMORY_DISK_ROOT_SIZE=2880 # 1.44M, same as a floppy +##options MEMORY_DISK_ROOT_SIZE=8192 # 4Meg +##options MEMORY_DISK_SERVER=1# make the ramdisk writeable + +# network pseudo-devices +pseudo-device loop # network loopback + +# miscellaneous pseudo-devices +#pseudo-device pty # pseudo-terminals + Index: src/sys/arch/ia64/conf/GENERIC.SKI diff -u src/sys/arch/ia64/conf/GENERIC.SKI:1.12 src/sys/arch/ia64/conf/GENERIC.SKI:1.13 --- src/sys/arch/ia64/conf/GENERIC.SKI:1.12 Fri Aug 7 07:29:33 2015 +++ src/sys/arch/ia64/conf/GENERIC.SKI Fri Apr 7 17:07:09 2017 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC.SKI,v 1.12 2015/08/07 07:29:33 maxv Exp $ +# $NetBSD: GENERIC.SKI,v 1.13 2017/04/07 17:07:09 scole Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/ia64/conf/std.ia64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.12 $" +#ident "GENERIC-$Revision: 1.13 $" maxusers 32 # estimated number of users @@ -32,27 +32,59 @@ maxusers 32 # estimated number of users # CPU-related options. # Standard system options +options INSECURE # disable kernel security levels - X needs this +options NTP # NTP phase/frequency locked loop + +options KTRACE # system call
CVS commit: src/sys/opencrypto
Module Name:src Committed By: knakahara Date: Fri Apr 7 12:17:57 UTC 2017 Modified Files: src/sys/opencrypto: crypto.c cryptodev.c Log Message: the processing said "ghastly hacks" is unnecessary now. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/opencrypto/crypto.c cvs rdiff -u -r1.87 -r1.88 src/sys/opencrypto/cryptodev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/opencrypto/crypto.c diff -u src/sys/opencrypto/crypto.c:1.53 src/sys/opencrypto/crypto.c:1.54 --- src/sys/opencrypto/crypto.c:1.53 Thu Apr 6 09:39:12 2017 +++ src/sys/opencrypto/crypto.c Fri Apr 7 12:17:57 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: crypto.c,v 1.53 2017/04/06 09:39:12 knakahara Exp $ */ +/* $NetBSD: crypto.c,v 1.54 2017/04/07 12:17:57 knakahara Exp $ */ /* $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $ */ /* $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */ @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.53 2017/04/06 09:39:12 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.54 2017/04/07 12:17:57 knakahara Exp $"); #include #include @@ -121,45 +121,6 @@ static TAILQ_HEAD(krprethead, cryptkop) TAILQ_HEAD_INITIALIZER(crp_ret_kq); /* - * XXX these functions are ghastly hacks for when the submission - * XXX routines discover a request that was not CBIMM is already - * XXX done, and must be yanked from the retq (where _done) put it - * XXX as cryptoret won't get the chance. The queue is walked backwards - * XXX as the request is generally the last one queued. - * - * call with the lock held, or else. - */ -int -crypto_ret_q_remove(struct cryptop *crp) -{ - struct cryptop * acrp, *next; - - TAILQ_FOREACH_REVERSE_SAFE(acrp, _ret_q, crprethead, crp_next, next) { - if (acrp == crp) { - TAILQ_REMOVE(_ret_q, crp, crp_next); - crp->crp_flags &= (~CRYPTO_F_ONRETQ); - return 1; - } - } - return 0; -} - -int -crypto_ret_kq_remove(struct cryptkop *krp) -{ - struct cryptkop * akrp, *next; - - TAILQ_FOREACH_REVERSE_SAFE(akrp, _ret_kq, krprethead, krp_next, next) { - if (akrp == krp) { - TAILQ_REMOVE(_ret_kq, krp, krp_next); - krp->krp_flags &= (~CRYPTO_F_ONRETQ); - return 1; - } - } - return 0; -} - -/* * Crypto op and desciptor data structures are allocated * from separate private zones(FreeBSD)/pools(netBSD/OpenBSD) . */ Index: src/sys/opencrypto/cryptodev.c diff -u src/sys/opencrypto/cryptodev.c:1.87 src/sys/opencrypto/cryptodev.c:1.88 --- src/sys/opencrypto/cryptodev.c:1.87 Fri Apr 7 12:15:51 2017 +++ src/sys/opencrypto/cryptodev.c Fri Apr 7 12:17:57 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cryptodev.c,v 1.87 2017/04/07 12:15:51 knakahara Exp $ */ +/* $NetBSD: cryptodev.c,v 1.88 2017/04/07 12:17:57 knakahara Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ /* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */ @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.87 2017/04/07 12:15:51 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.88 2017/04/07 12:17:57 knakahara Exp $"); #include #include @@ -668,13 +668,6 @@ eagain: (uint32_t)cse->sid, >crp_cv, crp)); cv_wait(>crp_cv, _mtx); /* XXX cv_wait_sig? */ } - if (crp->crp_flags & CRYPTO_F_ONRETQ) { - /* XXX this should never happen now with the CRYPTO_F_USER flag - * changes. - */ - DPRINTF(("cryptodev_op: DONE, not woken by cryptoret.\n")); - (void)crypto_ret_q_remove(crp); - } mutex_exit(_mtx); cv_destroy(>crp_cv); @@ -895,10 +888,6 @@ cryptodev_key(struct crypt_kop *kop) while (!(krp->krp_flags & CRYPTO_F_DQRETQ)) { cv_wait(>krp_cv, _mtx); /* XXX cv_wait_sig? */ } - if (krp->krp_flags & CRYPTO_F_ONRETQ) { - DPRINTF(("cryptodev_key: DONE early, not via cryptoret.\n")); - (void)crypto_ret_kq_remove(krp); - } mutex_exit(_mtx); if (krp->krp_status != 0) {
CVS commit: src/sys/opencrypto
Module Name:src Committed By: knakahara Date: Fri Apr 7 12:15:51 UTC 2017 Modified Files: src/sys/opencrypto: cryptodev.c cryptodev.h Log Message: fix race among crypto_done(), cryptoret(), and {cryptodev_op(), cryptodev_key()}. crypto_op() waited to be set CRYPTO_F_DONE with crp->crp_cv. However, there is context switch chances between being set CRYPTO_F_DONE in crypto_done() and done cv_signal(crp->crp_cv) in cryptodev_cb(), that is, cryptodev_op() thread can run to cv_destroy(crp->crp_cv) before cryptoret() thread is waken up. As a result, cryptodev_cb() can call invalid(destroyed) cv_signal(crp->crp_cv). Furthermore, below two implementations cause other races. - waiting CRYPTO_F_DONE with crp->crp_cv - context witch chances between set CRYPTO_F_DONE and cv_signal(crp->crp_cv) So, use other flag(CRYPTO_F_DQRETQ) for cryptodev_op() and cryptodev_key(), and then call cv_signal(crp->crp_cv) immediately after set CRYPTO_F_DQRETQ. Tested concurrent over 20 processes with software and hardware drivers. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/opencrypto/cryptodev.c cvs rdiff -u -r1.29 -r1.30 src/sys/opencrypto/cryptodev.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/opencrypto/cryptodev.c diff -u src/sys/opencrypto/cryptodev.c:1.86 src/sys/opencrypto/cryptodev.c:1.87 --- src/sys/opencrypto/cryptodev.c:1.86 Wed Apr 5 08:51:04 2017 +++ src/sys/opencrypto/cryptodev.c Fri Apr 7 12:15:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cryptodev.c,v 1.86 2017/04/05 08:51:04 knakahara Exp $ */ +/* $NetBSD: cryptodev.c,v 1.87 2017/04/07 12:15:51 knakahara Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ /* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */ @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.86 2017/04/05 08:51:04 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.87 2017/04/07 12:15:51 knakahara Exp $"); #include #include @@ -663,7 +663,7 @@ eagain: goto bail; } - while (!(crp->crp_flags & CRYPTO_F_DONE)) { + while (!(crp->crp_flags & CRYPTO_F_DQRETQ)) { DPRINTF(("cryptodev_op[%d]: sleeping on cv %p for crp %p\n", (uint32_t)cse->sid, >crp_cv, crp)); cv_wait(>crp_cv, _mtx); /* XXX cv_wait_sig? */ @@ -744,6 +744,7 @@ cryptodev_cb(void *op) mutex_enter(_mtx); } if (error != 0 || (crp->crp_flags & CRYPTO_F_DONE)) { + crp->crp_flags |= CRYPTO_F_DQRETQ; cv_signal(>crp_cv); } mutex_exit(_mtx); @@ -780,6 +781,7 @@ cryptodevkey_cb(void *op) struct cryptkop *krp = op; mutex_enter(_mtx); + krp->krp_flags |= CRYPTO_F_DQRETQ; cv_signal(>krp_cv); mutex_exit(_mtx); return 0; @@ -890,7 +892,7 @@ cryptodev_key(struct crypt_kop *kop) } mutex_enter(_mtx); - while (!(krp->krp_flags & CRYPTO_F_DONE)) { + while (!(krp->krp_flags & CRYPTO_F_DQRETQ)) { cv_wait(>krp_cv, _mtx); /* XXX cv_wait_sig? */ } if (krp->krp_flags & CRYPTO_F_ONRETQ) { Index: src/sys/opencrypto/cryptodev.h diff -u src/sys/opencrypto/cryptodev.h:1.29 src/sys/opencrypto/cryptodev.h:1.30 --- src/sys/opencrypto/cryptodev.h:1.29 Mon Mar 6 09:59:05 2017 +++ src/sys/opencrypto/cryptodev.h Fri Apr 7 12:15:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cryptodev.h,v 1.29 2017/03/06 09:59:05 knakahara Exp $ */ +/* $NetBSD: cryptodev.h,v 1.30 2017/04/07 12:15:51 knakahara Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.6 2003/07/02 17:04:50 sam Exp $ */ /* $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $ */ @@ -473,6 +473,7 @@ struct cryptop { #define CRYPTO_F_ONRETQ 0x0080 /* Request is on return queue */ #define CRYPTO_F_USER 0x0100 /* Request is in user context */ #define CRYPTO_F_MORE 0x0200 /* more data to follow */ +#define CRYPTO_F_DQRETQ 0x0400 /* Dequeued from crp_ret_{,k}q */ void * crp_buf; /* Data to be processed */ void * crp_opaque; /* Opaque pointer, passed along */
CVS commit: src/lib/libc/sys
Module Name:src Committed By: kamil Date: Fri Apr 7 00:56:14 UTC 2017 Modified Files: src/lib/libc/sys: ptrace.2 Log Message: Correction in ptrace(2) about operations that emit signals PT_STEP and PT_DETACH cannot emit signals PT_CONTINUE and PT_SYSCALL can emit signals Pointed out by To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/lib/libc/sys/ptrace.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/ptrace.2 diff -u src/lib/libc/sys/ptrace.2:1.62 src/lib/libc/sys/ptrace.2:1.63 --- src/lib/libc/sys/ptrace.2:1.62 Thu Feb 23 08:11:09 2017 +++ src/lib/libc/sys/ptrace.2 Fri Apr 7 00:56:14 2017 @@ -1,7 +1,7 @@ -.\" $NetBSD: ptrace.2,v 1.62 2017/02/23 08:11:09 wiz Exp $ +.\" $NetBSD: ptrace.2,v 1.63 2017/04/07 00:56:14 kamil Exp $ .\" .\" This file is in the public domain. -.Dd February 23, 2017 +.Dd April 7, 2017 .Dt PTRACE 2 .Os .Sh NAME @@ -535,11 +535,10 @@ argument should be set to .Li sizeof(struct ptrace_siginfo) . .Pp In order to pass faked signal to the tracee, -the signal type must match the signal passed to process with -.Dv PT_CONTINUE , -.Dv PT_DETACH +the signal type must match the signal passed to the process with +.Dv PT_CONTINUE or -.Dv PT_STEP . +.Dv PT_SYSCALL . .It Dv PT_GET_SIGINFO This request can be used to determine signal information that was received by a debugger