From nobody Wed May 25 20:30:09 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8647B1B4C416; Wed, 25 May 2022 20:30:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L7jNy0nm9z3j88; Wed, 25 May 2022 20:30:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653510610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9tgFJnUqrM5gp0RknsLOnP3iL3yxaJ/D5dGKNld3pYw=; b=lx9bXd741r0417cuCGphb+ONRz5aDGO0dTGuyVTk5/rPx2k5jw8VigxL+bEE78f+VaEV2B XKlyuRxygu20rWe/8KE3129DAX2OM+NB9IT+mMDZAni0DtNeHI8m4TZwQnhtUT6lX7RRzR vvWeYyRo5HHX6b0nmA3gSYoaNV6RdtsoucBlc6j0r8nJhqzrEY852OcwcYxMxpeYdIWw+m IjYnkJ/ggojjejsbTyyh3PJj5PdXf4rWfeiWE8qI5+QsjHzqPFM8XBzP6SKWzEv9EoxN7p sBXrw7Y4kkpCXTMVJKwdaKLIbiuJbnvLLCS3Y4wQwhIOZWrMYuGG7777+Vpy0g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2449200BE; Wed, 25 May 2022 20:30:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24PKU9Di040773; Wed, 25 May 2022 20:30:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24PKU9qF040770; Wed, 25 May 2022 20:30:09 GMT (envelope-from git) Date: Wed, 25 May 2022 20:30:09 GMT Message-Id: <202205252030.24PKU9qF040770@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 4682ac697ce9 - main - unix: turn check in unp_externalize() into assertion List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4682ac697ce9b306d11e03a628d1ac07f4b540c8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653510610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9tgFJnUqrM5gp0RknsLOnP3iL3yxaJ/D5dGKNld3pYw=; b=sV9MPRWSpbrpTEHjkPbxawrYFKBygnuelUeC1bxGnau0R5z/N2TqKy9Ui5VS4h5omvhQs2 SMaTlBdqLOlSGnEosolUxT7/c4ydG6dSZc7Oyb6fRIaQRJ9ygwcDJ0DeUTqs1wqyfLRr50 9DjrNxI+wjw+NB3pd+nm5rJjLP9JWOMsCheVHIQS14z4ohlYR62xsu1dJuGe5qBOtc02BN ylx1KZcjYOa7kBArfc5jZULX5CDKtkY7rBQTvUSsSQE7gIE+3NQe7XiVGpq8j/Se2Ih6Ld KzkkqGV6sPL9KXHLwslXMkqaNdz6+EOcloMcanr/xuNL33eau2YbZxaC8+ZMvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653510610; a=rsa-sha256; cv=none; b=r0qBZuTjqauE4cOjdAN7+XzjehxP/P65rqhSU6pj/HT9bLFCnyMpdX/3gJ6UoQWZKdeOcY YDMX0WrDbtn6GMYknRaqy4PwxpJhsBI4/U2H5W7e5l7U4gUIyiKy8E1MsUxL1HMeCfuBi2 HtcHHWucApzpgsLdxr5TQSIJt97hgC7C+WzKsA9X+AkAOjNjcKpCeUPvjaQ9r4GckTIM2z umjHsFQHjktwq4Fp2+jsg6QMnrgdSwg+XEzeC8bbFxekifEyOKd1gGflbr/+uxfnnQV2IM rigwjkFnUuuRqW5+XCr4Sl/C+XxYaArtG8V9fV7phVdYYKbw4Kz5zI1D4nLGog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=4682ac697ce9b306d11e03a628d1ac07f4b540c8 commit 4682ac697ce9b306d11e03a628d1ac07f4b540c8 Author: Gleb Smirnoff AuthorDate: 2022-05-25 20:29:20 +0000 Commit: Gleb Smirnoff 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