From owner-svn-src-stable-11@freebsd.org Mon Mar 27 18:22:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62E6BD20D7B; Mon, 27 Mar 2017 18:22:35 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id 39B44E15; Mon, 27 Mar 2017 18:22:35 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2RIMY1v018128; Mon, 27 Mar 2017 18:22:34 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2RIMYRO018124; Mon, 27 Mar 2017 18:22:34 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703271822.v2RIMYRO018124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 27 Mar 2017 18:22:34 +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: r316039 - stable/11/lib/libkvm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Mar 2017 18:22:35 -0000 Author: ngie Date: Mon Mar 27 18:22:33 2017 New Revision: 316039 URL: https://svnweb.freebsd.org/changeset/base/316039 Log: MFC r315595,r315601,r315603,r315647: r315595: Remove a commented out line before kvm_getprocs(3) The commented out return value for kvm_getprocs(3) was misleading -- the uncommented line is correct. No content change r315601: kvm_open2(3): remove '*' when describing addr argument for `resolver` As noted by vangyzen, with a similar issue in D10022, the pointer portion of the .Fa macro call is unnecessary, so remove the '*'. r315603: kvm_close(3): return `error` instead of blindly returning `0` `error` is the accumulated error from previous close(2) calls. This bug has been present since the libcall's import from 4.4BSD Lite (r1573). Noticed by: vangyzen (D10022) Relnotes: yes r315647: Handle kd == NULL gracefully with kvm_close(3) Don't segfault in kvm_close(3) if provided a NULL pointer. Instead, return -1 and set errno to EINVAL. Document this new behavior explicitly. Modified: stable/11/lib/libkvm/kvm.c stable/11/lib/libkvm/kvm_getprocs.3 stable/11/lib/libkvm/kvm_open.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libkvm/kvm.c ============================================================================== --- stable/11/lib/libkvm/kvm.c Mon Mar 27 18:20:32 2017 (r316038) +++ stable/11/lib/libkvm/kvm.c Mon Mar 27 18:22:33 2017 (r316039) @@ -534,6 +534,10 @@ kvm_close(kvm_t *kd) { int error = 0; + if (kd == NULL) { + errno = EINVAL; + return (-1); + } if (kd->vmst != NULL) kd->arch->ka_freevtop(kd); if (kd->pmfd >= 0) @@ -552,7 +556,7 @@ kvm_close(kvm_t *kd) free((void *)kd->argv); free((void *)kd); - return (0); + return (error); } /* Modified: stable/11/lib/libkvm/kvm_getprocs.3 ============================================================================== --- stable/11/lib/libkvm/kvm_getprocs.3 Mon Mar 27 18:20:32 2017 (r316038) +++ stable/11/lib/libkvm/kvm_getprocs.3 Mon Mar 27 18:22:33 2017 (r316039) @@ -47,7 +47,6 @@ .In sys/param.h .In sys/sysctl.h .In sys/user.h -.\" .Fa kvm_t *kd .Ft struct kinfo_proc * .Fn kvm_getprocs "kvm_t *kd" "int op" "int arg" "int *cnt" .Ft char ** Modified: stable/11/lib/libkvm/kvm_open.3 ============================================================================== --- stable/11/lib/libkvm/kvm_open.3 Mon Mar 27 18:20:32 2017 (r316038) +++ stable/11/lib/libkvm/kvm_open.3 Mon Mar 27 18:22:33 2017 (r316039) @@ -32,7 +32,7 @@ .\" @(#)kvm_open.3 8.3 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd November 27, 2015 +.Dd March 20, 2017 .Dt KVM_OPEN 3 .Os .Sh NAME @@ -196,7 +196,7 @@ function is called, specifies the requested symbol name. If the function is able to resolve the name to an address, the address should be set in -.Fa *addr +.Fa addr and the function should return zero. If the function is not able to resolve the name to an address, it should return a non-zero value. @@ -227,10 +227,29 @@ and write the error message into .Fa errbuf . .Pp +.Rv -std kvm_close +.Sh ERRORS The .Fn kvm_close -function returns 0 on success and -1 on failure. +function may fail and set the global variable +.Va errno +for any of the errors specified for +.Xr close 2 . +.Pp +The +.Fn kvm_close +function may also fail and set +.Va errno +if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value passed via +.Fa kd +was +.Dv NULL . +.El .Sh SEE ALSO +.Xr close 2 , .Xr open 2 , .Xr kvm 3 , .Xr kvm_getargv 3 ,