NetBSD Problem Report #47951
From riz@slash.lan Fri Jun 21 18:28:59 2013
Return-Path: <riz@slash.lan>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 99BA370A07
for <gnats-bugs@gnats.NetBSD.org>; Fri, 21 Jun 2013 18:28:59 +0000 (UTC)
Message-Id: <20130621182628.1D004CCC34@slash.lan>
Date: Fri, 21 Jun 2013 11:26:28 -0700 (PDT)
From: riz@NetBSD.org
Reply-To: riz@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: modstat(8) can't display load address
X-Send-Pr-Version: 3.95
>Number: 47951
>Category: bin
>Synopsis: modstat(8) has no option to display load address
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jun 21 18:30:00 +0000 2013
>Closed-Date: Mon Oct 07 03:38:35 +0000 2013
>Last-Modified: Mon Oct 07 03:38:35 +0000 2013
>Originator: Jeff Rizzo
>Release: NetBSD 6.99.21
>Organization:
>Environment:
System: NetBSD slash.lan 6.99.21 NetBSD 6.99.21 (DTRACE) #23: Sun Jun 16 22:36:30 PDT 2013 riz@slash.lan:/usr/src/sys/arch/amd64/compile/DTRACE amd64
Architecture: x86_64
Machine: amd64
>Description:
The modstat(8) command should be able to display the address
at which a kernel module is loaded.
>How-To-Repeat:
Want to find the load address for a module. Note that modstat(8)
can't do it, even though it has all the information.
>Fix:
This is a SMOP, as in sbin/modstat/main.c, the information
is already retrieved from the kernel (ms->ms_addr) - it just
needs to be displayed. It's probably not needed by default,
but maybe an option flag?
I started in on some actual code for this, and realized I
don't have time to make it look nice enough, but it should
be easy enough for someone with a few minutes at hand.
>Release-Note:
>Audit-Trail:
From: riz@NetBSD.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/47951: modstat(8) can't display load address
Date: Fri, 21 Jun 2013 12:15:13 -0700
OK, I cooked up a patch that is untested on anything except amd64
at this point.
Index: main.c
===================================================================
RCS file: /cvsroot/src/sbin/modstat/main.c,v
retrieving revision 1.15
diff -u -r1.15 main.c
--- main.c 7 Aug 2012 01:19:05 -0000 1.15
+++ main.c 21 Jun 2013 19:13:25 -0000
@@ -175,9 +175,9 @@
if (maxnamelen < namelen)
maxnamelen = namelen;
}
- printf("%-*s %-10s %-10s %-5s %-8s %s\n",
- (int)maxnamelen, "NAME", "CLASS", "SOURCE", "REFS", "SIZE",
- "REQUIRES");
+ printf("%-*s %-10s %-10s %-5s %-16s %-8s %s \n",
+ (int)maxnamelen, "NAME", "CLASS", "SOURCE", "REFS", "ADDRESS",
+ "SIZE", "REQUIRES");
for (ms = iov.iov_base; len != 0; ms++, len--) {
const char *class;
const char *source;
@@ -204,9 +204,9 @@
else
source = "UNKNOWN";
- printf("%-*s %-10s %-10s %-5d %-8s %s\n",
+ printf("%-*s %-10s %-10s %-5d %-16" PRIx64 " %-8s %s\n",
(int)maxnamelen, ms->ms_name, class, source, ms->ms_refcnt,
- sbuf, ms->ms_required);
+ ms->ms_addr, sbuf, ms->ms_required);
}
exit(EXIT_SUCCESS);
Index: modstat.8
===================================================================
RCS file: /cvsroot/src/sbin/modstat/modstat.8,v
retrieving revision 1.11
diff -u -r1.11 modstat.8
--- modstat.8 12 Aug 2012 17:20:19 -0000 1.11
+++ modstat.8 21 Jun 2013 19:13:25 -0000
@@ -32,7 +32,7 @@
.\"
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
.\"
-.Dd August 6, 2012
+.Dd June 21, 2013
.Dt MODSTAT 8
.Os
.Sh NAME
@@ -92,6 +92,9 @@
.It Li REFS
Number of references held on the module.
Disabled builtin modules will show a count of \-1 here.
+.It Li ADDRESS
+The kernel address at which the module is loaded.
+Builtin modules will show 0 here.
.It Li REQUIRES
Additional modules that must be present.
.El
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: re: bin/47951: modstat(8) can't display load address
Date: Sat, 22 Jun 2013 10:03:34 +1000
please be aware of releasing ALSR-based info to non priviledged
users...
.mrg.
From: Jeff Rizzo <riz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/47951: modstat(8) can't display load address
Date: Fri, 21 Jun 2013 17:13:05 -0700
On 6/21/13 5:05 PM, matthew green wrote:
> The following reply was made to PR bin/47951; it has been noted by GNATS.
>
> From: matthew green <mrg@eterna.com.au>
> To: gnats-bugs@NetBSD.org
> Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> Subject: re: bin/47951: modstat(8) can't display load address
> Date: Sat, 22 Jun 2013 10:03:34 +1000
>
> please be aware of releasing ALSR-based info to non priviledged
> users...
>
>
> .mrg.
>
This is a non-setuid program, and I'm only printing information which is
already retrieved by the syscall...
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, riz@NetBSD.org
Subject: re: bin/47951: modstat(8) can't display load address
Date: Sat, 22 Jun 2013 10:19:15 +1000
> > please be aware of releasing ALSR-based info to non priviledged
> > users...
>
> This is a non-setuid program, and I'm only printing information which is
> already retrieved by the syscall...
yeah - i noticed that from the followup patch.
alsr is hard :)
From: matthew green <mrg@eterna.com.au>
To: John Nemeth <jnemeth@cue.bc.ca>
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, riz@netbsd.org,
gnats-bugs@netbsd.org
Subject: re: bin/47951: modstat(8) can't display load address
Date: Sat, 22 Jun 2013 11:12:01 +1000
> } > > please be aware of releasing ALSR-based info to non priviledged
> } > > users...
> } >
> } > This is a non-setuid program, and I'm only printing information which is
> } > already retrieved by the syscall...
> }
> } yeah - i noticed that from the followup patch.
> }
> } alsr is hard :)
>
> Not to mention, they are kernel addresses, not userland
> addresses, so ASLR isn't applicable.
ah right, we haven't fixed our kernels to be properly
relocatable yet.. pity.
.mrg.
From: John Nemeth <jnemeth@cue.bc.ca>
To: matthew green <mrg@eterna.com.au>, gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, riz@NetBSD.org
Subject: re: bin/47951: modstat(8) can't display load address
Date: Fri, 21 Jun 2013 17:38:19 -0700
On Jun 22, 10:19am, matthew green wrote:
}
} > > please be aware of releasing ALSR-based info to non priviledged
} > > users...
} >
} > This is a non-setuid program, and I'm only printing information which is
} > already retrieved by the syscall...
}
} yeah - i noticed that from the followup patch.
}
} alsr is hard :)
Not to mention, they are kernel addresses, not userland
addresses, so ASLR isn't applicable.
}-- End of excerpt from matthew green
From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47951 CVS commit: src/sbin/modstat
Date: Wed, 26 Jun 2013 17:55:38 +0000
Module Name: src
Committed By: riz
Date: Wed Jun 26 17:55:38 UTC 2013
Modified Files:
src/sbin/modstat: main.c modstat.8
Log Message:
Display the load address of modules. PR bin/47951.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/modstat/main.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/modstat/modstat.8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 07 Oct 2013 03:38:35 +0000
State-Changed-Why:
submitter fixed it a week later
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.