From nobody Thu Sep 21 12:00:29 2023 X-Original-To: dev-commits-src-branches@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 4Rrv9V21DYz4v2Gt; Thu, 21 Sep 2023 12:00:30 +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 4Rrv9V1X81z3HsF; Thu, 21 Sep 2023 12:00:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695297630; 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=4P2/a1sh87pyx/GroX6JXdm2Wq/tjSjS768GWAfOZl4=; b=lm3++EMc33dTopAQwXezYa6DbtKrIYFNp7vTM8COwD8o9zGxb3LOdE/6ybfSD3456f9OLF 8f4DAIaBSOGaD1sCrf+4Ml0KKsOmrCAMxDj8eEQnBpHtfqtNE1BqEGvU/578nrqugrLrma tn6PNktCODElLXzpUa2aHQTPMfNIhAd58E1qcYJ8bsB2pBMQBf7KVOn6pktDxFLakXTNby Hp4Grc+tQUVsTzaBTV+t4NmcU+VaMSS1dqwEzF9vFNjeLm41btNovr7+1OXk8e1nVoct4B 729894OVwL5HyHpNCO0XPUYuUGFY4l+frWot23umVRgqJ13TeQpKDCW1N/3V3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695297630; a=rsa-sha256; cv=none; b=sT0erKtioXQ+YDy6yvSgny7KL6NSLL2mHszYxvRL/WpMpEoxaHwzfIyp7pF5rx7mW378GY pl2ERY8hKe5xeL4q8l51SeRswEVkoBszXY+DvB83s8+9KpxDAlCkwGyXssk4PQ1W73R8i8 V1k1IFHzDcweFe/CMPMbg6pEBs/L4ScdOCP2Jx10DvzUiDKmJvz8bt7br/bt7VBg5ChYeD SGF8xjYpCch7xhZZohWwMuQYGjAae/CMXnnlDmY3/mGsyA2BDlwUAgbLn76to0XL8brm08 GjzZEFRuLzeoufUMfRdpHtbBAzcnCWZGVbhpMrJA7lAKMilxH0ZDMluoTnvLbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695297630; 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=4P2/a1sh87pyx/GroX6JXdm2Wq/tjSjS768GWAfOZl4=; b=ZqYUbmS6ANSUE/AivmJ7ozSmbYMh2KVt6nRcfKEokQmhbBrrZSh5IB7IIHukyUso588QbW DDZ/IKZj0nenvHtTp0AcFvXPPLfT7zx7XYIr+9N8/8rIYRCSoH5/ZiKZu11eLTzYJ5D5QE swW0X60PxvzIaJIN21OkMI0GH3HG40z66YJZS6cLsV5alqwEKX9+qAlpCCVAHST1eF6Bke jY0VBIrTTANQoEV/xH3IaVEawMLzsFGWEjc7P2gQENc7jF849V7aJ3gqjJC+G9NjoVsYMM g3kQtFiELLQl98/JSbRjm9gm4nN2F8upRR0qhzuz8QeH7NVNelgznq9mO1jySg== 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 4Rrv9V0Zj3zd3H; Thu, 21 Sep 2023 12:00:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38LC0T8s050927; Thu, 21 Sep 2023 12:00:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38LC0T2h050924; Thu, 21 Sep 2023 12:00:29 GMT (envelope-from git) Date: Thu, 21 Sep 2023 12:00:29 GMT Message-Id: <202309211200.38LC0T2h050924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: a9326cd7656b - releng/14.0 - ndp: cope with unresolved neighbours List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: a9326cd7656bdb84b3bbdcf12ed0e66aee19b450 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a9326cd7656bdb84b3bbdcf12ed0e66aee19b450 commit a9326cd7656bdb84b3bbdcf12ed0e66aee19b450 Author: Kristof Provost AuthorDate: 2023-09-18 17:01:17 +0000 Commit: Kristof Provost CommitDate: 2023-09-21 12:00:00 +0000 ndp: cope with unresolved neighbours If we've not (yet) resolved a neighbour nda_lladdr will be NULL, and NLA_DATA_LEN(neigh->nda_lladdr) will dereference a NULL pointer. Avoid that by checking nda_lladdr first, and only dereferencing if it's not NULL. Test case: ping6 -c 1 ndp -a Approved by: re (kib) Reviewed by: melifaro MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D41903 (cherry picked from commit b57df6fbcc484f1941bf306cb60a3adaf538df69) (cherry picked from commit 100bed131d76893e9fc03f7a81dca3b83b030359) --- usr.sbin/ndp/ndp_netlink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.sbin/ndp/ndp_netlink.c b/usr.sbin/ndp/ndp_netlink.c index ace3e5e5fa11..954d16995b5a 100644 --- a/usr.sbin/ndp/ndp_netlink.c +++ b/usr.sbin/ndp/ndp_netlink.c @@ -230,9 +230,12 @@ print_entry(struct snl_parsed_neigh *neigh, struct snl_parsed_link_simple *link) .sdl_family = AF_LINK, .sdl_type = link->ifi_type, .sdl_len = sizeof(struct sockaddr_dl), - .sdl_alen = NLA_DATA_LEN(neigh->nda_lladdr), }; - memcpy(sdl.sdl_data, NLA_DATA(neigh->nda_lladdr), sdl.sdl_alen); + + if (neigh->nda_lladdr) { + sdl.sdl_alen = NLA_DATA_LEN(neigh->nda_lladdr), + memcpy(sdl.sdl_data, NLA_DATA(neigh->nda_lladdr), sdl.sdl_alen); + } addrwidth = strlen(host_buf); if (addrwidth < W_ADDR)