From patchwork Thu Sep 15 10:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12977236 X-Patchwork-Delegate: kuba@kernel.org 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 26109ECAAA1 for ; Thu, 15 Sep 2022 10:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbiIOKvI (ORCPT ); Thu, 15 Sep 2022 06:51:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiIOKvE (ORCPT ); Thu, 15 Sep 2022 06:51:04 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B10B80EA0; Thu, 15 Sep 2022 03:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NDbuMrLiSk5BKqqO3CoTMswFlh4oAZs80jeZ8W5EigQgwhrjhZkG2GszIeBjAMXLkIWJb+LGD7WVKULJ5lyeH8AR2Qoq/J+UrzEYmQX2janLAIqOA6zzp85agmrD0LPVxLA/SuXn81EomjNmAqk9FgLKPFAA5VjkL+ZY3VNmc9M48G53M3yQwhA/m76iP8D/nC+9+9bPHfw1awvCHFh/0BdfBQnRY2IpHWCWnlbHAmkaPl55CqCVygQTBeIM8VzdTT/dxZrzHOeY907IBRWE3tRFcLNgTuIrQjW/OGIh8Oxo2PVMCJ2A3MKlyJCJY4KB+HyQgxl60E8JJ5eixcb7Rw== 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=OVllrFQAyaq6mv4H0bPEc2mXWu0XjDAty9O/abvxXVE=; b=OLi9i6D3uMtKLwS5u3HmFC9zujsXfiImJMk9rNNRk5lwsGts37+lIJu9Jd7Gt0aEN9wT6m6fo910Td0m8rL8jF6iN+DEZU5Z14fmhkOOh/wKoU0kWWqAnThgWZmyH2GZgIoDWbttKFo5KaLgHvzN4Z7DuA6570AShW14b1JJIvC4xIqx8T2fe0tPQ4VV9Rt9YXtRP2gbHERBwPDknmaPdAKtN9LS3aoIvJqpirKwGriE04RPt2BVUm0D/5JogwmPhKNtNrYeSqCZ2PhDBG800RR+fW9TaKT5xLSW3qXBC5q+qu+Xj5XMyWmF8Y3XTBHaYjtKPyCbE22/ldmUJoyUKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OVllrFQAyaq6mv4H0bPEc2mXWu0XjDAty9O/abvxXVE=; b=WVAOSlpAMGp/dPiqXScXiIPuLu7wAABLWpfVq2r60k+ti5sOP4Uj8mbAIIPmni/h+HgcOkQUqi8xj2jJqQ8qUgKxbZ2XTv8hHwXaaugGN5HKbJC1NNXhhOfDNlN2FXpSvy+40C4Ipn0dE/kTWWXQ7eGq2jsB6HS6IAkGN0CNHSA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB8PR04MB7163.eurprd04.prod.outlook.com (2603:10a6:10:fe::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Thu, 15 Sep 2022 10:50:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5612.022; Thu, 15 Sep 2022 10:50:59 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Voon Weifeng , Vladimir Oltean , Kurt Kanzenbach , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 3/7] net/sched: taprio: use rtnl_dereference for oper and admin sched in taprio_destroy() Date: Thu, 15 Sep 2022 13:50:42 +0300 Message-Id: <20220915105046.2404072-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220915105046.2404072-1-vladimir.oltean@nxp.com> References: <20220915105046.2404072-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR09CA0052.eurprd09.prod.outlook.com (2603:10a6:802:28::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB8PR04MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e34fa99-9322-4db5-56f2-08da97082c82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YLTxZMV6RpatO9q9paFbipVoGng/iXzUqu2HflWutbzGLpAHEGX5Ur9dHxyGQTxk1CPeFS2rnMB+7FHgWyQlZyz4GdxvW6B4fWgFyjcDvjJs0srDo/8ci98LGPe0gEEo+DriPoRNCQDbZnYuJRVGANFfFZiMY16mij+DqNcVK6sLlKGF40k7ZitpeJr7jlgfBoSQ89sOP4yQeSH85Agj4TC16s2w+GNpWL0TR3s4o2u8y4Xi8pcZv8LcOhklgh4Y81oHR4n+iAj0FOjiqhAB/J/txGpIkM/DKylLPJoAoj+J1owYeMNsDOoRnWv1V9prHHN+R9GJPMRImKzUE0tMiLnxyzY5s7Y8CXl4NTyC/l1CxzJAGE3GrtX3GNRWWdqPc5ZS+SGu3FxPAThNyXvE73pVRQ3Lm435pVS0ndVN3vyFEbEChWAHzbDdCDH+iIhBQtRJ1GiIX1s5j7k+Pq9KnyR0QhVJt8/LgPXX+SIHj3O8TJPgysdegXphTiknXuA/iEt2QS25RH6KMWZmC46e6NiWkuS9Wm9c+JLdy0e023rKg3htOUC02zECpFXC2IrozvPswQaDz80dMZTau2u0f86CzPs2iLaTbLzIluyZDBzgZCBLx9WNKVAfsO7uTQ2aTHrvF//14CNmg+4kujMWpBlcgsmMR8tkV9Iouyx2gLooB84YB6CiZRv4BZ+Wtem928EQGwlom3Qx/pqdJwyg5foWViTxpW/i1L204Dv99fnEhSeYHCqvWOCQijsvHzTKtP8v9K5EBhzZLvRF69srFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(396003)(39860400002)(366004)(136003)(451199015)(6916009)(5660300002)(6486002)(7416002)(2906002)(478600001)(66476007)(36756003)(54906003)(44832011)(38350700002)(8676002)(38100700002)(6666004)(316002)(2616005)(83380400001)(1076003)(186003)(66946007)(41300700001)(6512007)(86362001)(4326008)(6506007)(8936002)(66556008)(52116002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aKklTgPfg8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Nl6R8Ed3+vOemvcBZEY9GcRT2FSxKasIjdPWKUQWh/pAAGUmNbrntq+iQyPPcrWBwdtXTfYv+5yiuvSEKWWgHoBP49Jyst0ARuTfRqFp0U7cyRPtky8NuSkf8I6E6ckjSL4jJ+YjikoZgI84ys49+9fAsHPhGnM6OSfU35ZbYdGjLiQbUVnRpG+RKZyZMpBaF0lTla4kS+PCnNALgYykiBAauErPorkdXD5rm0LX5DMsg7e0/ceQUwHDZwRF4SIO7sQxwJ64PIGrYHI6fomeLzV/Mqi3qGmG80OmxZ1vTSVp/rHU5wEi2H8J5gV4kS9qJI5VpB6IwN9m9SQkfKPC3bWCMpC3KR7G3X1I6OBXu8hO56yHimNRLx6HjVgh7gemQVDx5k6CLUAcZrIPLiHRdD85TunyNNbvR0DtCXpb2jBBopQjf7qGsW1OJT6txNooxs1ICXGksYUppjH3l8eOmm+iRG9Lir+Nw35oo+mq9wG/ECjazov/ybepjxbcWMIoWdF0+sFb4W4+CtzT9d+61OK8Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e34fa99-9322-4db5-56f2-08da97082c82 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2022 10:50:59.0649 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qUct/gTwpaZNAH4Oeh98AHl0oFXziYXbF0cpweKZ/eZeTY0/ou6wLeL6I42FpYQjhau9xmnjTjjXKkZanTYtHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7163 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Sparse complains that taprio_destroy() dereferences q->oper_sched and q->admin_sched without rcu_dereference(), since they are marked as __rcu in the taprio private structure. 1671:28: warning: incorrect type in argument 1 (different address spaces) 1671:28: expected struct callback_head *head 1671:28: got struct callback_head [noderef] __rcu * 1674:28: warning: incorrect type in argument 1 (different address spaces) 1674:28: expected struct callback_head *head 1674:28: got struct callback_head [noderef] __rcu * To silence that build warning, do actually use rtnl_dereference(), since we know the rtnl_mutex is held at the time of q->destroy(). Signed-off-by: Vladimir Oltean --- v1->v2: resend to net-next, use rtnl_dereference() instead of opening an rcu_read_lock() net/sched/sch_taprio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 63cbf856894a..6113c6646559 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1636,6 +1636,7 @@ static void taprio_destroy(struct Qdisc *sch) { struct taprio_sched *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + struct sched_gate_list *oper, *admin; unsigned int i; spin_lock(&taprio_list_lock); @@ -1659,11 +1660,14 @@ static void taprio_destroy(struct Qdisc *sch) netdev_reset_tc(dev); - if (q->oper_sched) - call_rcu(&q->oper_sched->rcu, taprio_free_sched_cb); + oper = rtnl_dereference(q->oper_sched); + admin = rtnl_dereference(q->admin_sched); + + if (oper) + call_rcu(&oper->rcu, taprio_free_sched_cb); - if (q->admin_sched) - call_rcu(&q->admin_sched->rcu, taprio_free_sched_cb); + if (admin) + call_rcu(&admin->rcu, taprio_free_sched_cb); } static int taprio_init(struct Qdisc *sch, struct nlattr *opt,