Date: Thu, 11 Jan 2024 14:32:35 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: b8233245b8d0 - stable/14 - stats: Check for errors from copyout() Message-ID: <202401111432.40BEWZ6Y024217@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b8233245b8d04816d13ea0c4441c0ded57323840 commit b8233245b8d04816d13ea0c4441c0ded57323840 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-01-04 13:33:58 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-01-11 14:19:19 +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 (cherry picked from commit a0993376ec5f979272a62b140ec9f41bc02107b3) --- 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 0e7d2fad5f68..6a9dff2b9126 100644 --- a/sys/kern/subr_stats.c +++ b/sys/kern/subr_stats.c @@ -1108,13 +1108,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 - @@ -1126,14 +1132,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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401111432.40BEWZ6Y024217>