From nobody Wed Jun 28 01:33:09 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 4QrPGt17Wbz4kxlW; Wed, 28 Jun 2023 01:33: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 4QrPGs5ddjz3Ddp; Wed, 28 Jun 2023 01:33:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687915989; 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=AZstMLRQcKpjmlwblU9/HKBnEmgFqKuHrKDEUaecl9o=; b=bvKUQybzi+mFaE3xmswutrkEZ5Q0rLMLZiGlIs7fvHFYwaiLWASFhTV2ObJURA/dTdZ/sM AVcCAPznSAog9Xvmds84ZhkeR9R+oRl1hlHrQg1MBjtngoMNEKRsrhUOnBkpciOxfxPoEV 3quMLqRSJMuPznGZ4y5MXXE4tUNyNoy2nZrRRgQRmMACGK3yVEZVdyxNfUksqQ0+0nsjKO ASr8QlyDsQQ5LjpabxrNXsYpqzwiHUAXMVfGKyYMyx7cEUZ0NcyS+gRksKoYkeUmSrNjUB Xqcw31Swy2uddoC06iXzRWBizdLLPPgXOVFnwuwE31bXTyuwF5XZG6WlWcJ5GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687915989; 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=AZstMLRQcKpjmlwblU9/HKBnEmgFqKuHrKDEUaecl9o=; b=qJAQlTwLRu46fNWItwKh30V8HMGyknntPjqzjNv5qzVIDol635G7PY9ArE61VvaJ2CNfb7 0tVHHFDrLJPK0FPHgp8Xui2cZBSL4urMU+ahvlXm+UgO9DI5MCOBozG45JnPi318PGO3uu bEkGMaqdOWEenQy/79FPoINvk2yubBsJVgP/ICjkfLRvPdRAGA682KvJn4y6l+DfERW3nL vtLrszLHYEolQmEq/XEjkKqluJmdW3dJndjveXzELnrjCnC19acq1ab/Gly90edmRicdAy A8ILxPzkzvfG8m8YLARm5GTWoPry+XdfonIxzuZBrNHaSK09xD1pX/MjIjbUpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687915989; a=rsa-sha256; cv=none; b=HlNQJhC2St6xqjQSJE7QJ3fCKh9DwnVQzGn8n6+sjxlTU3+w7zOcI1I7EiTN9NennI1ol4 s8a4FZAl5Nd47P4tpOU700sFjW009+miOfBGRu11XRXrdRlBqBavA6U9xtsizPGXTT58Ad LGzKiSAN6+gMNVCbrMgcmajvvU7MSr2PlX0fOGqX72U0wQKJ5sBYrmpRdksBRZOf0VkvSL a6OVVoXYmO8YbHFrzCkDbfAjDf2CWVQmfWA9MrnpJVzt/gMn7Gh8yx397IfHx4nt67Liv7 1UBba5AYlXiLDAfBMuPPxS/DpVs9sQ6R3GHFhH3jiUQ0spFiaPEoCJAk77WB3A== 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 4QrPGs4lJJzG1b; Wed, 28 Jun 2023 01:33:09 +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 35S1X97L045115; Wed, 28 Jun 2023 01:33:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35S1X9OJ045114; Wed, 28 Jun 2023 01:33:09 GMT (envelope-from git) Date: Wed, 28 Jun 2023 01:33:09 GMT Message-Id: <202306280133.35S1X9OJ045114@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 5771c3bd1df8 - stable/13 - systat: Fix a bunch of use after frees in fetch_ifstat(). 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5771c3bd1df809113214abbbc3f42d8e05277b4a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5771c3bd1df809113214abbbc3f42d8e05277b4a commit 5771c3bd1df809113214abbbc3f42d8e05277b4a Author: John Baldwin AuthorDate: 2022-11-22 19:11:42 +0000 Commit: John Baldwin CommitDate: 2023-06-28 01:32:47 +0000 systat: Fix a bunch of use after frees in fetch_ifstat(). I think this was probably just a typo. initifstat() continues around a similar loop if the mib data fails to fetch, and fetch_ifstat() was already using a FOREACH_SAFE loop here so expected to keep going. Calling clearifstat() from the fetch routine also seems wrong, and the sort_interface_list() call triggered by the existing needsort = 1 will itself set needclear to trigger a future clearifstat(). Reported by: GCC 12 -Wuse-after-free Differential Revision: https://reviews.freebsd.org/D36823 (cherry picked from commit f6fdf9214a657351e78c68aac1888e674c0481f6) --- usr.bin/systat/ifstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c index 82e3429dbfda..d5e43cf1d0aa 100644 --- a/usr.bin/systat/ifstat.c +++ b/usr.bin/systat/ifstat.c @@ -299,7 +299,7 @@ fetchifstat(void) SLIST_REMOVE(&curlist, ifp, if_stat, link); free(ifp); needsort = 1; - clearifstat(); + continue; } else if (strcmp(ifp->dev_name, ifp->if_mib.ifmd_name) != 0 ) { /* a device was removed and another one was added */ format_device_name(ifp);