From nobody Fri May 13 20:06:12 2022 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 F13BF1ADD26A; Fri, 13 May 2022 20:06:12 +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 4L0KQr6SFbz4vkv; Fri, 13 May 2022 20:06:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652472372; 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=p87QknIiMRFA97UuYS7kTu/2/C4MY1LXd7YuCwqc1ME=; b=rV0i4gTYUeidRl5YlJ4aiJzEr0ztQFrEqyaZQlf31EVWipoUKGOKW3a3fYEcBh0fpT5Ncv TxmFVZr20uSCee4YvvNY6PgrUUlfM2ITATluRWo/POVnibAkBCqqGAY2nQwq08pZeGq65x +ewhuvdzgwkOjjRa7rxUY3cchlwrV9UtUA+eRAyghLV1ZuzL2vUGGHIa6kxwqddJDjZXUE No3ynmqOncwaa6ORz8Lrc/8HireJl/EggQVjdENc1cNtKi+5G3qKQZZt3kcmnzUj0lQf72 epgLh7kow2P2TTFDOch/2vZAda/X2g3Y90F3CO837AohK1jNOyvFutxBhiSeIg== 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 BD9C6FF9; Fri, 13 May 2022 20:06:12 +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 24DK6Cja048999; Fri, 13 May 2022 20:06:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24DK6C8X048998; Fri, 13 May 2022 20:06:12 GMT (envelope-from git) Date: Fri, 13 May 2022 20:06:12 GMT Message-Id: <202205132006.24DK6C8X048998@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 9573cc35555e - main - rtsock: fix a stack overflow 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9573cc35555eb0da35da5712462de9f6107fb974 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652472372; 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=p87QknIiMRFA97UuYS7kTu/2/C4MY1LXd7YuCwqc1ME=; b=HjvT8j/Zo3E159HPP04tSjs/qpBYJyzn6aUh8qeZxetVlDNrugPsuWh78A71gcOiwHpGOC J8cwFaQaAVzsv0XZBncMKCH66KQG6qKqlo1Rp07rReMQJU5zBE2bDXIV0TCWJxUsuAB6QO oP3CfyOvraqa/uvdLNwoP9ZjHfOedm9cBUkfJTZsOwdH0sqz4x/PQLFRub4/14/eZAbusv S7Pq8VioyNe0NeBuMd/baM4gQs5/VflVO0YAqR3RczyRfVOAnGJ2Gz4xUEFMmKO/uRtn+T QIk2I0PFLIgR/UF/EdxC43xIxN9GvRSbYGm/kvYP5Jp9SLNzBHv23AUtslxcNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652472372; a=rsa-sha256; cv=none; b=gbwPZJVVyeqcey6ev/UHJCHXOT19W0U2qmRs6TyIighOX6+4kO0ZLoBGxMt0KLnxy8CUGK FYIa2fFJ5P3E9tFMCjw7NVnjNTjbeFrGelvy9m5viXLWifBXQbsSS9pj48iObKlM11Oq85 gVwwtRFz8DY+14tjuhYrVuFoGPMBEpa31qz1ylR3m9FR4r05fBgP9BnNLu+Lec4KC5s+/k eKW7RFEY+6ULlD8e9oUsFrcZeFIYNseAOnIjazW/K97No8SDKIQha+i688yW6B4pAsxfhk wNbTycA1rsiMNLgOvEJiRnz9+SGUuPtIkXN2kddJisGg50GVkKFYhdg87Uq2qQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9573cc35555eb0da35da5712462de9f6107fb974 commit 9573cc35555eb0da35da5712462de9f6107fb974 Author: Kurosawa Takahiro AuthorDate: 2022-05-13 17:58:11 +0000 Commit: Kristof Provost CommitDate: 2022-05-13 18:05:36 +0000 rtsock: fix a stack overflow struct sockaddr is not sufficient for buffer that can hold any sockaddr_* structure. struct sockaddr_storage should be used. Test: ifconfig epair create ifconfig epair0a inet6 add 2001:db8::1 up ndp -s 2001:db8::2 02:86:98:2e:96:0b proxy # this triggers kernel stack overflow Reviewed by: markj, kp Differential Revision: https://reviews.freebsd.org/D35188 --- sys/net/rtsock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index bc35255315b2..bbdd0279a04c 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -786,7 +786,7 @@ handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, * TODO: move this logic to userland. */ if (rtm->rtm_flags & RTF_ANNOUNCE) { - struct sockaddr laddr; + struct sockaddr_storage laddr; if (nh->nh_ifp != NULL && nh->nh_ifp->if_type == IFT_PROPVIRTUAL) { @@ -796,17 +796,17 @@ handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, RT_ALL_FIBS); if (ifa != NULL) rt_maskedcopy(ifa->ifa_addr, - &laddr, + (struct sockaddr *)&laddr, ifa->ifa_netmask); } else rt_maskedcopy(nh->nh_ifa->ifa_addr, - &laddr, + (struct sockaddr *)&laddr, nh->nh_ifa->ifa_netmask); /* * refactor rt and no lock operation necessary */ - rc->rc_rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, - &rnh->head); + rc->rc_rt = (struct rtentry *)rnh->rnh_matchaddr( + (struct sockaddr *)&laddr, &rnh->head); if (rc->rc_rt == NULL) { RIB_RUNLOCK(rnh); return (ESRCH);