From nobody Sat Feb 18 11:55:48 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 4PJnFJ1yC0z3s7Kn; Sat, 18 Feb 2023 11:55:48 +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 4PJnFJ1XHYz3CM3; Sat, 18 Feb 2023 11:55:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676721348; 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=vZEGYSYnBNPGfW7BuqfJJ1KKRQkA5ol0H/bKiDoA8vE=; b=llac1s+ozrVPOvV7HGWlhL8NhYZft6U3Mmw5EjzdkuztOx6XIKtGlXucLPbmLb6k7iVq+E WXFqrmudd22LjwiDADZfbZvfCTLloap9Sl8MGq9DOiBXoDdZHCdwzxggZi8/VjiHxcxXgc 81RIZ1F/D2ojNy7QNVlQZ5Go997qodrTClpZBuAQxYCw19ma4x8nTqsPsLLVTrcX9Ctvl+ raoEJpADZtgxSCYyw+DZTwc4bieGjHkp+jJ02x1LzgfP65m/YevK4pabNSor07xunOSHA0 q9Y4ukoY32DHkSqLLASpdzw1eu2bmz9TYMrfyzMLT8NghK/wDfy9PUJp5ekatw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676721348; 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=vZEGYSYnBNPGfW7BuqfJJ1KKRQkA5ol0H/bKiDoA8vE=; b=QfEExzfwd/7U51CVb92gpUGJJJJtvOaofsLq6B0s1bUr3IK2Bc/qWAM7C1boDUi3nmbPh1 93TS/YySoqUXCBJewJXfMEslv+7fi+206Fj/qms8jAzlfzavwLnWNhyaNvnOriN5VPHQDM Bk8Md9aqKzJSnn+LnLhKfDhQIh1MUIndfAoyD9l2Ownin6J2mGZTnc93qFo+EbcuzP7BOk Udxbtj1aPQHDhmtwpKnnfNiRNN83tKrRboZ7C9wF1E42FP//7ncDKDLFroR9sNPG0KFZy5 OkBKudpnfoHrRI3DMZP5ss7HLDrJxOjKvMQGYDWBYm+bxUVKvEOJ0Ub5LkWLuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676721348; a=rsa-sha256; cv=none; b=QZMJTgtHbm2LYVrHH/PoJI1h4CqJHK/UChLfnpsew5jEiRuttPVSPdz8LhDI4xTgxmPjhL XjqwAY3IoTH7q/kvn6EzScY6meSPqllffgWhB7RrNTrEqIJtqJOl8RHf9ET3O5FO7VWE4t rKFaVgJx5rVE80Dyit8Bzk+BtEmhjkHzsF2GfnVSWaR/UTyctOknI6yY/Yh3aWdMfF9qQT +G3eLvN5EOxhsgyolNycJ84CJKPJjlT8SB2s7kG1x/u4HFT/hPvjqmFAH+p0Yq6hzPXfc0 QwqxaHEDz9qRFn7cqQ2VhIRizJvgYYxqeDGwhmrtJ9/xj2WczhkbN1Ovq78r6g== 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 4PJnFJ0cxbzMP6; Sat, 18 Feb 2023 11:55:48 +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 31IBtmNK069528; Sat, 18 Feb 2023 11:55:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31IBtmeQ069527; Sat, 18 Feb 2023 11:55:48 GMT (envelope-from git) Date: Sat, 18 Feb 2023 11:55:48 GMT Message-Id: <202302181155.31IBtmeQ069527@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: 13e997289240 - stable/13 - netlink: Zero-initialize mbuf messages 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: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 13e997289240c4697536f904167720a29abf7a58 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=13e997289240c4697536f904167720a29abf7a58 commit 13e997289240c4697536f904167720a29abf7a58 Author: Mark Johnston AuthorDate: 2023-01-17 14:36:54 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-02-18 11:53: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 (cherry picked from commit d91be0f1211b0196a0087cdfa237a6a0d2a43b65) --- 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);