Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7025199rwr; Tue, 25 Apr 2023 07:11:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YFvJ4uWhpFw5y5fbMg4kzS7YDivTez3EBLV/qfER8P0fBKQqpkhPQPn6kcYKjy4V35LSKX X-Received: by 2002:a17:902:d54e:b0:1a6:c110:9029 with SMTP id z14-20020a170902d54e00b001a6c1109029mr18977761plf.59.1682431897848; Tue, 25 Apr 2023 07:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682431897; cv=none; d=google.com; s=arc-20160816; b=rdY0jQLodw8SLLBw5XdVgKUi4YPKWL5/yQuohJA7pIiVtG4USFddGgKINiacFcNEno L8cptC1dIC1/rEt54VCspcfn5HcrNGdy/W1U2V3ZOmtH4S5LY/3H2hMe/Rn14Td0rfYI /Odv+ePxj4gNxksdcbTEJAb1Ug79TyjlDkpDE0Cuey1DP4pVXE0qcoEiFRbvxOssQ2Bj DtYnJ818x2qSw5BlihbKeHErJw+TkIS7iCQ5rS1wOCZ/fRVH/lnENsjRYGZWBR8IGLm9 R3UDzTKy1dgTljLwEv+NIPfKzd+rzN0TAipT8DA2w6cRbCAwyFWV9YptNQWz6gRGhs7e e3Vg== 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=ky4or7cbHu9y2lAhkNJDV4gPS/WcEX9x/ObLAA4vgOA=; b=HwEcgJK5o2qv0u4KJ5WiE0Yv5qvUdybOgg0trDY1Jd4ptgIQreJJGKbqPpTY7PQvhS blKf64kVhri13uCOdJnegg+9or3yWsmpKPdHxY/asDZvxKNTfb36xbgIu1eo5yd1I6jT cAK4f9UlWExzdrRXE/iJdfBu6KmwbHo/z6+/UfK7gxNwGdD+SLtwZRIJdk0DabD+dVEa QR7ihH3Bd9gdxayrZSkQC05zkWmsUByYSUZTCiGveWP/xIgAFqckB7yE4ujmADfII5QW +fA1oEpls3fAS3GnEeVgR02ptc4QMjgg6uPBX0VkiuFmZQMqUDCXQpelBKkkC97SdiOc Y1JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Or81DViK; 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 b14-20020a170902650e00b001a1c005bd39si13484760plk.97.2023.04.25.07.11.23; Tue, 25 Apr 2023 07:11:37 -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=Or81DViK; 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 S234268AbjDYOHC (ORCPT + 99 others); Tue, 25 Apr 2023 10:07:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233704AbjDYOHB (ORCPT ); Tue, 25 Apr 2023 10:07:01 -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 98FB2E6A for ; Tue, 25 Apr 2023 07:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682431572; 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=ky4or7cbHu9y2lAhkNJDV4gPS/WcEX9x/ObLAA4vgOA=; b=Or81DViKcry4UI8VdHBJohr8jp+0IwrG9SIyz0/zsRrL92uXACQSacD1i6HSRdf3O7ajcH hmdr1xVg8JrGjgkeINpKTzLRt66BoUJeEfxzCv2JlacTy6oyoVkGJEX13Fufpw2eCwA5oJ sprH3DZMndfa0w3PGAX7dlMtUKW41ho= 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-183-bVPvqCw8PY-I2o_YWzJQCQ-1; Tue, 25 Apr 2023 10:06:09 -0400 X-MC-Unique: bVPvqCw8PY-I2o_YWzJQCQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C573884EC5; Tue, 25 Apr 2023 14:06:08 +0000 (UTC) Received: from p1.luc.cera.cz.com (unknown [10.45.226.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07EB840C2064; Tue, 25 Apr 2023 14:06:05 +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 , Paul Blakey , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] net/sched: flower: Fix wrong handle assignment during filter change Date: Tue, 25 Apr 2023 16:06:04 +0200 Message-Id: <20230425140604.169881-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.3 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, URIBL_BLOCKED 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 Commit 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier") moved filter handle initialization but an assignment of the handle to fnew->handle is done regardless of fold value. This is wrong because if fold != NULL (so fold->handle == handle) no new handle is allocated and passed handle is assigned to fnew->handle. Then if any subsequent action in fl_change() fails then the handle value is removed from IDR that is incorrect as we will have still valid old filter instance with handle that is not present in IDR. Fix this issue by moving the assignment so it is done only when passed fold == NULL. Prior the patch: [root@machine tc-testing]# ./tdc.py -d enp1s0f0np0 -e 14be Test 14be: Concurrently replace same range of 100k flower filters from 10 tc instances exit: 123 exit: 0 RTNETLINK answers: Invalid argument We have an error talking to the kernel Command failed tmp/replace_6:1885 All test results: 1..1 not ok 1 14be - Concurrently replace same range of 100k flower filters from 10 tc instances Command exited with 123, expected 0 RTNETLINK answers: Invalid argument We have an error talking to the kernel Command failed tmp/replace_6:1885 After the patch: [root@machine tc-testing]# ./tdc.py -d enp1s0f0np0 -e 14be Test 14be: Concurrently replace same range of 100k flower filters from 10 tc instances All test results: 1..1 ok 1 14be - Concurrently replace same range of 100k flower filters from 10 tc instances Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier") Signed-off-by: Ivan Vecera --- net/sched/cls_flower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 475fe222a855..fa6c2bb0b626 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -2231,8 +2231,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, kfree(fnew); goto errout_tb; } + fnew->handle = handle; } - fnew->handle = handle; err = tcf_exts_init_ex(&fnew->exts, net, TCA_FLOWER_ACT, 0, tp, handle, !tc_skip_hw(fnew->flags)); -- 2.39.1