From nobody Tue Nov 22 19:12:14 2022 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 4NGv5W0k9Fz4hLmS; Tue, 22 Nov 2022 19:12:15 +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 4NGv5W03KWz3sym; Tue, 22 Nov 2022 19:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669144335; 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=IjYaFkn5XfD26uEsf+6LY/79jDYNUj33LL4cfznUe2g=; b=uPfI1eZ9wZB+inexiwMNu7FDDMY1x0cWlKzKDLvY3rGKsMqUBREq3TfNQruHjskAxcsuYw o/NkYx5d38NT4NVoTaJH6isj0+90xWGz6r1HuyZDoRnHN2//2cJfEQbOqMT3sy3To/K5uL UUox/uX6e856dYZmzcnA69jCgzJDfEzEflByuFy0POvaeZhgHG/4KT0rUdtoLaJqUuVW8O 00XOTbVAV8UxhcIvAH0o5AKlx8BH19YUl48SAvPJVVqgbnD/yiwsbrAjsUUBAsFwHLJbDt ENw/+xs5mNXkr1TorVibfaNT7jsCI5VhEGfaLoezLk3YAb2DGv7B3wEXtkT3kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669144335; 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=IjYaFkn5XfD26uEsf+6LY/79jDYNUj33LL4cfznUe2g=; b=XKf7TMHErYjnLyvq2zSPTM4RQNBywaiTeOnstKPAbLtHrU9UcMoIJt4hmgOhkERnlRL6G+ trWUBozRcvrnJKUQSjEgv+I82L1dcXmoNEh4czyRYRpD1oo93L6iiXWLqbo//v01CJpLwJ jcX9iGchi8qMIsjEQpdUXGboZK0Ba2DGXuJBnk+H5TtmbGcmAvdfqnRQrQC8o0kBwwBjmV KmY2jJ1G6pFdVSqi9J/tlaQ75C0nL7j15qUazEErhcRoxYeNkq61XG8Jbjct4WcZhxmtYs dQgvkXyg19xGAFFLRjJ/AQ/s9858LdgSOBjN6vEIR1zxDE58U5UYQj0YYrCuQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669144335; a=rsa-sha256; cv=none; b=rcO71Hgl1HUwiV8NVveU51ZGuAH3tvDL4gX/Ft7OR6JVohIWA3IUASMODMan2r9mKzTZbU P85wRGTdTbcU1eOWli5Tn9mnjydv4wJHacuJs2WbSkZyjWR/Pduesi76zhhCKf4BB5M4FJ WA3KTxRarOfhchCnR5aEwkm9IR4v+dYEoF0QHxmfa/EgOsRNGg6OCiaq8tqLwgC+p3//Sk c7LC4CD2gHDE51H2J70bnuyf4+sVPpNPtk3XXDgPlnrFWE1OwhNbSMRCyw8gfEMmIiQG8q 3VXYBtPfXVTNxI8XzI4gYQLK7jafprSizBXXrfw70oOBQECONV4hTKAugjdNUg== 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 4NGv5V6Dk3ztkJ; Tue, 22 Nov 2022 19:12:14 +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 2AMJCEQn081879; Tue, 22 Nov 2022 19:12:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AMJCEjF081878; Tue, 22 Nov 2022 19:12:14 GMT (envelope-from git) Date: Tue, 22 Nov 2022 19:12:14 GMT Message-Id: <202211221912.2AMJCEjF081878@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: f6fdf9214a65 - main - systat: Fix a bunch of use after frees in fetch_ifstat(). 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f6fdf9214a657351e78c68aac1888e674c0481f6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f6fdf9214a657351e78c68aac1888e674c0481f6 commit f6fdf9214a657351e78c68aac1888e674c0481f6 Author: John Baldwin AuthorDate: 2022-11-22 19:11:42 +0000 Commit: John Baldwin CommitDate: 2022-11-22 19:11:42 +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 --- 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 c97e586ae7a3..3ac230c77561 100644 --- a/usr.bin/systat/ifstat.c +++ b/usr.bin/systat/ifstat.c @@ -290,7 +290,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);