From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 27 18:36:26 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7BFA31CC; Fri, 27 Mar 2015 18:36:26 +0000 (UTC) Received: from mail-pd0-x22a.google.com (mail-pd0-x22a.google.com [IPv6:2607:f8b0:400e:c02::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 44285113; Fri, 27 Mar 2015 18:36:26 +0000 (UTC) Received: by pdbop1 with SMTP id op1so104154301pdb.2; Fri, 27 Mar 2015 11:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=RPRj5sdwLf91eFy29HUeTFiIjV0iPrDGLt2iVfS623I=; b=Lii9Kij7vr+j+hzgAUNIa1inGmNUEl3jAafL4O4ck6wucYBVsIbTTN90ZI9szgexkg H8ieHw0BsmdtuItcg2V8Qtkk352H2nZhZDrCPqWH8WRx8Rsx4R4B63RYQXJ5JKUL6zRK CIPlnbbxBsI+CNj/gmfRvaNXu9vpEFoiCnZNZldg9ikLdRHPmIZDInjFfWaHjMLUgpNb x6LNqPROqCqRbWEnMM+0UGUUS+pBeyA6q9In1C54fZZUYfbVCig5oSeRdWvMU9gykEEP 2IM+YVKdcMPhnz7TPIkswauVH3r0euq8OHHbJaHtcLUnLZoaK/Xc11clc1vluXZEOamz ExEg== X-Received: by 10.66.234.2 with SMTP id ua2mr37426234pac.137.1427481385794; Fri, 27 Mar 2015 11:36:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.179.203 with HTTP; Fri, 27 Mar 2015 11:35:55 -0700 (PDT) In-Reply-To: References: <20150321220246.GE14650@dft-labs.eu> <20150321232622.GF14650@dft-labs.eu> From: Yue Chen Date: Fri, 27 Mar 2015 14:35:55 -0400 Message-ID: Subject: Re: How to traverse kernel threads? To: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: Benjamin Kaduk , Mateusz Guzik , Oliver Pinter X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2015 18:36:26 -0000 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 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" >