From patchwork Tue Jun 6 23:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 1791459 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=Cp2J8ISK; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QbQwf2TVGz20Q8 for ; Wed, 7 Jun 2023 09:02:26 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q6fgv-0002U9-KJ; Tue, 06 Jun 2023 23:02:17 +0000 Received: from mail-mw2nam12on2060.outbound.protection.outlook.com ([40.107.244.60] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q6fgc-0001we-Cm for kernel-team@lists.ubuntu.com; Tue, 06 Jun 2023 23:01:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UA6J3xPQgKCm/I+YuvYECr3KhWASTQIhpwfyen7Y/9g7meTy1OieM+OENcH4ms6lgP9IUrC5tiBzn6yhQ9DoR2yazaaxnFAfRMLaS/h0PyCLHjREfkmdmENeRxibTcJl22nfshXro+8EI03hVgcC6U6W7C1p9Xgbo33aiArlmdXQnXgBL1LyoKKuilmQ6cpQ8QrOsr/l2nl3SuWR726IvfjqsJC+KkiQeUaQEb/0oQWsCKqPGKc0N2imBPWEFUMVpkdWjZsmpTy1tmT8MXnEU7hKxAo+5+I4WDMA0T7KirECayJ/ePTQnkOARGwgBHGyoKfBG2jfAd4rMCxE7feD/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iwavmGI+5w5lUo6Gl9ZhLNxthwuvsC7WJxGcvdTB0oo=; b=JA1gYS2HC5UMp+Jiez+W/o/sJ5Ddj8huEcALrefe4KW/F2wvXdraEyvyBQFJRlZ3TKsr7ItzpYY3moVmxkkw003bfvQXznPpX4ioVwtJBWDBpJyFVpLeCOOKq4B3AA3TWL6h1eV4mKiTZaRhwtrZsvWJWWOyHiNr18UKoGUCPicWd/hx4s0k3S1REuV/771uRG7mnc0L/qbJg068PDXxVapOLsu4sqZYVX6ljg5lMr0TZ4gk5osEEC9lzIrpSZKRmukkyGOUbn4sEgQjvVnU/qyUuIodj7wb2fw7IognDNPgx4vsCEIlQZKqnTH5TfMgukE0At9N/T0G+1ObkXvHhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=canonical.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iwavmGI+5w5lUo6Gl9ZhLNxthwuvsC7WJxGcvdTB0oo=; b=Cp2J8ISKB4OsH8edP+y0YUzwrZvEYguK7478cfKfOHv2bkndEZ83CGiTwSvE7quunTuJqg3scNNOBeFXgCUC9TaZb/+fl5f+cHuFtEEBLBSN4e3Ma8yZe1gruNgK/mwcXVUKJEVaL9Y5Zh8cZN+7OcnHOYEosaNVucJTEY0XjyKfQbKP9jQoG3XrxbPmrS9nXAHfL/bVvdXDHWt75t7BySogKAGiTxf+tz9STShbW8muqGGiFgicXhhz3tB0RlB7UFfCU/s5jlszZmFSZKvhfUEMXRP4Xdl//4twp4MsuwlD7J5vUdxuvSZp9zeg4yDGAPJJonhzqk3NVzWptbRLdQ== Received: from MW3PR05CA0008.namprd05.prod.outlook.com (2603:10b6:303:2b::13) by MN2PR12MB4517.namprd12.prod.outlook.com (2603:10b6:208:267::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 23:01:54 +0000 Received: from MWH0EPF000971E5.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::dd) by MW3PR05CA0008.outlook.office365.com (2603:10b6:303:2b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19 via Frontend Transport; Tue, 6 Jun 2023 23:01:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000971E5.mail.protection.outlook.com (10.167.243.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.13 via Frontend Transport; Tue, 6 Jun 2023 23:01:53 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 6 Jun 2023 16:01:40 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 6 Jun 2023 16:01:39 -0700 Received: from mtl123.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Tue, 6 Jun 2023 16:01:39 -0700 Received: from sw-mtx-002.mtx.labs.mlnx (sw-mtx-002.mtx.labs.mlnx [10.9.151.106]) by mtl123.mtl.labs.mlnx (8.14.4/8.14.4) with ESMTP id 356N1LCV011133; Wed, 7 Jun 2023 02:01:36 +0300 From: William Tu To: Subject: [SRU][J:linux-bluefield][PATCH v3 08/11] net/sched: flower: fix error handler on replace Date: Wed, 7 Jun 2023 02:01:17 +0300 Message-ID: <20230606230120.407292-9-witu@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230606230120.407292-1-witu@nvidia.com> References: <20230606230120.407292-1-witu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E5:EE_|MN2PR12MB4517:EE_ X-MS-Office365-Filtering-Correlation-Id: c7820d7c-f174-420b-7585-08db66e20548 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HpVvi46ybXF5umqjQsuBhT5Ev8cgj+pyUXrxnqoBfLniCcgtnUeQ74ULTgX+/9V1IVgQLKPBGl/GVhWEwgigcTcHsX9Uq0+psmWHyCJpE5wgf2yHc/XzxqFrYPGtBqQAXV0S+alsVrsKmq6P+3JiuG4eC0gCkC6Blj6wA0puaql3m0vyoWy6EOBu3cGebynSDuqc+RrpFsVRcl3ph70LhkpIYQpNsPv9Wl4cxiIm1s0eYuIJqEurr5sTjmqtYU7CtiCek80or2sAyQe+yJWu1BSgZghf9Ak81iddHEFsfzJ7dBIcKEQNEUu+1X18pZaIVC/dZSHPnOT9gOP9zCRfc/8a/7chXvyLI5i4FbQZVHx0nFFNREKq7F+aA59sMwVV0ctqZ257RYJ7sOYAWEc4uIkA14Ptc/z5YeyQ7nEW8q04TPWvxmaleDDDkB5z63L6h6RgAFJu17+voqp7Ezr4ucB5mUs6T3UBmvAEyhdAQ6demY8JF9s1z0ZGS5m0WyINGwzs2WnkTXv0SvLzcHhsAWHFUR1WvZFzWzKV3IPqQ/tSkcKZGTUqQbuqs8N76Jnw8oyc6gOvjKTkrL5trjWLhqoR673321TVBGkiQUe6lo4212tN8Mxa+zzGlV8TLQ3ogcpxJ/mHEN7Wvju+KH9BJ5tjpYnkpqPJVO4ZNbQjo2Vi93nhvcrOGEgw4cfcPc5B6jKaTScUdSyYCHGjeu97U9sgj/rwGhThkCA4x+7xarUTbYE1xCfrEnOwtOcNPfhMLs2WbbphRJhpr/92psXOPfk8HXl9LJdWpV+uDT1PfHM= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(39860400002)(376002)(136003)(346002)(451199021)(40470700004)(36840700001)(46966006)(83380400001)(40460700003)(47076005)(336012)(2906002)(2616005)(36756003)(86362001)(82310400005)(356005)(82740400003)(7636003)(36860700001)(40480700001)(41300700001)(316002)(6666004)(5660300002)(966005)(107886003)(8676002)(8936002)(478600001)(54906003)(6916009)(70586007)(70206006)(4326008)(26005)(1076003)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 23:01:53.9396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7820d7c-f174-420b-7585-08db66e20548 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4517 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dann.frazier@canonical.com, paulb@nvidia.com, vlad@nvidia.com, yifeid@nvidia.com, bodong@nvidia.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Vlad Buslov BugLink: https://bugs.launchpad.net/bugs/2012571 When replacing a filter (i.e. 'fold' pointer is not NULL) the insertion of new filter to idr is postponed until later in code since handle is already provided by the user. However, the error handling code in fl_change() always assumes that the new filter had been inserted into idr. If error handler is reached when replacing existing filter it may remove it from idr therefore making it unreachable for delete or dump afterwards. Fix the issue by verifying that 'fold' argument wasn't provided by caller before calling idr_remove(). Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier") (backported from commit fd741f0d9f702c193b2b44225c004f8c5d5be163) [witu: manually fix the idr_remove line] Signed-off-by: William Tu Signed-off-by: Vlad Buslov Reviewed-by: Pedro Tammela Signed-off-by: David S. Miller Signed-off-by: William Tu --- net/sched/cls_flower.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 71ffd558a5f2..33b1eeccc21b 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -2183,7 +2183,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, errout_mask: fl_mask_put(head, fnew->mask); errout_idr: - idr_remove(&head->handle_idr, fnew->handle); + if (!fold) + idr_remove(&head->handle_idr, fnew->handle); +errout: __fl_put(fnew); errout_tb: kfree(tb);