From nobody Wed Dec 17 10:00:47 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66B61C77B72 for ; Thu, 20 Apr 2023 18:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbjDTSAw (ORCPT ); Thu, 20 Apr 2023 14:00:52 -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: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 actio= n") 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 n= et *net, int action, exts->action =3D action; exts->police =3D police; =20 - if (!use_action_miss) + if (!use_action_miss) { +#ifdef CONFIG_NET_CLS_ACT + exts->miss_cookie_node =3D NULL; +#endif return 0; + } =20 err =3D tcf_exts_miss_cookie_base_alloc(exts, tp, handle); if (err) --=20 2.39.2