From patchwork Thu Jan 4 23:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1882670 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 4T5jh41nf1z23dn for ; Fri, 5 Jan 2024 10:38:11 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rLXHn-0007li-SO; Thu, 04 Jan 2024 23:38:03 +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 1rLXHi-0007kX-PW for kernel-team@lists.ubuntu.com; Thu, 04 Jan 2024 23:37:58 +0000 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (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 CB75D3F18E for ; Thu, 4 Jan 2024 23:37:57 +0000 (UTC) Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6805f615543so15220926d6.1 for ; Thu, 04 Jan 2024 15:37:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704411476; x=1705016276; 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=Yff26zEPKiuHMGzzjC6IZnkdiQTINRWUs+Zk/eivVQI=; b=ji0LtbkSvN96LP5186u8VNBN7CYdQV0ei/s+yDNxcQk0JFmZK4RqqxGuDTq0WjnUFt RnuEClbKFQmaxMF4Rj4Wzu8sJ2g0yXpmqVOw9Si4rqcoN610hpfOFEc47ffseBpaKxI1 aUaNtDTJR6k3j8yZdJYiDLPVi67UeHKoLPckyvSqR3OlPWZCSjTpgfJavNN+Egvq6rZD Kt3TPDx4/7zOkzgctNyboVF6baWOIw9sdxiO3tTEXJKZtdkFVJcVm2OPP7BQMdYzpBUQ Mae4cw3jXC+8718L2QMAbF62gCcovPRPfqlxXDBHuVabP9UoIpbydL9BHtKfJ0WZgf0q WNcQ== X-Gm-Message-State: AOJu0Yxbr/TyKWeOATl4eOBRqRrbVU1tZNokYcBsgWjuo9b1kEtXI8oc g8wVMhGo2KqFrLIZ7F3cGXpiqHBsrrG/5ikjhcuvlcscYs5klkDU7cK1K+hZn+BDN+sv/d0nLCL 0wycbMOie1SRApJgxlt27Tg+0p74QOghhtAXmIaU4TVM9xjVUiCqbThFe X-Received: by 2002:a05:6214:5193:b0:680:857:1bc3 with SMTP id kl19-20020a056214519300b0068008571bc3mr1232016qvb.97.1704411476316; Thu, 04 Jan 2024 15:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRm4xf/oRl082IpGCEpZGFNblBqxYhXRJJxs/h9d/d1QUZ7GZ7EyOo1J2E3iH2XLqf3fjM9w== X-Received: by 2002:a05:6214:5193:b0:680:857:1bc3 with SMTP id kl19-20020a056214519300b0068008571bc3mr1232014qvb.97.1704411476106; Thu, 04 Jan 2024 15:37:56 -0800 (PST) Received: from cache-ubuntu.hsd1.nj.comcast.net ([2001:67c:1562:8007::aac:4795]) by smtp.gmail.com with ESMTPSA id c4-20020a0cd604000000b00680c81edc44sm173781qvj.38.2024.01.04.15.37.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 15:37:55 -0800 (PST) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [SRU][J/L/M][PATCH 1/1] netfilter: nf_tables: bail out on mismatching dynset and set expressions Date: Thu, 4 Jan 2024 18:37:52 -0500 Message-Id: <20240104233752.57535-2-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240104233752.57535-1-yuxuan.luo@canonical.com> References: <20240104233752.57535-1-yuxuan.luo@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 If dynset expressions provided by userspace is larger than the declared set expressions, then bail out. Fixes: 48b0ae046ee9 ("netfilter: nftables: netlink support for several set element expressions") Reported-by: Xingyuan Mo Signed-off-by: Pablo Neira Ayuso (cherry picked from commit 3701cd390fd731ee7ae8b8006246c8db82c72bea) CVE-2023-6622 Signed-off-by: Yuxuan Luo --- net/netfilter/nft_dynset.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c index 5c5cc01c73c5a..629a91a8c6141 100644 --- a/net/netfilter/nft_dynset.c +++ b/net/netfilter/nft_dynset.c @@ -279,10 +279,15 @@ static int nft_dynset_init(const struct nft_ctx *ctx, priv->expr_array[i] = dynset_expr; priv->num_exprs++; - if (set->num_exprs && - dynset_expr->ops != set->exprs[i]->ops) { - err = -EOPNOTSUPP; - goto err_expr_free; + if (set->num_exprs) { + if (i >= set->num_exprs) { + err = -EINVAL; + goto err_expr_free; + } + if (dynset_expr->ops != set->exprs[i]->ops) { + err = -EOPNOTSUPP; + goto err_expr_free; + } } i++; }