Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern ptrace(PT_LWPSTATUS): Fix lid=0 case.



details:   https://anonhg.NetBSD.org/src/rev/8ef4246f6f0f
branches:  trunk
changeset: 368421:8ef4246f6f0f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Jul 10 17:47:58 2022 +0000

description:
ptrace(PT_LWPSTATUS): Fix lid=0 case.

Make ptrace_read_lwpstatus always overwrite the whole struct
ptrace_lwpstatus so the caller doesn't have to make sure pl_lwpid is
initialized correctly -- ptrace_lwpstatus was missing that
reinitialization after ptrace_update_lwp, but it's less work for all
the callers if we just make the assertion an assignment instead.

diffstat:

 sys/kern/sys_process_lwpstatus.c |  9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diffs (37 lines):

diff -r 004c905f245e -r 8ef4246f6f0f sys/kern/sys_process_lwpstatus.c
--- a/sys/kern/sys_process_lwpstatus.c  Sun Jul 10 14:18:27 2022 +0000
+++ b/sys/kern/sys_process_lwpstatus.c  Sun Jul 10 17:47:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_process_lwpstatus.c,v 1.3 2020/10/20 22:31:20 rin Exp $    */
+/*     $NetBSD: sys_process_lwpstatus.c,v 1.4 2022/07/10 17:47:58 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_process_lwpstatus.c,v 1.3 2020/10/20 22:31:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process_lwpstatus.c,v 1.4 2022/07/10 17:47:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -56,8 +56,7 @@
 ptrace_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
 {
 
-       KASSERT(l->l_lid == pls->pl_lwpid);
-
+       pls->pl_lwpid = l->l_lid;
        memcpy(&pls->pl_sigmask, &l->l_sigmask, sizeof(pls->pl_sigmask));
        memcpy(&pls->pl_sigpend, &l->l_sigpend.sp_set, sizeof(pls->pl_sigpend));
 
@@ -79,8 +78,6 @@
 process_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
 {
 
-       pls->pl_lwpid = l->l_lid;
-
        ptrace_read_lwpstatus(l, pls);
 }
 



Home | Main Index | Thread Index | Old Index