Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3398074rwa; Tue, 23 Aug 2022 04:14:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ff4hWIPRpUbzDH+Qb5emWmaik3IZxue/CWFAYSsz12Pzq3zEVC90T3XrhHFCXV7Bj+ZHQ X-Received: by 2002:a17:90a:d90c:b0:1fa:c99f:757d with SMTP id c12-20020a17090ad90c00b001fac99f757dmr2888915pjv.240.1661253249340; Tue, 23 Aug 2022 04:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253249; cv=none; d=google.com; s=arc-20160816; b=zfLw/AzuHd01+JWQBh2f4DZrsqpdteNXLk2Fka2yoZDAVYVrZzY2wtO61KiPmrFztN /oXVlV8vqk15mBVxAeDl+yEKxule25pOnD57TsIfAUAkTgvLMUUNSPUkL0lk29LSrfwc +K74LpbZN076RRc6G8xCgS6RlvmqQyeQRrxlFdnfZoA+XW1CAyLPvgEVuI6EzmwKnr0s dPPFqh6BcN1ipPS3JkZT6CiVdY+IVRyVEqF/mj7mnHRW+47lZsbxP4gGaadMI8EB4K/W UTHm6Dz6HavOfz3MgR0hYtQ9stP4dZtcltF43oTPi7i7SgLBbIV5ILLa0EeqrwRwIq8V aaHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GLUecsx20f/ofxJCxWR09luFmOD/IlxPOQsOxpbhufM=; b=uKSmAMq9Ji+qmK6lJ0+zNJNjXM83iELoDNry4vuyp8ymGu3ofy4seUHkwRgAU4xhvy Ku6kmKhZJB9Sf5tmuvA8sKIoVyeuqVzxoZI73tMx5UeIfi82Nv3OukwNkl9NZskR2Eso K1Hj1h3UkgNln2+3Rlon2m4jpkqdFyPDJuocN2EOxlfFN6elpHk3E2ToITmkFmxbZzwm ORYa0pgBqeAQg9aJVNE8YbBPUzW42rcs/kCRTxkFE8aNDzvQs8bgApO8V0yAXlKbYCXa a6KBEEi7bgz6WQV/jkefQs6cxmC0FCsNGry5iTqTB9L+yb0Aa3vTaP6hPFEFJ7mqpHto aqEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2mAsYmkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a056a000a8e00b0052edbdb0910si8618088pfl.128.2022.08.23.04.13.58; Tue, 23 Aug 2022 04:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2mAsYmkv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353002AbiHWKJ5 (ORCPT + 99 others); Tue, 23 Aug 2022 06:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352728AbiHWKCZ (ORCPT ); Tue, 23 Aug 2022 06:02:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 622677C527; Tue, 23 Aug 2022 01:50:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC92461377; Tue, 23 Aug 2022 08:50:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3D50C433C1; Tue, 23 Aug 2022 08:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244635; bh=z1UAbFAEBCVO/+MvUTbYWvY6QVA8Oi88OBcKimNBt8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2mAsYmkv3DokyukLm/jC84fXeTWh8We4mkk3W8IDQXojaWNzQVECfO4ucMuy2UDsJ 4NdelBXU0wovNUbDEJGLP6hDJuOH7kRqD+jordOagHVKlOAFjhNmHajIaK+MgvgocT KA1cBaf/yFXy0JpRqHMZc18RBtHL5PvAihthMwyo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso Subject: [PATCH 5.15 126/244] netfilter: nf_tables: possible module reference underflow in error path Date: Tue, 23 Aug 2022 10:24:45 +0200 Message-Id: <20220823080103.290641883@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso commit c485c35ff6783ccd12c160fcac6a0e504e83e0bf upstream. dst->ops is set on when nft_expr_clone() fails, but module refcount has not been bumped yet, therefore nft_expr_destroy() leads to module reference underflow. Fixes: 8cfd9b0f8515 ("netfilter: nftables: generalize set expressions support") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5479,7 +5479,7 @@ int nft_set_elem_expr_clone(const struct err = nft_expr_clone(expr, set->exprs[i]); if (err < 0) { - nft_expr_destroy(ctx, expr); + kfree(expr); goto err_expr; } expr_array[i] = expr;