From patchwork Thu Oct 17 17:37:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840531 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2077.outbound.protection.outlook.com [40.107.241.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEBD11DFD9D; Thu, 17 Oct 2024 17:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186921; cv=fail; b=ZJthyUK+rL60iOVUwh9QDfoEhe4jEwwhMf0tQfBn68m+dhgU7lI3a/NVXBpj4CH3rHGWe3kSLbM/yrPs+IyKr7tnIuot5GIG0OJuD40gfWqRr1Fl9WDZVNbJeAC3B3I/tHuPq2CrxGaQ4lA/jekJ1JPJMp1nGAkJ+pEmsHp/USI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186921; c=relaxed/simple; bh=Mqa3oRJvEYi4Z1BGXH+qlE37o8GuUaS5ggwk2PhoT0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lrCLR48ivgehzXGvywc+kjvzn3lDvFo3+7IuqLfx1rnmP5SOVE1FxfqzaFZ2ut50HBvle0P6J6phvG4Hy6PYROhqzNKGZuG9jnXPZv4V1Voge/3y3Tda/ToGRhDZPNcGTRLNKVD+5m/bnC2gEme+B9WJUirSnkrvHX3fIP0q/GM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=kYFcfArw; arc=fail smtp.client-ip=40.107.241.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="kYFcfArw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f1+8Kvog6kuRxbNvDLA5m2ajXFYXRkoQobdYZM9N2B2td62eg+p3KhUEDnSkG5aJdCttZLdMy/DaoPBtPHuCcAaEHGqHcAFCHsBnPxFbRvCkVMqYHVjLO+HMurKMfO7GafRux+BOwhq1DJ31y9Qui2+vvqKLyp4sje0FtfY7UDcefUgvCgjuzbVLiHXl8SP62GYWZjdtYLKoUFxvcEI9qX7jHtCUalYW8+Agga/7TIfiyT1u5YuWy7eQbWjQT1HqlziilCpKZTANcOfOs/7F/QA2nLGOwoBFeONIAZdVzapxF8WAfpohYOVag60uMkXx6wfiqOGB3Xxw7I4RJIHkoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=uY1mh5l4i+G90c3YH0eEWk+Coa26tbSZkxfW6YbD+Fg=; b=mi+/7qUuYsAKKJS0t3Skpj8L4wKPazDN5SGSe1nOyci+KOC2cTJZ9BWV8r6FN8Wz2pka5/L018GLXehupJdT6f4rDn1BC32bcyGphl7iogq5qIvSNee+A6a41gsmiNN1CBnzpL5bZtnF2ovnNQpDrMUJdXQ3T91lA3ScAu5Htzo2bXk1GwMwJNlU9PXNYT5oz54vVLZOJ+Rhjnfa8Zb5onxiAayzStd58egKbu3jI0NkmhKYki4apkJZ/jOOKL+8OR/LBmccO/JuP9jS7a8ZYejo4o+kyOs+eNXbjIAaxF2Psufc2JKlcp9OJmPs7b5RAOmLpIpLN9sEWlHLO8QYAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uY1mh5l4i+G90c3YH0eEWk+Coa26tbSZkxfW6YbD+Fg=; b=kYFcfArw5f/ooqcBp0Nww2X7bC+xCRMcA1gWs4bVPDQjbWHZvrIvB0afJmz/Pbf+GNwazN6reThl4p5a39HI01rcBtjq1wuz23xU8oRYmFTIF6e/FMk6CtbDV+8IqZrad+TNoX7YPbh5gRXAhea7WS6+CXpqiyiDQr/2Pjy+mfDG4pf8X8HposwPvqJC+jUDT3LoimFLQr/YYynLtMC9cJQJWUFRWI//R7iIa7g4mLCqkwjp2h49OUWmAIqqKgSUci5YoWK53L0ILvPIyGRQQwMSARYTaSWFejP+TnScr+QKX0Vxeh6jr1lPaE796c8YIzDveeA59IEIwNJUi3ptTA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:41:42 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:41:42 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 01/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_vif_seq_start() Date: Thu, 17 Oct 2024 19:37:43 +0200 Message-ID: <20241017174109.85717-2-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c9c1092-b5e1-4acd-f164-08dceed2f620 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 0V8IgfIG4Nr15OZNrxOSWfTmo6IWzw8TRHooFoaJiO44r0X2vX17Aiz3p3jpWf9mrv3ZlBppKPYcPQdrjY6l0r2e4EmbFbim8I8li6bP9eF0H2F1pplMRXBFOLNAiRJr1PqrBrJS78Tctz7gOLRgr3OqJ8gQlVWgFPMzkKtULb8F981/CzFpGNvgLqSMwRfQg0oYpl2ZxF6OZLvy71GiE17VsZ5OumCH9BZI7WKIubjnaOfxiLAiN8W0MDn/QbtmrZXHhaiLLVvu19/rq9Hcxg4+CRYlGs+P39HbNzzFq6nwJZxcuaqpa3X8wZEaYi0iafCnlIvHJRczhvBO6M1y+60Gecrs8o+dC2+5xfSPyypAh/9yyhOri59Mya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V:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PjM3xnFyaqUXpWZmmpLzzpj5T0XBXSuhEQHGk0mHW9cYtmxv3u/sqRBMIyEWVPom1SLOS2v+0uIl/ATuF/ANcxO0zGSFJVdzaH5meanms9+iszqibIkedA+OZDKoycTkz/MCqBa4zSmGd4ao2dcjcyODYWilpRJY1OgGQy3aS243YzVdMueIKZneYRyPPZwuqf2NIm1xtUxemfsKaBfMdQmNuojJ2gHlngY1eTZ7CvUKN/hayZUk13jvDPIxWIn6eCjyyuPu8Q/Nc6V27qEZwenT7wnvjUCe3F7WdXVlImaDILcUKpOjj36GqKax4GkDqiw3dmJ5NvgWO6CLxUwzNcgycsYHl8bFUx6uBSXEi3hTYxSd9sA70b2jVcl4yNrbYxXTn2myeu4J2MM3rNFYkU0PrgDwmDCtjwnzR0d0gxc0MVrrkGLOyRI9Mo5FWWrlo60ZTkQAQGeIbzrUc9Oq5Z5BBbcfKCmMe/XShnWEywz9EJnwi9EurNkYeCowGy076ahBNG7x0mcCXsvgN5UBr8AgL8ntVEpeNLbHoV6+yhrgP1NZv9Cak5tR+PYvnOWExFNlduYC/YVv4l4xb40VLFNe5kDYL15XyREYylQT1xyXmdtaZD3ryUov7KOV80QNeTbjIf6W6h/jlJfcW61I8YavdJi2bnWDoFOmbVTa8mozgvwnuYInArRhRoXNWWiwJvx4Fmf3zXhFlqr1yiInFxf9uiFU3nm5O+kZ45KaDHkQ0EiLVEva259Xry8oB/mctG6oaEm9KBs4Y1PuC8qqF9id83+YRYg7DpGFxAYQdL/PMh0skL5x8kXNA6F+2/AHcLnbc+IWxTP6MB1B6ap+mvq1PVdCb3mxdITb9bVoJ9cbNQWQ4SjcMruz1MYLLKfBftFWT5h6pqP0zJdE4pRv1QUQJiWtzFMU3DtHn07XQuJZiwHIqRJsbHyNajn7fC/M8TnG1D3ImhmsqklTZgkNEyxQRb5kt36gxvdBJkOsE0qLajyP2cHkQ6exHua0f2DeipHgYV331d2mE0M9neUs9SKpZBxLFg2fh9bQvMXIyxoXEa1jYbKhH0Bgigf5GNu6qEryNqzNgMy1RC+aeu8yT86g8HR1vTZ/nNeNFTm4e+F4YkaT0ugpacKSaoNznPZJFlLg5IOC9BfkH1NuaK8YqH8KYiHeFRU/Rl6HpinMssanovXmJ1FEizqVd9porKgmvVuGdk0KFFt0pK2zFAHBBISb8DQeT852iBcSwJvJE6el12q33yO9TRuhuVbb0nmusIinKc4h/oy3gvfSiCsIunQntac2GbRx31T5lW08YYDLG4kpxPLGgSlnx3Hx9a9SDXOBydjCQ1QDHm8esFum3x4mwfG/pQTIq/oIOsk7rmHUtLjbpov7H4hxkKUMDZMq3Q1OrjyriX792vZIUcBcz3LrsPNL3NceQk9W8GyW+z9kvINh8iUiYaZAKQX4/LJfj8hs3ifTep+FynbgFsW+KE/cfSR9PcHoz8jPWE9LhfVXJ4/gbfKWX/tzPyGtYfQSNu+Qeo5A8Y5/z685L0rapuClEqvL5k94xDvTBou3EBUjHDBPhC5HXyR6YviH13PWR0kLnfWOAHtll9TkfFBIgw== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c9c1092-b5e1-4acd-f164-08dceed2f620 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:42.0507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D4fHHyNBQChuCHrxHHdqTraVKRiBU+tKN00Wye4tSto+/pBVyD7/DGGM20wjBNBvmWtbT6/nKjzycytdKX0kZNlBjejZYL5u/e/u/pEKmIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. In case ip6mr_vif_seq_start() fails with an error (currently not possible, as RT6_TABLE_DFLT always exists, ip6mr_get_table() cannot fail in this case), ip6mr_vif_seq_stop() would be called and release the RCU lock. Signed-off-by: Stefan Wiehler Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Reviewed-by: Eric Dumazet --- net/ipv6/ip6mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 76db80a7124c..3acc4c8a226d 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -411,13 +411,13 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos) struct net *net = seq_file_net(seq); struct mr_table *mrt; + rcu_read_lock(); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); if (!mrt) return ERR_PTR(-ENOENT); iter->mrt = mrt; - rcu_read_lock(); return mr_vif_seq_start(seq, pos); } From patchwork Thu Oct 17 17:37:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840532 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2077.outbound.protection.outlook.com [40.107.241.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C8CA1DFE37; Thu, 17 Oct 2024 17:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186927; cv=fail; b=lintn2jArGfYZeTpdKmzD10CPsBnUml4hBc6JyiUuYCkCa838kwPZngX/HO4idIiui5bwrxyeMroSuTZSJqx4mLNIGRKu7lbu5Cdiuwxvhis9BmbPHLuj+jG2/+qWaOEd453yrqoYov4G0kaom6O1O8UvEoOHFfwqFWZI6fxvEw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186927; c=relaxed/simple; bh=aG+3kbS0jDIXIc/fN7GNIJUny4PT6JMFy5HR6UVeoVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=N0yEc8O+KDh1caEj5hQ5RpyZPvwy1+4P7n0GD4lLzVJ6w6nOvM3HolIO/IO9G8jeguNsAjLvvJQS/8UT74nILy6HDq6nip2Lj2uUOUEfQ1NNzVgjnRBHEsMtOL505MkQSsR1oISfixyseNHdEblIhTRyYHFOZnfzFlbbLJTzvyk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=eZWdhm4H; arc=fail smtp.client-ip=40.107.241.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="eZWdhm4H" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ecax/3+hNu8WDjdZt685KvWvUonL7Gdf3pvw51N3gaTwVwxPJylRnvb454thneMVObjJFkUYXfcgAJ1i5t7q06s2U8AiNlTXRli37zdWS01oFoR8/ekWak1e/k9SwM/SLmMPm2ViBEA3ajyH5Ey+7G/hNCQUaZWK4wscag9+xtCH8sML5oU/qrbog/vNKpREQDGyMVQuvOF6cOY79k9DyQedU2yORe0sox3WPHtroGCPEQWRLEDd6cL7ByzcfY5UrYo+NKSQU/Hjf4JNySq3WeL9cvkUnfd15WnBjl4Y0A985wM6PoquomipaMQMnlZFKOLbN4R7cATqL48b6rGjQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=czG4YTN92i2Zf0PpFjrqIaKBLv1DFfD2T6PPvoJU8kk=; b=vnIX87Nh6WNJEQGd2Ns5c5jjYySNXO6+zQSRt9P+N5CqDDoAM5gHrm3ZRpwn9tZgkfJr55ow5iCcfakLU377hk5t8F/GFhBypQWIkb07JoQm/HiPUbI/g8EpcOMx9ROjK9AIT1MZMzR2bFnqyCwJML3JYh7qBTPaI+pFSIT4Ou3Gf/ex3fXvkbsJr0bruEuTHww1K21ikSezb/da1rhdob9UfV8m+90ICw42xgIerWmiCVYmbSsR7GnvyY6m41HvZ6/nywQA4KFlVdZYyLbGYgMteCEOtfflIWxakj9ltA+r7L5dd6ZmA2dybbFOCcc2rkWN4nUWD6YuwvJvAaIeUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=czG4YTN92i2Zf0PpFjrqIaKBLv1DFfD2T6PPvoJU8kk=; b=eZWdhm4H/u+0LqnsIeLcpwoJxIMvDvyAT+yzxsyyWJ7iE3Pr7K73onsLQ/TXn17bdOney4yBi8kkaPXQc1PqjlrL1PDq+gvioNhm6t3l0jhoPsFWbaWsaYB/3hFnc3+nlnm79fYTzOZGxZHTe7zzNy9MG9abB9rB3KfCfp42oCmqwWvYsLQ5idtLVb9hM0Y/hm+gKrRBURZb2EhlKUoSokjcUaxtRxH+sexs9jKbD2ZfRr4D4j8v3AfEI9UpK6UlkVkmDUcFOUT71BqyvGa/7LoFkIuW1sRepszhFzy/xLUrdRGaMUNWjINZHWj26Z++whf8rR8sCMv+P+r5rgECsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:41:53 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:41:53 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 02/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_ioctl() Date: Thu, 17 Oct 2024 19:37:44 +0200 Message-ID: <20241017174109.85717-3-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: 79c09f41-febf-4a29-8220-08dceed2f64e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: Jn2gm2cdONILml6tQgKqQon1mDi1dLDEj9HkFr2CIqlMZZfSbzaJb5dWF1IWLVepx/oZYucD2WHcxtrNm1ZC04/XY/Fha/Ytq+9F5ZO62zwr5ElcdAm12bF0rF3MMX5Ut8TAKKFg9adjzrY7CWDt+GddJwGYJxczC+flpNUSa7hGJ/jp4spr+r8oZuAKsCDTkfeAp71taHHxg0yxnrG1Ovp1Zy4Uhyt4+F8o1T20Kcio1OAivgbkEsRpshClXIGyN42lhoXgTv//1QT+nx95tqDKvb9BT+dAIBkylUy/qJls/BboHeRYpVzONsKWlKzwmWZyeCobKVB3sK0wlbX+L1d/Ii6D5jgai5DwDf8cdt8xYmR8XXQ2Exms+xBZ0dfqfvhmQ+D3RqNLZ4Nfu/8ZR3q8o9+TTcl4QPphM6xxwdrelXQVcJb4rQYv4TWkoHIiMaeevzeIBVTEM/NG87lamOjT2r+xM5HBnj/LMbeTBPpP2PauEJ6m4PN80iTcC81PbCrZDmjxbqDsJPe0aZu1Eg0KV/I3bnVPVskR6FaJu2InRTaJXd+6Ij44GYW4sky8by/acvUPT2t4iGmjTTTsYaNkybAtRphvEECOFnBLl4jEbCgTokduGK6gxwt74oWPGNYaqHo1D+DLrzLBgB3olr+PEC5JPbESSGOoCFdUGSV8o5pTtxtAFVIbgBpq6xPUc8YTwoCXr/LgQEmDGRzJnfCxoWiVAXaklilI9u9/0w9TSkI9EJMrZBjYsz8gMjWbXzzdXbK22Z2l+TivzN6egQOsUN252+Xf3Ha+XAO4KJVI8H7r7y9TyzqFiG+VZLjAhT2NHC7Iga2bwv/76m/LizuVtuVK313PYJTM2mI0i8X9/jCvwOZEgnPW5YDfYMBcsBpxAF/gSpBQKONpnRfbIq2a2R71odf8dz62RvdtIRZcnQTJ0jEJ3Ei7CbmgTphBgBk/KNlQHK8kNicEBLf7xdq4Lr0PPt1sylawM8cZdYo28wjVcqKjkI5RVICHJ9cHknldzikyo+wNwWM1j55D56dtQVcqwojxNvmiMncqxp8REeC0qavO/4n5GORN2Y0iSdTeF3RpLdUhrC8/z/Ux0ZVH1btSZDPKGL8lMB8gvXm0P/aJ+wuIglW0BNieC2yFyTLGIBDe6H0qEQcDd1d7kWCON2P7lrGTrEW7IRknXk6skxGYUcfnn87lTO9+aS5R34eRcENO/emT92yQGgu6rkiQlaz1g/VMljU4imwOZxSwwMWPH5FnNKXWQSbwjSgnYYeoOh/51pblUI2UVM1P8ZEum+D5x/ztbO5Z9ErefTmFnMMcDmoZlVksgPS+c+DzgUYzbuJkftWQX991JJkcr0xAXWM2gCd7A0U+LUPiNy0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r0SGaYCcVD5CLssolMMFozWhqpr3IQaXh8qFJZnpibBKIA+MAItkR43Zobi6OP9g/MoAo0y5JG39tRYCENCWPUzj4PMq5CAK0UvbViEE+WAiAOdwI8zHob2at1jJpseXDOq8zJSJX19lqqp4EepXkFskkY7h+oB6mZ9VGnDdDUqFTZyscVi0yRXIzLw3PYnsnMNtWBio+/GgW6HIMuxku18Oe6AFi+GICjgvY9F7E1WjIwCGqaQBP+8AwcxsPKlxfz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ha8AKE4r2/2wolvWm8S1zUn+q2uzBTbQYTCK8F5DCUAIdYR65BVEnwvgGX9tLiW1EnriLnLrspN9o0j+DR81VcHjIc1bwTVV2KX2J8Zb+C+FGf58Rs4PPhQ0rNsW08Q6b9aJXEUtgx+N/sqT72CEMFF4YjxAzVIrM9OmTAcrXlHvM3V1HyqgE4qxeE/J4ev7E0EsH2Gn1htOFQdA5l2jYKikD51DqxiRUjDPtgVpm3ZIO9Fxdyo7e2gXIt+oOWI4g8/4wBVLUpi6ga+MBewSOhhT7+OapNOrQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79c09f41-febf-4a29-8220-08dceed2f64e X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:42.3440 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6PK7tNM3rGrKJ1Wd9jX1W5PmTN0F6OWf3xHM5CJrDG5hBzJhFAY+dIRjMNZevDEm4J9Ov1y0bUYJAWpkIcSm0sIOxicNrJiiBqiruAjMplw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Detected by Lockdep-RCU: [ 48.834645] WARNING: suspicious RCU usage [ 48.834647] 6.1.103-584209f6d5-nokia_sm_x86 #1 Tainted: G S O [ 48.834649] ----------------------------- [ 48.834651] /net/ipv6/ip6mr.c:132 RCU-list traversed in non-reader section!! [ 48.834654] other info that might help us debug this: [ 48.834656] rcu_scheduler_active = 2, debug_locks = 1 [ 48.834658] no locks held by radvd/5777. [ 48.834660] stack backtrace: [ 48.834663] CPU: 0 PID: 5777 Comm: radvd Tainted: G S O 6.1.103-584209f6d5-nokia_sm_x86 #1 [ 48.834666] Hardware name: Nokia Asil/Default string, BIOS 0ACNA113 06/07/2024 [ 48.834673] Call Trace: [ 48.834674] [ 48.834677] dump_stack_lvl+0xb7/0xe9 [ 48.834687] lockdep_rcu_suspicious.cold+0x2d/0x64 [ 48.834697] ip6mr_get_table+0x9f/0xb0 [ 48.834704] ip6mr_ioctl+0x50/0x360 [ 48.834713] ? sk_ioctl+0x5f/0x1c0 [ 48.834719] sk_ioctl+0x5f/0x1c0 [ 48.834723] ? find_held_lock+0x2b/0x80 [ 48.834731] sock_do_ioctl+0x7b/0x140 [ 48.834737] ? proc_nr_files+0x30/0x30 [ 48.834744] sock_ioctl+0x1f5/0x360 [ 48.834754] __x64_sys_ioctl+0x8d/0xd0 [ 48.834760] do_syscall_64+0x3c/0x90 [ 48.834765] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 ... [ 48.834802] Signed-off-by: Stefan Wiehler Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") --- net/ipv6/ip6mr.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 3acc4c8a226d..19ce010016b9 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1887,47 +1887,56 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void *arg) struct mfc6_cache *c; struct net *net = sock_net(sk); struct mr_table *mrt; + int err; + rcu_read_lock(); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + err = -ENOENT; + goto out; + } switch (cmd) { case SIOCGETMIFCNT_IN6: vr = (struct sioc_mif_req6 *)arg; - if (vr->mifi >= mrt->maxvif) - return -EINVAL; + if (vr->mifi >= mrt->maxvif) { + err = -EINVAL; + goto out; + } vr->mifi = array_index_nospec(vr->mifi, mrt->maxvif); - rcu_read_lock(); vif = &mrt->vif_table[vr->mifi]; if (VIF_EXISTS(mrt, vr->mifi)) { vr->icount = READ_ONCE(vif->pkt_in); vr->ocount = READ_ONCE(vif->pkt_out); vr->ibytes = READ_ONCE(vif->bytes_in); vr->obytes = READ_ONCE(vif->bytes_out); - rcu_read_unlock(); - return 0; + err = 0; + goto out; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto out; case SIOCGETSGCNT_IN6: sr = (struct sioc_sg_req6 *)arg; - rcu_read_lock(); c = ip6mr_cache_find(mrt, &sr->src.sin6_addr, &sr->grp.sin6_addr); if (c) { sr->pktcnt = c->_c.mfc_un.res.pkt; sr->bytecnt = c->_c.mfc_un.res.bytes; sr->wrong_if = c->_c.mfc_un.res.wrong_if; - rcu_read_unlock(); - return 0; + err = 0; + goto out; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto out; default: - return -ENOIOCTLCMD; + err = -ENOIOCTLCMD; + goto out; } + +out: + rcu_read_unlock(); + return err; } #ifdef CONFIG_COMPAT From patchwork Thu Oct 17 17:37:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840534 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2074.outbound.protection.outlook.com [40.107.249.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC1AD1E008E; Thu, 17 Oct 2024 17:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186933; cv=fail; b=B6DX2YNi/gqYmVk4dcQTMXVoFq/9ahtGoLR6+27eThowNuHFdK2gQbBMAriIApgbLuALY43mqXMZzhkg68dc7iAIY66F4sn/I23FZbuh040Npmtju0481hNKDKHiK7HvAnqSKHjAj/sJ6zEJVG8L1cISXRrAI8i7XALtMqsQCs4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186933; c=relaxed/simple; bh=AzsqNPRCn7xT/MIsou4hdgu2fqBPg/OE+TRg4NDiFhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mc3OE+ZfzAxd3qoSCZDxUTCB5p7Vf9YAgMZCIthEvspy6TBGETjSxd7DeJoSOBWf0kt5LkvQQq8xs2kkCbI5rk1q7WK+fVTOC+u/Dn06NPQ0M/7HASiN8TfOvT+K5Cn3k3YYr7G4s53DAntMh3Gy/WrwmcQwXav5C1XbSsaveFE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=hJJssVdP; arc=fail smtp.client-ip=40.107.249.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="hJJssVdP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KDn+kYPY4MeBvLcVsYO/GsjjO8rIQ2LWQFLshHjc78g6+0seLuB2TtySOY0CBRXIUst5iILlKnUHumXG47LclNDsaSVIfGSkXfhHGqfpWKNYvL9RMQlZi85OzzNQ0Ls+6c2APJZUld/w5KZFQLlVqlCJxjCpSzAMLoBvfBuWscA2PtKeaoHkZG0dnytl43aYWV31h8iA3COmB19UsoqMDL4GZxyTRN8dmxhYvUhkYXDZ26apRn58k44ocyh236YwkATn8Txs3DB3gyMgyzIkDfgoaKtiph3dqixpSCHPZ6KNpjl374k3Q4We3Cdv4smzbh9Ed2Eb6yHWhZK0Fmq2YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Bc62ejWQEAFY/jjmMhFTB2GtcEkp5ZuMwW+WJaDXHcY=; b=kgJ6AlC/1IWoAGkSc0i8Ebkzb9C5IsTrx+8ftRIa3SQ3gyF5jIKb0BUZDWEe+tTo/rphxOttmS9dS8BpC+jXbalp4hbeco1SRE1dgQWGssAJ1aXuEifzL4fga48qOSIz0dh2m8+rGhT4HTb0ujEZB58iQak7kMCDTj1laYWZ1zXHard8/VE8wSHhsHDADDq6pjqX2DndBWB1mSyUpzAM5gh/bjPDY8ldpwYYVp6kcrJ9fM4DPXDboDRuf1xhlwSLiQjOz12YsMjUJL2wF6kLAhXVbdH6s8Zs4+Oh045GP3gq/oi5SthduRbUKEkt6FQ56BaYBZNuFE7mAd1yXDwPCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bc62ejWQEAFY/jjmMhFTB2GtcEkp5ZuMwW+WJaDXHcY=; b=hJJssVdP4RzvE6xwfgKqYl0T6/9d09DOiMRsuZRzGNptKjJZPW8qPQW2IjCTtJH9AOcJinOlti7ae2Bv78EnW4a13ecDB3FtIEjS+FDmSiVdldSqzeEE9S21IIIka+zVlHRqa/PswCQWHubBrxQ92eLt8xVuWpACciTpf0jCVYxdfspT7HBiUQbgNqGuKa486H0p2DVsIcUWA5WYhvH/UHVEYKj7FQ4cwVmqvcMtXnSbzG4OikApijNspjjnDHFqkhC/mbbfdBNAHAImeP/dMArzZWwMWfG53WAEWCLqJ9ASsJbdUBGXvYDnNbjtyIlLnUWTkHbgrrvXHbWZre27ow== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:41:53 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:41:53 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 03/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_compat_ioctl() Date: Thu, 17 Oct 2024 19:37:45 +0200 Message-ID: <20241017174109.85717-4-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: ebbf071a-8b64-4419-75e2-08dceed2f67b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 9tSPrt0fLlpknzmCckgQo2rP5l+3L0oiF+Csh1ncR5tli2oRm87YFbrbXlG0VW5+qOSlSPQwKvfKWZYYXsTmVLeQtg8ZcmcB62uIdqqiPUg07AAHrh+6oQQnRe+22ggvgwXNyEn+NiaDkY7IUTSbO+4rIydpL+L1szkPZy0PpCrIGbV17o148nTHQIT40Oh9Np1xRktsSgFwBK4blTzWRyse0dgaT7FCdcJf08jPFC28t2uVGjpTh2lpZCt2Pj5DF6whQ5GgEbfK5IGmjYwepuehWnuLCyQnlJuG0EDkaFROOLBk2Cv8GrxDIsuh3qoaCltw5uy7rxEx+GSbYVi5Bg9h66kpeMnMSVpQozdARo/SnqjWlorSJCMV7GsG/QUr/S8WYv0EJI5Z/mJcYXBorL4Z+RnxeTCkB3BOGjlKRSRkE4LR9goOjcyOHPQLaJniAOY6C0S2y1MupUGZQM65tXpeUJZFcL62uJI/egc1G8aRt42kiuE66W2ZsGdKjveKYneVhwFvYA/IsZUHTJphZI6PuZfGZybpi7cHbWWigeZ7hnazBgnTjyhl7acIPAyqpfLSns3d7+iREL3e7aoYItAXiR0BrTxfwymXjpZjJ1eo+t1KPRoGSAVH5kfCWyWn2h7HNfUJJMemNgbGVhyNBULFJFguDfCIs4kB8oqCMRVhQT8dFjQrjd8rwNrcSo801VPc4KljEYoWlCcYJFACwoUCaVyNNLyv3BryBUUPNYL3rLD9XKxTfIG5w1tvkEIyxpJcdxb2C94dPMPRPQmqOpnjXGEAK75Bt9c5nIRwzk3ggPtxHpiiR2IWvtI4JSdYb90o+dnWEXfr4/2xVdf3ZGZi2uAntFZz7pc8DWAYEuS5OlVCiq8/yKxftWqncApymL/vwoOLW4fx6pZaHlkfzDx8gSJMoCpCvZugTMZruVcHMwMnqKLmYrwO4h66QUzZGbrGhncTLBvY4ejs2+5XuYx69nfYLNYyzbkE03dngpYnjkDKDHfj5AU3vxEnQ/aWh5JKOmlk7FkkdOY9v6zb7EOzxUZoZcQ2VZKgXNCS+qrF8kVHqyey6k8I9NR3U9Y9D324T/431EZxu5D2afPliUeJL6dWa4w1IKfij3k3jC53CVTyfl1LncbuQ9xi+iHpCJu3vx0WV2yZBpCiJAsGZ4eFL7b1QQoqxzNPGtrSgoeP2Xeg2ELyyskxcn5NemZA46VTmdW+6sAz3Dk6mF4HbISewaYJX8gu/El/0fR2PITllX/4gCNNu8E0E9VQSRPvxwj24a8TTWCLJQ13Zn44ye+xeZ2cBNNp24l267QLmfJSD2q5rb+SdoHd0lN07xcDNtIX+DFlPf5bjp7YJ0iK869BbGkzQ5wKXPRqJKDI/6k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PS/3oMLCatIzycVgxmwddsIl3+dC0LjV292X/bPX8EJcttyEp4MH0SxJTHDeJBKjOIwZiWgvzXtsMv0cv1ATd4uK2Ebwg35Np8T44IQZIZDXXxCAT7berVDIyCkpFKn2wG0uNVqoK6FEdiUHFcjrN5WjsqkQNoQCNtKKxZpIi2ukE7WngRIemv//+wT2BXsd6D9s52tJOkCI2AR4e+LWgRJHOl45sSDTJ65baZVw2XFZcq1W/8Y3nXbyn8wdKgcSilern1D6c8wMRxOmCJiyhYzAcEHh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p7ODbhVXglD8uRR6is9Ckm77np/VjJfIEamY2Wjh13rx/HJkBTUjFtgv2ru7+dePCa/gA4es87XZBZevwL9MUdMKuad2cecWijyPPlcFgOg61RVF8owUFP8ZYzwmOQ8vJ/MRM9UQgkOx+juNIWIvFq0vHxDBEap4pgCzhPMRYft3DzabRaM52yhtR77Xb9HmwUSgFvwZ8ZxBeqa+Jf6M0kvx7PJe15eM8BaHsFgEsIUV5jwdDHVN8VCUFccHZ5S+vg6+h1XAnA== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebbf071a-8b64-4419-75e2-08dceed2f67b X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:42.6425 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sMZqbtFPxuWaDDM87Iss6DudUq2K4wcIgp8G1etyaUKhI9py4QAq6lLCZxsf/QzS8EEei2m7DNp57Nt0uZfj8hDp1BLQZvvZvp5TeiLPxZ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Copy from user space must be performed beforehand as we are not allowed to sleep under RCU lock. Signed-off-by: Stefan Wiehler Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") --- net/ipv6/ip6mr.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 19ce010016b9..968642bde8f8 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1964,19 +1964,35 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) struct mfc6_cache *c; struct net *net = sock_net(sk); struct mr_table *mrt; - - mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + int err; switch (cmd) { case SIOCGETMIFCNT_IN6: if (copy_from_user(&vr, arg, sizeof(vr))) return -EFAULT; - if (vr.mifi >= mrt->maxvif) - return -EINVAL; + break; + case SIOCGETSGCNT_IN6: + if (copy_from_user(&sr, arg, sizeof(sr))) + return -EFAULT; + break; + default: + return -ENOIOCTLCMD; + } + + rcu_read_lock(); + mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); + if (!mrt) { + err = -ENOENT; + goto out; + } + + switch (cmd) { + case SIOCGETMIFCNT_IN6: + if (vr.mifi >= mrt->maxvif) { + err = -EINVAL; + goto out; + } vr.mifi = array_index_nospec(vr.mifi, mrt->maxvif); - rcu_read_lock(); vif = &mrt->vif_table[vr.mifi]; if (VIF_EXISTS(mrt, vr.mifi)) { vr.icount = READ_ONCE(vif->pkt_in); @@ -1989,13 +2005,9 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) return -EFAULT; return 0; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto out; case SIOCGETSGCNT_IN6: - if (copy_from_user(&sr, arg, sizeof(sr))) - return -EFAULT; - - rcu_read_lock(); c = ip6mr_cache_find(mrt, &sr.src.sin6_addr, &sr.grp.sin6_addr); if (c) { sr.pktcnt = c->_c.mfc_un.res.pkt; @@ -2007,11 +2019,13 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) return -EFAULT; return 0; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; - default: - return -ENOIOCTLCMD; + err = -EADDRNOTAVAIL; + goto out; } + +out: + rcu_read_unlock(); + return err; } #endif From patchwork Thu Oct 17 17:37:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840533 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2077.outbound.protection.outlook.com [40.107.241.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EDE61DFE2A; Thu, 17 Oct 2024 17:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186932; cv=fail; b=FYJl9QJeH9QbqAnvL01stSukteTY9RWTIhR4MSjmyF6pFxZIsH2OVDEEe+J/DPxuBgwM3KMY24ZWxZmXBtWr2hKTgiz4sVBVoKqlkKwV4JjTRq6M2Iq9hKi719EPjRPYO7AXeFCslVyapzwu50AF6SYRGSEJ51g17ibbL7rtPeg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186932; c=relaxed/simple; bh=7XajWwwKYUyPnHl4RxdyG7BDoP7pfbQwp3SHYG4Utqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OEf8gG3+l5F8478TGypdXPjWeohMM12GxkWZEX0ODcxfht0gUGEPsWGRacnoblYCJThjgoFe/8/TxQgq6WRFQyVLbZdR6vKttC0LDLK2eGM1zRlTX+NMNTNkgQL1wN0k0xhvVz8M4VB6XEYwp4aJ2pau9VhxzmRLAOlwPZ5e3r0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=Ai0cAhS+; arc=fail smtp.client-ip=40.107.241.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="Ai0cAhS+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZS4qNxEolNDCR48G19KkWlHDOflaT2rITI616EnYwQ+T1THOAe0vz80qtUSVTtycXD9ICrhqxYxx1pgVeP2v9Z/NgCddtZFC7KmLo9UFVlQsQU6eWJ1/MN9PB+BWEITfgK8nxSJ/8uUh/80l62CSrKqenQ5WDgx81nT+SoSGlfhCypycrgJPhmTUXiWTNwXFBvkh0fF7KXs8jAozMezlEJc+AJIuXjN5KGTUjSjT0K/4XaAEMCnfy8pVHcdnerjR1+U0PbKQ9JFh2a0I9+yWbZxPvzUc4kfVRG5qlgqLj4izMvicZJW04OGgIscluIiiumM1VCUiFrUkHb1XDRvNYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=I3+JfUc7sae+MSPXt5wBH65gqbhnwiyq8IxPP5WrClY=; b=G1x/vE6BVmPxsbn3mHAu9yn7rbwB2wf3F6UaESiiNNswAtVKEYWzIAgWL3EKetHF8PQcvoEsydIG0a8nYXaxAB83FbB4mwxm3AcUWj4K3kKqIROIpfcHNe+eNgZbC1TUzk/i3bOiwVG5ImzgrVE6X5Pv5Fyj19ZV90qnoUAZJmku8X39LyUMTlI7AHVIL4pn3Jevd+EssQ1DsRK5ZFOW8J5Il/BcAjvc8d/voibDhI0Y/+soReSfEB/SrxlFzFYHNp4+KiLYh1P3RXR9GZIIVbF1eEr+xdVv6nkGNEVNK+GQ4ABll5CTXTJcnP34fERAsGhqudlBN8Qns9ubYUQB5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I3+JfUc7sae+MSPXt5wBH65gqbhnwiyq8IxPP5WrClY=; b=Ai0cAhS+tKbUs4C9TVfasxdLufeorAOYygcdSyJqVWCfNQOPP/Q4B+MFUgGyR4WOJQ7lgToa+pCKEV2uZCWZ1sU8iWcLD8fibGnw5KIfAsQ4bLoi6qa6M62y/ug58P54ee+xTycAqqRS6rSI6XTL/iLNCYedsBMPEnRiRhJbl0wo3TFy/SoLIx3i7KZEZ605g9KehH014ug35IcJwHMRYx9D0xU4ykD51VXAueAgj88ASHa5juNe00xWITZZiAwb58rRd98NY6m3z9qH7Fjxr/8yaRdVfPflTu+y2Y70XFw9RNxiI8SmEk5/EBFrHvCq+jYBrdpg7nC3TBpkWZtluw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:41:53 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:41:53 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 04/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_get_route() Date: Thu, 17 Oct 2024 19:37:46 +0200 Message-ID: <20241017174109.85717-5-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: 2905dc10-1fda-4910-8ceb-08dceed2f6a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: J4/BPqGqtw01PLo/2hDvY2Z5Xk50OTBxzJ0w+a6pN1D7EQDyOxqL0G+axIp39u3MRx8nSqXueGPpFFg+5szvJtZu/oGSamF0dToMSfQJxfy2Vt7co9Maogl6P0y2sAnkjij5vcZbDSN8Pm+vpFB5u4gA6O6498N6Vy7IUJAvYB6wpk4tSRACzFtYBTv9Ob5kazoJQOnRZWK3ef/l3bjiQXg06zTdTYcHGWLx5O/f0D80WXNuMzLXbqOJnSci9/i9RzGVyvaLayn4pvyIybeK8/94A0V7T9OejfW6TwAH7SAQRklJ4eOqMkNMFCOwliFvmR50pJh6Ay/bBpoFZepjdKuvZkp4ocFELivrXIId9F4vcIfiu1zuMGu8a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NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vWvR96hykHKLqNqxqmnUwLg0ftJfD/p8Xwybk77Ow/c6Ajcpe0TeRpqt6ytRwl92lvM0psHG8HQ1bWUsN4sRrnIknm9bCRsIduo1fSQN0kHr3xYo2WAJ8nS3sLqVss5W5SLRWtp20ypT5ws6zE5uRqBMiXc5bFYx9EKMjd85Xo9xrEyyYJOinynib+MNZIeZ4DZ0Kp2lOHD9tw5fuGq24Ji2enKWzVarLk/YzBb5SuY0zNR7q6sJv/XyssMmBrGEqWNkEyC/lTQdsvEWWv8iFh/9mv7YN250cnXZ4TjYvXnqGhexl2cetsmUUd+BgfDxXYZKu6dti+y3r5NRUSOP4erdOeBGzRxMNzjVj/xgYIHQRLdXJlexobCvXpaPiNT5Fld9tanIHiSVqtrOOyIRWb+tZV9wIT8Xe+H/qKtbn21m1eWisoKhxEz8ZGbwofz6GJR8Qi4ssVhIWXmpnGYruIvZ/i9CM9a4fxsXGOWbe9+CgXKX+4XlYhLrpmx2o6AwwRFp4RM2FsOCO7aaqiBGnlhktdPtgkEH0xVCWngoZ1W5M2xmz3skyLqZn5AEivqnN+437GSrbTWBMimgJxxfzBFPhU2H7ne2Lr3S+fPVyhFIlhkCyghD1jFhu1mUd9Fnix1dWS9LIyKFSFsUvdqEcxIGIFz4BfDnxM+x69O6AKdj1DUMAzb4tWzDWUmMPExhSuF9U9ZRKSTZTE71YxmEE6xBXAY2sRmayuctPvFzeLwD68foNofGSH2Z//rEZumkK4ixPYRdHaCowYtd0lQGtR6Upx3obfrYK+EcjWYsBKuJdF3feA6Xl+LSZQ5L6aiE4G8dvTVnI3MSoitj2OMz7TWLaZ1zN2l0bc/KucmndmKVxrvjNNF1f8fhuMC8iyOT0n76Sj+Kkdz/pZPpQmNiLQUxK3YBijiQuzEq3OmtN/duQKEw9oUHpI9XJrG+5dGKUcCqJg6HTPu6eENaw7xdLqMvkiZogR//Wilqlwxqyk3cEkltKNlAYCcy7I9kdTGV1z/6GJEknKDHhI9yBYSG8qF9wAOFHXaxcsAdlShrOk4x0HPhdkySyUXvDdrr3sicz2hXRs2qY/1rckHlP56ZqsvRtOISkRFfdIYFF2bOcyQ64iF7AaFYdEYyLNa8vN+Gd5TIIxQDKiwvuw05h0Iv3xJEUjjd9uQkd99fqWwPeF2jJq4QPyj8J7+yuku3iW89RK4PJuZXmRb0wQjMgykirMafA93x4w4d99mHJUlksY9RQH/588IvMu+8uwOiyTrwOVwOGhkev059ufJQXT1JZj1kOXfYkfZYbsxBdDUsxUDoKVvhHDzgoT05O/PlbNsUWw7yNIhlIkIdEytp/URyOgaSNtqFXN96diUp+wrK27BJk6+3FUCinTS84sHt681ehAcBxSP3G1zOTg1GjSfd6ZMyDKgH5BEgcba5Bq/jOKjrNRVQOKEly8CleIqQOT2Yd1wHG/pa4g70C3exKBO2Yr8PTjs8n6tSH8s/kf5Rkd2nIrcCdvcq6Tiu32CMbnm64AuWQZLoWDSOfohCU112Ptz35eNqWub2yPawHgdtKZQ3a4IpXaTdrJmfGTPEbLuao5ULX6sSheeK3jBir5Y25g== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2905dc10-1fda-4910-8ceb-08dceed2f6a9 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:42.9472 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1pV4uBIijan+ywtYRhskFxGl86Sc/R8jn0g1pdxPh3iFOf+5kiHbyOmRwCq1w/CI/EbLnsK2lnxWnVDkygub+lpihOGFYX2NdfMmirZ3BqY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Signed-off-by: Stefan Wiehler Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") --- net/ipv6/ip6mr.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 968642bde8f8..017f9e31edfb 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -2303,11 +2303,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, struct mfc6_cache *cache; struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); + rcu_read_lock(); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + err = -ENOENT; + goto out; + } - rcu_read_lock(); cache = ip6mr_cache_find(mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr); if (!cache && skb->dev) { int vif = ip6mr_find_vif(mrt, skb->dev); @@ -2325,15 +2327,15 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, dev = skb->dev; if (!dev || (vif = ip6mr_find_vif(mrt, dev)) < 0) { - rcu_read_unlock(); - return -ENODEV; + err = -ENODEV; + goto out; } /* really correct? */ skb2 = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC); if (!skb2) { - rcu_read_unlock(); - return -ENOMEM; + err = -ENOMEM; + goto out; } NETLINK_CB(skb2).portid = portid; @@ -2355,12 +2357,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, iph->daddr = rt->rt6i_dst.addr; err = ip6mr_cache_unresolved(mrt, vif, skb2, dev); - rcu_read_unlock(); - return err; + goto out; } err = mr_fill_mroute(mrt, skb, &cache->_c, rtm); + +out: rcu_read_unlock(); return err; } From patchwork Thu Oct 17 17:37:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840535 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2077.outbound.protection.outlook.com [40.107.241.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB2071E0B64; Thu, 17 Oct 2024 17:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186938; cv=fail; b=fUB8HPg2MpA3J6uSMPojlHzYaBAqzsbX9L6qMNV8ySCo2P5ll0bo0tSXDLmvmmolqXnqat7vzZuNIjqSKmGcKocV7gIXvpQuPyknrzjlqTUwx7OhuC0KHolyXI91xcWejukBGHt/3WD4ifxpYU+AViqJr1Pb/27y7vcTtO/2H4E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186938; c=relaxed/simple; bh=CV7DLPOS3ZzbAX/Zx0kScfL8ePrssFXGJsUA6SSy2uY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=kUGJ+cRPhnh5VH6RC9eTgzXcnR5GnserTw2nnn2/xvt0JVp8ZzFa3i3Lcw/GMQ22ZhKVvrLWO6ZRk39Tx/Z6fxgSDBJ2j56UC/I8WqLDqokoR/O+kKXaDgZhsgkY3BZVWDzJ9axQYggOTzjmkW4TZty7sbsM6fnxyWPQ+aHgdNs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=TgpmGOSe; arc=fail smtp.client-ip=40.107.241.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="TgpmGOSe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oPAXuhbnf9CfAmeAL8bSv1BTZpgu76qXiZ4XancCldRvJ08lqacg1d2SDhesFMW88P6YtJvaLBSvsUVRsvBHe68gB5rkHS9qhIGo0kxbZ70bKoywZQ2m+90NlYiM70/M942sJ0WzQjWka2iCW8UkYsOSVNJEsr/hXFDY/Oxl0snsCRMMCFunaQV419ChhrQ76KjjBS0CeYyugMCwZoINRoHhyc5hizf0p1zfBdFlUzyI1Mk8h/gowwXq58cdjbqv8aYadJFLpv6loaQ5gtD/xgAl+wkF0l/viwYOFVtsjkLHb3LvIiLwAzLEzEiLoua6UgZWCRgbwEhgt8c80fAHig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=yhFnquXnBlFEfFr68qI6NMcJ6v8CKDiUdj/NHobyRMg=; b=JN3CGzLkkqJk44Am1MUnbximyVHENvzxfDvDjwl+r9gGCDEVcIfGEaYa2wrQlOuY8WP5M9bHd7adYRYmPGfEFxYhbpbEZv/+bFRKsaOpY3FBTobYwFtTeinWhNepN7uA71RHzx+Fl6Bw9bpd/Zglp/BPcO4x7O26MSxVoyBlrM0VsC9rVzZxkbSD72o9R3ABbW21ljecEzCM7VkugYfALRiG8EzzYGYIxlupr99AqpR6QYHoOFe8r2Ak8Ii+f4agB+r5HCNcTbf5hT3HQMvSDel30lNurb66F1KqS7tAZ2rX4aAb//oVBELM0TBBRD1/FuusFQZmpNBlgI2ek9j4YQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yhFnquXnBlFEfFr68qI6NMcJ6v8CKDiUdj/NHobyRMg=; b=TgpmGOSebIzjod6ifG1YUP74Hkz/R4TYZOEhpLSylDRY3ikVQrQZhHEQRVh2e42SADmkScRtgC1PSIvFYkPpZRXWGZCyIGNkiHlliSVwausMTlnv9tQjEXTXGfOaFeTAGXWQ2+zpnm2QKSF3QhMIFllBllp5vJa0dPoonqc1AwPvrzV6mqfV4TxZe3VYUQfT+KoHkZ/e5bwc5pyqTMDMuJm+LrEswZk0iQXZYSgDgsi1FHmTJy3Jb7ecJaWt6rZrprnrIP0q3RcjwzWbnViIlyfMQUcw0Qn3g3d2jAK6NZhnTF8OdnTUTNMNsalVqDbPZZiYm0N4zENJG9qW5Bs4Dw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:42:01 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:42:01 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 05/10] ip6mr: Lock RTNL before ip6mr_new_table() call in ip6mr_rules_init() Date: Thu, 17 Oct 2024 19:37:47 +0200 Message-ID: <20241017174109.85717-6-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f7be4bb-d4f4-42bf-49be-08dceed2f6d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: AT4SGStjSCIbXX7DG8zFXX4RNfiDUZ9X23/BEsUl/YMJZG0WNmzmN/6Z7NEBpOo86YKPab4ttx8NDN3ahOeQw6qvAFMxb/xsJmwQb1wZy1cdMvTMmBh1o11bPauUdml4a1wLemZpqrZGhHN0uSnBeZNRV4kSwRUWLSoSEdqkIj9nhraJbLKbPVdW2FAwLJIKS4aE+eAYXFCwXUkA4GWod6ACyrx+ih/fPmb1ZBY3gDjEAJhN5sOLHKkLPYwluwZPgACB9Th9KMTDA9sDFi0hNCg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dE2nXKFIykHkzE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JrAsSJGx5/FyULILmI6f+n9UF8/irNjl67FMp8321FfySgSfEaAf9jKJjWPaxQcKVQzZBl4L4kGdSPpycl7DprCrf4rlHXo7v20z5jLKen9fVMkRXIOdRpajVbH+TkqEWlZKt9tMzhSsor+DEdyv9LhLAMkVa8SMj6I6vafU1g6vHp4FJq5oPuG1G1pYND24fN3tMbhiYKmOB9HPTfKNStptmdpl+KPKavB6loUryYSVKI0ZKTjY+tAGFa+4Jhh57fXS6VqCzAii/1M3FsY7k0pn/cWARpZy+I8AhSxMtdexsXlxWfX/nMHdU/gOl6PcMCA6D9inGDQFi/ff2jyOYaQG+rJWsjb215Sbjbs50lpeiwy2/IOyU1f4DteCgPl6BFBC0qfjNwGT7jkFwwmvQVyvnXgxoPbfks6bNrMmZCFlg+nlEbe2dYbS6tCftryTs9MheWJm8BKdMBDHOgu3QgzYWNLClrtijTRVv+lV5xgtApYM8q7lIjOiEJHPjYJvquyMNnrf9u1BP2MS+GA8PyOnD4lJe/6J52gOJnffzSRNl04RJXtQ4W8cJ8D5Xhp55c0llWQfHSBaQlcXhcllCOiEBcdiaZBWob7+ji2ll9bcqpCIbNa6n1QRZBvJ4uCSUljJseVjZJtWVsNKX/i5ksTUOk+yynGDjMXZEERuX3X9AhxUDlYhgSFAyeG/hXlCov5wnH4bKCAR301/JRWOkM3/S9AquwbLp/u7PgpfBJ3ZoXKSeAU0i2wrWv0wKnXnJHmFjjQg7+DOydQQVpdDj8PggwdKLxG5SSWjl5FITSDqVdDN/2n+JVt5KODDiOfrccCJ8O2i3f8fRuRQ8l+EwLFjfyEb/kfXzPRqZCjyvF7v/p0PJFuXITvB5tpnP2m/qUgCWiwde9YW9sd42Vt+zHZ1u49+OiNrbcV8FkgdjGkEO1DgS2DhwLvXB7VUoHFSzGGtBrdRygmOsY/SQDmbR+QjOqaagJNhyBkMtEDZALyXKs50trsplipzgG/2nssV6tkwpTaZPsn/hbV/B8EZYzNgU21UvgIqcp8CCcbJPcZX0D+kFCrOcNccSMRCQqtG88CCGOgjDQ4X72TJWDpY8NpvVt7G0+/jr/FbxwA5Ih19exdob/VVquikJD0v+U6M748oqblR3KundECQOfsDEWJWpa0whxYYCgbgzJYun6OqGQL0toUj3UqYUcgxfoNq0VluKizYqoC/FYpP+qmTro8kquby6zUTlCDpe+/fE1Ynr2mX/WzeqOD2yZZ7COXmLL1QVqAxz5pa6TfL/rWRErE1tYhjiVhyuoJvSaMNQbH+AfXxrOh71tBuaVL9w8FbW5T6zErQCKK6XCEXyMuHZlzUegIPf8gkq+RR8GDXII2UIdGjqXh03T8F8uTCWsP39xrn0qQ515sRfrNVSHONYmGfBbbzaje4ZHgAGNaf7UC7XFQI4ROyfe+fbd/L/z8WPUoP+bLorfpafIC69Qg5OyCANciBUcahif8jt2In8bWsNnZVVxWXaxYY2WEtZ67PgxxHIlik4pZEqitIaT2LMd2BjgpT11iV53m47waX9mgLAOFHQQArq58rcH4yzckwfCEGF4ci1h5qB9koPbP1TA== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f7be4bb-d4f4-42bf-49be-08dceed2f6d8 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:43.2535 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nj9a3DNXAKiS83upQccyOyxwCXWg3lEmk0Y/QwUbmxe9Vt1k3FjoGodD/JK2uE2U/fxmg9yeGVDjEKRIfhhWQzdlZ38wtE+HjaAWmG6bV6s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Since mr_table_alloc() can sleep, we call ip6mr_new_table() under the RTNL lock. Detected by Lockdep-RCU: [ 10.247131] WARNING: suspicious RCU usage [ 10.247133] 6.1.103-49518b10de-nokia_sm_x86 #1 Not tainted [ 10.247135] ----------------------------- [ 10.247137] /net/ipv6/ip6mr.c:131 RCU-list traversed in non-reader section!! [ 10.247140] other info that might help us debug this: [ 10.247142] rcu_scheduler_active = 2, debug_locks = 1 [ 10.247144] 1 lock held by swapper/0/1: [ 10.247147] #0: ffffffff82b374d0 (pernet_ops_rwsem){+.+.}-{3:3}, at: register_pernet_subsys+0x15/0x40 [ 10.247164] stack backtrace: [ 10.247166] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.1.103-49518b10de-nokia_sm_x86 #1 [ 10.247170] Hardware name: Nokia Asil/Default string, BIOS 0ACNA114 07/18/2024 [ 10.247175] Call Trace: [ 10.247178] [ 10.247181] dump_stack_lvl+0xb7/0xe9 [ 10.247189] lockdep_rcu_suspicious.cold+0x2d/0x64 [ 10.247198] ip6mr_get_table+0x8a/0x90 [ 10.247203] ip6mr_net_init+0x7c/0x200 [ 10.247209] ops_init+0x37/0x1f0 [ 10.247215] register_pernet_operations+0x129/0x230 [ 10.247221] ? af_unix_init+0xca/0xca [ 10.247227] register_pernet_subsys+0x24/0x40 [ 10.247231] ip6_mr_init+0x42/0xf2 [ 10.247235] inet6_init+0x133/0x3b9 [ 10.247238] do_one_initcall+0x74/0x290 [ 10.247247] kernel_init_freeable+0x251/0x294 [ 10.247253] ? rest_init+0x174/0x174 [ 10.247257] kernel_init+0x16/0x12c [ 10.247260] ret_from_fork+0x1f/0x30 [ 10.247271] Signed-off-by: Stefan Wiehler Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") --- net/ipv6/ip6mr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 017f9e31edfb..9bf42aafc7f0 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -236,11 +236,13 @@ static int __net_init ip6mr_rules_init(struct net *net) INIT_LIST_HEAD(&net->ipv6.mr6_tables); + rtnl_lock(); mrt = ip6mr_new_table(net, RT6_TABLE_DFLT); if (IS_ERR(mrt)) { err = PTR_ERR(mrt); goto err1; } + rtnl_unlock(); err = fib_default_rule_add(ops, 0x7fff, RT6_TABLE_DFLT, 0); if (err < 0) @@ -254,6 +256,7 @@ static int __net_init ip6mr_rules_init(struct net *net) ip6mr_free_table(mrt); rtnl_unlock(); err1: + rtnl_unlock(); fib_rules_unregister(ops); return err; } From patchwork Thu Oct 17 17:37:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840536 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2074.outbound.protection.outlook.com [40.107.249.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 788711E0B7F; Thu, 17 Oct 2024 17:42:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186938; cv=fail; b=tKm1a2ADtRxlD1f0klF7s7BRc47APup5dpX9RwYDdaTe9s1U8PHbOXMAzFAoVxkp72eBI70au0snEJSOaVb+rV+AA/vtp2N0mrjQQR9U3fM8GaUD7cZfhoIPqel2P5052/ATPxtL5T/lmwOTrt5Ies/AFP+KVrkUxt1bkfn+ohw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186938; c=relaxed/simple; bh=iaXMrJ0vaF2emybVkxW//Ik8cBssajZPiz9MRv/G1zM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=WwVcczmpSVqEEe1PL/1O+0WLTPmyK+r93zwPolyBltFVMR0R73fNRAE6gIt/Kg1Mn2fPvxpIjmzYohLsrFHSi20sHMzyBsAVFstsgD0rw9CHwxNn5OhQT9qFLn5uQSB0s34NIcYyWuAkO1S4fZ+lxboMqgm0sGJciROzyB9xjyM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=MjXcuti1; arc=fail smtp.client-ip=40.107.249.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="MjXcuti1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pBannn/5EDennmA8QSnKAi8nwqJKzD9F/NnBlisPUzcSCQEI8DI2EhgTUymhqGzeG0nrj3fjlxk/nXiKzqFEccSjEJ+ELaJaiv+S1YZGCNFa/5vaIgCdjMm2VjY2YY5CTEfX+aIIPSYT93PhwHcwWOAJ5i4sBoN7G18o0SFRqKDU3yTlx8vFUdue1vRMkAG3Hv/fGgsXaj2qLToGuO2204VkSfBJARHiXSbE97yZ2TZssVCfUcpHRYrOGnTQy7MSDKJi+UXXgtM5rFXXyJNfgSy21spSzsmmbERl3O041nXEQTdryqDjVypdzlg/CVZy2/I2GYYyd7RY6tUXEQH1KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ReSQj0l6DZ/BD4r3nkGqyXuyPDGJTmJHtKrO8kW7Hi4=; b=suagHEI805rfnShrABbRK27s7bhv8VgRO9r3Eze3ExZKUKauk2PsFMpEt2Xvgu3xsW3QLtQkugn9NoPWesa678olIs7FH59GByxUowGQN2Z2iclzvtMnTgS0IoN64xwUv1gzs5xKSt+7sRUYXbqa4nZw1kDiuOutKK9yOtDA50/mVHc/FmK8Dp33OgY443/9zbOgQb9RBxfVBp/Ua7ulRNWu0E8VRVUDA8aCboPCqp+uq/qZODNbCXJp4gkpnJTUdliqK+ntrB8pepkELmUjusFuNQ/RbZiO1bqTfw0uB3+q4eIq71m+jjtoDJ84c5fDppE+fazMsddHf4qchIHU8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ReSQj0l6DZ/BD4r3nkGqyXuyPDGJTmJHtKrO8kW7Hi4=; b=MjXcuti1ibgX6z/9hCMfmTD0yc5P+JIG6Pj6O1O4xfclDkXzkiNmmSTCaAdEYz+OtuGLDEht7k/v3jYQwf7mE2nyLZozErICsTaHzFi6V7dd1iF+//c025U2ZEviSHZjdsbf34WWDFC0bijK3MIwsAHM1MrbRl4M4TvUt9L8pILH37lf+88oyzTgeqVAOWiFRkkBP2vZkczZm9sAIXxNBB5nLVeLYha5zRfsm5Nj2143fEjer568AooJGTTsI1vvvXNA4LjACCZpz0nWlMTtmYTjEyNpdSbluam8BAAp4FsqVutWfI6aWmTtKSgzoPY1sVLqesYtM4fgAIVwyyQjzA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:42:01 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:42:01 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 06/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_mfc_seq_start() Date: Thu, 17 Oct 2024 19:37:48 +0200 Message-ID: <20241017174109.85717-7-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: dbc3efb5-138a-4153-482f-08dceed2f707 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 3enHzkiBNbRhFMdgzsOEsMbZJQUtmbhGHwvhfG4Q+k5khty4fTzm/+lCA3/jFA6oKxqQIIOE7IkVL9PpTmvFb5v+QYqAZqKqqIMxukVmGmEFF73HhfmSdejQFfmUkHc5oSbG4rYGtT4Al/j/CRVyAR/GGE6xFKhvi31snVLoQ4kzNT0zjCgD2kCu2GEnbB14iL1+uHYmnL0L4P0bkAnmbWnailVzwTx+vMbNfge9EhLMODDJfzqrx+u84D/XtFk8cJVi5e/QA7GhXYiIXZ2WfDSOqKM7BchSXADr7kc4xEhlVaHsoiI7WDwtQE5o4CyqaAMbq6clzrmdW/uP2/1QVhFi0yDWL43jIurrs6v/b+cKPweqy2VJ553G5vYHccJPRN6IXpwCeeatZXUVIhQua/SHaULt0vBBBAh533jlSSkUNeBHgViPKJSePfE7oRbocB2o75Jqrwl3ZqljIHOpS3DkUaZKr04nDyDf4fvF9W8njZfibZFTC8ROlgSo1EUW05ErB3AaqFavAoVZkuJCxHDCULyO1wKKZ1RAlzctOaqNudHun8yKT0TTbvLpH15xQB41gc8M/J90nh5mnzRigrGvD6WuV1ukHVcjeGyeZKuPupTpjGrHy8B/kvrmEf9uScT7V8uPdiKiaJ80PaajSnsvKVDchvlRdyBjaIvpyYhOLYkPH3vWQZLd4kzoKP4NZa1qSRHC8+XTAaxh66kaYQ725e5yQrGlyPFr4MYj5XOO6tyr1FI1HMDwJk/PMMY0gQPSR54e3iYmREIQHMKhl95y9Mr3pKE21mrjaR6m7+VUKgz+6QVLnRI66wxdSuzwL1LS6I+rUu/kTxfE5lzPl7ifeobmfgPLuR45W7jN99SZHmmfaEyhiguQo/q8P3iK5MbM+s7k4tUwyi/7iowe1phBqNdK42Vj6rGqq3+ogXKCMsRsXZBNXmQXHD3wNT9aoXb6FP1Z8mNW/UtCycMxxgoiq9j0Qk31hmn8LYXy0gdBs07UeDWwOTqCvI7PVTH4TObcIvLqnfaA/Gyq8OeEjbKXmSDZA1kFG29Pvy4WNBWOHZAwjXulYzVoq+ltZ6advSUPzvEjguoI8+pf+tFft01Gez2XWG8u+ymAZTxdxmK9Rt3aBFHzhzxfBbXhEGPy7iai+E8SrE5ZtzGnBblMeRLx2KzE771ZeQEY8NyX0fN2gpq8x0Ro4WEJIWutndue3wQdItbOSWUtLxHBfJIak0ej+gSMlVTQHppLwEFJguClapThuK/vj8b9LestHv2wYMdokCT9aT6DYFQadMF/Gcazge/WD79yopmBLYlTtDY3PGsYBTzFqUzIPgLkf4Mj23RN3dAyUtAq3ggVkXAlqWtWigrgvpj/0qKEc9gi2xo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kjAcMKmaw4dg76UfklTPaQVh/IkvGAVIrTz28qM+zmvq6tNUc1cdQ8SkWW1eSEYFOmBpNjVsHX8eWdV0/zT8LSX1HGb4ugh/qAyQN4ujmu4LlrlS+Yrzt8/Jd7wnwz+uib9aykIaLz2bjAy+4hdffMJZElClugQQ3oVwJiK1xE+ZwhHJ5XfnTNahX5G/rsXUwzy+WU+fT3/egianGngvZj4Pf7KoV+4cUO5HHJcrRCS3+kAgfY3HCjmC+AyCDhz0u7xhO6hmAFDAdGAo4YRCn1QfF98B/U1jqTEhFxFy29f4MlHG/TI16wQEhg+VRVQ8i+dxhcwWcX+p/Q9yYZtwwWdvz3z2xvHvOxsPevzqYgP0DlhLdZqWpsMgapug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e/BxbVgBtac1arH2BVQnLrkWhIADlnO67NcG4HH7ElhLkgUq0Jchw7MFBZ43kxrz2j2xQ6kIi3Uxbv3zkYYLfBJyxv6sGL8ZJTLFr9yaZKcWDpLq2/meZOn96JLsfwon5zCzSEnX/4fELqCHAXQN/R0BAvxqxF2iNDnLzP5Qc6C3W5g== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbc3efb5-138a-4153-482f-08dceed2f707 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:43.5504 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aBsosIXbds60+Mfy2PJcFasXR60GqjlgWVWpa1s/eVzgdCE8jSwE8prZy43yH7LFSiStN7wmVIRsONR/Pwh9ZqdKDGtvc9MFNfZ5Lob1ARo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. In case ip6mr_mfc_seq_start() fails with an error (currently not possible, as RT6_TABLE_DFLT always exists, ip6mr_get_table() cannot fail in this case), ip6mr_mfc_seq_stop() would be called and release the RCU lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 9bf42aafc7f0..90d0f09cdd4e 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -464,10 +464,12 @@ static const struct seq_operations ip6mr_vif_seq_ops = { }; static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) + __acquires(RCU) { struct net *net = seq_file_net(seq); struct mr_table *mrt; + rcu_read_lock(); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); if (!mrt) return ERR_PTR(-ENOENT); @@ -475,6 +477,12 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) return mr_mfc_seq_start(seq, pos, mrt, &mfc_unres_lock); } +static void ipmr_mfc_seq_stop(struct seq_file *seq, void *v) + __releases(RCU) +{ + rcu_read_unlock(); +} + static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) { int n; @@ -520,7 +528,7 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v) static const struct seq_operations ipmr_mfc_seq_ops = { .start = ipmr_mfc_seq_start, .next = mr_mfc_seq_next, - .stop = mr_mfc_seq_stop, + .stop = ipmr_mfc_seq_stop, .show = ipmr_mfc_seq_show, }; #endif From patchwork Thu Oct 17 17:37:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840537 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2077.outbound.protection.outlook.com [40.107.241.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 551761E0DE5; Thu, 17 Oct 2024 17:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186943; cv=fail; b=T5GWVdVx8qH4DNUVZipAmQPJadZh4hGeg8mUq4Kr6wfPR/bYwzYi01/FLKtuAhw/H97ZAo/MwjbTqjEch/dvKOCFrBUVHJre+LOYXMzQhJrfpzr8Mrea/7UksEzzV5wH6aH+PXYp8J1Gfed+wUHx7dPo2/hJiLQSLi5RflvJ3Ss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186943; c=relaxed/simple; bh=oagg/QKxHvgPVqHwmV1uYjqfAE2MWo1gIE8DBlOU7aE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gMZe3g9ObdGeTl9vN7l+HMdnkRDN/4XtDbcJROy1+Zk3iYScVCFuvXdPk6JYh5lVCOM9wFgHEk1NxxAf2EAfkHHuV8ojHu97n9BAGGNRLjmJKk19flgbyH24opBNokK79uDGWkQviQNO9kERJqlzKJY15kO7Z387ckQwa6oDwyU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=fOlz/VKw; arc=fail smtp.client-ip=40.107.241.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="fOlz/VKw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XrwjqQjS1HiwcnH5QV+quMK1N+YgvpcsLsUAMxKLisgqwJFedmQQA2L1CNdRFJSAD/YJtjpoblqbHTBs54EpWblCXPubrJJ/GEmHDyy+79gexBbXcpsWCXLjGkjBbZ/k8s+DVG/0Vf9nms/bxrX/YfEfrTpfQPykt3DYYeD7FkKksPXg4mtkFCfE3V1LK0h7vFURs8aqZEsYTby3CePmfhDGnlTkvCdUWYROFlyHXGEV218O4VjcC4CMNZQMC3sgP+2fuPL+yASeH4PDhxi9XdcnHd1+uPhTS61VirBVGMGIf3KObaXKFobkKDix/apsa2ZANOTO+1GtA7833AnD+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+2XYd+ef4QXPkhNAZAaNzaPV6vCmrjU3M3yiht1TQP4=; b=pQyMHn2X+cVH83v+clfwac7tzLX83Kf2kCUSGLbxmWtAEjkto3n/TMITiIb/+ofu9A4m1VJ8JVgkOswlM9/BsUUCq9vkyohwqYr+CulV636hZuTFw8KG3dPceHsyzUde6+brV0qr0D9f6ZHd8oX/TRDM14h+V8jbjQotujwOO9OP7dRRAT2iQoHfrAqpA5sxD4W5Mh7nVAVPewiZb3ZDSb8DfLRNdYaML6YHPZhvkpVcR36kSjpjiizDi/xzjzbuTZEygWhWt5Y6vF89aQhBCSeLxnDBdFrqTLGxdvtmI+08yvx6FzPe/izNvRh6R6GDRfgzmawLFczv07VX5RK6bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+2XYd+ef4QXPkhNAZAaNzaPV6vCmrjU3M3yiht1TQP4=; b=fOlz/VKwe11/FbbL6iSn2P21kSHI7LdgI3Di1ybufPxa7Rps1ff3L3X9VT8Ev7MCKuq4tE1ouWwgH2m1CZy5w3FYAN9pidiS3Xyqut8bO3oDqXAXj+DOUSJE3TwlqJ81nM8gKpw9CbwBGYYb6WxG+dY1ebCg8eCvrNTPzlSOl+SX2QwW9Nqe63GNleKxVcdSZruWjFosHrFanbbgq//Nlxt4Vg7S0xp3dULw53Y/w+Ip6/0wQM2UbXs6AeEvFQiaxkPBfVxG7s+9jW08wtQ7GtFC0fIGIZJsCfxztagnRHR4Q02mJuW0/N2xSz26MxygBm97XShxQ0PMpoHqJQwBUw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:42:01 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:42:01 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 07/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6_mroute_setsockopt() Date: Thu, 17 Oct 2024 19:37:49 +0200 Message-ID: <20241017174109.85717-8-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b78e508-c36c-4788-42d7-08dceed2f735 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: N1+lTCVvyHZK0ugfchn6UWlWllz0cDTK74Rr7Gsjv0PkdXyccUR0z9snmwtAxM+WARMColTa4Ot/ktG3G8p/WCGop9YAl6haqce29aBnbETJIn3c5AMzBvyn2CDITNWXPi5gmfGJte/1iIob1PIoid+bHCGUrnGKBp+9OBDq2CY7804zjGW4fYoe0QUi+UAq8tjurkosMoabmxEfK/ZZPJWFxjRwdV0GcszGbK7Eo5eGS4HD4lIFRdINsUmNKF6c4tpnB/5doO0KQ7mRf6OJsl/iVBGxnZ1IMS4nqFlHrHDoPZfTvgSdO4A4HrN2cNQ6f/c/fPv2gqpvyFgnMiUv53fKctC8Zs0flkVJt+bbg/QV/otjEhbIj0JWe5urqubO19wZfeOclO8wqjJnmNsGgHe0a8htC14PTXZjBKFOXdZmU5xb1mYf5e6ncYxIuToRCZpu1OZ6h+3G8zjq6QyV0lIrPa5PBRFpznBWg/QVkhurUU218SLVifdnJSlivRPoBxaFaJ1YakA5KAdCRJ02tHX5a65MSIFpcXLoHfPsizsPtiT6nFXW+YWlqw3fI+vWpJhh/yn0V/mI4t3WLqsP5PSuAuRZKKS62HROmZuvIgLX8TR4OzSloq7tdpNiB85VGrJiBdmJ8bdSUitXhtnUywK5l6UU1Dbt9hhLZOTjzAdw6R/CM+6i72TPBlicZeDOGtp/8i7nn0/goaz43hDy8SPdJPFmgq1s/TeiRT8dTcINzE77diCw1WGsvIe4jJEVzQ7NsUAh+j2bm3bEtIPFZX/7tBPCcrgdOWtXHMLQgDWOBYU3aJwelXwvEpx5MEduPxpfsZK3TpOart/gO0gBuUyJ7IWCNR2yYT5J7SDG7bNuuzTJdEky0zfFypo9LRgBCI+AUrpTvVq3Ww5ljofAx1jemf2X5kW0H90O8cgIedeCUMHuwJSYKB7NBwzQcUCARcLoozoA/5EIisiUTBMesdjQkHSC12XZzrBZ9qzsE+9jJ3SM5CkmN/qZW/u65hghfp6LyaN0E1HsFCY9Rqk8zWEZK740W74V1pbJg5txF1YlrOTQNvKxPzzEGwgA0m8wCzdoEpMBVPrwerOcjlr0DqnEsz2JZc70hxwoz0/mb6XzB4xoNmTnk3+EB5f2W0Yp25V92hcV3vQWzwqsMz6V0IRhEcLCZUDf5WS/vkQRw9WqYWp/H9rUBMrgwVAS2Q/oBLpQESxwApIuY44FeKvWLClaxhF3RfUTPa++3FZtApgXfB+B7+f1JlXVxwSmDWhF+ZU2gUFCWKaWArzEH8arnhn8ppS+Z2yIONeP//l+ZkiprwMSfB5lEDakz4eKtrnDAIRCq85FoEzGZRwX0utk2685R2jdiXLecc+3U1tJIWA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tS/ZARH1LtQ8WwVnnuy9yJfEUtfrxaFKy5KJxhcN2tRhGv+bCBvYqanoT4ju3Y7rt7vtb2QW5mIY2aJ9L0iPj3nTsQ6St3K0NxmpkSjs2m3tHlGHf4aPEF28hmZbo4PqVpz+U3i/y3bScrZ65JZOYMbH4u8q/niXLqpjtTEyF4N30mgxHhl91yO7sAMWWM3nRmiTg4sLpY1fwM271EGLYGXcmzwixIrqiaAEar7MrV06LUOyYhstMpUkb1vW8b5Wz58G9b/LH8pR42wawXzl2bGJindjVU6j2jvNEfY2mYkbigK43Pc4Jd9/Mup1Fi+nXnjnaekiGizZakrNYp6IqEg1faOvQE3sZvkZ7g0jC9Zzpf4fJLtoRZRgvR/CgNEVgXQmfzYugOALqI4YyexdAuDdzi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F4h/dLcBQ43DaVIC0Y0qELbtltSkXXmQbgPohAvrhzZwtwBMPmtuLOfW75gVzyYq8BS3FsKTDnE2Mqa1LRi9mNcP46zMs+pPHdqZbU0jAJM/0seLQtKbjaeOtzwC5FrVXsjO9Xw== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b78e508-c36c-4788-42d7-08dceed2f735 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:43.8603 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y73rTUYzb7mln5O4ZfC54Xkt6PZ+vfUfXlyAtNlqa3/tyuS5pzNJA/21y9cuZJ/qI4+MeAyFwwbb7LapRSVl1W/JWbDgrTp2xor9xYOzfzc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 165 +++++++++++++++++++++++++++-------------------- 1 file changed, 95 insertions(+), 70 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 90d0f09cdd4e..4726b9e156c7 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1667,7 +1667,7 @@ EXPORT_SYMBOL(mroute6_is_socket); int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) { - int ret, parent = 0; + int ret, flags, v, parent = 0; struct mif6ctl vif; struct mf6cctl mfc; mifi_t mifi; @@ -1678,48 +1678,103 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, inet_sk(sk)->inet_num != IPPROTO_ICMPV6) return -EOPNOTSUPP; + switch (optname) { + case MRT6_ADD_MIF: + if (optlen < sizeof(vif)) + return -EINVAL; + if (copy_from_sockptr(&vif, optval, sizeof(vif))) + return -EFAULT; + break; + + case MRT6_DEL_MIF: + if (optlen < sizeof(mifi_t)) + return -EINVAL; + if (copy_from_sockptr(&mifi, optval, sizeof(mifi_t))) + return -EFAULT; + break; + + case MRT6_ADD_MFC: + case MRT6_DEL_MFC: + case MRT6_ADD_MFC_PROXY: + case MRT6_DEL_MFC_PROXY: + if (optlen < sizeof(mfc)) + return -EINVAL; + if (copy_from_sockptr(&mfc, optval, sizeof(mfc))) + return -EFAULT; + break; + + case MRT6_FLUSH: + if (optlen != sizeof(flags)) + return -EINVAL; + if (copy_from_sockptr(&flags, optval, sizeof(flags))) + return -EFAULT; + break; + + case MRT6_ASSERT: +#ifdef CONFIG_IPV6_PIMSM_V2 + case MRT6_PIM: +#endif +#ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES + case MRT6_TABLE: +#endif + if (optlen != sizeof(v)) + return -EINVAL; + if (copy_from_sockptr(&v, optval, sizeof(v))) + return -EFAULT; + break; + /* + * Spurious command, or MRT6_VERSION which you cannot + * set. + */ + default: + return -ENOPROTOOPT; + } + + rcu_read_lock(); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + ret = -ENOENT; + goto out; + } if (optname != MRT6_INIT) { if (sk != rcu_access_pointer(mrt->mroute_sk) && - !ns_capable(net->user_ns, CAP_NET_ADMIN)) - return -EACCES; + !ns_capable(net->user_ns, CAP_NET_ADMIN)) { + ret = -EACCES; + goto out; + } } switch (optname) { case MRT6_INIT: - if (optlen < sizeof(int)) - return -EINVAL; + if (optlen < sizeof(int)) { + ret = -EINVAL; + goto out; + } - return ip6mr_sk_init(mrt, sk); + ret = ip6mr_sk_init(mrt, sk); + goto out; case MRT6_DONE: - return ip6mr_sk_done(sk); + ret = ip6mr_sk_done(sk); + goto out; case MRT6_ADD_MIF: - if (optlen < sizeof(vif)) - return -EINVAL; - if (copy_from_sockptr(&vif, optval, sizeof(vif))) - return -EFAULT; - if (vif.mif6c_mifi >= MAXMIFS) - return -ENFILE; + if (vif.mif6c_mifi >= MAXMIFS) { + ret = -ENFILE; + goto out; + } rtnl_lock(); ret = mif6_add(net, mrt, &vif, sk == rtnl_dereference(mrt->mroute_sk)); rtnl_unlock(); - return ret; + goto out; case MRT6_DEL_MIF: - if (optlen < sizeof(mifi_t)) - return -EINVAL; - if (copy_from_sockptr(&mifi, optval, sizeof(mifi_t))) - return -EFAULT; rtnl_lock(); ret = mif6_delete(mrt, mifi, 0, NULL); rtnl_unlock(); - return ret; + goto out; /* * Manipulate the forwarding caches. These live @@ -1731,10 +1786,6 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, fallthrough; case MRT6_ADD_MFC_PROXY: case MRT6_DEL_MFC_PROXY: - if (optlen < sizeof(mfc)) - return -EINVAL; - if (copy_from_sockptr(&mfc, optval, sizeof(mfc))) - return -EFAULT; if (parent == 0) parent = mfc.mf6cc_parent; rtnl_lock(); @@ -1746,47 +1797,27 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, rtnl_dereference(mrt->mroute_sk), parent); rtnl_unlock(); - return ret; + goto out; case MRT6_FLUSH: - { - int flags; - - if (optlen != sizeof(flags)) - return -EINVAL; - if (copy_from_sockptr(&flags, optval, sizeof(flags))) - return -EFAULT; rtnl_lock(); mroute_clean_tables(mrt, flags); rtnl_unlock(); - return 0; - } + ret = 0; + goto out; /* * Control PIM assert (to activate pim will activate assert) */ case MRT6_ASSERT: - { - int v; - - if (optlen != sizeof(v)) - return -EINVAL; - if (copy_from_sockptr(&v, optval, sizeof(v))) - return -EFAULT; mrt->mroute_do_assert = v; - return 0; - } + ret = 0; + goto out; #ifdef CONFIG_IPV6_PIMSM_V2 case MRT6_PIM: { bool do_wrmifwhole; - int v; - - if (optlen != sizeof(v)) - return -EINVAL; - if (copy_from_sockptr(&v, optval, sizeof(v))) - return -EFAULT; do_wrmifwhole = (v == MRT6MSG_WRMIFWHOLE); v = !!v; @@ -1798,24 +1829,21 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, mrt->mroute_do_wrvifwhole = do_wrmifwhole; } rtnl_unlock(); - return ret; + goto out; } #endif #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES case MRT6_TABLE: - { - u32 v; - - if (optlen != sizeof(u32)) - return -EINVAL; - if (copy_from_sockptr(&v, optval, sizeof(v))) - return -EFAULT; /* "pim6reg%u" should not exceed 16 bytes (IFNAMSIZ) */ - if (v != RT_TABLE_DEFAULT && v >= 100000000) - return -EINVAL; - if (sk == rcu_access_pointer(mrt->mroute_sk)) - return -EBUSY; + if (v != RT_TABLE_DEFAULT && v >= 100000000) { + ret = -EINVAL; + goto out; + } + if (sk == rcu_access_pointer(mrt->mroute_sk)) { + ret = -EBUSY; + goto out; + } rtnl_lock(); ret = 0; @@ -1825,16 +1853,13 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, else raw6_sk(sk)->ip6mr_table = v; rtnl_unlock(); - return ret; - } + goto out; #endif - /* - * Spurious command, or MRT6_VERSION which you cannot - * set. - */ - default: - return -ENOPROTOOPT; } + +out: + rcu_read_unlock(); + return ret; } /* From patchwork Thu Oct 17 17:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840538 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2074.outbound.protection.outlook.com [40.107.249.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4D1F1E0DF3; Thu, 17 Oct 2024 17:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186943; cv=fail; b=cw5n7XVjwUBaZi/Ymy3tZ/J+S5KB7tzfraEn8IoBGi3LZbBFogZXnfOyIRybtAAFAZ1gLESirt1IxsBnZ2KTnAPQ3iW5Vr9IziPdFZ68XdKHJlUK8Jn7odJZWZyZwfsgoY06VZedb1Lx6SVoL+ETrQxEwUv5+gLQPt5PJoXi8uA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186943; c=relaxed/simple; bh=bsnji3s7HKifLkl783vHLUc4NahaFWDvZ8mRiX3D5yQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gUSIwAZB/6vQC0sXgiPoODMhNkJD2qBkSfIyC+y9uK67UB6k/svelY0nL5dGzE7ywfdMZ8V5rUN7CnbPtFma0m2CvEcrfDhBjw/n4smsLd7wUx85zpirve8chvrkPJy3z8Gl6Dp8uyi/9z8bkzLItwkIxqQys+o9HGHA6x3WGls= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=ryF/GvCM; arc=fail smtp.client-ip=40.107.249.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="ryF/GvCM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CZyDCqU3DDBdSZf5QHbOOzllDXumRwccq33i303y+J2L+fJxKXuEebQUlj9IVhPQtpYsYExHjLhXcB9++bEGanXZTsk6XZvT2Kd3cCSDRWuzsyFVj5m02JF5DkDfpBKEJs3x0Igt0CJNFAlvFv8E7uhaMoEA1RNqpf70E6W3YXiF3NCzHP9pN8gt8KMXrQLMjNWL2kS+JmvIR99tjYm5Tw3FMBE5Mt/dhdA1UjEDr27beTwYPLQFvaSx/18ZR1bYGcw6w3cVZ4eA1NqmU2t9mh4HAXL0OdFOQy+UwytgHKdC0wCZGB6tYzLJf5xxJhJny+5G9ypu4htR1APZJaRe2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=RD4rMLTIB3NVr3y185/98BGbBbtVJ/82dZM8g63EPHk=; b=yc2lYRnVYLhaO0a2u429ZnUwjF22IfeOT/C3y6BqIu30uge5uoQVvn/pYXf7/JQIQI09zyy2SDg+hZYX8TmWAD6JfpQh+/M4tl15iY0Y7prj55xAS4M2MW2WnGar53Ur/UV/5CBPvPyGV4j/D06OqgMeRtH9a3w+ZwGpg6qsDQW9WKUWzfCq9Qc+Lb8cfGRck4nBAdmuOHW4De+7C3SQaohjOt7otYgJPTJaiBZv2Cj7yjwp3heI+pdqk4NjQBd2+RTnUP5gSJDSogIEX3p0xTVrF113y/kUfQg/SLZ7VpwWQgeDwEpBQ/t2i3Nbh09n4iB7gVZyMhH4fN1+ZlePVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RD4rMLTIB3NVr3y185/98BGbBbtVJ/82dZM8g63EPHk=; b=ryF/GvCMlv+NnKPUjaoLOpE3ENiDjHgdBBG5FPSWRSeyn483GyAU9XRmmZP/4HMOFq4Z40BZBTUqMZvgoqwWuKTMeNoQ7wqXpTU0iZRaHxQsEO/pqRXDudED0DjxDgu44XmxCi+B8badeOZfU5gn/XiAIIIv1XLNXRrgXGSf7/ovOZqblcYegTBnn5C1tzp+Fnty/9ALoRAz7NMvr8WCa3B66ecWxBU3k7m009kWriEi1DtwMoVgvRNWs3l5YV7d+qIiKj7tiJExB7kD7yzIs8fom4SVp6fUfI8LNDyjRM3H3jwEnydPmE4PcxLdDz3yMyqW+REWmoOcoKOzjsVEjQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:42:01 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:42:01 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 08/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6_mroute_getsockopt() Date: Thu, 17 Oct 2024 19:37:50 +0200 Message-ID: <20241017174109.85717-9-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: f51742a4-531f-4d98-7c63-08dceed2f762 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 3JZAMVPrwAPRSquMZoKCGwFWgFB9HCSL8or7dlgTXwsPSVEflKjcwJAs4fmhpfsc4bbzvgWax+Jc6QHCdM5jii5LdUZOmKezsH1k7EdcVIzsSC9Y1q0q+Id8Pc7pIFSargk7KUTzlvhdT2RdcFnQw8Mqy1heY4yH2wIcQ8dg9kpiwuqhXH5uyrBCDXEYAh8iCKSc1RKSIMB9YaayLqlMXrAxHrNANAydGKe1SlpD/PYxHguLT3wakbdKtdUB+R8Y113zLIbBN4WUfG4m7a+7w5VzKByQ7Gp5BEgtfERrJidewXSopxw+0eEeX3EtzHU5YPKSkm0VLGbPhczYmVW3NIagPA10PDew5ZMj6ZQPqkaNu/aMkcWoYkxK4pmIhZAqCBzejMkf5hCkejpCDsq2C2ZkmnZ/oMI0xYBbetjbkjrFyt6wibn3Rwh/bDrYIHT0PxeKP8RxUDpNSz9b5Gs+AWOj2+VPAa4LHZisOnibKzOHLNaoW86suEM7X3A/6O+5baCDxciNu/fd0hxAp+iup3KEGO7Z1jP7pCEqCP0UUp5eTGPLJLsjm3PzXg4SNePz73AXHOFcbsAYtgjzhZJgehNk/ajQV0lUj6tU8f6twlb0CEh6lbr9cRpZ1IaGRNekA1Iirv1UXYEaS572Kp7EMdeZGigAAisUTsqBr0BjI6rCc1HRrUoR/WNqUqT17gi52WQDwzglOrFzRlY2Xrvv8DHoBNe0OsdMl9KHzgkA//e9U9hGUZAuQ07DhWkzQ9bbext57gO4P5lX9IzhDTX/8u1m9Cl0z+dUvaldcKNexvYQIws1PVWasK9Wq2KKN3tKxEQhLJkVRpNiA5eeBozG9nMStPx0sftTcV5GApB8UHPzNXFZcdjeUmAzcBezOdIhvp8StdivuhmG0o7JbzVDZWhQnV8IMhSYf6NWcTy8FrnNh97hUqxoh3mw1ANZcVJ11H9zyLdrFe+23wNZQHKg/LESJjCIO6nL2ANb+zinaSe+zBC5RR5tp0zPmtY5daM6LvXAP98ceI+wv5ywL+HN2qezTP4Tw0f/6owCzlT0GCu/gcSgrE2WWQzqgZcALtH15++01DXjsqyOKUR3639tfdBMzBqV/CNRleZLVcMTL7reBRdISiWZV6ksQR3Nm5lPyUGe/Q6aGZtLmhwgAY5/A6FoMcdIq0yRAIuh97mHSN17SMNf3quYAjvMNUZ+suJZzKbQa+/kbpstfT/1DvZy7t8AqZOvaNII0nHjydzk416v9pno6YwHdSyBMDBUWScQDtEusecupoKMVdnzwzhldGfP4N+0pA533rYtkwVPzSTMziKVrGPMPl47ounT/9mbJ7V+dA58GKJDs4ol/2Gnsh9+W7xO+SdQe1p/eedySuU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uGZJ/3nkYRiFSweaq9qoDNajaE0ORTu6arBa+TF0zGALb8oiZlwJhdmqHQX4pwdVufYiFg3kbbI9t0ACx1eos7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ul+/JxpFlM/liJ1aZ7IuvMKKpnzJ214QA6kkXCq8JkHMbZrO/WihX2djKM07yyA06tn4G3BKSxDiOfTLuCUSHP7WU1AZpErqFH/KqcQdm/EWqP4PA6iJIDOvkKlDUw2CmdRoUxI848g9JURxDY2GIIP13DxAm/VbqHPxhmjoEhhR2ND8bsh1d1rQGy4tiPtSZESxBzP2s7XN4LApbe4L6LkHd3LzPrYENsZFJTuAFOPQSXHgZp78wlloIwsAw1O1jqJKO/DU7iJRVz3mg9e1ZLoRysMglc1cXqcha3IacD1fDP9EID9a8wYQTSrlaJ+fYOc4TneKTqoIerIykQs4GvBSzbQWcTLjXnaH7GlNaRKGxqEGgQPsrG59b4/fY91Y4mDwhkGpiZxkjl7p3keAC/c+laTOK6O2IkEPG1f2GuJe4v/JsUWot9pIlI3uUM8RX4O4CWN1S3gjg== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f51742a4-531f-4d98-7c63-08dceed2f762 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:44.1694 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RWPR+dVLyVkx4JZ6o+GpUsXlOHpgHMyEriD/2wJrWUQxQY9AN5wwT82spkiodi8QBGL/YlyREd11Ad6OJxJfWjZpRhxuEBhLQA0tJ9wIaLs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 4726b9e156c7..b169b27de7e1 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1878,9 +1878,12 @@ int ip6_mroute_getsockopt(struct sock *sk, int optname, sockptr_t optval, inet_sk(sk)->inet_num != IPPROTO_ICMPV6) return -EOPNOTSUPP; + rcu_read_lock(); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) + if (!mrt) { + rcu_read_unlock(); return -ENOENT; + } switch (optname) { case MRT6_VERSION: @@ -1895,9 +1898,12 @@ int ip6_mroute_getsockopt(struct sock *sk, int optname, sockptr_t optval, val = mrt->mroute_do_assert; break; default: + rcu_read_unlock(); return -ENOPROTOOPT; } + rcu_read_unlock(); + if (copy_from_sockptr(&olr, optlen, sizeof(int))) return -EFAULT; From patchwork Thu Oct 17 17:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840539 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2077.outbound.protection.outlook.com [40.107.241.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1F591E132E; Thu, 17 Oct 2024 17:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186949; cv=fail; b=t5/uHBNVLrJpBMWqjTanp1r0Rx4WCaLQqNjMVuORqIsrt7XZFvBjmPTyl39DngJIqIwC9Go+NensjPVQ5sFM1u8WaDCfoZ9nS6d0HRHnmws4tYmccyHyVjux44EreNW0sd6yNxmOo7ubOelzo84/LyyPR/Rzi0fhyiJ/BnzUPKc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186949; c=relaxed/simple; bh=lxtjnhc7l4hQrdQRQxsYKC8wR7e/j1c2jF2grs1cCn8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=SAlwSlLEfEyJcNTQVN+ykl0UmtoqkGqek5dh4y6c20cmgcGXaHy4kMFJ2RJRukr9Ov1H4/FtQrbz1PENyxfQUcmTSvDA9T2WViRdxvH/OKkAvz+34+uwfFKP0tO52+SRpMCaNSe5pdLYeQ8czziOq6BOZOqpu8ZES3k50dkBpO4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=USnMNFZP; arc=fail smtp.client-ip=40.107.241.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="USnMNFZP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oFX/+sI/NoaDMpsaCcZdCih4J63aNIJE6b2QBaoi+hYk2+w9y5qSb2eTcS/DKD3KuvEShsxHgwH38qM2d3h9wltKhGcK0yvOrA7gW6rITg/f15j+djnYY2na9ej5n/1ZlY4AU17v2y7DMRoHkuec48akRVicXligf078yUkBcQKcwv04K3cRcgUH3F6OambXJ5UvVqhTNbhwuj38ukuZVRgGFOnByQmSa+pZxLRI4PYXgyl8ZxT17WkBLtJxHueGiS6vwtOVC3PmwAjreVSI9Y6YI7aaWREbbhHSLgSsGzpBA2RglJLPBx2x1JEfddzI+0ZSDQQzvUcmapLp9NjP1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IuokgqduQgCWV9bbIJLzlimTFKYrKb9Dnwoo8X/5dWA=; b=OE3mnrIQYCScUcW2qM0JcbxgYcAtPiQIm7NzGS63U2D/3YhWTm/ZFqfMiantp9JfHcRH+87Ypptw8b4FrZUF0LRTfUx50AMO71gkbGYEHwNTfSAqAHG5EcOok2IFA7/f1SHBDgbOktl3bCCFjDhuRa6oBho1agp7ru557gaVeGA2/8ZmLcp3o0lykTLWIhcAzUzh2up4u75i2u8fsPcR6xGGA7PbH8HnCQBNqOHN/vMIq/doSsFRXUPmEaXLN6jljpZ4+v90YUHxGmsLiENxrcx4fpGM7x0rvR7vSKT7qa7Xm3EKdSrOmOo26bREO3quxA+PHXYggmtqs3y1YJ/FcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IuokgqduQgCWV9bbIJLzlimTFKYrKb9Dnwoo8X/5dWA=; b=USnMNFZP8a144RCtOjEfPUfyYeqC+ISJ0CovqFEvZK+32Ohv50Qv5X0Wx4CDIfWY255GGDnI1Wf/aJPQF2V+V8i5s6z/gmdKz9LHRGvGui1OIqTZSmUaIMNCCsuzSV90RsejV6EI2/XuCCu2fYlxVdmEXmdpzCEsyRLx+rReRprHJqD4qwZKRcA/AagEPe8pMYwdC+rJP3l3XdCLoRWLhIbBrgAdPZoBsSNnRW/atXVaOfDjUv1HWga8MO7DS95eGtSo3HqoI6C5/18mwiPqrqx4WrXcyz1i26ftu7fMQ7nUfetLgaA+zZnO9XShE5W/tvf2MRkOWoAU4sM7uKuUfw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:42:02 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:42:02 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 09/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_rtm_getroute() Date: Thu, 17 Oct 2024 19:37:51 +0200 Message-ID: <20241017174109.85717-10-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: e2127cca-5e8e-49af-02b7-08dceed2f794 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: kwX8wPYQ889jbjHblMh10EsiCZq9RMW+wwfMhG9dFInna8QStKOX3OF5XR8Mt3lXy1nfqEFqJkA4K2+zeXijWRAhSjQrhA3UXzUt2uzCP/7S78A/n5tIT4eg73H0167YCsntrC/SkpM6iJ1XR4LEaTd85kQ9gtgNghurWcrJMzbrmIPHCY4qCvVKhwkRV21mKvaFwTxrdObsDeXfBVuN3Gl6Plj2OSOGh5egDRVqiEDa8xQd49RHkSls4zvt9uIGWQL0c08qWyAV5LrwY/B92xEkz595/4g8l4feBb8ClsE4DMychDh5lxSa2I79xseYDC04R5QIWtgvDrxoLNEtkoSC1A72dDY3idxcVP6+U7kGCnA3XylYglxAW0anDklMTvirtL9U+llSzHF7xX3dzmVwFSDY3+T3TbZ3A04xfpX6GNeRL3cAU2X9A4RE0TAn2XH72goCm+dAHa+qjJoYhQRU2V4Pj1uGjitVmWIWslO7opKniqw9DCuIbSpCuY1MoTTx3JZDIGwCzNZc1aAdHpyIN1NoM/JjdvdqyA02T4202CCT/FI9LbnAgW8CgSDmcG7NO28F4fO9W4NBL5VnL/pxkcXQVWmny3x4YC58+6bJLoIRgiLxifTb9BmtxWRx8o+tqdhk+xlDNkFxe2R+2r51fA0Ww9hSEdBWYUhMZeYBQnSSH3kKMYHzmLI6MQHOd9NgmGkhIpCOcSMBFMjtTMbhWMhoQk2YrQW6Uzu030wJdk3XxmHeiKg7v0ugu834ZDXGvGjswiWoLDU6cwdwwb2mwo4wLocIYFKI1NqyNYtujOJx/3C9DJd6IXAfIc6jAUfpApe+piFcEsiJ8THQfrabb92qs/Vz1o6yY8W480e+YN/FPggVruNKWHtGfQ6/wyWNUaGW8XqEUtCag+W3NFy+aMTeOPJipZ38nl54r/ffbVe3lALSbMitTNkoSiVcnmUgF9qv2HtJtAmvaheIBf1OFVSJlNMcj26NNvIjIiY4KWAC91VMNQtvV3Pf8JM/Ss24St297GMLrnIef6mnidV41Ra9JA/oKh80bYAMvtxlAqMqIH17+qKD4y+emdtzFYlOE6Tz7uph7DoS3yXsls08ccKuXBjtDGaNdfAbJyo/717De+Wd6mkmWxvfCcvy0O2RrtqvWWAEUk4KrnfuxbSVwoiYMjNoLYqA29q04sKWlQjDJV8JMfuOoqfVMX1ZqgbSd3EBkGekRGHwJEg7CsRwvOd0ZXlsDqJMATo7BuTHoZoXVJH41ChISK4BljRRMf9zvt1vv1S67Bk8CizyTSUrWHDYAtzyDSlDZhjvkw9LH4rq8M1PE/iATBQTX8jWuGWMfTi4ubkFpZWVF/u7bgHxtNOZcVNzJrU280I98m4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fQbVi0O+/CqDrzC/4QG5Vk4MsxvpfHtWTW7+0tkT68VSWCU3CbzEbsIZVzerqbtb+h5sPqRUj0qpuYcSb1hCwIKEg1MXjrg6JF8CZWB4jTSCmJ81IOO43FdJ11bd5S906gvF8WsDD/iFLAFWsOkL2f8U8XkzVd4ztAbezfiRJLVK9t27vlOheKF9kbMtela+d13bFVj3tw7Ffi0LywOFwfNIU2PuBZUt5j8nXryesrn8faOtCIjNgWZibAYffmrRsYfP0cK2Fh/EJChoJZvYUn9l3W4h+TVW5cov3UlQkPGl3ImTkoUIDVYVLiny8dATTMG4Q62QWB+xJkoy+m/s8NnVtof/5zpK9a8wXHor2DMZogslTCpbHAnM07Dyc1gBdiKA8Ka9W9lBV8goQ276wrMDhWZ+x1pOcP5s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HPJH5PU7QJ3HkxcJJbwTtN4LTNNCvfbsl3m6OMIPL2Z/UsBSrJ8fbUcfIy7+vX/cw01UJ0UVZrlrf9l6hl6xat2ao8Oz44e+riQZgvdPrGBvCjtgyDmx148RS/6Oq0aW2hg9iPDykKljQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2127cca-5e8e-49af-02b7-08dceed2f794 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:44.4869 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: udh2sh8nwLyHBxC89moN6pK0e7H4VyFJBXGVkjdKRyEW6yuRlthG8IDbvrnjbuihXX23UZHO0abwSDD56cWEEkW3EMWRFZhEqo8T4Ol4ZVY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables must be read under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index b169b27de7e1..39aac81a30f1 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -2633,27 +2633,31 @@ static int ip6mr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, grp = nla_get_in6_addr(tb[RTA_DST]); tableid = tb[RTA_TABLE] ? nla_get_u32(tb[RTA_TABLE]) : 0; + rcu_read_lock(); mrt = ip6mr_get_table(net, tableid ?: RT_TABLE_DEFAULT); if (!mrt) { + rcu_read_unlock(); NL_SET_ERR_MSG_MOD(extack, "MR table does not exist"); return -ENOENT; } /* entries are added/deleted only under RTNL */ - rcu_read_lock(); cache = ip6mr_cache_find(mrt, &src, &grp); - rcu_read_unlock(); if (!cache) { + rcu_read_unlock(); NL_SET_ERR_MSG_MOD(extack, "MR cache entry not found"); return -ENOENT; } skb = nlmsg_new(mr6_msgsize(false, mrt->maxvif), GFP_KERNEL); - if (!skb) + if (!skb) { + rcu_read_unlock(); return -ENOBUFS; + } err = ip6mr_fill_mroute(mrt, skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, cache, RTM_NEWROUTE, 0); + rcu_read_unlock(); if (err < 0) { kfree_skb(skb); return err; From patchwork Thu Oct 17 17:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13840540 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2074.outbound.protection.outlook.com [40.107.249.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3940D1DACA1; Thu, 17 Oct 2024 17:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186949; cv=fail; b=Csyqg/FK8R9bf2qHmy07WxcEyJN2i3IX+sjUudmWL2ycoAnDlW7xOXThdxcCS0h18Rwy+YVMe1VA025yk9JZOVoShDKi1Ii0djBnt+yBV6mLvOoroZFsFLUEKjPTRWb2cPaTpLqgZPP4SXfxahhzUT3dvP/9wkdmtfcTOoX30bI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729186949; c=relaxed/simple; bh=JfG1QsWhuGlOr4RAim4sFuqX79NyiKi9VBf3jaAUTjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=KsHxBd71XMw66NXSeZ276OxuqQhkxi6yqtBiURmSA0Xd/rANcu5UiZ2xW+/uqhRp/+YzGI1MDJaRm/eLxA9lNOn23uFdYh8s+RuAlSLME4aRH6Yt7HBi+5XsbAWoeCuO7oxiajwwX7ErjK24mIfvcZnC8UEMfQzJ5QQ1moT1Jws= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=dRwC+kG9; arc=fail smtp.client-ip=40.107.249.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="dRwC+kG9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rx6PyaDv+0r3DE7T1boiIxtvgctVcFUKBy8HwD8yonUdVY6vOPyuX8NW49DQibnKfgXGIoOT2IGRs0lxhegUMOPsunL2PGcBJCaw6Qt/JEH0D3m9lpD0u/aAkpoiYY6D+I9/kEMbu9yunKDbgSMMTGoZp8kyOcCtYBLZuENySgIQ6MhgcNNdhtfPnTgyLvSIa8xx2Sfw+xBTQyCew8d4q1tZAlnMur+R+GO+p6JF85KPL4vEY24eW2X05Fs2iNJ5li5WTyTHRZY9srntBKc4E3haQXoKFm+5aF0LBfVyk0/o7g46KL9wELUxA0MMYEyltFsM3AcFbSwnhFzOXwk1fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DrIS7wGESh9C8aRQhIZpXsjnwm9dkno6LqxzJFrTWQc=; b=ZcQjNBveOuYXRcT69gCJI3IAiIbKbhofpbAEz3vi+iy1ijse5xhepFDEbNQCn02zt3wM1mXBpXvkrshGPvlRecd+GkyIFfPAGiyGXYs+6KBWdFd5vnYxRfWVv9JPBuhEPAUh+SctapeUcuY2qgbVwO4EEskV1JI7+goeziwqXplZCNMeTUheit6izPWZYlyfuhiD+QjgXBcPJ2scQE9zhBVsuhAecQNj2XAqwi966VOCwfxVw42TlFfOj3OuxaJBtYtND0m2RH8l3LZe+ypvQZGN6uXKw8vlGgAyOYYD09Js7WJjydFTL01Z+tmMzNmObiy9GSQCHpIMXi8ESH98dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DrIS7wGESh9C8aRQhIZpXsjnwm9dkno6LqxzJFrTWQc=; b=dRwC+kG9hAL9QcuSUfHl166Z8D7OuAHoAf/dVp7J1c4rONuzV3Eokc6/66O9WPIDuzxlCdThharhgmU5sgEJuZ7RDVdDM2qjepNkRoQ5Th6CT41YLb6WKVT4/2Y3iV6R04fF4K66jotF90YsYqLPpm3AMZxedQeAoUU0SE05tv80M54Y6e7MB8KEwbqtW12n9ALwgTgI0NxEmHMG6vzHlt1X/W4hr/H8Z7mi0TpAyQU79nt7I/bnL//UogcCM/tQOKNHSfPm1kwYlAR0umaRhYjVNNhFoLx9pnZ/QL/ZfoMD9UKCR4KhHZH2G/B/VOy4bFWJY3M88GpxVvx8oGFBvw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 17:42:02 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::6b9d:9c50:8fe6:b8c5%4]) with mapi id 15.20.8069.018; Thu, 17 Oct 2024 17:42:02 +0000 From: Stefan Wiehler To: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Wiehler Subject: [PATCH net v6 10/10] Revert "ipv6: Fix suspicious RCU usage warning in ip6mr" Date: Thu, 17 Oct 2024 19:37:52 +0200 Message-ID: <20241017174109.85717-11-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241017174109.85717-1-stefan.wiehler@nokia.com> References: <20241017174109.85717-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR0P281CA0197.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::20) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: 3207dbc2-4e7a-4fb6-4d03-08dceed2f7c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700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D74JUoExx99avPrCcK6GAxCc0jG2T7ai7NxAVPFyEINxqZ5Fm+3a/aIViAQNxeENctlEFOQopssQJBlP1AA7Ee1dZhE6iSir7ku25Ippj779X3qsM0GItsI647LXZZ0DVHcvTQIU5wSgvhSCyRuPLSe12TlhiI5Q00hZDFUOQ46CEEoiNs3TIehJr7kWdqM+GmaAjHNSSUvnS/uoTHjIvj7UJOVO9x2+XlX3q0uYyAdjMafX0bkKNY0XfpzszihwPiofD0/ZPLYCqOdqoa+qmlXDuFYOgv5gyB5WtZdMTH5/87NctOfKmwR8X3e7jhDrgvrLPAUM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3bIeCPUn1/n0VK89MpoC4ufFFWjoZ7OJJ1nnGj3NN/vRh55wmj5IJipPW/6PN79lIDBiBVK6nhmFVr46jURQZYgMAWn5FepnftxyO+4CntazdzaAl2RD+LfbP9gl35zibbdInwQ+ehP6L6/XHDfbZM8VscoNsolkb0mPikymdX03HhrFaf9DwG1r1KeyPzvj0718VXR4KwY+LtJampgKV13lDPmUeg0Wrg4V6yD6sDkT7Ff9enB276OnqVbDiMBYRBfmQFNd9TrLnLHqKg2hfcuNefhynV4CfU6Smna/+fZ0xsG743Vb/wIZRC1toTr7lhKtRrLtvYVkLp9Gl3jsr0EHjPrssP39esj5wReS8kR7M3nZRueXxk5rj0P/hMM1ZYhiFGBI/65SV1lR+qOD1g10V9KV139kLJk4T7+BEaA15f/DfyZfZ0DGf0VWOZmCpD7TMXvMr9lsQOsVkxkhxzxS5kMWHvoq2I/xP6xY0Uj+U83GFoU+AjTBorMR0wtZ0+AFMcc7rZZh4YZWi1rH5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2xybBm+Afng2zA== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3207dbc2-4e7a-4fb6-4d03-08dceed2f7c2 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 17:41:44.7847 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jIjvW4+h3v3HXj28Wr1XEhNYDUL6SAu5avnwtpmBtYlu6grzW9T6S9zfWyTO5kbDCizo1Pu5HB18CUjpWTBzyLyVFkU4/btkYlj4VM2f+pk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org This reverts commit b6dd5acde3f165e364881c36de942c5b252e2a27. We should not suppress Lockdep-RCU splats when calling ip6mr_get_table() without RCU or RTNL lock. Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 39aac81a30f1..66cf3ea344aa 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -105,8 +105,7 @@ static void ipmr_expire_process(struct timer_list *t); #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES #define ip6mr_for_each_table(mrt, net) \ list_for_each_entry_rcu(mrt, &net->ipv6.mr6_tables, list, \ - lockdep_rtnl_is_held() || \ - list_empty(&net->ipv6.mr6_tables)) + lockdep_rtnl_is_held()) static struct mr_table *ip6mr_mr_table_iter(struct net *net, struct mr_table *mrt)