From nobody Thu Jan 26 15:46:45 2023 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 4P2lSP5sC6z3c8dS; Thu, 26 Jan 2023 15:46: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 4P2lSP5RDbz3jqJ; Thu, 26 Jan 2023 15:46:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674748005; 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=zVu7MmbvGBoESr9QpMjj9Xm8MtkGUARUvsf9hfxzSsk=; b=qnr3AgECSRNvXEYQCeW7zZPHImP7GL8IkmDlFUW2BMhKUAoBk1rkUBQV2s2n/tJqmJgEBt Mzj15ToZIuXYHCLksR8Jy6xhO8/xcSYHjScHJD1Pa/pDySEqpWgImqwVMQcFHAeKcmXRG7 x6xH+01Cr4x2XrqFUrwBaGJXXhAT2lVqVkwlT4H8hOfhl6a0XXeZ9wQc+3rWyZVrfNtPhD 6s3K9RABxZk5l1SxHOYFwbWQrbK5KRRLwNLhbfpj+BQlPKXp7eDoCrJCo0DDd8HyvoFYXW 3xxTNLAsmHiiG+1tWDp5vWRb1EqgbXUHTQBYbVPbIY4bbqF4G1VZFpnnmdrMaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674748005; 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=zVu7MmbvGBoESr9QpMjj9Xm8MtkGUARUvsf9hfxzSsk=; b=hBakFiM+FvVU5skLhpl7fjFzqTo/1E4HYL1cXyD0k1B0vuzK96jTkSDqFj6SC4KocogVOQ Yj5rQcNax14wiwDtspVNZ/vNlbyOLqGVo0p7oO4vn5eZx+pdDRgor6WDK13uJNbaLH1Wyj FhF6vwc9Sh7c5jejVuBEPyM66rW4DpyhEiawt9Jj3nI6+mWh+x1xJ9wRamBWy6qLOkgazG sm2tgij+kDr0KlRzIIlFWt8xSopbfofp/QpUcxrhh5vUAlwQ72/OGl7RjeYtJuezCfPFpG SiwRuWjr0I+Wl0AVfc59GcjMLzLvDT6OtWXQN5zOxnBk6Dv12nN+UEu9vFTaOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674748005; a=rsa-sha256; cv=none; b=j6aySLqLz2hYv7pBfShFnnSlZbysgdOaV+Y7dQxOt5js4y+lZV2TUx06rGChEEtAmquw3F vKmqoOXj+NjjC/2LH9fkVAYnReQq3QySZSzl4guwa7e1HEfkzLPLGtK9tdbUWVJXbb0IFV m3ZFcigvG5aqyV9C3TTXaV2GaC4A6MmQaAp7VNyfSSQvFvbr5kDh25f0NTGZJn2gPTly88 Eirsu8FAx+VU57iUjG4qh1ZWDBBNtYoEnv4D+63izg13r01sozFnG6U6EKjNmtB+y7RlWb 24Iouy0KnPZGsPoz3700qADlECH3nJwQ/RjQcCx52wfmIbEDJ4kGbfgN5Xal2Q== 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 4P2lSP4MJQzZwm; Thu, 26 Jan 2023 15:46: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 30QFkjDr062604; Thu, 26 Jan 2023 15:46:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QFkjhl062603; Thu, 26 Jan 2023 15:46:45 GMT (envelope-from git) Date: Thu, 26 Jan 2023 15:46:45 GMT Message-Id: <202301261546.30QFkjhl062603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7a78ae88659e - main - netlink: Zero-initialize writer structures allocated on the stack 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7a78ae88659e0f6a901574d17672d1ccdc3e971b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7a78ae88659e0f6a901574d17672d1ccdc3e971b commit 7a78ae88659e0f6a901574d17672d1ccdc3e971b Author: Mark Johnston AuthorDate: 2023-01-26 15:46:19 +0000 Commit: Mark Johnston CommitDate: 2023-01-26 15:46:19 +0000 netlink: Zero-initialize writer structures allocated on the stack The prevailing pattern seems to be to simply initialize all fields to zero. Without this, it's possible to trigger a branch on uninitialized memory, specifically, when testing nw->ignore_limit in nlmsg_refill_buffer(). Initialize the writer structure in a couple of functions where this is necessary. Reported by: KMSAN Reviewed by: melifaro Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38213 --- sys/netlink/route/rt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c index 07735cd9d5bc..9854785d0ee8 100644 --- a/sys/netlink/route/rt.c +++ b/sys/netlink/route/rt.c @@ -336,9 +336,9 @@ static void report_operation(uint32_t fibnum, struct rib_cmd_info *rc, struct nlpcb *nlp, struct nlmsghdr *hdr) { - struct nl_writer nw; - + struct nl_writer nw = {}; uint32_t group_id = family_to_group(rt_get_family(rc->rc_rt)); + if (nlmsg_get_group_writer(&nw, NLMSG_SMALL, NETLINK_ROUTE, group_id)) { struct route_nhop_data rnd = { .rnd_nhop = rc_get_nhop(rc), @@ -918,10 +918,9 @@ rtnl_handle_getroute(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate * void rtnl_handle_route_event(uint32_t fibnum, const struct rib_cmd_info *rc) { + struct nl_writer nw = {}; int family, nlm_flags = 0; - struct nl_writer nw; - family = rt_get_family(rc->rc_rt); /* XXX: check if there are active listeners first */