From nobody Mon Feb 20 20:13:05 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 4PLDB95HWgz3s6Xl; Mon, 20 Feb 2023 20:13:05 +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 4PLDB94nRtz3KdC; Mon, 20 Feb 2023 20:13:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676923985; 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=j+6lTaX3bXlzbFDOiRMlIooPQtHFDysDCJLHvPWQ/pE=; b=IbejJLRDmliNEu7IVnMAPbGa+DvOrl2TdX8sCUeuYyymKuwI3UabriyVWFwCvEzmRj1JGu EJDTnsOVujLnyKeo1PEPKaOXRrTCeI9WGpOaxgCRjnMg1A1JFIp3KnngLpXDAA1T7YPa3W 01dp7PZT9IhmzryjNmXl5Md6cVu6ioMi758j9TPwm3MG0p4QQrm9WNFVgj/o7uQBg0T0iq hC1ijKvglzSUkrF+9V7pAT6JXXwFaS/agAtnGvxjJ4sWpK1ODQdm40opcM+RWOlVrCzBPp RR1SGCytv/5anfnZpcODnGuHhMjYgG1kkqv5F0MBfXVzyDT1WLzkYl9oLvFy+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676923985; 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=j+6lTaX3bXlzbFDOiRMlIooPQtHFDysDCJLHvPWQ/pE=; b=heN0hlmr33F2eDkxx7xDCOw04s6D7UdgpIdU6QaqV29JRFavjAH5Cv//STqhcRF781QiYD Unj/3idAoRBNz00hQ35XDGqwEqwXRDYnkGInW2oCJisdeqmPnXwoRIUWVd4KZBUwSTB1mr w9Cw2tzoeoCJqbiKWuKdqOG4zAzeZMINiEkJ16lTJt0BbQmcbTtGc/P1O0K8Vay11glagT 4mPs1XG1S5geHK2BpUKjSsQEK7+L0cOvI8ZbmTTjx9pl1Kdlu9DKa7MeP2QdfFZyFo8yPm rcVZSO6R00nDiav3dia0s84vJ6OiIQseOzejV2t0X8NsRUaURUsD+ukNbHD9+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676923985; a=rsa-sha256; cv=none; b=NDHt3sEx7heB47MlB9WTlhL6Mft8ist+qkpdq9bHO8sFEiiOx0hrbF5c33pl8kO3ZHqYCv WSGKj9CGTgut/epKIyrSf5WBBeI59PBHERmozUNczOWO87TWXzA0bwyA5dzffoA9sde5/O IYo6cDP2suKMIBZBK7BSbrNxSz+JdMeChPd9UNe2Sk3lXrfqnGZ5qfrfllQYIgJmnyN1BC KIbsgiwNIAcj+YtKi0ZXXzy1G5dEhb0DyJnhWferpuBTS5yDkATxEWiz3hTRO5AbFP14G0 CzTQib/Ue6JDKHISN4rRNpr6wfz6N8m305od/2JgFmxbOB59ROMxaQ/JYvWrSw== 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 4PLDB93qVbzv4y; Mon, 20 Feb 2023 20:13:05 +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 31KKD5lw094050; Mon, 20 Feb 2023 20:13:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31KKD5UZ094049; Mon, 20 Feb 2023 20:13:05 GMT (envelope-from git) Date: Mon, 20 Feb 2023 20:13:05 GMT Message-Id: <202302202013.31KKD5UZ094049@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 2e847957c50c - releng/13.2 - netlink: Zero-initialize writer structures allocated on the stack 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: 2e847957c50c63ebecdd6825b9466e3d979fac9b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.2 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=2e847957c50c63ebecdd6825b9466e3d979fac9b commit 2e847957c50c63ebecdd6825b9466e3d979fac9b Author: Mark Johnston AuthorDate: 2023-01-26 15:46:19 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-02-20 19:48:12 +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 Approved by: re(cperciva) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38213 (cherry picked from commit 7a78ae88659e0f6a901574d17672d1ccdc3e971b) (cherry picked from commit 2de541757e0a2e25ce974b3c4c29bc8b753b8b6a) --- 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 48a6b0928cab..59b34c53ad4b 100644 --- a/sys/netlink/route/rt.c +++ b/sys/netlink/route/rt.c @@ -341,9 +341,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), @@ -926,10 +926,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 */