From patchwork Thu Apr 20 18:36:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Vecera X-Patchwork-Id: 86012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp551219vqo; Thu, 20 Apr 2023 12:03:32 -0700 (PDT) X-Google-Smtp-Source: AKy350aWhRqIKV2bkx74qeoyy4i9F6iFuuSO5/Q4peMhuV/PG2AJfd9h905MwLuom7Sd7yd6TcMe X-Received: by 2002:a6b:7406:0:b0:763:5a8f:fe6 with SMTP id s6-20020a6b7406000000b007635a8f0fe6mr2073385iog.21.1682017411843; Thu, 20 Apr 2023 12:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682017411; cv=none; d=google.com; s=arc-20160816; b=SmbT8z6gQI3YbpM8CQ/y8K9nvqROEV1vA8ZX+0YaXtn6xAL/3lSU8rA1Fob3AFzNFD JSz1ILhDpOGu1W8RDegBkBuusJu+4N4yemL/Nb8Qe+elcG0vND43mK9Eat13P94h+p4v DdaSWLT9GqLv4eibcEkI0VZiTz5tDAbde58xQ+O6STQ/MG8vr2cd9SfyY5QZCrWg3LrO 1WEoALG7UdiQ1L0OR7GMT2aVajRZhWf1+8bYBShdvdVnKtCE6AMIKBtDTX0iZ4/7q8Zv RNqYquely6IDD6B74NNj6qarxiljk2Bn/B9lt9bIMlWrQDqgE1yRpoNwx+XBe6N7y2GL jYpg== 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=4qwGp/6dgqHFxVBe4E5Tv6rcAaAWlfJIcD3N6fbbtpE=; b=w1rewUWmJ2L8QZJfwUL6D45VMvxTjj9Ad/Ldi32cHJgsyJO7iuHt3QIZRz2+POiajL zpXZfNioFRp9QwIY7zS1/qOkAXuaFuWwFYRbdaG4Mq99vEC0f6etEH7IVmZUJX6pdDKk KtnrdQmRcD2KLa2XA7aLYHY9EcYFM5pzT2K7OXssAvaIXXSvlUsmoj0/D3KzRWyZ0FwG nDwooOJeDIAb0yi/2Sv+kA7pbfJkl4ATHLRDEnqRGChD7OSQ5lDjk99/4V3KLAm6q/tM f4ffjPWW3dkkRf/m2PtdLFrnmx9CiX4ibxiR8X+GcOKhAl9vI1Z7f6a1xOcJ2OcTNfYz HWtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zo2n5DBD; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d43-20020a023f2b000000b00408f4c167c6si1763429jaa.181.2023.04.20.12.03.14; Thu, 20 Apr 2023 12:03:31 -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=Zo2n5DBD; 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 S231723AbjDTShr (ORCPT + 99 others); Thu, 20 Apr 2023 14:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231845AbjDTShk (ORCPT ); Thu, 20 Apr 2023 14:37:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D8F0524B for ; Thu, 20 Apr 2023 11:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682015798; 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=4qwGp/6dgqHFxVBe4E5Tv6rcAaAWlfJIcD3N6fbbtpE=; b=Zo2n5DBDd1CvabF9Vhgqr26ZUIyuLhLmwSdRBJID4g0a3TrMT3NJL/XtA1qISTY5b0UuRg m7BQw2qpZ/Go5vcjHeEDAm+PpXifLY8azzjQz8QdObkZq3SrNvVcGnIwDJl4uM1YUGXUFf Fbe/z7gqREZU3lIdfE7rOK64DdZmChg= 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-155-eEGeaDn7NISQPTdTicEhKQ-1; Thu, 20 Apr 2023 14:36:37 -0400 X-MC-Unique: eEGeaDn7NISQPTdTicEhKQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FD621C0898B; Thu, 20 Apr 2023 18:36:36 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.226.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id C48D6492C3E; Thu, 20 Apr 2023 18:36:34 +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 , Simon Horman , Marcelo Ricardo Leitner , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net v2] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used Date: Thu, 20 Apr 2023 20:36:33 +0200 Message-Id: <20230420183634.1139391-1-ivecera@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763722112990149814?= X-GMAIL-MSGID: =?utf-8?q?1763723089696106198?= 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. Ensure that the field .miss_cookie_node pointer is 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 Reviewed-by: Simon Horman --- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 35785a36c80298..3c3629c9e7b65c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3211,6 +3211,7 @@ int tcf_exts_init_ex(struct tcf_exts *exts, struct net *net, int action, #ifdef CONFIG_NET_CLS_ACT exts->type = 0; exts->nr_actions = 0; + exts->miss_cookie_node = NULL; /* Note: we do not own yet a reference on net. * This reference might be taken later from tcf_exts_get_net(). */