Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Feb 2025 19:25:36 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: 31af1ba0a87c - stable/14 - Reinstate returning EOVERFLOW from stats_v1_blob_clone()
Message-ID:  <202502141925.51EJPa0w039065@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=31af1ba0a87cbf2fcc9850e012e5a62f750211b1

commit 31af1ba0a87cbf2fcc9850e012e5a62f750211b1
Author:     Lawrence Stewart <lstewart@FreeBSD.org>
AuthorDate: 2024-04-02 06:34:25 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-02-14 19:25:19 +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()")
    
    (cherry picked from commit 7eb92c502eb503d808a51296e426de625239a0d9)
---
 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 6d04b9ae1588..23908c59c996 100644
--- a/sys/kern/subr_stats.c
+++ b/sys/kern/subr_stats.c
@@ -1079,9 +1079,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) ||
@@ -1132,14 +1132,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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502141925.51EJPa0w039065>