From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2D124779A8; Tue, 16 Jun 2026 17:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781631687; cv=none; b=jnyJEFGqsQkYaMwpRPvqhGy2eQtCkObUxxexdubMX7ZzF4jtRHxpamnZYGENPdcsSq4Zyy4M4wqEwO/AL1XzNTEEo5NqY/dYMUB0cbAriXRBdvuL4DrxMz1/JBiJbDz0Setam8Y5EVseHie3EmqHWlZGpp4cq6i1Z3kp7ZwfGS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781631687; c=relaxed/simple; bh=jmCeg+0KEPpuFZhTmfTR7u0+JIKE04/cRma8uvBPDaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mqa/DcWLE7d4nD8EuxNjnYJNuRbZnZWbkmV5cN6+Kpbf+PzrUq4SDx6ptEtks95I4xPRsPMUQBM83KRiWnXaP9JhlB8H1Qlhj5zc6U/H1rwS0/0Y/Rx084ngbVSRSsh+OSjgP4c2Jtyvyi4dLQuIag++t6tFrDtHzt5DqhCSHvw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2OUCFd4U; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2OUCFd4U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 581241F000E9; Tue, 16 Jun 2026 17:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781631684; bh=BrUR2LqRNl2uhFnAleP8Zc78BTjg5b5bBqsNzcuZNsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2OUCFd4U1hIBE3dm6PiCwwZieVQaqWo716mGsVm92qYsQnXJjh09HE22eo45mTiPD eLdgwmbMbGGxWOs2JfufMwaaf/G7+9EHOlX5+Bd4x40o2uN6pex6WoLWt7rgAdEfnm /AN+V1srRv8JKDy6/9PDsGUR3uIvtLEYXPbwE1k0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tristan Madani , Fernando Fernandez Mancera , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 6.1 267/522] netfilter: nft_tunnel: fix use-after-free on object destroy Date: Tue, 16 Jun 2026 20:26:54 +0530 Message-ID: <20260616145138.438563962@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tristan Madani commit c32b26aaa2f9216520a38b3f4bfeec846eb3eb8a upstream. nft_tunnel_obj_destroy() calls metadata_dst_free() which directly kfree()s the metadata_dst, ignoring the dst_entry refcount. Packets that took a reference via dst_hold() in nft_tunnel_obj_eval() and are still queued (e.g. in a netem qdisc) are left with a dangling pointer. When these packets are eventually dequeued, dst_release() operates on freed memory. Replace metadata_dst_free() with dst_release() so the metadata_dst is freed only after all references are dropped. The dst subsystem already handles metadata_dst cleanup in dst_destroy() when DST_METADATA is set. Fixes: af308b94a2a4 ("netfilter: nf_tables: add tunnel support") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani Reviewed-by: Fernando Fernandez Mancera Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nft_tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/netfilter/nft_tunnel.c +++ b/net/netfilter/nft_tunnel.c @@ -699,7 +699,7 @@ static void nft_tunnel_obj_destroy(const { struct nft_tunnel_obj *priv = nft_obj_data(obj); - metadata_dst_free(priv->md); + dst_release(&priv->md->dst); } static struct nft_object_type nft_tunnel_obj_type;