From owner-freebsd-bugs@FreeBSD.ORG Mon May 7 06:40:09 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 453811065670 for ; Mon, 7 May 2012 06:40:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1E48A8FC12 for ; Mon, 7 May 2012 06:40:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q476e8UO089538 for ; Mon, 7 May 2012 06:40:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q476e8nq089537; Mon, 7 May 2012 06:40:08 GMT (envelope-from gnats) Resent-Date: Mon, 7 May 2012 06:40:08 GMT Resent-Message-Id: <201205070640.q476e8nq089537@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, David Marker Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4056C106566B for ; Mon, 7 May 2012 06:31:56 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 1259E8FC08 for ; Mon, 7 May 2012 06:31:56 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q476VtPx065753 for ; Mon, 7 May 2012 06:31:55 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q476VtWV065752; Mon, 7 May 2012 06:31:55 GMT (envelope-from nobody) Message-Id: <201205070631.q476VtWV065752@red.freebsd.org> Date: Mon, 7 May 2012 06:31:55 GMT From: David Marker To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/167671: libkvm doesn't initialize vnet X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 May 2012 06:40:09 -0000 >Number: 167671 >Category: misc >Synopsis: libkvm doesn't initialize vnet >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 07 06:40:08 UTC 2012 >Closed-Date: >Last-Modified: >Originator: David Marker >Release: 9.0-stable >Organization: >Environment: FreeBSD familiar 9.0-STABLE FreeBSD 9.0-STABLE #0 r235098: Sun May 6 19:31:38 MDT 2012 root@familiar:/usr/obj/usr/src/sys/FAMILIAR amd64 >Description: Adding "options VIMAGE" to kernel configuration causes symbol lookups to fail in libkvm. For example `netstat -rn` will complain "netstat: no namelist" >How-To-Repeat: Add "options VIMAGE" to your kernel config, rebuild and install. Now `netstat -rn` will complain. >Fix: /usr/src/lib/libkvm/kvm_vnet.c is looking for "dumptid" (among other symbols) when calling _kvm_nlist() in _kvm_vnet_selectpid(). The other symbols are there, but "dumptid" is not and it causes _kvm_nlist() to return an error. Further down the code, comments suggest the "dumptid" symbol is only supposed to be there if libkvm is working on a crashdump. Removing "dumptid" from the nlist fixes the issue and `netstat -rn` works as normal again. I'm attaching a patch that works, but I confess I do not understand how "dumptid" is supposed to work so it would be best to consider it just a starting point. Patch attached with submission follows: --- kvm_vnet.c 2012-05-06 23:27:25.701672209 -0600 +++ kvm_vnet.c 2012-05-06 23:49:27.186721426 -0600 @@ -75,12 +75,16 @@ { .n_name = "vnet_head" }, #define NLIST_ALLPROC 3 { .n_name = "allproc" }, -#define NLIST_DUMPTID 4 - { .n_name = "dumptid" }, -#define NLIST_PROC0 5 +#define NLIST_PROC0 4 { .n_name = "proc0" }, { .n_name = NULL }, }; + struct nlist dnl[] = { +#define NLIST_DUMPTID 5 + { .n_name = "dumptid" }, + { .n_name = NULL }, + }; + uintptr_t procp, credp; #define VMCORE_VNET_OF_PROC0 #ifndef VMCORE_VNET_OF_PROC0 @@ -108,12 +112,15 @@ return (-1); } + /* dumptid may not be there */ + (void) _kvm_nlist(kd, dnl, 0); + /* * Auto-detect if this is a crashdump by reading dumptid. */ dumptid = 0; - if (nl[NLIST_DUMPTID].n_value) { - if (kvm_read(kd, nl[NLIST_DUMPTID].n_value, &dumptid, + if (dnl[NLIST_DUMPTID].n_value) { + if (kvm_read(kd, dnl[NLIST_DUMPTID].n_value, &dumptid, sizeof(dumptid)) != sizeof(dumptid)) { _kvm_err(kd, kd->program, "%s: dumptid", __func__); return (-1); >Release-Note: >Audit-Trail: >Unformatted: