From owner-svn-src-all@freebsd.org Wed Jul 11 19:23:12 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FC09103A65E; Wed, 11 Jul 2018 19:23:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 20F7A827D3; Wed, 11 Jul 2018 19:23:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 01CC916EAE; Wed, 11 Jul 2018 19:23:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6BJNBNG096469; Wed, 11 Jul 2018 19:23:11 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6BJNBlW096468; Wed, 11 Jul 2018 19:23:11 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201807111923.w6BJNBlW096468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 11 Jul 2018 19:23:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r336204 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 336204 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2018 19:23:12 -0000 Author: kib Date: Wed Jul 11 19:23:11 2018 New Revision: 336204 URL: https://svnweb.freebsd.org/changeset/base/336204 Log: MFC r335935: Add a way for the process to request cleanup of the kernel cache of the process arguments. Modified: stable/11/sys/kern/kern_proc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_proc.c ============================================================================== --- stable/11/sys/kern/kern_proc.c Wed Jul 11 18:53:18 2018 (r336203) +++ stable/11/sys/kern/kern_proc.c Wed Jul 11 19:23:11 2018 (r336204) @@ -1945,11 +1945,20 @@ sysctl_kern_proc_args(SYSCTL_HANDLER_ARGS) if (req->newlen > ps_arg_cache_limit - sizeof(struct pargs)) return (ENOMEM); - newpa = pargs_alloc(req->newlen); - error = SYSCTL_IN(req, newpa->ar_args, req->newlen); - if (error != 0) { - pargs_free(newpa); - return (error); + + if (req->newlen == 0) { + /* + * Clear the argument pointer, so that we'll fetch arguments + * with proc_getargv() until further notice. + */ + newpa = NULL; + } else { + newpa = pargs_alloc(req->newlen); + error = SYSCTL_IN(req, newpa->ar_args, req->newlen); + if (error != 0) { + pargs_free(newpa); + return (error); + } } PROC_LOCK(p); pa = p->p_args;