From nobody Wed Dec 01 14:05:01 2021 X-Original-To: dev-commits-src-all@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 2253C18BEE88; Wed, 1 Dec 2021 14:05:02 +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 4J417K5xcvz4dtL; Wed, 1 Dec 2021 14:05:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AC2E327F8; Wed, 1 Dec 2021 14:05:01 +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 1B1E51Sb072861; Wed, 1 Dec 2021 14:05:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1E51ck072860; Wed, 1 Dec 2021 14:05:01 GMT (envelope-from git) Date: Wed, 1 Dec 2021 14:05:01 GMT Message-Id: <202112011405.1B1E51ck072860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 13c196a41e26 - main - sctp: improve handling of assoc ids in socket options List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 13c196a41e2604e6f9a4484b997279b82173dc40 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638367501; 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=Z7dtGewV2jGVh7Amw8PVXAwuC6j/fVQL7dzJcLD2Ung=; b=gKvolpYxOx8sqPRR+FWxuiykhziTpUtunoO73FBLHtMUj35KCYvMVAMmFLcNPnmvcjXSVM 6MeuXw4lIY7T7HeJGF/EubY4HsGRgeE1/B3wJSlwsFCs0c3XEn2HfMJqnGo3x9PntSAVHu WknmAOqdGrg1EtOWoZqTsXFrmW72Vo7m877p516Ke+Y0blVycUaMzTksoVql8WC333N/u6 FVfqVgwGU0hr8JYDyws90PN4v8cEuuHxz0J4+YQe2zxkTvPaRk8GWrAkRpdfl3XmGrhXGT 24nVFcgf5CJCbDGhDyKC7enhJbMv0EMkRvqDiipFLe+bzkacRX7yf7BADGTMMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638367501; a=rsa-sha256; cv=none; b=HiQGfD3UgYEo2JD6hENQRiCJ9ArUJH8kWwfwv595x/B44HU1iWW6XOuk8DL7NK+Uq8HSpI yHOuAmmaxXQxdv0PZdkI0aE6hc5Ym5JkkvT1t4bdfZK92hjhNFfoPo7X2+F7hKFAlp7WDc znbhqgabtdhqnoeAHph3xCcmeVwN8b2DUNwS6ORKPo8NYCxNzVU+LPG4wKTPMX/BFNgkXd hDUh//9eG9QXZdfEAT9v96zf3GZufqfLDtDI3DUYdmpTgr/abenaq8VQWzUFhj62REM16v D+OeHcShVvAdn+qcAJRpM4ooUj0TuABO7hBsk/KL0C54y7w4dBn9a/ge+tnb/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=13c196a41e2604e6f9a4484b997279b82173dc40 commit 13c196a41e2604e6f9a4484b997279b82173dc40 Author: Michael Tuexen AuthorDate: 2021-12-01 13:54:55 +0000 Commit: Michael Tuexen CommitDate: 2021-12-01 13:54:55 +0000 sctp: improve handling of assoc ids in socket options For socket options related to local and remote addresses providing generic association ids does not make sense. Report EINVAL in this case. MFC after: 1 week --- sys/netinet/sctp_usrreq.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index dae35c566d4e..c5c45a2f2072 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -2187,8 +2187,13 @@ flags_out: *value = (uint32_t)size; *optsize = sizeof(uint32_t); } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN); - error = ENOTCONN; + if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && + ((sctp_assoc_t)*value <= SCTP_ALL_ASSOC)) { + error = EINVAL; + } else { + error = ENOENT; + } + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); } break; } @@ -2262,8 +2267,13 @@ flags_out: } SCTP_TCB_UNLOCK(stcb); } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); - error = ENOENT; + if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && + (saddr->sget_assoc_id <= SCTP_ALL_ASSOC)) { + error = EINVAL; + } else { + error = ENOENT; + } + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error); } break; } @@ -2275,12 +2285,18 @@ flags_out: SCTP_CHECK_AND_CAST(saddr, optval, struct sctp_getaddresses, *optsize); SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id); - limit = *optsize - offsetof(struct sctp_getaddresses, addr); - actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa); + if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) && + ((saddr->sget_assoc_id == SCTP_CURRENT_ASSOC) || + (saddr->sget_assoc_id == SCTP_ALL_ASSOC))) { + error = EINVAL; + } else { + limit = *optsize - offsetof(struct sctp_getaddresses, addr); + actual = sctp_fill_up_addresses(inp, stcb, limit, &saddr->addr[0].sa); + *optsize = offsetof(struct sctp_getaddresses, addr) + actual; + } if (stcb != NULL) { SCTP_TCB_UNLOCK(stcb); } - *optsize = offsetof(struct sctp_getaddresses, addr) + actual; break; } case SCTP_PEER_ADDR_PARAMS: