git: 4682ac697ce9 - main - unix: turn check in unp_externalize() into assertion
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 May 2022 20:30:09 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=4682ac697ce9b306d11e03a628d1ac07f4b540c8 commit 4682ac697ce9b306d11e03a628d1ac07f4b540c8 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2022-05-25 20:29:20 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2022-05-25 20:29:20 +0000 unix: turn check in unp_externalize() into assertion In this function we always work with mbufs that we previously created ourselves in unp_internalize(). They must be valid. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35319 --- sys/kern/uipc_usrreq.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index cf9e04034760..c9e40c664042 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -2015,10 +2015,8 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp, int flags) if (controlp != NULL) /* controlp == NULL => free control messages */ *controlp = NULL; while (cm != NULL) { - if (sizeof(*cm) > clen || cm->cmsg_len > clen) { - error = EINVAL; - break; - } + MPASS(clen >= sizeof(*cm) && clen <= cm->cmsg_len); + data = CMSG_DATA(cm); datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data; if (cm->cmsg_level == SOL_SOCKET