From nobody Thu Sep 21 11:10:10 2023 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 4Rrt3Q4kHVz4tyT8; Thu, 21 Sep 2023 11:10: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 4Rrt3Q4Dfdz3CnW; Thu, 21 Sep 2023 11:10:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695294610; 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=LiW7W178zncc5X7SdwfI6tVZHXbeYJbOyUwt43Wkvfs=; b=I8nWYWe3co6zxInX9N1sLJNFKwU498g81d0oyfarnqvR/BdlU8OfkLlVB7nxvW+ECEMLpJ r3lgL/aamzuhGrhkDfK/4G9Jg4LM/pyPU+z1HhtqdYUZo+PsavfO3ernjbEMogEXsQuyz2 EPoUdS/7z0ZBQl+PyXLlgiVmexZs+5Lx1bBhPZbj2QnrT5J3bc9iMZJSQ+kRy46mYuPybP kHQaXxcHOpX1O/KJm9gNYPH1gjSk/rGgY2qVAxVFTXY5HL+ietea+Pz5+jUKtk+FVsnHgN gKfBzVinMj/62vzYckyQbK6AMGrIZpOkwVO/NSNxFyaZzib1/gUo2tkucWqbvg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695294610; a=rsa-sha256; cv=none; b=tdZPyBKRtQXbbkEHc0pyx3ss4GZaIlKo5B92LLbelra42p6wLuFvPhaHC6hqzxHKPRKn2K G+3E4oauy5dYVlF37+9V/Wpmrzwx+wnK9sSz42yPlQei0kpjW9LXFVSuiWVvG6pDND7/Oh +sLQi6SSi/JWtCmz+23BM6cbY4H530XKM8oR9Fg8c8l4GBx7P7mqIRr4gY7GXQ6axTJvVX wrrCrxiB+qfh6fWL35RETMfHQ9m5FIwH5xThDw9SxTx1zZBuSTJETJQOdw4jXBLxC45MZg t3x9J6TJlmwCqfvfr9pOTmZyP8PHPVT4e3gjliDCLL2hQISoTgEt0nfF1EzlqA== 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=1695294610; 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=LiW7W178zncc5X7SdwfI6tVZHXbeYJbOyUwt43Wkvfs=; b=mq8FTg6j708imt8vfvtN9EGtTuVdrdqhyLwspAMQpdbBoqcHsn0JiwG5sOAVnenYe1Ajdm QgpkHnSfiWSsBBoDc3shXXWTdDTBECMWsqCNP0tjNt5tnqNrfCnVpYAVaGY511eTdNEvBz nRypShylJ2dBc3piJi9Jn1HnnyVWfTVgVolKnKXEaVd0zPEepQM8ogVIUGFFTtCAUsejfS 7i/TmHWg/vPdrrbFtoXJYhGsEQsrZssWZviEXu3z04tnxdD3bPUCr5FiDRCwGPQP3xb6CS E8sezNyyJXoDL0hk1XoVXu2dhziwPuTMKopaXCPSEbbtgW0seBUt6SS6lxMdGA== 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 4Rrt3Q3HC0zbWN; Thu, 21 Sep 2023 11:10:10 +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 38LBAAqa063307; Thu, 21 Sep 2023 11:10:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38LBAAbQ063299; Thu, 21 Sep 2023 11:10:10 GMT (envelope-from git) Date: Thu, 21 Sep 2023 11:10:10 GMT Message-Id: <202309211110.38LBAAbQ063299@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: 100bed131d76 - stable/14 - ndp: cope with unresolved neighbours 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 100bed131d76893e9fc03f7a81dca3b83b030359 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=100bed131d76893e9fc03f7a81dca3b83b030359 commit 100bed131d76893e9fc03f7a81dca3b83b030359 Author: Kristof Provost AuthorDate: 2023-09-18 17:01:17 +0000 Commit: Kristof Provost CommitDate: 2023-09-21 11:09:57 +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 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) --- 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)