From patchwork Sat Sep 16 00:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1835332 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=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RnXd96DQXz1yhP for ; Sat, 16 Sep 2023 10:54:21 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qhJZX-0002CU-QB; Sat, 16 Sep 2023 00:54:08 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qhJXC-0008OQ-TG for kernel-team@lists.ubuntu.com; Sat, 16 Sep 2023 00:51:45 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 883873F627 for ; Sat, 16 Sep 2023 00:51:42 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-1c456e605easo110485ad.2 for ; Fri, 15 Sep 2023 17:51:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694825501; x=1695430301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8SWFQeXPtLy3rx03e3Kh+QFZv4wXFQ7OgtyK20ozbks=; b=SJNpCVDp1GODmgMOIhL31oFwj5HL+HDvf8FGOP0jgZXxGwe9MJjFk4G7pdS6kCZBKD descFQDJtSU+Q73NWlcJnFNudLYN+9PVrdsgvWoovD8GLdghwdM1gU/VIyMKA2jilM6D b0Im476JoUZb5awL/tFj9LY0aCp5DppqWYgUr8pqRkjurLw+rt+DON4DqmoYbUzuCCPZ iR/pdIY0QHXx/5ro0n9bvk7OQ/VkJKIWEtrj+GS0LJ+AA61tQsY9Ga/eHb+oOzYt81He JsxzLfF+wB6XmB0PqesReJafjYzaOcopynowVN2bXm327VuHreeeP0jBg5Yuw03cVR9k 07Vg== X-Gm-Message-State: AOJu0YxvzQCimhuc8/lEGWabRNJy8Jj3g8xH45kylu+Pwto6Gn4G47vZ fiieQJlMVWMVvuyskK0vRcg4mOznrkLEvhipP2dSF6QVk/diEY+lMpN7uf7Lb1XijNh+gDsjuCY HucEADoxIbCKM2ljoYBxbFyFiU4EDvmVAR6+2OJiB2uAyLzJo1YOB X-Received: by 2002:a17:902:db0b:b0:1b9:de67:286f with SMTP id m11-20020a170902db0b00b001b9de67286fmr3940832plx.49.1694825500832; Fri, 15 Sep 2023 17:51:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOrHO7CcBvMP7iHQ/v0kZBbCCu67DkthqR05NTaiw9wh2Set//JKJi9XlDPsF6jYLvQSI8sA== X-Received: by 2002:a17:902:db0b:b0:1b9:de67:286f with SMTP id m11-20020a170902db0b00b001b9de67286fmr3940820plx.49.1694825500523; Fri, 15 Sep 2023 17:51:40 -0700 (PDT) Received: from localhost (uk.sesame.canonical.com. [185.125.190.60]) by smtp.gmail.com with ESMTPSA id q5-20020a17090311c500b001b9de39905asm4054472plh.59.2023.09.15.17.51.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:51:40 -0700 (PDT) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU Jammy, OEM-6.0, OEM-6.1, Lunar] netfilter: nf_tables: GC transaction race with abort path Date: Sat, 16 Sep 2023 03:48:36 +0300 Message-Id: <20230916004839.706452-27-cengiz.can@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230916004839.706452-1-cengiz.can@canonical.com> References: <20230916004839.706452-1-cengiz.can@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Pablo Neira Ayuso Abort path is missing a synchronization point with GC transactions. Add GC sequence number hence any GC transaction losing race will be discarded. Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Florian Westphal (cherry picked from commit 720344340fb9be2765bbaab7b292ece0a4570eae) CVE-2023-4244 [cengizcan: fixes the fix commit] Signed-off-by: Cengiz Can --- net/netfilter/nf_tables_api.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 13912f504776..10646308b06d 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -9886,8 +9886,12 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb, enum nfnl_abort_action action) { struct nftables_pernet *nft_net = nft_pernet(net); - int ret = __nf_tables_abort(net, action); + unsigned int gc_seq; + int ret; + gc_seq = nft_gc_seq_begin(nft_net); + ret = __nf_tables_abort(net, action); + nft_gc_seq_end(nft_net, gc_seq); mutex_unlock(&nft_net->commit_mutex); return ret;