From nobody Tue Jan 17 14:45:43 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 4NxBX758B9z2sTPL; Tue, 17 Jan 2023 14:45:43 +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 4NxBX74VW5z4CXt; Tue, 17 Jan 2023 14:45:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673966743; 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=BKcZR8Oghv+NYK0TqOKC6fNRQkzw9wzWjAUyR1bBlMY=; b=AT4IxeBlx0/R32/sdYvMvIjzuWgp1wyoInOVGsdSdnZFp4YzctN1TyM4NyCYzqrx/xMXzF G5oICNImwotLjhxhRMO8MMdyEfidgZnhBJNfiMo1CgdqPh7NpwDjR+SGOZEvaNXfc1MFu6 U/IFGE9CuCcUG51o+ho/5YvhaYGGYDmPieLqMoMjRIGQoWBmHW1ZEytbYEye/cu2oWf3gk VyubT6VeEBZo4U1ns15h0QEPhjnpcLv3gcRyaepDFqtkOioLaWTsmlGjDC/bguP4rYi1o5 zROyXCqWOWC0G/zUURIWxCyVjbCXGMVa4EdlJQhx6iCyDBsjq6CbLsBhN5pcnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673966743; 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=BKcZR8Oghv+NYK0TqOKC6fNRQkzw9wzWjAUyR1bBlMY=; b=Onhha0ACPhQz65v5t2PseqSejFoFgYJgnzVXLs7P9wArj7OFYb5ImqHkPdUhQBg32HoL/l BTyLkkNai7iQpnXoESHa5NA/tl/CtHREnXBZ3r8lViQNxdU4fLgJKTTvhZdB9UJP3ToMs5 FvEcHS1hYm2RVZ5rknT0GWAGQ5kNIqib2s0x7W8XjzC9+7STRDzV2rkat8aP+hptvY1ihQ xrWvlxwDL5zSyTpM0FCeGae3VrKGB9J/IKjdXR6KCBebhjrwXi79TX+GV2paR6YHzcJBbf HE44iyNu5EHzMLAKquaWW8Hymm6b2C+ejtl7ahanIFM600qXmHvaI2q4feeIYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673966743; a=rsa-sha256; cv=none; b=bgwxCc5lu2KsWTqVavH/Bh4NfgA9m3PkwYSCxBFsPZqoJNQpKwYqwLc0BEj3pzGmIgJaSC A/Q7EymLotgJmL1bVPdnxX2JNYuRTaKUm3lricsJEm/PJSTkDcqrHzPGCsFkQewz2MmyFi dtwV2jRZkkWI9clt547QxZUur34Hf0ILVC4aI1rIlbdTvlFwajzgtPs3zEvDKKc9BprYfw K2MqcSAGgRxy/3ys1HxT0CjNbWbH0kqQx1ELOpuOMq6fPSEpN3aS9Qfdw7apnyBAfC9sZg B3JhtU82pNcmAVStBDr9HY2EwimuLmWl3M3RRz3yUC7Il+p5i19d+T45mmLOeQ== 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 4NxBX73bgyzbPy; Tue, 17 Jan 2023 14:45:43 +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 30HEjhFH033641; Tue, 17 Jan 2023 14:45:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30HEjh8P033640; Tue, 17 Jan 2023 14:45:43 GMT (envelope-from git) Date: Tue, 17 Jan 2023 14:45:43 GMT Message-Id: <202301171445.30HEjh8P033640@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: d91be0f1211b - main - netlink: Zero-initialize mbuf messages 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: d91be0f1211b0196a0087cdfa237a6a0d2a43b65 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d91be0f1211b0196a0087cdfa237a6a0d2a43b65 commit d91be0f1211b0196a0087cdfa237a6a0d2a43b65 Author: Mark Johnston AuthorDate: 2023-01-17 14:36:54 +0000 Commit: Mark Johnston CommitDate: 2023-01-17 14:36:54 +0000 netlink: Zero-initialize mbuf messages Some users of nlmsg_reserve_object() and nlmsg_reserve_data() are not careful to fully initialize pad and reserved fields, allowing uninitialized bytes to leak to userspace. For example, dump_nhgrp() doesn't set nhm->resvd = 0. Meanwhile, nlmsg_get_ns_buf() and nlmsg_get_ns_lbuf() zero-initialize the buffer, so nlmsg_get_ns_mbuf() is inconsistent. Let's just make them all behave the same here. Reported by: KMSAN Reviewed by: melifaro Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38098 --- sys/netlink/netlink_message_writer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netlink/netlink_message_writer.c b/sys/netlink/netlink_message_writer.c index 37414703c6f6..6573394eb881 100644 --- a/sys/netlink/netlink_message_writer.c +++ b/sys/netlink/netlink_message_writer.c @@ -215,6 +215,7 @@ nlmsg_get_ns_mbuf(struct nl_writer *nw, int size, bool waitok) nw->malloc_flag = mflag; nw->num_messages = 0; nw->enomem = false; + memset(nw->data, 0, size); NL_LOG(LOG_DEBUG2, "alloc mbuf %p req_len %d alloc_len %d data_ptr %p", m, size, nw->alloc_len, nw->data); return (true);