From nobody Thu Jan 04 13:40:22 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T5SQG2yvXz56Q80; Thu, 4 Jan 2024 13:40:22 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T5SQG1cVNz41d2; Thu, 4 Jan 2024 13:40:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704375622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HeiJTvglC/+aiLeD8j+V19newH+JYgadPSHC7mG2zU8=; b=bALWpd2UO+MSUDdsYmV/weIumzcnT0/oxmZ9PwDFb/zJRCo0kZY6l6hCDb7T66Cc/L+Vj4 PqNteRB0DQxKtIcPLrd65/rR2OwemlrgIhmDXLdqFyCq+kJPScryYtu6JbUCNO6381PsWH 7+oiiaLM4JdfhEkKbz/4EVYfHgdB5hYOy1duWqZC+r1GC6HWX+tErBdLh0GiVGA9KE8QXR qVk2qb0EgCVzMU9EbjaoR8UAH0zVf3vhD8hWiDVXwJNlnS3Y1gSyyGqmyQYUxtBVZMjnhL QSi3ynpMlAU6i3tVC1dCVpoEuyN0Rb6ywJThV7BnUxKpkhkaWCh/bkvBgKp4ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704375622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HeiJTvglC/+aiLeD8j+V19newH+JYgadPSHC7mG2zU8=; b=M0j+x+1KcwHzi3lJ0uBAa6+yPbM18hMGI+V1hfH0xloSWvPvgsdBS86foDQG0o1LqMffIP uGVF2JVPearoGIS6hwbLVtSDOPTn2/lOPPohNSw9l22/085dLSmITgKKvK784v1U+zQFR3 LQ1pTu4RHEcb68K6T+GiXOC2PkN3snvSwQwv9kL+w1cTrqLOkqq3Jb9xGz2CXVEYB6BRLk Ws0TAmNK4m9akE+Du7TZHI0bCrJlCuKF/4smWRlC3Iet5gHjR6xWITObRVfJ+/ppkBislj ObdpKUic0K0ZVxm8K+feXHow2TpxPk90F0bIyIfZplhBRxh6ivmHPvtJ32yLYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704375622; a=rsa-sha256; cv=none; b=eLCl19sY/wuDBoYEUgk+yQVRWneu3Bs84xffop/B1u003xs1Pf0PZLC+nUGzXXkB74RcuV Kyro9wqoJ9vwBMsdmic/X5EtD8dcUdQL7DlNwsif2Ww8S7M7ReELeJo54f5yT6rDCmrlFi L2/sJJNiWPzHoqYqs0j5xr87cnMRPLMOuNT9DgIIES8OkJ0DiVpPImfFMvXcS6opjsxznb qhGRxBK6n3nX8PHnidx8LrhE5zSzWl+FWCRgFQgH/HKFTkn5YR49PYoKb/bXHT6/8b9uJn rC7GBhXjc2o56Q3b93UyJf5E9f4G1LBY6vPZB3g4st+WuEXQdM76fjV8Xi0k7A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T5SQG0kmLzFwl; Thu, 4 Jan 2024 13:40:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 404DeMNH042024; Thu, 4 Jan 2024 13:40:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 404DeMrc042021; Thu, 4 Jan 2024 13:40:22 GMT (envelope-from git) Date: Thu, 4 Jan 2024 13:40:22 GMT Message-Id: <202401041340.404DeMrc042021@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a0993376ec5f - main - stats: Check for errors from copyout() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a0993376ec5f979272a62b140ec9f41bc02107b3 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a0993376ec5f979272a62b140ec9f41bc02107b3 commit a0993376ec5f979272a62b140ec9f41bc02107b3 Author: Mark Johnston AuthorDate: 2024-01-04 13:33:58 +0000 Commit: Mark Johnston CommitDate: 2024-01-04 13:39:53 +0000 stats: Check for errors from copyout() This is in preparation for annotating copyin() and related functions with __result_use_check. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43179 --- sys/kern/subr_stats.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_stats.c b/sys/kern/subr_stats.c index 63fd785d9175..0f1b83a5783a 100644 --- a/sys/kern/subr_stats.c +++ b/sys/kern/subr_stats.c @@ -1107,13 +1107,19 @@ stats_v1_blob_clone(struct statsblobv1 **dst, size_t dstmaxsz, */ #ifdef _KERNEL if (flags & SB_CLONE_USRDSTNOFAULT) - copyout_nofault(src, *dst, + error = copyout_nofault(src, *dst, offsetof(struct statsblob, maxsz)); else if (flags & SB_CLONE_USRDST) - copyout(src, *dst, offsetof(struct statsblob, maxsz)); + error = copyout(src, *dst, + offsetof(struct statsblob, maxsz)); else #endif memcpy(*dst, src, offsetof(struct statsblob, maxsz)); +#ifdef _KERNEL + if (error != 0) + goto out; +#endif + if (dstmaxsz >= src->cursz) { postcurszlen = src->cursz - @@ -1125,14 +1131,18 @@ stats_v1_blob_clone(struct statsblobv1 **dst, size_t dstmaxsz, } #ifdef _KERNEL if (flags & SB_CLONE_USRDSTNOFAULT) - copyout_nofault(&(src->cursz), &((*dst)->cursz), + error = copyout_nofault(&(src->cursz), &((*dst)->cursz), postcurszlen); else if (flags & SB_CLONE_USRDST) - copyout(&(src->cursz), &((*dst)->cursz), postcurszlen); + error = copyout(&(src->cursz), &((*dst)->cursz), + postcurszlen); else #endif memcpy(&((*dst)->cursz), &(src->cursz), postcurszlen); } +#ifdef _KERNEL +out: +#endif return (error); }