From patchwork Wed Sep 27 11:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magali Lemes X-Patchwork-Id: 1840176 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 4RwZHJ6Dchz1ypS for ; Wed, 27 Sep 2023 21:33:16 +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 1qlSmw-00072Q-Aa; Wed, 27 Sep 2023 11:33:06 +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 1qlSmq-00071I-3j for kernel-team@lists.ubuntu.com; Wed, 27 Sep 2023 11:33:00 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (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 C82F53F044 for ; Wed, 27 Sep 2023 11:32:59 +0000 (UTC) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1c61908b2caso77382615ad.0 for ; Wed, 27 Sep 2023 04:32:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695814378; x=1696419178; 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=zoVx35n05HhjegRrjS8ClObsKaw1qim/nUR1i1bI+xo=; b=jIVHv9ieCzTJFFxRQ6bf5YpTOboXTO7YMJwShYzgBHTx2OPh+qzf+0qP1sxdzMvYYm Yzm2gOQKbqy9xMA7yRpYVt8C9/n/tvmkeODl6DdZ8KK/hsRaGJs2aMb04lMNqiXjm2ET V4MqyHzPKFYysnP06yHdOW/5IDsvBsxDG6dWw/FQTZyNy6uFf+hzKmeb+muPnzrnOCNT zJ6LT6BqAx+ZNiXHNmV2K/ef1mbU2czYBGsc1D7rtw03j759fsDz7/oN1LhO1ZAGSeeo GkRhFAsyBmlZuMEzGwY+MNtZ0whRjp0ikvM5RFIKOa3MvvxrR0nrddg5WtFFWwkLuC/R TsLw== X-Gm-Message-State: AOJu0YzRbsbibm+vM8vUdBWqSalJn1C0u9lQyDeTVaDFzS4Vw0sKKy0D VMu3KV0MzuqNeJhVbIXnJeXau/f4iVKfOcv17d9VJ87SfM38dSyIaBSlVKnER6+D/9dsf0yja8o S3D/YbItuDXLAAVLac0RehUgExV099uY81laCvwlhBUQkyoD0Xcbh X-Received: by 2002:a17:903:185:b0:1c3:308b:ecb9 with SMTP id z5-20020a170903018500b001c3308becb9mr1605797plg.11.1695814378069; Wed, 27 Sep 2023 04:32:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEL6TalOG6I46cYG3A6fdz4FXvd11VuneYPXN32erLzyx39pT0H3AmhLdlHtbrcrKP+gSnl9A== X-Received: by 2002:a17:903:185:b0:1c3:308b:ecb9 with SMTP id z5-20020a170903018500b001c3308becb9mr1605775plg.11.1695814377692; Wed, 27 Sep 2023 04:32:57 -0700 (PDT) Received: from magali.. ([2804:7f0:b443:b14:14:e2c0:a734:24de]) by smtp.gmail.com with ESMTPSA id n12-20020a170902d2cc00b001c474d6a408sm12830889plc.201.2023.09.27.04.32.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 04:32:57 -0700 (PDT) From: Magali Lemes To: kernel-team@lists.ubuntu.com Subject: [SRU][F/J/L][PATCH 1/1] netfilter: ipset: add the missing IP_SET_HASH_WITH_NET0 macro for ip_set_hash_netportnet.c Date: Wed, 27 Sep 2023 08:32:53 -0300 Message-Id: <20230927113253.15134-2-magali.lemes@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927113253.15134-1-magali.lemes@canonical.com> References: <20230927113253.15134-1-magali.lemes@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: Kyle Zeng The missing IP_SET_HASH_WITH_NET0 macro in ip_set_hash_netportnet can lead to the use of wrong `CIDR_POS(c)` for calculating array offsets, which can lead to integer underflow. As a result, it leads to slab out-of-bound access. This patch adds back the IP_SET_HASH_WITH_NET0 macro to ip_set_hash_netportnet to address the issue. Fixes: 886503f34d63 ("netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net") Suggested-by: Jozsef Kadlecsik Signed-off-by: Kyle Zeng Acked-by: Jozsef Kadlecsik Signed-off-by: Florian Westphal (cherry picked from commit 050d91c03b28ca479df13dfb02bcd2c60dd6a878) CVE-2023-42753 Signed-off-by: Magali Lemes --- net/netfilter/ipset/ip_set_hash_netportnet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netfilter/ipset/ip_set_hash_netportnet.c b/net/netfilter/ipset/ip_set_hash_netportnet.c index 005a7ce87217..bf4f91b78e1d 100644 --- a/net/netfilter/ipset/ip_set_hash_netportnet.c +++ b/net/netfilter/ipset/ip_set_hash_netportnet.c @@ -36,6 +36,7 @@ MODULE_ALIAS("ip_set_hash:net,port,net"); #define IP_SET_HASH_WITH_PROTO #define IP_SET_HASH_WITH_NETS #define IPSET_NET_COUNT 2 +#define IP_SET_HASH_WITH_NET0 /* IPv4 variant */