summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2011-11-22 20:43:03 +0000
committertrociny <trociny@FreeBSD.org>2011-11-22 20:43:03 +0000
commitbd0ca7a0ba7d398a2d0d0faf886ceb00713cddb7 (patch)
tree4945c7a3f75cc1efc6eb74ad7045e295cd137b91 /sys/fs/procfs
parentce852d7df63c4656892a289f46406817c001bc66 (diff)
downloadFreeBSD-src-bd0ca7a0ba7d398a2d0d0faf886ceb00713cddb7.zip
FreeBSD-src-bd0ca7a0ba7d398a2d0d0faf886ceb00713cddb7.tar.gz
In procfs_doproccmdline() if arguments are not cashed read them from
the process stack. Suggested by: kib Reviewed by: kib Tested by: pho MFC after: 2 weeks
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r--sys/fs/procfs/procfs_status.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c
index 4bfa06f..d981e5e 100644
--- a/sys/fs/procfs/procfs_status.c
+++ b/sys/fs/procfs/procfs_status.c
@@ -170,15 +170,10 @@ procfs_doprocstatus(PFS_FILL_ARGS)
int
procfs_doproccmdline(PFS_FILL_ARGS)
{
- struct ps_strings pstr;
- char **ps_argvstr;
- int error, i;
/*
* If we are using the ps/cmdline caching, use that. Otherwise
- * revert back to the old way which only implements full cmdline
- * for the current process and just p->p_comm for all other
- * processes.
+ * read argv from the process space.
* Note that if the argv is no longer available, we deliberately
* don't fall back on p->p_comm or return an error: the authentic
* Linux behaviour is to return zero-length in this case.
@@ -190,30 +185,13 @@ procfs_doproccmdline(PFS_FILL_ARGS)
PROC_UNLOCK(p);
return (0);
}
- PROC_UNLOCK(p);
- if (p != td->td_proc) {
- sbuf_printf(sb, "%.*s", MAXCOMLEN, p->p_comm);
- } else {
- error = copyin((void *)p->p_sysent->sv_psstrings, &pstr,
- sizeof(pstr));
- if (error)
- return (error);
- if (pstr.ps_nargvstr > ARG_MAX)
- return (E2BIG);
- ps_argvstr = malloc(pstr.ps_nargvstr * sizeof(char *),
- M_TEMP, M_WAITOK);
- error = copyin((void *)pstr.ps_argvstr, ps_argvstr,
- pstr.ps_nargvstr * sizeof(char *));
- if (error) {
- free(ps_argvstr, M_TEMP);
- return (error);
- }
- for (i = 0; i < pstr.ps_nargvstr; i++) {
- sbuf_copyin(sb, ps_argvstr[i], 0);
- sbuf_printf(sb, "%c", '\0');
- }
- free(ps_argvstr, M_TEMP);
+
+ if ((p->p_flag & P_SYSTEM) != 0) {
+ PROC_UNLOCK(p);
+ return (0);
}
- return (0);
+ PROC_UNLOCK(p);
+
+ return (proc_getargv(td, p, sb, ARG_MAX));
}
OpenPOWER on IntegriCloud