From 207e4b38a785bf665de26471f4fc5fde67fa99f0 Mon Sep 17 00:00:00 2001 From: guenther Date: Mon, 26 Jul 2010 01:56:27 +0000 Subject: Correct the links between threads, processes, pgrps, and sessions, so that the process-level stuff is to/from struct process and not struct proc. This fixes a bunch of problem cases in rthreads. Based on earlier work by blambert and myself, but mostly written at c2k10. Tested by many: deraadt, sthen, krw, ray, and in snapshots --- sys/kern/exec_elf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'sys/kern/exec_elf.c') diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index e962f9fb0f0..10993c60152 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.75 2010/07/24 09:50:45 guenther Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.76 2010/07/26 01:56:27 guenther Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -1137,6 +1137,7 @@ ELFNAMEEND(coredump_notes)(struct proc *p, void *iocookie, size_t *sizep) struct uio uio; struct elfcore_procinfo cpi; Elf_Note nhdr; + struct process *pr = p->p_p; struct proc *q; size_t size, notesize; int error; @@ -1159,11 +1160,11 @@ ELFNAMEEND(coredump_notes)(struct proc *p, void *iocookie, size_t *sizep) cpi.cpi_sigignore = p->p_sigignore; cpi.cpi_sigcatch = p->p_sigcatch; - cpi.cpi_pid = p->p_pid; - cpi.cpi_ppid = p->p_pptr->p_pid; - cpi.cpi_pgrp = p->p_pgid; - if (p->p_session->s_leader) - cpi.cpi_sid = p->p_session->s_leader->p_pid; + cpi.cpi_pid = pr->ps_pid; + cpi.cpi_ppid = pr->ps_pptr->ps_pid; + cpi.cpi_pgrp = pr->ps_pgid; + if (pr->ps_session->s_leader) + cpi.cpi_sid = pr->ps_session->s_leader->ps_pid; else cpi.cpi_sid = 0; @@ -1263,7 +1264,7 @@ ELFNAMEEND(coredump_notes)(struct proc *p, void *iocookie, size_t *sizep) * per-thread notes. Since we're dumping core, we don't bother * locking. */ - TAILQ_FOREACH(q, &p->p_p->ps_threads, p_thr_link) { + TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) { if (q == p) /* we've taken care of this thread */ continue; error = ELFNAMEEND(coredump_note)(q, iocookie, ¬esize); -- cgit v1.2.3-59-g8ed1b