git: 7eb92c502eb5 - main - Reinstate returning EOVERFLOW from stats_v1_blob_clone()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 03 Apr 2024 02:01:32 UTC
The branch main has been updated by lstewart: URL: https://cgit.FreeBSD.org/src/commit/?id=7eb92c502eb503d808a51296e426de625239a0d9 commit 7eb92c502eb503d808a51296e426de625239a0d9 Author: Lawrence Stewart <lstewart@FreeBSD.org> AuthorDate: 2024-04-02 06:34:25 +0000 Commit: Lawrence Stewart <lstewart@FreeBSD.org> CommitDate: 2024-04-03 01:58:26 +0000 Reinstate returning EOVERFLOW from stats_v1_blob_clone() a0993376ec5f (from D43179) subtly changed stats_v1_blob_clone() to stop returning EOVERFLOW in the case where the user buffer is not large enough to receive the entire statsblob. This results in any consumers which are implemented to retry on receiving EOVERFLOW to instead give up after receiving an empty statsblob header. Fix by latching any errors recorded prior to copyout. Reviewed by: markj Obtained from: Netflix, Inc. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44585 Fixes: a0993376ec5f ("stats: Check for errors from copyout()") --- sys/kern/subr_stats.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_stats.c b/sys/kern/subr_stats.c index 0f1b83a5783a..9fb8f8cbd74b 100644 --- a/sys/kern/subr_stats.c +++ b/sys/kern/subr_stats.c @@ -1078,9 +1078,9 @@ int stats_v1_blob_clone(struct statsblobv1 **dst, size_t dstmaxsz, struct statsblobv1 *src, uint32_t flags) { - int error; + int error, tmperror; - error = 0; + error = tmperror = 0; if (src == NULL || dst == NULL || src->cursz < sizeof(struct statsblob) || @@ -1131,14 +1131,16 @@ stats_v1_blob_clone(struct statsblobv1 **dst, size_t dstmaxsz, } #ifdef _KERNEL if (flags & SB_CLONE_USRDSTNOFAULT) - error = copyout_nofault(&(src->cursz), &((*dst)->cursz), + tmperror = copyout_nofault(&(src->cursz), &((*dst)->cursz), postcurszlen); else if (flags & SB_CLONE_USRDST) - error = copyout(&(src->cursz), &((*dst)->cursz), + tmperror = copyout(&(src->cursz), &((*dst)->cursz), postcurszlen); else #endif memcpy(&((*dst)->cursz), &(src->cursz), postcurszlen); + + error = error ? error : tmperror; } #ifdef _KERNEL out: