Reinstate returning EOVERFLOW from stats_v1_blob_clone()
a0993376ec(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:a0993376ec("stats: Check for errors from copyout()")
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user