From patchwork Tue Sep 3 12:19:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 1980008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=netfilter-devel+bounces-3646-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wyl6p10fHz1yZ9 for ; Tue, 3 Sep 2024 22:19:30 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 960B7284FEE for ; Tue, 3 Sep 2024 12:19:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 533611C984F; Tue, 3 Sep 2024 12:19:23 +0000 (UTC) X-Original-To: netfilter-devel@vger.kernel.org Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB6031B12F6 for ; Tue, 3 Sep 2024 12:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.188.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725365963; cv=none; b=kgix+iz57bTm29fBAF80KLKmkKoyWFrqDoMYaPS8EkC3suQSNPIlz9fBgculECR3lMDlHeCghDB8t/1EbHznVUKRJZvLvrb4YUEbbFfmz733X42YEhtoknD7qtv76cQ8MLEfs3OGYm/F0/85ruUVLMZnnGMHMjbM5/sg5FVhS8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725365963; c=relaxed/simple; bh=2p7rx6HJBgt+jUF/+pQs/s50zPYMRrt0jpGbPShRN44=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=AQgzR8CRjfcdGNjdOMzHLkbnKehvQgEj3mbHNRfxD3LIo6cFpuoqdebUi2xToUHJKBHzVrDSydkfuMDmD5Wja+gMgvaPa9qlFZEWFAF0TXsR+hQUOzjuqzwHqtPJLs+3tWiAOdEFUT1Eia6jLTKHYduNgu9wy8f+mOWevwlGrj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; arc=none smtp.client-ip=217.70.188.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH nft] libnftables: set variable array to NULL after release Date: Tue, 3 Sep 2024 14:19:10 +0200 Message-Id: <20240903121910.305004-1-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User reports that: 1. Call nft_ctx_clear_vars(); 2. Call nft_ctx_free(). because nft_ctx_clear_vars() is called from nft_ctx_free(). results in double free, set ctx->vars to NULL from nft_ctx_clear_vars(). Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1772 Fixes: 4e8dff2cb4da ("src: expose nft_ctx_clear_vars as API") Signed-off-by: Pablo Neira Ayuso --- src/libnftables.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libnftables.c b/src/libnftables.c index 7fc81515258d..2ae215013cb0 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -160,6 +160,7 @@ void nft_ctx_clear_vars(struct nft_ctx *ctx) } ctx->num_vars = 0; free(ctx->vars); + ctx->vars = NULL; } EXPORT_SYMBOL(nft_ctx_add_include_path);