git: bd287fa8bcac - stable/14 - geom: Report copyout() errors in g_ctl_ioctl_ctl()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 02 Jan 2024 00:37:31 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bd287fa8bcac0d985d503c01d581c85ffb6d25ee commit bd287fa8bcac0d985d503c01d581c85ffb6d25ee Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-12-26 01:43:06 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-01-02 00:29:57 +0000 geom: Report copyout() errors in g_ctl_ioctl_ctl() Despite the name, req->serror is used in some cases to copy non-error messages to userspace. So, report errors when copying out so long as they don't clobber an earlier error. Reviewed by: mav, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43146 (cherry picked from commit bbf221e3e822d15dafb37bd8e200a9864f2636b4) --- sys/geom/geom_ctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index b7c80c77d4ba..f075488a832c 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -617,8 +617,10 @@ g_ctl_ioctl_ctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct th } } if (sbuf_done(req->serror)) { - copyout(sbuf_data(req->serror), req->error, + nerror = copyout(sbuf_data(req->serror), req->error, imin(req->lerror, sbuf_len(req->serror) + 1)); + if (nerror != 0 && req->nerror == 0) + req->nerror = nerror; } nerror = req->nerror;