From nobody Wed Aug 31 04:25:45 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 4MHWLx6yX6z4b1rQ; Wed, 31 Aug 2022 04:25:45 +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 4MHWLx6KK8z3VLd; Wed, 31 Aug 2022 04:25:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661919945; 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=xB+mS4Ui1Pk2XufDTbzLOl6UCcrbVblRX69vepl2oi4=; b=xFeqq3Q1AKBiurCp+ExqVY6uiaN/EkcfKw8vtbA78MK34nU4Pqy6fde41jwpQrQkZCuOZq rOadIKNBguuzBhw7dPJ+GWx2MKoDQkkHFM1f023EaT8bsATUdq4YZRIku+YL38D8b3wjnR p/H63c6pZJaI9fKAuYY9qVQlFfffjWPXmTWg5ZvliiLiF6+fCBfmYQsIb+Uc/my+m74Vxa y+wuJvVNuseIRJ+Z+faSsFeqeYTkgrDO1mOQdf6fnz2ljh1DnYxQE8+VKwHbM7RUSbYxMv 9wIsoceokrgzUW0Rbj0oCN5dlcnt6SJnf1wjuQQ63uVV4PZKWhVfjhWtVOo17A== 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 4MHWLx5Kfwz11MF; Wed, 31 Aug 2022 04:25:45 +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 27V4PjPl045248; Wed, 31 Aug 2022 04:25:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27V4PjfB045247; Wed, 31 Aug 2022 04:25:45 GMT (envelope-from git) Date: Wed, 31 Aug 2022 04:25:45 GMT Message-Id: <202208310425.27V4PjfB045247@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: 24af7808fa12 - main - protosw: repair protocol selection logic in socket(2) 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: 24af7808fa1293f34beb6b7de38894326feeb74f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661919945; 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=xB+mS4Ui1Pk2XufDTbzLOl6UCcrbVblRX69vepl2oi4=; b=KU8u2Uw3VQPJ21ikySU5mk1yllWlJ2TWx1+wGnsfR832Ikg1dVxwvkReFHmOjgEAMeiAuA uv/XNzpitgUjCf1jM4mXPPbnwRp6gEBe/iimSsPvTBNwPIRYAe4rfNOCvRX3eoZHMmdeZQ ZnKpncXNbHn51ajmh1+XNc9+2/62/65NInNw9S+VlHXTCD3T2zr26WHB4jdxTvLDAw8U+p 0OfEtqDJd9HjwwHG7SVU9JTF9DFYCrrt2vuVWWPrTAms6EzV/ZjHV8ASQ1RGUqSAJwLIqu yKqnmkPW74EQctZT8qZcxJfaOBE/pXgLwkAW6oCdMIW0f0ykEkY4N7pOCZ+4Rg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661919945; a=rsa-sha256; cv=none; b=vw04SFXnlazoiF5ppH0DkbhkmmrMfxAh+bsxMZ3e+xK6h98r9sy5FjYdUbOd/y+AchsJce MdhpChXk7bGoPfXeKIpSWgd5p0wugAgS9McjSA5DOJ+NYZDRU1kRbpetG9pL0MlXfLrxII TMlWMjljcjnwFKyUjjYELPiEddgoQiMqZg0koFDXgP06GAU7Vlk8HbZVuOQyk9tFyNGElC xIct0B6JBOrVkX99Dk954Eqdn51S0gwEYrJ4moSdUa6kVq/5wHF+4odEA1qKMhtVs77K7B 5T88n1qQBiXoDQnOebSvF4hPh18Dv7aHA1VsppS6560PItcMNSsBZAYtHeiF2g== 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=24af7808fa1293f34beb6b7de38894326feeb74f commit 24af7808fa1293f34beb6b7de38894326feeb74f Author: Gleb Smirnoff AuthorDate: 2022-08-31 04:19:46 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-31 04:19:46 +0000 protosw: repair protocol selection logic in socket(2) Pointy hat to: glebius Fixes: 61f7427f02a307d28af674a12c45dd546e3898e4 --- sys/kern/uipc_domain.c | 6 ++++-- sys/kern/uipc_socket.c | 4 +--- sys/sys/protosw.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 832afca510fa..f1b2c616c662 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -290,7 +290,7 @@ pffinddomain(int family) } struct protosw * -pffindtype(int family, int type) +pffindproto(int family, int type, int proto) { struct domain *dp; struct protosw *pr; @@ -300,7 +300,9 @@ pffindtype(int family, int type) return (NULL); for (int i = 0; i < dp->dom_nprotosw; i++) - if ((pr = dp->dom_protosw[i]) != NULL && pr->pr_type == type) + if ((pr = dp->dom_protosw[i]) != NULL && pr->pr_type == type && + (pr->pr_protocol == 0 || proto == 0 || + pr->pr_protocol == proto)) return (pr); return (NULL); diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a93256cd7f63..360b7b56cee5 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -520,7 +520,7 @@ socreate(int dom, struct socket **aso, int type, int proto, td->td_proc->p_comm); } - prp = pffindtype(dom, type); + prp = pffindproto(dom, type, proto); if (prp == NULL) { /* No support for domain. */ if (pffinddomain(dom) == NULL) @@ -530,8 +530,6 @@ socreate(int dom, struct socket **aso, int type, int proto, return (EPROTOTYPE); return (EPROTONOSUPPORT); } - if (prp->pr_protocol != 0 && proto != 0 && prp->pr_protocol != proto) - return (EPROTONOSUPPORT); MPASS(prp->pr_attach); diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index f05aff962420..3b89c6f78caf 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -236,7 +236,7 @@ char *prcorequests[] = { #ifdef _KERNEL struct domain *pffinddomain(int family); -struct protosw *pffindtype(int family, int type); +struct protosw *pffindproto(int family, int type, int proto); int protosw_register(struct domain *, struct protosw *); int protosw_unregister(struct protosw *);