Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1236212rwr; Thu, 20 Apr 2023 11:53:11 -0700 (PDT) X-Google-Smtp-Source: AKy350arq8MBtSh/oFEQYzZBbUweF/4aUeLOk/XrvdwDdEOikRT/QiygtJS4a2MRTDXRZzcG4/gp X-Received: by 2002:a05:6a20:d2ca:b0:d6:c92:9925 with SMTP id ir10-20020a056a20d2ca00b000d60c929925mr3278327pzb.31.1682016791341; Thu, 20 Apr 2023 11:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682016791; cv=none; d=google.com; s=arc-20160816; b=U7UHLaL8cnwz4AE3SNoTPTzZTq+lYDJTKZw2sMZRDGdax3fCO1FJDNt74i8RcscUGU 5Ag8G/BOONdw6wCISfR08Zz6OWRiXV/5Glq/YFTf2wfUxBlVm+e750NK/hXLI9YtEQKs YU/GV0KsKZEF3v8Wpf1UKoik/XQGc+cP2+W5RhPkwttF7ApxYedj7gwInp0HaXGChYEC IVqGDYRm/wtVaQ4wVwGOaxidrq2SCZvO/HFdirFAqNKPOayk47ZJ9rFx3eJklzO5YgqQ mL8/GmZihjCnJcyZxtz/q7/Ik6Sw6l6MhhMGlgevD9BZ0pCsMLDsqnW788oQpZur+KVb xe2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=h8fnLn8BWRY7RpMARBocXs4+D30uJmhAwI4qVpsGczo=; b=MUVGBM4mBZH5OxhShaOWP22x+/yNWQZ6nvOpHPeVNr0gljcKwUAuYuUU1eZ0AAT7x1 tOSWtXZlBsdFMky50IfxmMO2IZO8ANz9vYNrakpNqreOsjY/KERL67JTbFjKBEDW0YRa XfQaeOxtZIZDM4jg9C9xmOPGFJx4jl6G8GCJqTNq/lU3hpMuvfWXDUZNPIBE27f38BXG vouJQfVWaiy3fGdv7Q3VliVGIu25SuXlvVasY+/1CRGptVwdCHFS9QuogrjnIg/dfdV8 T3v+1cHpCGUu5p5gQqWkJa+hTr5MC+zFKvqWkZh5JwlUDRm4MOTxNdZ2wUqtCXJ/zlOu UHdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=URC8a6Sb; 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 e69-20020a636948000000b00524b27f659fsi2326828pgc.35.2023.04.20.11.52.58; Thu, 20 Apr 2023 11:53:11 -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=URC8a6Sb; 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 S229577AbjDTShE (ORCPT + 99 others); Thu, 20 Apr 2023 14:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjDTShD (ORCPT ); Thu, 20 Apr 2023 14:37:03 -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 8592649E7 for ; Thu, 20 Apr 2023 11:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682015717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8fnLn8BWRY7RpMARBocXs4+D30uJmhAwI4qVpsGczo=; b=URC8a6SbGDf9UPxGym4TxUhIRFjArOBBLnAWaTxHPQhPUS2wxFVAHlSk0qEPioo4XSZlDe TVqqkUJdZsPaFFCXIgNHAaSHHi8FvWgQauomwbbWJZocV4KCZtcRRsGtmNg3hZDVAlkcht 5pRmkkqIUh2XmCVe7sSxRwrdE9OuUFo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-uCB-MpQzMAmrYc3XocnvJA-1; Thu, 20 Apr 2023 14:35:11 -0400 X-MC-Unique: uCB-MpQzMAmrYc3XocnvJA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 67BF3811E7C; Thu, 20 Apr 2023 18:35:10 +0000 (UTC) Received: from [10.45.226.231] (unknown [10.45.226.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A961C16024; Thu, 20 Apr 2023 18:35:06 +0000 (UTC) Message-ID: <54f90db4-dc37-cee4-b5b4-3eedec7cef16@redhat.com> Date: Thu, 20 Apr 2023 20:35:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH net] net/sched: cls_api: Initialize miss_cookie_node when action miss is not used To: Pedro Tammela , 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 , open list References: <20230420175952.1114302-1-ivecera@redhat.com> <77920a21-96ab-54e5-db3d-5083a11d5691@mojatatu.com> Content-Language: en-US From: Ivan Vecera In-Reply-To: <77920a21-96ab-54e5-db3d-5083a11d5691@mojatatu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 On 20. 04. 23 20:21, Pedro Tammela wrote: > On 20/04/2023 14:59, Ivan Vecera wrote: >> 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) > > The problem described here also happens in the case some error happens > if the action array allocation fails and before the 'miss_cookie_node' > assignment inside 'tcf_exts_miss_cookie_base_alloc()'. > > Seems like a better way to solve this issue is to just: > diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c > index 35785a36c802..3c3629c9e7b6 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(). >          */ Looks better, will repost... Thanks Ivan