Date: Mon, 7 May 2012 06:31:55 GMT From: David Marker <dmarker@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/167671: libkvm doesn't initialize vnet Message-ID: <201205070631.q476VtWV065752@red.freebsd.org> Resent-Message-ID: <201205070640.q476e8nq089537@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205070631.q476VtWV065752>