Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Mar 2015 14:35:55 -0400
From:      Yue Chen <ycyc321@gmail.com>
To:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Cc:        Benjamin Kaduk <bjk@freebsd.org>, Mateusz Guzik <mjguzik@gmail.com>, Oliver Pinter <oliver.pinter@hardenedbsd.org>
Subject:   Re: How to traverse kernel threads?
Message-ID:  <CAKtBrB6ZF2FVExmDd%2Bt8yFpN0H7xHwaieWgvryR535Vc2cNBjw@mail.gmail.com>
In-Reply-To: <CAPQ4ffuszSi%2B_SopJdCkoFr4OoY9=BZVbO6oo_s0sKrn8Rgjrw@mail.gmail.com>
References:  <CAKtBrB4h13ZFJ=V0fvkDeTG-L6=e5Uz9%2BHfYc8vY523Y3X6N0A@mail.gmail.com> <20150321220246.GE14650@dft-labs.eu> <CAKtBrB5KNqt6UJ1R_BQpPfTvQZdUzGvZZtT7Uz5qd4VrrfgEdw@mail.gmail.com> <20150321232622.GF14650@dft-labs.eu> <alpine.GSO.1.10.1503221644440.22210@multics.mit.edu> <CAPQ4ffuszSi%2B_SopJdCkoFr4OoY9=BZVbO6oo_s0sKrn8Rgjrw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
When using the following code on kernel module loading:
------------------------------------------------------------------------------------------
struct thread *td = kdb_thr_first();
td = kdb_thr_next(td);
------------------------------------------------------------------------------------------
The kernel panics.


And when printing all threads in proc0 (all kernel threads?):
------------------------------------------------------------------------------------------
struct proc *p = pfind(0);
FOREACH_THREAD_IN_PROC(p, td) {
    uprintf("td: %x\n", td);
}

td = curthread;
uprintf("cur td: %x\n", td);
------------------------------------------------------------------------------------------
The ``curthread'' (from this kernel module running the above code) is not
in the 0 process group.



On Sun, Mar 22, 2015 at 4:58 PM, Oliver Pinter <
oliver.pinter@hardenedbsd.org> wrote:

> Probably take a look at DDB:
>
> https://github.com/HardenedBSD/hardenedBSD/blob/hardened/current/master/sys/ddb/db_thread.c#L88
>
> On Sun, Mar 22, 2015 at 9:45 PM, Benjamin Kaduk <bjk@freebsd.org> wrote:
> > On Sat, 21 Mar 2015, Mateusz Guzik wrote:
> >
> >> But once more the real question is what are you trying to do. I don't
> >> see any use for stack info of random threads.
> >
> > One thing that comes to mind is for live binary-patching the kernel, to
> > confirm that no thread is currently in a routine which would be patched.
> >
> > -Ben
> > _______________________________________________
> > freebsd-hackers@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > To unsubscribe, send any mail to "
> freebsd-hackers-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAKtBrB6ZF2FVExmDd%2Bt8yFpN0H7xHwaieWgvryR535Vc2cNBjw>