git: bd8a789e3c28 - stable/13 - geom: Report copyout() errors in g_ctl_ioctl_ctl()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 02 Jan 2024 01:13:13 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bd8a789e3c28e4f2debf0c511c89fadbc29a34f9 commit bd8a789e3c28e4f2debf0c511c89fadbc29a34f9 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-12-26 01:43:06 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-01-02 01:12:45 +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 33ec28dcd371..bf029e749102 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -556,8 +556,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;