From owner-svn-src-all@freebsd.org Wed Apr 15 20:28:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBB9A2C1703; Wed, 15 Apr 2020 20:28:20 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 492YpD4dPkz4NCj; Wed, 15 Apr 2020 20:28:20 +0000 (UTC) (envelope-from brooks@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 9872C24C0C; Wed, 15 Apr 2020 20:28:20 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03FKSKa1095845; Wed, 15 Apr 2020 20:28:20 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03FKSKhp095844; Wed, 15 Apr 2020 20:28:20 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202004152028.03FKSKhp095844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 15 Apr 2020 20:28:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359991 - head/lib/libc/gen X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/lib/libc/gen X-SVN-Commit-Revision: 359991 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.29 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, 15 Apr 2020 20:28:20 -0000 Author: brooks Date: Wed Apr 15 20:28:20 2020 New Revision: 359991 URL: https://svnweb.freebsd.org/changeset/base/359991 Log: Attempt to use AT_PS_STRINGS to get the ps_strings pointer. This saves a system call and avoids one of the (relatively rare) cases of the kernel exporting pointers via sysctl. As a temporary measure, keep the sysctl support to allow limited compatability with old kernels. Fail gracefully if ps_strings can't be found (should never happen). Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24407 Modified: head/lib/libc/gen/setproctitle.c Modified: head/lib/libc/gen/setproctitle.c ============================================================================== --- head/lib/libc/gen/setproctitle.c Wed Apr 15 20:26:41 2020 (r359990) +++ head/lib/libc/gen/setproctitle.c Wed Apr 15 20:28:20 2020 (r359991) @@ -20,6 +20,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include +#include #include #include @@ -112,6 +113,10 @@ setproctitle_internal(const char *fmt, va_list ap) /* Nothing to restore */ return (NULL); + if (ps_strings == NULL) + (void)_elf_aux_info(AT_PS_STRINGS, &ps_strings, + sizeof(ps_strings)); + if (ps_strings == NULL) { len = sizeof(ul_ps_strings); if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, @@ -119,6 +124,9 @@ setproctitle_internal(const char *fmt, va_list ap) return (NULL); ps_strings = (struct ps_strings *)ul_ps_strings; } + + if (ps_strings == NULL) + return (NULL); /* * PS_STRINGS points to zeroed memory on a style #2 kernel.