Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1192710rwr; Thu, 20 Apr 2023 11:10:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YcvAiv41Rd1zwjeQ6zRhzzQb189NJELjHtCclOjqIupjM7nuT5lNJh5unJBZn6UeGBPZf5 X-Received: by 2002:a17:90a:3487:b0:240:9ccf:41ff with SMTP id p7-20020a17090a348700b002409ccf41ffmr2106905pjb.49.1682014257711; Thu, 20 Apr 2023 11:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682014257; cv=none; d=google.com; s=arc-20160816; b=ZfPtRt/flRr7fm4CRcrDy5KyCOdTlCfxqcC3+6kZPpGu+wGtXLuuzrg9bzQNOHsSQr 5kR004VCBJxiaSYMzcBZHMv9HITmx3htEMRGIeJ7Na86XM/KU27fqZqWRLGi5PWGO1FW 55Y/st7tLRFVxE4omh4mAhUSWrx92y8LqOjJtS6/OEuJHgbx3QMxNV7zZtBElmnAvXYu l8jVLx+SHzO/Gz+AKO1W49fQHMBP97ezlIm2x1tsA+1okoXGvahfvbN29UlPWusO5s8f KMkj4PuWcTFqsoGTJuUyTN/9sLS+kXtyVORaobbJk3VELPswljA9TP084AN9RKezc2Iw ZcJw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=sYEObKgK9ZsZ163F+qEC5kfelVhULo1SPruXGXXCNIM=; b=YiDc4CA1nlqdVNO2e2E3LtJaG9H4TELG84kinKlaB/p60WWTgRxG41Wxbsm4kA+RsD zllh4ztDyr4TLYz3QWXCyqCMxDaWvLW/ko6pxNJCmCvfPAdlZ51i5FPts6f+p6Bav/UR djcY6pzH+S+IVsHb2PfHf1zidfJIgj3VuZFv4/8SKZzeKdOFCur7yrQe8PUkIq/mY3YD ETq53IhZ2Nr7YM5Xrps5QqUczAC+yceG95+1AmLaV+ZnIDt4L8cEN8HBazwOGyvoQrj1 WPRXJ1YZs1ZeUWoodTLUvNFR+cpc4RzOc+eapl3lpSLB5q63V3gcLxybIAWZQqpxDyuT Ifqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S1UyZXQB; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a170902c94500b001a8a110407esi2421430pla.540.2023.04.20.11.10.41; Thu, 20 Apr 2023 11:10:57 -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=@redhat.com header.s=mimecast20190719 header.b=S1UyZXQB; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231534AbjDTSAv (ORCPT + 99 others); Thu, 20 Apr 2023 14:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbjDTSAr (ORCPT ); Thu, 20 Apr 2023 14:00:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6736619A1 for ; Thu, 20 Apr 2023 11:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682013600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sYEObKgK9ZsZ163F+qEC5kfelVhULo1SPruXGXXCNIM=; b=S1UyZXQB275FUujSVHefBnZh2PBWZq0VMychvml5fVcj/YUr7k64RHpdBdMSpHXsZ//8Gv zD+hQeat5uRl6rROVmozo1BnFHwkJfbzBL0+Ase7AaMcT5DaTSevoo6o8PxJR34Iy2w5qT NWZcRO0oFnoQTYX+SHdmh5oNwR4ZJXI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-248-ea5QQMH0NwaenUbQ9iTEtg-1; Thu, 20 Apr 2023 13:59:56 -0400 X-MC-Unique: ea5QQMH0NwaenUbQ9iTEtg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B227296A605; Thu, 20 Apr 2023 17:59:55 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.226.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A6241410F1C; Thu, 20 Apr 2023 17:59:53 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Paul Blakey , Marcelo Ricardo Leitner , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used Date: Thu, 20 Apr 2023 19:59:52 +0200 Message-Id: <20230420175952.1114302-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Function tcf_exts_init_ex() sets exts->miss_cookie_node ptr only when use_action_miss is true so it assumes in other case that the field is set to NULL by the caller. If not then the field contains garbage and subsequent tcf_exts_destroy() call results in a crash. Initialize .miss_cookie_node pointer to NULL when use_action_miss parameter is false to avoid this potential scenario. Fixes: 80cd22c35c90 ("net/sched: cls_api: Support hardware miss to tc action") Signed-off-by: Ivan Vecera --- net/sched/cls_api.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 35785a36c80298..8bc5b9d6a2916e 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3224,8 +3224,12 @@ int tcf_exts_init_ex(struct tcf_exts *exts, struct net *net, int action, exts->action = action; exts->police = police; - if (!use_action_miss) + if (!use_action_miss) { +#ifdef CONFIG_NET_CLS_ACT + exts->miss_cookie_node = NULL; +#endif return 0; + } err = tcf_exts_miss_cookie_base_alloc(exts, tp, handle); if (err) -- 2.39.2