From owner-svn-src-head@freebsd.org Wed Jul 4 13:22:49 2018 Return-Path: Delivered-To: svn-src-head@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 5CEF610350BE; Wed, 4 Jul 2018 13:22:49 +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 108DA7A036; Wed, 4 Jul 2018 13:22:49 +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 E55EB3AAC; Wed, 4 Jul 2018 13:22:48 +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 w64DMm7B002553; Wed, 4 Jul 2018 13:22:48 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w64DMmgv002552; Wed, 4 Jul 2018 13:22:48 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201807041322.w64DMmgv002552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 4 Jul 2018 13:22:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335935 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 335935 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 13:22:49 -0000 Author: kib Date: Wed Jul 4 13:22:48 2018 New Revision: 335935 URL: https://svnweb.freebsd.org/changeset/base/335935 Log: Add a way for the process to request cleanup of the kernel cache of the process arguments. New arguments length zero causes the drop of the pargs instead of allocation of useless zero-length buffer. Submitted by: Thomas Munro MFC after: 1 week Differential revision: https://reviews.freebsd.org/D16111 Modified: head/sys/kern/kern_proc.c Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Wed Jul 4 09:07:18 2018 (r335934) +++ head/sys/kern/kern_proc.c Wed Jul 4 13:22:48 2018 (r335935) @@ -1988,11 +1988,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;