From bd0ca7a0ba7d398a2d0d0faf886ceb00713cddb7 Mon Sep 17 00:00:00 2001 From: trociny Date: Tue, 22 Nov 2011 20:43:03 +0000 Subject: 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 --- sys/fs/procfs/procfs_status.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'sys/fs/procfs') 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)); } -- cgit v1.1