2018-05-01 21:53 GMT+03:00 Theo de Raadt <dera...@openbsd.org>: > ktrace makes the problem more clear: > > 25908 ps CALL > sysctl(1.55.75675.1<kern.procargs.75675.1>,0xed0cc780000,0x7f7ffffcd3d8,0,0) > 25908 ps RET sysctl -1 errno 14 Bad address
And that's it, thanks! Now little ps(1) is happy. But now there's a question, about kvm_getargv() and kvm_getenv(): what behaviour do we want? a) They use same space, overwriting each other results (this is what happens now, and noone complains). b) Their working space should be independent of each other. This isn't hard, just splitting kd->argbuf into kd->argbuf and kd->envbuf. Seems a bit saner. I'm fine with any direction. The patch below implements (a), since it's less patching. Is it okay, or should it be (b)? -- WBR, Vadim Zhukov Index: kvm_proc.c =================================================================== RCS file: /cvs/src/lib/libkvm/kvm_proc.c,v retrieving revision 1.58 diff -u -p -r1.58 kvm_proc.c --- kvm_proc.c 7 Nov 2016 00:26:33 -0000 1.58 +++ kvm_proc.c 1 May 2018 19:23:01 -0000 @@ -458,12 +458,14 @@ kvm_arg_sysctl(kvm_t *kd, pid_t pid, int { size_t len, orglen; int mib[4], ret; - char *buf; + void *buf; orglen = env ? kd->nbpg : 8 * kd->nbpg; /* XXX - should be ARG_MAX */ - if (kd->argbuf == NULL && - (kd->argbuf = _kvm_malloc(kd, orglen)) == NULL) - return (NULL); + + buf = _kvm_realloc(kd, kd->argbuf, orglen); + if (buf == NULL) + return NULL; + kd->argbuf = buf; again: mib[0] = CTL_KERN;