git: a0993376ec5f - main - stats: Check for errors from copyout()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 04 Jan 2024 13:40:22 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=a0993376ec5f979272a62b140ec9f41bc02107b3
commit a0993376ec5f979272a62b140ec9f41bc02107b3
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-04 13:33:58 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
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);
}