Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2014 17:07:51 -0700
From:      Adrian Chadd <adrian@freebsd.org>
To:        Mateusz Guzik <mjg@freebsd.org>
Cc:        "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>
Subject:   Re: svn commit: r270745 - in head: bin/ps sys/compat/freebsd32 sys/kern sys/sys
Message-ID:  <CAJ-Vmo=M=JoV8DxZkG4ghj88r8fpUSAnOiFvdcur26Hs=0eAPQ@mail.gmail.com>
In-Reply-To: <201408280841.s7S8fC6X012986@svn.freebsd.org>
References:  <201408280841.s7S8fC6X012986@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi!

So I'm now getting panics in the process coredump path on -HEAD. The
proctree lock isn't held.

Assertion : proctree not locked @ kern_proc.c:795

path:

sigexit() -> elf64_coredump() -> elf64_note_procstat_proc() ->
kern_proc_out() -> fill_kinfo_proc() -> panic.

What did you peeps do this time? :P



-a


On 28 August 2014 01:41, Mateusz Guzik <mjg@freebsd.org> wrote:
> Author: mjg
> Date: Thu Aug 28 08:41:11 2014
> New Revision: 270745
> URL: http://svnweb.freebsd.org/changeset/base/270745
>
> Log:
>   Return real parent pid in kinfo (used by e.g. ps)
>
>   Add a separate field which exports tracer pid and add a new keyword
>   ("tracer") for ps to display it.
>
>   This is a follow up to r270444.
>
>   Reviewed by:  kib
>   MFC after:    1 week
>   Relnotes:     yes
>
> Modified:
>   head/bin/ps/keyword.c
>   head/bin/ps/ps.1
>   head/sys/compat/freebsd32/freebsd32.h
>   head/sys/kern/kern_proc.c
>   head/sys/sys/user.h
>
> Modified: head/bin/ps/keyword.c
> ==============================================================================
> --- head/bin/ps/keyword.c       Thu Aug 28 08:25:15 2014        (r270744)
> +++ head/bin/ps/keyword.c       Thu Aug 28 08:41:11 2014        (r270745)
> @@ -157,6 +157,7 @@ static VAR var[] = {
>         {"tdnam", "TDNAM", NULL, LJUST, tdnam, 0, CHAR, NULL, 0},
>         {"time", "TIME", NULL, USER, cputime, 0, CHAR, NULL, 0},
>         {"tpgid", "TPGID", NULL, 0, kvar, KOFF(ki_tpgid), UINT, PIDFMT, 0},
> +       {"tracer", "TRACER", NULL, 0, kvar, KOFF(ki_tracer), UINT, PIDFMT, 0},
>         {"tsid", "TSID", NULL, 0, kvar, KOFF(ki_tsid), UINT, PIDFMT, 0},
>         {"tsiz", "TSIZ", NULL, 0, kvar, KOFF(ki_tsize), PGTOK, "ld", 0},
>         {"tt", "TT ", NULL, 0, tname, 0, CHAR, NULL, 0},
>
> Modified: head/bin/ps/ps.1
> ==============================================================================
> --- head/bin/ps/ps.1    Thu Aug 28 08:25:15 2014        (r270744)
> +++ head/bin/ps/ps.1    Thu Aug 28 08:41:11 2014        (r270745)
> @@ -29,7 +29,7 @@
>  .\"     @(#)ps.1       8.3 (Berkeley) 4/18/94
>  .\" $FreeBSD$
>  .\"
> -.Dd August 7, 2014
> +.Dd August 27, 2014
>  .Dt PS 1
>  .Os
>  .Sh NAME
> @@ -665,6 +665,8 @@ accumulated CPU time, user + system (ali
>  .Cm cputime )
>  .It Cm tpgid
>  control terminal process group ID
> +.It Cm tracer
> +tracer process ID
>  .\".It Cm trss
>  .\"text resident set size (in Kbytes)
>  .It Cm tsid
>
> Modified: head/sys/compat/freebsd32/freebsd32.h
> ==============================================================================
> --- head/sys/compat/freebsd32/freebsd32.h       Thu Aug 28 08:25:15 2014        (r270744)
> +++ head/sys/compat/freebsd32/freebsd32.h       Thu Aug 28 08:41:11 2014        (r270745)
> @@ -343,6 +343,7 @@ struct kinfo_proc32 {
>         char    ki_loginclass[LOGINCLASSLEN+1];
>         char    ki_sparestrings[50];
>         int     ki_spareints[KI_NSPARE_INT];
> +       int     ki_tracer;
>         int     ki_flag2;
>         int     ki_fibnum;
>         u_int   ki_cr_flags;
>
> Modified: head/sys/kern/kern_proc.c
> ==============================================================================
> --- head/sys/kern/kern_proc.c   Thu Aug 28 08:25:15 2014        (r270744)
> +++ head/sys/kern/kern_proc.c   Thu Aug 28 08:41:11 2014        (r270745)
> @@ -791,6 +791,8 @@ fill_kinfo_proc_only(struct proc *p, str
>         struct ucred *cred;
>         struct sigacts *ps;
>
> +       /* For proc_realparent. */
> +       sx_assert(&proctree_lock, SX_LOCKED);
>         PROC_LOCK_ASSERT(p, MA_OWNED);
>         bzero(kp, sizeof(*kp));
>
> @@ -920,7 +922,9 @@ fill_kinfo_proc_only(struct proc *p, str
>         kp->ki_acflag = p->p_acflag;
>         kp->ki_lock = p->p_lock;
>         if (p->p_pptr)
> -               kp->ki_ppid = p->p_pptr->p_pid;
> +               kp->ki_ppid = proc_realparent(p)->p_pid;
> +       if (p->p_flag & P_TRACED)
> +               kp->ki_tracer = p->p_pptr->p_pid;
>  }
>
>  /*
> @@ -1166,6 +1170,7 @@ freebsd32_kinfo_proc_out(const struct ki
>         bcopy(ki->ki_comm, ki32->ki_comm, COMMLEN + 1);
>         bcopy(ki->ki_emul, ki32->ki_emul, KI_EMULNAMELEN + 1);
>         bcopy(ki->ki_loginclass, ki32->ki_loginclass, LOGINCLASSLEN + 1);
> +       CP(*ki, *ki32, ki_tracer);
>         CP(*ki, *ki32, ki_flag2);
>         CP(*ki, *ki32, ki_fibnum);
>         CP(*ki, *ki32, ki_cr_flags);
> @@ -1287,10 +1292,11 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
>                 error = sysctl_wire_old_buffer(req, 0);
>                 if (error)
>                         return (error);
> +               sx_slock(&proctree_lock);
>                 error = pget((pid_t)name[0], PGET_CANSEE, &p);
> -               if (error != 0)
> -                       return (error);
> -               error = sysctl_out_proc(p, req, flags, 0);
> +               if (error == 0)
> +                       error = sysctl_out_proc(p, req, flags, 0);
> +               sx_sunlock(&proctree_lock);
>                 return (error);
>         }
>
> @@ -1318,6 +1324,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
>         error = sysctl_wire_old_buffer(req, 0);
>         if (error != 0)
>                 return (error);
> +       sx_slock(&proctree_lock);
>         sx_slock(&allproc_lock);
>         for (doingzomb=0 ; doingzomb < 2 ; doingzomb++) {
>                 if (!doingzomb)
> @@ -1422,11 +1429,13 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
>                         error = sysctl_out_proc(p, req, flags, doingzomb);
>                         if (error) {
>                                 sx_sunlock(&allproc_lock);
> +                               sx_sunlock(&proctree_lock);
>                                 return (error);
>                         }
>                 }
>         }
>         sx_sunlock(&allproc_lock);
> +       sx_sunlock(&proctree_lock);
>         return (0);
>  }
>
>
> Modified: head/sys/sys/user.h
> ==============================================================================
> --- head/sys/sys/user.h Thu Aug 28 08:25:15 2014        (r270744)
> +++ head/sys/sys/user.h Thu Aug 28 08:41:11 2014        (r270745)
> @@ -84,7 +84,7 @@
>   * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
>   * function kvm_proclist in lib/libkvm/kvm_proc.c .
>   */
> -#define        KI_NSPARE_INT   7
> +#define        KI_NSPARE_INT   6
>  #define        KI_NSPARE_LONG  12
>  #define        KI_NSPARE_PTR   6
>
> @@ -187,6 +187,7 @@ struct kinfo_proc {
>          */
>         char    ki_sparestrings[50];    /* spare string space */
>         int     ki_spareints[KI_NSPARE_INT];    /* spare room for growth */
> +       int     ki_tracer;              /* Pid of tracing process */
>         int     ki_flag2;               /* P2_* flags */
>         int     ki_fibnum;              /* Default FIB number */
>         u_int   ki_cr_flags;            /* Credential flags */
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-Vmo=M=JoV8DxZkG4ghj88r8fpUSAnOiFvdcur26Hs=0eAPQ>