From nobody Wed Nov 01 09:06:06 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 4SL1ML6dP0z503jB; Wed, 1 Nov 2023 09:06:06 +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 4SL1ML60spz3KJq; Wed, 1 Nov 2023 09:06:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698829566; 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=rdBzidDBTWXTQn2EdlT99dyBYeroRu+F49L0ZTutjxA=; b=y4q1yboUIJShX9AEET/GQuK/381rqFyCVICW4zWSubh/0fErH2wuiZE7dPssZEqoW7fRHo uEhe8d4MNcnxeg64/PyW+HZuecLbf2zuDAlkVzvRTnjPMr3MoGQMxDJVM9lmxM9E9Nk8Zc r+DgnwUOjdqmhPNIYdjKZDE/xwr24Rgx8r8oEaRSf7qmKq9o/0ZoQq9qRAnIPoofqmmS9P ZrY6B/tHrJAGoICpVELrxvedZq8CG4iCZ+Z4JI7GIjmKVGP/HtBVrWb102duZqSFBLkQ1X xfTUqn654hP6L37o8Sj6+A1JFCkNYaWRBuV/DqBu1dlZ07unHaUo9hbiiWKJkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698829566; 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=rdBzidDBTWXTQn2EdlT99dyBYeroRu+F49L0ZTutjxA=; b=HgphoUsPaSH4DmQ2zNgaBOKNKgEkvq89hGMtE463xDL7oHZO7DeGFPjaeG9akjRRIbgNp8 QiEdpXhBkJtDptexSWkExlT7QsoXrQafxn8v5bKtEwNwskLeQj3USorrXOKtr2ihnAfReh zOMTdxSqGaNmfSu8nuFd6mhnPGudMx+4AI8wI9EXhO9NpoaAAyVnJriOjhq9jg2VBqyTWk LAvA7GMkTn3xmBBN3VFPOXl81p+WjdUMoWowO2DH5VseoBYs1w8feuJLDgFNQ/X0eQVImV JZe1ANxMx4h+CHHUDGAHjbfe3ntC9M5Ja2H3MIFAl/42fMz0yYR5tEDWbhi6mw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698829566; a=rsa-sha256; cv=none; b=kQgP1wNR9auSBcdCu7lMqGtyg0QL+9zRzMk/LqRN77Ad1ezTn8jheF0GNtk0GG8QSNAnJJ 0NEETnr57G7pXI+7n1TcYF6voEtJHnFC6szqgqZNq4R3XXEWSC+SPlFIN9zvCkOSa6JexC Nll8G6wSJrSauSGRoJimBcvfVRWKrhSjZgW6NZYVXJW/VpaohIG8va+C1U7zTH5ut8zCN2 m8avnO6f1/innZ3Z42ccnJV9Rmms3/55CVNmUq/mTFbJwhDkcrCNaHpaazW9KU59SDfsBe n6Rn1SylGsZLk+v8xqaiIE0cPd7QOFPlKnlbsi9bI8lPzWZ7RrZFkQ7jjCGlgg== 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 4SL1ML4kBDzfvM; Wed, 1 Nov 2023 09:06:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3A1966Lv065080; Wed, 1 Nov 2023 09:06:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A1966wN065077; Wed, 1 Nov 2023 09:06:06 GMT (envelope-from git) Date: Wed, 1 Nov 2023 09:06:06 GMT Message-Id: <202311010906.3A1966wN065077@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 9f5ab6bddfc0 - stable/14 - libpfctl: fix pfctl_do_ioctl() 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9f5ab6bddfc0974b385f2a198878f739424fd040 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9f5ab6bddfc0974b385f2a198878f739424fd040 commit 9f5ab6bddfc0974b385f2a198878f739424fd040 Author: Kristof Provost AuthorDate: 2023-10-23 11:43:52 +0000 Commit: Kristof Provost CommitDate: 2023-11-01 09:05:49 +0000 libpfctl: fix pfctl_do_ioctl() pfctl_do_ioctl() copies the packed request data into the request buffer and then frees it. However, it's possible for the buffer to be too small for the reply, causing us to allocate a new buffer. We then copied from the freed request, and freed it again. Do not free the request buffer until we're all the way done. PR: 274614 Reviewed by: emaste MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42329 (cherry picked from commit 2cffb52514b070e716e700c7f58fdb8cd9b05335) --- lib/libpfctl/libpfctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 1eccf3dfbcdf..d5347a7f8a84 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -72,7 +72,6 @@ pfctl_do_ioctl(int dev, uint cmd, size_t size, nvlist_t **nvl) retry: nv.data = malloc(size); memcpy(nv.data, data, nvlen); - free(data); nv.len = nvlen; nv.size = size; @@ -90,13 +89,15 @@ retry: if (ret == 0) { *nvl = nvlist_unpack(nv.data, nv.len, 0); if (*nvl == NULL) { - free(nv.data); - return (EIO); + ret = EIO; + goto out; } } else { ret = errno; } +out: + free(data); free(nv.data); return (ret);