On Sun, 11 Jul 2010, Craig Small wrote:
On Mon, Jul 05, 2010 at 06:32:42PM +0300, Matti H?m?l?inen wrote:
Invoking 'pstree -a' without other arguments results in segmentation fault (at
Hello,
I've tested this on two different setups and both work fine. Are you
able to run a strace on the program to show where it is faulting? If
you're not sure how to do this, let me know and I'll give you
instructions.
pstree also needs access to /proc and someone suggested that perhaps
grsec is interfering here. Are you able to temporarily disable it just
to see if that is the general problem area? psmisc should work with a
setup using grsec, failing gracefully if it has no access to something,
but it would be nice to know if this is the cause.
Finally, how are you running the program? On a text vty? gnome terminal?
The environment may be triggering something.
Indeed, it worked perfectly on stock Debian kernel, so basically my
vanilla+grsec kernel was triggering it. I should have thought of that.
However, after I fetched the source and did some debugging, I found the
cause - namely certain struct elements are not initialized and as grsec
prevents fetching information on later stage about PID 1 (as I have
process hiding on) for non-root users .. thus the kaboom when accessing
those struct members with garbage in them.
Amusingly enough at first I suspected stack / heap trashing, because
redirecting output of pstree made it "work", but such was not the case. :P
I am attaching a small patch that addresses this.
--
] ccr/TNSP^DKD^pWp :: ccr tnsp org :: http://ccr.tnsp.org/
] PGP key: 0466 95ED 96DF 3701 C71D D62D 10A6 28A6 1374 C112
diff -r 7471e48aefb0 src/pstree.c
--- a/src/pstree.c Mon Jul 12 10:04:26 2010 +0300
+++ b/src/pstree.c Mon Jul 12 10:45:31 2010 +0300
@@ -268,6 +268,8 @@
new->pid = pid;
new->uid = uid;
new->flags = 0;
+ new->argc = 0;
+ new->argv = NULL;
#ifdef WITH_SELINUX
new->scontext = scontext;
#endif /*WITH_SELINUX */