From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?0V8IgfIG4Nr15OZNrxOSWfTmo6IWzw8TRHooFoaJiO44r0X2vX17Aiz3p3jp?= =?us-ascii?Q?Wf9mrv3ZlBppKPYcPQdrjY6l0r2e4EmbFbim8I8li6bP9eF0H2F1pplMRXBF?= =?us-ascii?Q?OLNAiRJr1PqrBrJS78Tctz7gOLRgr3OqJ8gQlVWgFPMzkKtULb8F981/CzFp?= =?us-ascii?Q?GNvgLqSMwRfQg0oYpl2ZxF6OZLvy71GiE17VsZ5OumCH9BZI7WKIubjnaOfx?= =?us-ascii?Q?iLAiN8W0MDn/QbtmrZXHhaiLLVvu19/rq9Hcxg4+CRYlGs+P39HbNzzFq6nw?= =?us-ascii?Q?JZxcuaqpa3X8wZEaYi0iafCnlIvHJRczhvBO6M1y+60Gecrs8o+dC2+5xfSP?= =?us-ascii?Q?yypAh/9yyhOri59M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pNaxBt?= =?us-ascii?Q?eZF0iuTV9ILsws/bLVbeIe5n5XUNUM3+HtaPAbjST+oByUi29oQj8O6Vw021?= =?us-ascii?Q?LGE1S842UxdOsXkjl7x6wwc/hlt+bo85qQnpR3ZLD96wG+9Q09br5ZBX/wnu?= =?us-ascii?Q?Ckk4WE8=3D?= 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: =?us-ascii?Q?PjM3xnFyaqUXpWZmmpLzzpj5T0XBXSuhEQHGk0mHW9cYtmxv3u/sqRBMIyEW?= =?us-ascii?Q?VPom1SLOS2v+0uIl/ATuF/ANcxO0zGSFJVdzaH5meanms9+iszqibIkedA+O?= =?us-ascii?Q?ZDKoycTkz/MCqBa4zSmGd4ao2dcjcyODYWilpRJY1OgGQy3aS243YzVdMueI?= =?us-ascii?Q?KZneYRyPPZwuqf2NIm1xtUxemfsKaBfMdQmNuojJ2gHlngY1eTZ7CvUKN/ha?= =?us-ascii?Q?yZUk13jvDPIxWIn6eCjyyuPu8Q/Nc6V27qEZwenT7wnvjUCe3F7WdXVlImaD?= =?us-ascii?Q?ILcUKpOjj36GqKax4GkDqiw3dmJ5NvgWO6CLxUwzNcgycsYHl8bFUx6uBSXE?= =?us-ascii?Q?i3hTYxSd9sA70b2jVcl4yNrbYxXTn2myeu4J2MM3rNFYkU0PrgDwmDCtjwnz?= =?us-ascii?Q?R0d0gxc0MVrrkGLOyRI9Mo5FWWrlo60ZTkQAQGeIbzrUc9Oq5Z5BBbcfKCmM?= =?us-ascii?Q?e/XShnWEywz9EJnwi9EurNkYeCowGy076ahBNG7x0mcCXsvgN5UBr8AgL8nt?= =?us-ascii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PNL3Nce?= =?us-ascii?Q?Qk9W8GyW+z9kvINh8iUiYaZAKQX4/LJfj8hs3ifTep+FynbgFsW+KE/cfSR9?= =?us-ascii?Q?PcHoz8jPWE9LhfVXJ4/gbfKWX/tzPyGtYfQSNu+Qeo5A8Y5/z685L0rapuCl?= =?us-ascii?Q?EqvL5k94xDvTBou3EBUjHDBPhC5HXyR6YviH13PWR0kLnfWOAHtll9TkfFBI?= =?us-ascii?Q?gw=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 =3D seq_file_net(seq); struct mr_table *mrt; =20 + rcu_read_lock(); mrt =3D ip6mr_get_table(net, RT6_TABLE_DFLT); if (!mrt) return ERR_PTR(-ENOENT); =20 iter->mrt =3D mrt; =20 - rcu_read_lock(); return mr_vif_seq_start(seq, pos); } =20 --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?Jn2gm2cdONILml6tQgKqQon1mDi1dLDEj9HkFr2CIqlMZZfSbzaJb5dWF1IW?= =?us-ascii?Q?LVepx/oZYucD2WHcxtrNm1ZC04/XY/Fha/Ytq+9F5ZO62zwr5ElcdAm12bF0?= =?us-ascii?Q?rF3MMX5Ut8TAKKFg9adjzrY7CWDt+GddJwGYJxczC+flpNUSa7hGJ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D56dtQVcqwojxNvmiMncqxp8REeC0qavO/4n5?= =?us-ascii?Q?GORN2Y0iSdTeF3RpLdUhrC8/z/Ux0ZVH1btSZDPKGL8lMB8gvXm0P/aJ+wuI?= =?us-ascii?Q?glW0BNieC2yFyTLGIBDe6H0qEQcDd1d7kWCON2P7lrGTrEW7IRknXk6skxGY?= =?us-ascii?Q?Ucfnn87lTO9+aS5R34eRcENO/emT92yQGgu6rkiQlaz1g/VMljU4imwOZxSw?= =?us-ascii?Q?wMWPH5FnNKXWQSbwjSgnYYeoOh/51pblUI2UVM1P8ZEum+D5x/ztbO5Z9Ere?= =?us-ascii?Q?fTmFnMMcDmoZlVksgPS+c+DzgUYzbuJkftWQX991JJkcr0xAXWM2gCd7A0U+?= =?us-ascii?Q?LUPiNy0=3D?= 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: =?us-ascii?Q?r0SGaYCcVD5CLssolMMFozWhqpr3IQaXh8qFJZnpibBKIA+MAItkR43Zobi6?= =?us-ascii?Q?OP9g/MoAo0y5JG39tRYCENCWPUzj4PMq5CAK0UvbViEE+WAiAOdwI8zHob2a?= =?us-ascii?Q?t1jJpseXDOq8zJSJX19lqqp4EepXkFskkY7h+oB6mZ9VGnDdDUqFTZyscVi0?= =?us-ascii?Q?yRXIzLw3PYnsnMNtWBio+/GgW6HIMuxku18Oe6AFi+GICjgvY9F7E1WjIwCG?= =?us-ascii?Q?qaQBP+8AwcxsPKlxfzvrAXaojbGYG9uVLX+UPEIyRzkD1M50U+zOwHJBzM+o?= =?us-ascii?Q?crzHIqDW1FUF6/ODj0RTXNbeK5epik77tNy4D1BEPnffqIhuMPg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Q3tdeurOHmRd4bjVWVH7NWYR8yaou1PsZBUl?= =?us-ascii?Q?Yxbhrs2r7x/DX1eHG4Yuvb5Ux3BgbK0X4vBqjVLXG3SFHMgj4GPjxOOgRH5S?= =?us-ascii?Q?2xKeAbl8cjlJ6Ha8AKE4r2/2wolvWm8S1zUn+q2uzBTbQYTCK8F5DCUAIdYR?= =?us-ascii?Q?65BVEnwvgGX9tLiW1EnriLnLrspN9o0j+DR81VcHjIc1bwTVV2KX2J8Zb+C+?= =?us-ascii?Q?FGf58Rs4PPhQ0rNsW08Q6b9aJXEUtgx+N/sqT72CEMFF4YjxAzVIrM9OmTAc?= =?us-ascii?Q?rXlHvM3V1HyqgE4qxeE/J4ev7E0EsH2Gn1htOFQdA5l2jYKikD51DqxiRUjD?= =?us-ascii?Q?PtgVpm3ZIO9Fxdyo7e2gXIt+oOWI4g8/4wBVLUpi6ga+MBewSOhhT7+OapNO?= =?us-ascii?Q?rQ=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 sec= tion!! [ 48.834654] other info that might help us debug this: [ 48.834656] rcu_scheduler_active =3D 2, debug_locks =3D 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 =3D sock_net(sk); struct mr_table *mrt; + int err; =20 + rcu_read_lock(); mrt =3D ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + err =3D -ENOENT; + goto out; + } =20 switch (cmd) { case SIOCGETMIFCNT_IN6: vr =3D (struct sioc_mif_req6 *)arg; - if (vr->mifi >=3D mrt->maxvif) - return -EINVAL; + if (vr->mifi >=3D mrt->maxvif) { + err =3D -EINVAL; + goto out; + } vr->mifi =3D array_index_nospec(vr->mifi, mrt->maxvif); - rcu_read_lock(); vif =3D &mrt->vif_table[vr->mifi]; if (VIF_EXISTS(mrt, vr->mifi)) { vr->icount =3D READ_ONCE(vif->pkt_in); vr->ocount =3D READ_ONCE(vif->pkt_out); vr->ibytes =3D READ_ONCE(vif->bytes_in); vr->obytes =3D READ_ONCE(vif->bytes_out); - rcu_read_unlock(); - return 0; + err =3D 0; + goto out; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err =3D -EADDRNOTAVAIL; + goto out; case SIOCGETSGCNT_IN6: sr =3D (struct sioc_sg_req6 *)arg; =20 - rcu_read_lock(); c =3D ip6mr_cache_find(mrt, &sr->src.sin6_addr, &sr->grp.sin6_addr); if (c) { sr->pktcnt =3D c->_c.mfc_un.res.pkt; sr->bytecnt =3D c->_c.mfc_un.res.bytes; sr->wrong_if =3D c->_c.mfc_un.res.wrong_if; - rcu_read_unlock(); - return 0; + err =3D 0; + goto out; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err =3D -EADDRNOTAVAIL; + goto out; default: - return -ENOIOCTLCMD; + err =3D -ENOIOCTLCMD; + goto out; } + +out: + rcu_read_unlock(); + return err; } =20 #ifdef CONFIG_COMPAT --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?9tSPrt0fLlpknzmCckgQo2rP5l+3L0oiF+Csh1ncR5tli2oRm87YFbrbXlG0?= =?us-ascii?Q?VW5+qOSlSPQwKvfKWZYYXsTmVLeQtg8ZcmcB62uIdqqiPUg07AAHrh+6oQQn?= =?us-ascii?Q?Re+22ggvgwXNyEn+NiaDkY7IUTSbO+4rIydpL+L1szkPZy0PpCrIGbV17o14?= =?us-ascii?Q?8nTHQIT40Oh9Np1xRktsSgFwBK4blTzWRyse0dgaT7FCdcJf08jPFC28t2uV?= =?us-ascii?Q?GjpTh2lpZCt2Pj5DF6whQ5GgEbfK5IGmjYwepuehWnuLCyQnlJuG0EDkaFRO?= =?us-ascii?Q?OLBk2Cv8GrxDIsuh3qoaCltw5uy7rxEx+GSbYVi5Bg9h66kpeMnMSVpQozdA?= =?us-ascii?Q?Ro/SnqjWlorSJCMV7GsG/QUr/S8WYv0EJI5Z/mJcYXBorL4Z+RnxeTCkB3BO?= =?us-ascii?Q?GjlKRSRkE4LR9goOjcyOHPQLaJniAOY6C0S2y1MupUGZQM65tXpeUJZFcL62?= =?us-ascii?Q?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BbGkzQ5wKXPRq?= =?us-ascii?Q?JKDI/6k=3D?= 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: =?us-ascii?Q?PS/3oMLCatIzycVgxmwddsIl3+dC0LjV292X/bPX8EJcttyEp4MH0SxJTHDe?= =?us-ascii?Q?JBKjOIwZiWgvzXtsMv0cv1ATd4uK2Ebwg35Np8T44IQZIZDXXxCAT7berVDI?= =?us-ascii?Q?yCkpFKn2wG0uNVqoK6FEdiUHFcjrN5WjsqkQNoQCNtKKxZpIi2ukE7WngRIe?= =?us-ascii?Q?mv//+wT2BXsd6D9s52tJOkCI2AR4e+LWgRJHOl45sSDTJ65baZVw2XFZcq1W?= =?us-ascii?Q?/8Y3nXbyn8wdKgcSilern1D6c8wMRxOmCJiyhYzAcEHhoUW4XJCGjte7ezTt?= =?us-ascii?Q?ptmuRnRsVEvXK+bSsfle3L+hkSjUgrtUAk/6AFRtE8qPkYeG9l0IHlqwHS+5?= =?us-ascii?Q?nCWmNPSPhnaG6GrW7gPKB90EzUAjtvFyX7HFMMU8kjQHwibIN+8Ypc27UT27?= =?us-ascii?Q?g/qqdZg2Hwv1cgkd/3jfsoIL/4HiCxI4ZMv5dkc7NR1ImpGs2DeskmRBf20t?= =?us-ascii?Q?6p4k4PFRzwt2RSUXUXOTxK8RqaH1OGtFgCa41Nx/R/BWN76yQG53xVuE2uBY?= =?us-ascii?Q?It0HEp4W8EQpG6BKmicEuf2Ytcqje2Wevkmzxr2LYd/Obu+c3j/YG1rynvaZ?= =?us-ascii?Q?W7NMy6DfO21TweLwT+wqAlZXUglgKPVh4mSQm0QqaVi6nNLePwnkshbkoDEZ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aM52yhtR77Xb9HmwUSgFvwZ8ZxB?= =?us-ascii?Q?eqa+Jf6M0kvx7PJe15eM8BaHsFgEsIUV5jwdDHVN8VCUFccHZ5S+vg6+h1XA?= =?us-ascii?Q?nA=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 in= t cmd, void __user *arg) struct mfc6_cache *c; struct net *net =3D sock_net(sk); struct mr_table *mrt; - - mrt =3D ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + int err; =20 switch (cmd) { case SIOCGETMIFCNT_IN6: if (copy_from_user(&vr, arg, sizeof(vr))) return -EFAULT; - if (vr.mifi >=3D 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 =3D ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); + if (!mrt) { + err =3D -ENOENT; + goto out; + } + + switch (cmd) { + case SIOCGETMIFCNT_IN6: + if (vr.mifi >=3D mrt->maxvif) { + err =3D -EINVAL; + goto out; + } vr.mifi =3D array_index_nospec(vr.mifi, mrt->maxvif); - rcu_read_lock(); vif =3D &mrt->vif_table[vr.mifi]; if (VIF_EXISTS(mrt, vr.mifi)) { vr.icount =3D 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 =3D -EADDRNOTAVAIL; + goto out; case SIOCGETSGCNT_IN6: - if (copy_from_user(&sr, arg, sizeof(sr))) - return -EFAULT; - - rcu_read_lock(); c =3D ip6mr_cache_find(mrt, &sr.src.sin6_addr, &sr.grp.sin6_addr); if (c) { sr.pktcnt =3D c->_c.mfc_un.res.pkt; @@ -2007,11 +2019,13 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned in= t cmd, void __user *arg) return -EFAULT; return 0; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; - default: - return -ENOIOCTLCMD; + err =3D -EADDRNOTAVAIL; + goto out; } + +out: + rcu_read_unlock(); + return err; } #endif =20 --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?J4/BPqGqtw01PLo/2hDvY2Z5Xk50OTBxzJ0w+a6pN1D7EQDyOxqL0G+axIp3?= =?us-ascii?Q?9u3MRx8nSqXueGPpFFg+5szvJtZu/oGSamF0dToMSfQJxfy2Vt7co9Maogl6?= =?us-ascii?Q?P0y2sAnkjij5vcZbDSN8Pm+vpFB5u4gA6O6498N6Vy7IUJAvYB6wpk4tSRAC?= =?us-ascii?Q?zFtYBTv9Ob5kazoJQOnRZWK3ef/l3bjiQXg06zTdTYcHGWLx5O/f0D80WXNu?= =?us-ascii?Q?MzLXbqOJnSci9/i9RzGVyvaLayn4pvyIybeK8/94A0V7T9OejfW6TwAH7SAQ?= =?us-ascii?Q?RklJ4eOqMkNMFCOwliFvmR50pJh6Ay/bBpoFZepjdKuvZkp4ocFELivrXIId?= =?us-ascii?Q?9F4vcIfiu1zuMGu8aqZ+/NZqiXpJmKvrCxE6HkzcBrtgkefK0rR3SAtB7Pi1?= =?us-ascii?Q?OMTVxOIvfxQCscxVEXpvdTF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= =?us-ascii?Q?o/Eu4+YyiG5oCf/d406GGWg6YUgUMwzBcQiD4QZsQJZIgKAfBWtgMenoBjFY?= =?us-ascii?Q?ln/BGF8=3D?= 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: =?us-ascii?Q?vWvR96hykHKLqNqxqmnUwLg0ftJfD/p8Xwybk77Ow/c6Ajcpe0TeRpqt6ytR?= =?us-ascii?Q?wl92lvM0psHG8HQ1bWUsN4sRrnIknm9bCRsIduo1fSQN0kHr3xYo2WAJ8nS3?= =?us-ascii?Q?sLqVss5W5SLRWtp20ypT5ws6zE5uRqBMiXc5bFYx9EKMjd85Xo9xrEyyYJOi?= =?us-ascii?Q?nynib+MNZIeZ4DZ0Kp2lOHD9tw5fuGq24Ji2enKWzVarLk/YzBb5SuY0zNR7?= =?us-ascii?Q?q6sJv/XyssMmBrGEqWNkEyC/lTQdsvEWWv8iFh/9mv7YN250cnXZ4TjYvXnq?= =?us-ascii?Q?Ghexl2cetsmUUd+BgfDxXYZKu6dti+y3r5NRUSOP4erdOeBGzRxMNzjVj/xg?= =?us-ascii?Q?YIHQRLdXJlexobCvXpaPiNT5Fld9tanIHiSVqtrOOyIRWb+tZV9wIT8Xe+H/?= =?us-ascii?Q?qKtbn21m1eWisoKhxEz8ZGbwofz6GJR8Qi4ssVhIWXmpnGYruIvZ/i9CM9a4?= =?us-ascii?Q?fxsXGOWbe9+CgXKX+4XlYhLrpmx2o6AwwRFp4RM2FsOCO7aaqiBGnlhktdPt?= =?us-ascii?Q?gkEH0xVCWngoZ1W5M2xmz3skyLqZn5AEivqnN+437GSrbTWBMimgJxxfzBFP?= =?us-asc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pa4g70C3exKBO2Yr8PTjs8?= =?us-ascii?Q?n6tSH8s/kf5Rkd2nIrcCdvcq6Tiu32CMbnm64AuWQZLoWDSOfohCU112Ptz3?= =?us-ascii?Q?5eNqWub2yPawHgdtKZQ3a4IpXaTdrJmfGTPEbLuao5ULX6sSheeK3jBir5Y2?= =?us-ascii?Q?5g=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 =3D (struct rt6_info *)skb_dst(skb); =20 + rcu_read_lock(); mrt =3D ip6mr_get_table(net, RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + err =3D -ENOENT; + goto out; + } =20 - rcu_read_lock(); cache =3D ip6mr_cache_find(mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr); if (!cache && skb->dev) { int vif =3D ip6mr_find_vif(mrt, skb->dev); @@ -2325,15 +2327,15 @@ int ip6mr_get_route(struct net *net, struct sk_buff= *skb, struct rtmsg *rtm, =20 dev =3D skb->dev; if (!dev || (vif =3D ip6mr_find_vif(mrt, dev)) < 0) { - rcu_read_unlock(); - return -ENODEV; + err =3D -ENODEV; + goto out; } =20 /* really correct? */ skb2 =3D alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC); if (!skb2) { - rcu_read_unlock(); - return -ENOMEM; + err =3D -ENOMEM; + goto out; } =20 NETLINK_CB(skb2).portid =3D portid; @@ -2355,12 +2357,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff= *skb, struct rtmsg *rtm, iph->daddr =3D rt->rt6i_dst.addr; =20 err =3D ip6mr_cache_unresolved(mrt, vif, skb2, dev); - rcu_read_unlock(); =20 - return err; + goto out; } =20 err =3D mr_fill_mroute(mrt, skb, &cache->_c, rtm); + +out: rcu_read_unlock(); return err; } --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?AT4SGStjSCIbXX7DG8zFXX4RNfiDUZ9X23/BEsUl/YMJZG0WNmzmN/6Z7NEB?= =?us-ascii?Q?pOo86YKPab4ttx8NDN3ahOeQw6qvAFMxb/xsJmwQb1wZy1cdMvTMmBh1o11b?= =?us-ascii?Q?PauUdml4a1wLemZpqrZGhHN0uSnBeZNRV4kSwRUWLSoSEdqkIj9nhraJbLKb?= =?us-ascii?Q?PVdW2FAwLJIKS4aE+eAYXFCwXUkA4GWod6ACyrx+ih/fPmb1ZBY3gDjEAJhN?= =?us-ascii?Q?5sOLHKkLPYwluwZPgACB9Th9KMTDA9sDFi0hNCgEAJGpkv0/CcCRAcQPgJdy?= =?us-ascii?Q?vXN4Q+LKkmM14VFBTDJZ7aDbsGO4zeAiYvXq2Rytu/XsDQQsy5LbTRvkLJFO?= =?us-ascii?Q?5MAHjbSVXli30kU3cwVrqjE78Fcj5fjHUva00UMGywjMsxCgMY46EmuK0Vcs?= =?us-ascii?Q?12pFqCLk7AqDB3XuJybUW/ldhup++fcw1vHJfJXjUJvV5PhRegZ/8nikrD4L?= =?us-ascii?Q?Ayk6IXnmvKmyBelglPGpYDySddzIkJU6XEayxolLTka/AWxj1+6W4G/gQ1KA?= =?us-ascii?Q?soervZfiSgmoRURodZQN/G72aNPbA7zuopnFnn9Z6IULgHWk+0Austr9dVmB?= =?us-ascii?Q?gzxuzk5H8PrZW1WYNKTRaYd79MUZCZsq7XlVZNo/pBvdaNWuJX7LUvY4MW0C?= =?us-ascii?Q?ufcv68zS11Rp9CuK1qY5LxOR9Or7j9Zbwwi6bWOeNqyeDF4webLpAffr+Ti/?= =?us-ascii?Q?OQV2OGkPFxZo0NkDgrejWHK3Sx9UaCDYQmhbzmLDor7X6nkLm6tQ3GgNS4Dd?= =?us-ascii?Q?8GOcmOeGIfLxtHH6+rjjqEkSBUdkRLSreYrKn831J+zKd0oRXeByxZLApA+K?= =?us-ascii?Q?3YvFv3Wh4Fk9tgbJ8GehWoUZJuqb2J3sa79CBBd1/T57l6DFqvcPwFkSSLf4?= =?us-ascii?Q?OFFcQrG8AUlFwmap7amP0kuwoEsgs6V2wJqWhs6onM0UnKfyO5YHumH20r9F?= =?us-ascii?Q?iwRk94YSfTPhfVpmdd2pBnfWpDyYWJBBkdHzmMyH7I3SetKBjXk9fK2oQouc?= =?us-ascii?Q?JjSnJKPH7BMeV1udenOSUVdSRL+NefjgtZVX9uTNZzU0KDHDRawntIWN6uP0?= =?us-ascii?Q?hSgIiL0ybvJzOYRKsAwIAjt82CW7i0Vzime4o2JyPjzUOAdbWPEg/RmMwLG4?= =?us-ascii?Q?US+hFlpkszarvZr81puhQPf10IPdRcd9kwsKkNXBFujpN5JxwhQvwIq8YYra?= =?us-ascii?Q?QoQebELgNKLQZv535C0wx37z1fpothxdyIDenxA9H/ZCUS2VWq061CFCivVC?= =?us-ascii?Q?yWusuV1RS5sTsGpr2IM9lW+Sl3BLo8GMI05klbug4GsvnqdIeVaGugCiuxYP?= =?us-ascii?Q?BWyur3ZHRg7LLE57lBmpA1ZaKyX8KMikyXXipRb9OTgXOw92VEIeCdE2nXKF?= =?us-ascii?Q?IykHkzE=3D?= 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-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fyEb/kfXzPRqZCjyvF7v/p0PJFuXITvB5tpnP2m/qUgC?= =?us-ascii?Q?Wiwde9YW9sd42Vt+zHZ1u49+OiNrbcV8FkgdjGkEO1DgS2DhwLvXB7VUoHFS?= =?us-ascii?Q?zGGtBrdRygmOsY/SQDmbR+QjOqaagJNhyBkMtEDZALyXKs50trsplipzgG/2?= =?us-ascii?Q?nssV6tkwpTaZPsn/hbV/B8EZYzNgU21UvgIqcp8CCcbJPcZX0D+kFCrOcNcc?= =?us-ascii?Q?SMRCQqtG88CCGOgjDQ4X72TJWDpY8NpvVt7G0+/jr/FbxwA5Ih19exdob/VV?= =?us-ascii?Q?quikJD0v+U6M748oqblR3KundECQOfsDEWJWpa0whxYYCgbgzJYun6OqGQL0?= =?us-ascii?Q?toUj3UqYUcgxfoNq0VluKizYqoC/FYpP+qmTro8kquby6zUTlCDpe+/fE1Yn?= =?us-ascii?Q?r2mX/WzeqOD2yZZ7COXmLL1QVqAxz5pa6TfL/rWRErE1tYhjiVhyuoJvSaMN?= =?us-ascii?Q?QbH+AfXxrOh71tBuaVL9w8FbW5T6zErQCKK6XCEXyMuHZlzUegIPf8gkq+RR?= =?us-ascii?Q?8GDXII2UIdGjqXh03T8F8uTCWsP39xrn0qQ515sRfrNVSHONYmGfBbbzaje4?= =?us-ascii?Q?ZHgAGNaf7UC7XFQI4ROyfe+fbd/L/z8WPUoP+bLorfpafIC69Qg5OyCANciB?= =?us-ascii?Q?Ucahif8jt2In8bWsNnZVVxWXaxYY2WEtZ67PgxxHIlik4pZEqitIaT2LMd2B?= =?us-ascii?Q?jgpT11iV53m47waX9mgLAOFHQQArq58rcH4yzckwfCEGF4ci1h5qB9koPbP1?= =?us-ascii?Q?TA=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 sec= tion!! [ 10.247140] other info that might help us debug this: [ 10.247142] rcu_scheduler_active =3D 2, debug_locks =3D 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-49518b10= de-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 *ne= t) =20 INIT_LIST_HEAD(&net->ipv6.mr6_tables); =20 + rtnl_lock(); mrt =3D ip6mr_new_table(net, RT6_TABLE_DFLT); if (IS_ERR(mrt)) { err =3D PTR_ERR(mrt); goto err1; } + rtnl_unlock(); =20 err =3D 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; } --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?3enHzkiBNbRhFMdgzsOEsMbZJQUtmbhGHwvhfG4Q+k5khty4fTzm/+lCA3/j?= =?us-ascii?Q?FA6oKxqQIIOE7IkVL9PpTmvFb5v+QYqAZqKqqIMxukVmGmEFF73HhfmSdejQ?= =?us-ascii?Q?FfmUkHc5oSbG4rYGtT4Al/j/CRVyAR/GGE6xFKhvi31snVLoQ4kzNT0zjCgD?= =?us-ascii?Q?2kCu2GEnbB14iL1+uHYmnL0L4P0bkAnmbWnailVzwTx+vMbNfge9EhLMODDJ?= =?us-ascii?Q?fzqrx+u84D/XtFk8cJVi5e/QA7GhXYiIXZ2WfDSOqKM7BchSXADr7kc4xEhl?= =?us-ascii?Q?VaHsoiI7WDwtQE5o4CyqaAMbq6clzrmdW/uP2/1QVhFi0yDWL43jIurrs6v/?= =?us-ascii?Q?b+cKPweqy2VJ553G5vYHccJPRN6IXpwCeeatZXUVIhQua/SHaULt0vBBBAh5?= =?us-ascii?Q?33jlSSkUNeBHgViPKJSePfE7oRbocB2o75Jqrwl3ZqljIHOpS3DkUaZKr04n?= =?us-ascii?Q?DyDf4fvF9W8njZfibZFTC8ROlgSo1EUW05ErB3AaqFavAoVZkuJCxHDCULyO?= =?us-ascii?Q?1wKKZ1RAlzctOaqNudHun8yKT0TTbvLpH15xQB41gc8M/J90nh5mnzRigrGv?= =?us-ascii?Q?D6WuV1ukHVcjeGyeZKuPupTpjGrHy8B/kvrmEf9uScT7V8uPdiKiaJ80Paaj?= =?us-ascii?Q?SnsvKVDchvlRdyBjaIvpyYhOLYkPH3vWQZLd4kzoKP4NZa1qSRHC8+XTAaxh?= =?us-ascii?Q?66kaYQ725e5yQrGlyPFr4MYj5XOO6tyr1FI1HMDwJk/PMMY0gQPSR54e3iYm?= =?us-ascii?Q?REIQHMKhl95y9Mr3pKE21mrjaR6m7+VUKgz+6QVLnRI66wxdSuzwL1LS6I+r?= =?us-ascii?Q?Uu/kTxfE5lzPl7ifeobmfgPLuR45W7jN99SZHmmfaEyhiguQo/q8P3iK5MbM?= =?us-ascii?Q?+s7k4tUwyi/7iowe1phBqNdK42Vj6rGqq3+ogXKCMsRsXZBNXmQXHD3wNT9a?= =?us-ascii?Q?oXb6FP1Z8mNW/UtCycMxxgoiq9j0Qk31hmn8LYXy0gdBs07UeDWwOTqCvI7P?= =?us-ascii?Q?VTH4TObcIvLqnfaA/Gyq8OeEjbKXmSDZA1kFG29Pvy4WNBWOHZAwjXulYzVo?= =?us-ascii?Q?q+ltZ6advSUPzvEjguoI8+pf+tFft01Gez2XWG8u+ymAZTxdxmK9Rt3aBFHz?= =?us-ascii?Q?hzxfBbXhEGPy7iai+E8SrE5ZtzGnBblMeRLx2KzE771ZeQEY8NyX0fN2gpq8?= =?us-ascii?Q?x0Ro4WEJIWutndue3wQdItbOSWUtLxHBfJIak0ej+gSMlVTQHppLwEFJguCl?= =?us-ascii?Q?apThuK/vj8b9LestHv2wYMdokCT9aT6DYFQadMF/Gcazge/WD79yopmBLYlT?= =?us-ascii?Q?tDY3PGsYBTzFqUzIPgLkf4Mj23RN3dAyUtAq3ggVkXAlqWtWigrgvpj/0qKE?= =?us-ascii?Q?c9gi2xo=3D?= 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:O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d9PyGKsL8jj/0jBX94FzI4bawWw3v4q1zXfMxVm?= =?us-ascii?Q?E5f2FuF/JvnFJBHARaxL2Hg8F4VyJc/rYK0uqhef/4q4Ll/jmnZwXEsYNvCn?= =?us-ascii?Q?7xdh01bknfOGEuoncXOVzGF18EkSzbjK09tfxxTxbE1zyboBklhfjdSqaTPk?= =?us-ascii?Q?9yDTgw+nLEKu1rHtl2eA8GtOau6pPgLIDdnTKWqKYpTiNXOqziz5aAYg+kUB?= =?us-ascii?Q?dBBGwodyMYgdnQ0acoY5EI9zI1XrzmHfpGX3WdkBd5zKbu4W3QtGyxO8qn/J?= =?us-ascii?Q?+t6PUnKGCdPHZpLFSLb/CyI9Jr/aW+/IA9SoxfKzJkRTfQ2OPsg9UwcVuOP/?= =?us-ascii?Q?AUTSoIVi+iv3rtM9UH79leZFju4jWAn7Caarwc6M8BQ9lw/B8oFdtugigPgm?= =?us-ascii?Q?1xW5h/i27sYtTCX12GSddtDvr2KmRlchUfvHd7BqaTz5kbLH2qE8hisPwKZS?= =?us-ascii?Q?PVf/gZ1tRXrLYY2+jZJjyfLVeeUmC0KBwxWRT4PDGUwUfUYboiR61oB8SWDc?= =?us-ascii?Q?X/43YhZSsUuQfEDlcX4AFDUzrbTpiGchE631ivE8lKEqGh84YU+L3kP34aqN?= =?us-ascii?Q?OaigDZL/BN839lbgmnwmRl3cCRu+zEsSrjaHsf3PjxI98ePePZHi5SMf/CsG?= =?us-ascii?Q?JBIoi2+e/BxbVgBtac1arH2BVQnLrkWhIADlnO67NcG4HH7ElhLkgUq0Jchw?= =?us-ascii?Q?7MFBZ43kxrz2j2xQ6kIi3Uxbv3zkYYLfBJyxv6sGL8ZJTLFr9yaZKcWDpLq2?= =?us-ascii?Q?/meZOn96JLsfwon5zCzSEnX/4fELqCHAXQN/R0BAvxqxF2iNDnLzP5Qc6C3W?= =?us-ascii?Q?5g=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 = =3D { }; =20 static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) + __acquires(RCU) { struct net *net =3D seq_file_net(seq); struct mr_table *mrt; =20 + rcu_read_lock(); mrt =3D 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); } =20 +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 =3D { .start =3D ipmr_mfc_seq_start, .next =3D mr_mfc_seq_next, - .stop =3D mr_mfc_seq_stop, + .stop =3D ipmr_mfc_seq_stop, .show =3D ipmr_mfc_seq_show, }; #endif --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?N1+lTCVvyHZK0ugfchn6UWlWllz0cDTK74Rr7Gsjv0PkdXyccUR0z9snmwtA?= =?us-ascii?Q?xM+WARMColTa4Ot/ktG3G8p/WCGop9YAl6haqce29aBnbETJIn3c5AMzBvyn?= =?us-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zsE+9jJ3SM5CkmN/qZW/u6?= =?us-ascii?Q?5hghfp6LyaN0E1HsFCY9Rqk8zWEZK740W74V1pbJg5txF1YlrOTQNvKxPzzE?= =?us-ascii?Q?GwgA0m8wCzdoEpMBVPrwerOcjlr0DqnEsz2JZc70hxwoz0/mb6XzB4xoNmTn?= =?us-ascii?Q?k3+EB5f2W0Yp25V92hcV3vQWzwqsMz6V0IRhEcLCZUDf5WS/vkQRw9WqYWp/?= =?us-ascii?Q?H9rUBMrgwVAS2Q/oBLpQESxwApIuY44FeKvWLClaxhF3RfUTPa++3FZtApgX?= =?us-ascii?Q?fB+B7+f1JlXVxwSmDWhF+ZU2gUFCWKaWArzEH8arnhn8ppS+Z2yIONeP//l+?= =?us-ascii?Q?ZkiprwMSfB5lEDakz4eKtrnDAIRCq85FoEzGZRwX0utk2685R2jdiXLecc+3?= =?us-ascii?Q?U1tJIWA=3D?= 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: =?us-ascii?Q?tS/ZARH1LtQ8WwVnnuy9yJfEUtfrxaFKy5KJxhcN2tRhGv+bCBvYqanoT4ju?= =?us-ascii?Q?3Y7rt7vtb2QW5mIY2aJ9L0iPj3nTsQ6St3K0NxmpkSjs2m3tHlGHf4aPEF28?= =?us-ascii?Q?hmZbo4PqVpz+U3i/y3bScrZ65JZOYMbH4u8q/niXLqpjtTEyF4N30mgxHhl9?= =?us-ascii?Q?1yO7sAMWWM3nRmiTg4sLpY1fwM271EGLYGXcmzwixIrqiaAEar7MrV06LUOy?= =?us-ascii?Q?YhstMpUkb1vW8b5Wz58G9b/LH8pR42wawXzl2bGJindjVU6j2jvNEf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K8iX/ZAGGbe+FdKWdW8WNiRFiMaeV60xahZQew?= =?us-ascii?Q?1FhhU9g6LAsI8dGvoLBhJD3MOh1pmPelWoKsIyA0L5sxUPI6tdPFQeOjVF1+?= =?us-ascii?Q?p+9sscD4wikqEtgk1/cg0LpxP3hKQtfVwNSNFIdWt3C1Jg9POp/A682Bt2Ow?= =?us-ascii?Q?2hSOJyMZ1Ew8BqgVgl3wIIMAGzSCWKeKFg1p/pKY/mdl6m9aTVuNHUvqBR6c?= =?us-ascii?Q?Jdydqa9yPpzC9j3DBenNpaeimRbwtFijpeT2AGwk64gQ0TUEjSk8M/l52E5p?= =?us-ascii?Q?+bK3P5HzoJhGdK5P/VfS441V7JMBjLj60ha6yKapPMloFRgF4h/dLcBQ43Da?= =?us-ascii?Q?VIC0Y0qELbtltSkXXmQbgPohAvrhzZwtwBMPmtuLOfW75gVzyYq8BS3FsKTD?= =?us-ascii?Q?nE2Mqa1LRi9mNcP46zMs+pPHdqZbU0jAJM/0seLQtKbjaeOtzwC5FrVXsjO9?= =?us-ascii?Q?Xw=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 =3D 0; + int ret, flags, v, parent =3D 0; struct mif6ctl vif; struct mf6cctl mfc; mifi_t mifi; @@ -1678,48 +1678,103 @@ int ip6_mroute_setsockopt(struct sock *sk, int opt= name, sockptr_t optval, inet_sk(sk)->inet_num !=3D IPPROTO_ICMPV6) return -EOPNOTSUPP; =20 + 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 !=3D 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 !=3D 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 =3D ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + ret =3D -ENOENT; + goto out; + } =20 if (optname !=3D MRT6_INIT) { if (sk !=3D 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 =3D -EACCES; + goto out; + } } =20 switch (optname) { case MRT6_INIT: - if (optlen < sizeof(int)) - return -EINVAL; + if (optlen < sizeof(int)) { + ret =3D -EINVAL; + goto out; + } =20 - return ip6mr_sk_init(mrt, sk); + ret =3D ip6mr_sk_init(mrt, sk); + goto out; =20 case MRT6_DONE: - return ip6mr_sk_done(sk); + ret =3D ip6mr_sk_done(sk); + goto out; =20 case MRT6_ADD_MIF: - if (optlen < sizeof(vif)) - return -EINVAL; - if (copy_from_sockptr(&vif, optval, sizeof(vif))) - return -EFAULT; - if (vif.mif6c_mifi >=3D MAXMIFS) - return -ENFILE; + if (vif.mif6c_mifi >=3D MAXMIFS) { + ret =3D -ENFILE; + goto out; + } rtnl_lock(); ret =3D mif6_add(net, mrt, &vif, sk =3D=3D rtnl_dereference(mrt->mroute_sk)); rtnl_unlock(); - return ret; + goto out; =20 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 =3D mif6_delete(mrt, mifi, 0, NULL); rtnl_unlock(); - return ret; + goto out; =20 /* * Manipulate the forwarding caches. These live @@ -1731,10 +1786,6 @@ int ip6_mroute_setsockopt(struct sock *sk, int optna= me, 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 =3D=3D 0) parent =3D mfc.mf6cc_parent; rtnl_lock(); @@ -1746,47 +1797,27 @@ int ip6_mroute_setsockopt(struct sock *sk, int optn= ame, sockptr_t optval, rtnl_dereference(mrt->mroute_sk), parent); rtnl_unlock(); - return ret; + goto out; =20 case MRT6_FLUSH: - { - int flags; - - if (optlen !=3D 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 =3D 0; + goto out; =20 /* * Control PIM assert (to activate pim will activate assert) */ case MRT6_ASSERT: - { - int v; - - if (optlen !=3D sizeof(v)) - return -EINVAL; - if (copy_from_sockptr(&v, optval, sizeof(v))) - return -EFAULT; mrt->mroute_do_assert =3D v; - return 0; - } + ret =3D 0; + goto out; =20 #ifdef CONFIG_IPV6_PIMSM_V2 case MRT6_PIM: { bool do_wrmifwhole; - int v; - - if (optlen !=3D sizeof(v)) - return -EINVAL; - if (copy_from_sockptr(&v, optval, sizeof(v))) - return -EFAULT; =20 do_wrmifwhole =3D (v =3D=3D MRT6MSG_WRMIFWHOLE); v =3D !!v; @@ -1798,24 +1829,21 @@ int ip6_mroute_setsockopt(struct sock *sk, int optn= ame, sockptr_t optval, mrt->mroute_do_wrvifwhole =3D do_wrmifwhole; } rtnl_unlock(); - return ret; + goto out; } =20 #endif #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES case MRT6_TABLE: - { - u32 v; - - if (optlen !=3D sizeof(u32)) - return -EINVAL; - if (copy_from_sockptr(&v, optval, sizeof(v))) - return -EFAULT; /* "pim6reg%u" should not exceed 16 bytes (IFNAMSIZ) */ - if (v !=3D RT_TABLE_DEFAULT && v >=3D 100000000) - return -EINVAL; - if (sk =3D=3D rcu_access_pointer(mrt->mroute_sk)) - return -EBUSY; + if (v !=3D RT_TABLE_DEFAULT && v >=3D 100000000) { + ret =3D -EINVAL; + goto out; + } + if (sk =3D=3D rcu_access_pointer(mrt->mroute_sk)) { + ret =3D -EBUSY; + goto out; + } =20 rtnl_lock(); ret =3D 0; @@ -1825,16 +1853,13 @@ int ip6_mroute_setsockopt(struct sock *sk, int optn= ame, sockptr_t optval, else raw6_sk(sk)->ip6mr_table =3D 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; } =20 /* --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?3JZAMVPrwAPRSquMZoKCGwFWgFB9HCSL8or7dlgTXwsPSVEflKjcwJAs4fmh?= =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NWcTy8FrnNh97hUqxoh3mw1ANZcVJ1?= =?us-ascii?Q?1H9zyLdrFe+23wNZQHKg/LESJjCIO6nL2ANb+zinaSe+zBC5RR5tp0zPmtY5?= =?us-ascii?Q?daM6LvXAP98ceI+wv5ywL+HN2qezTP4Tw0f/6owCzlT0GCu/gcSgrE2WWQzq?= =?us-ascii?Q?gZcALtH15++01DXjsqyOKUR3639tfdBMzBqV/CNRleZLVcMTL7reBRdISiWZ?= =?us-ascii?Q?V6ksQR3Nm5lPyUGe/Q6aGZtLmhwgAY5/A6FoMcdIq0yRAIuh97mHSN17SMNf?= =?us-ascii?Q?3quYAjvMNUZ+suJZzKbQa+/kbpstfT/1DvZy7t8AqZOvaNII0nHjydzk416v?= =?us-ascii?Q?9pno6YwHdSyBMDBUWScQDtEusecupoKMVdnzwzhldGfP4N+0pA533rYtkwVP?= =?us-ascii?Q?zSTMziKVrGPMPl47ounT/9mbJ7V+dA58GKJDs4ol/2Gnsh9+W7xO+SdQe1p/?= =?us-ascii?Q?eedySuU=3D?= 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: =?us-ascii?Q?uGZJ/3nkYRiFSweaq9qoDNajaE0ORTu6arBa+TF0zGALb8oiZlwJhdmqHQX4?= =?us-ascii?Q?pwdVufYiFg3kbbI9t0ACx1eos7oZSOifQiXBZBXDBUOUrepZ6pRfoUqopOB8?= =?us-ascii?Q?wyS50qMn+7ihfliV+qr3Tlzo3m7P8z3UuvGe7fApj2AlTrQgWznTBghfhux0?= =?us-ascii?Q?9ry5JosseW2LEAZC0rJsmfG4xIy/QYMBeYnv9QBh/xwRAAaJjvrMLISPpqnM?=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/XDiqQj9F+RKxuJS1/E9QzWeQfniIO5ks?= =?us-ascii?Q?NFp+DAOqx6k1cBz2R5YsLul+/JxpFlM/liJ1aZ7IuvMKKpnzJ214QA6kkXCq?= =?us-ascii?Q?8JkHMbZrO/WihX2djKM07yyA06tn4G3BKSxDiOfTLuCUSHP7WU1AZpErqFH/?= =?us-ascii?Q?KqcQdm/EWqP4PA6iJIDOvkKlDUw2CmdRoUxI848g9JURxDY2GIIP13DxAm/V?= =?us-ascii?Q?bqHPxhmjoEhhR2ND8bsh1d1rQGy4tiPtSZESxBzP2s7XN4LApbe4L6LkHd3L?= =?us-ascii?Q?zPrYENsZFJTuAFOPQSXHgZp78wlloIwsAw1O1jqJKO/DU7iJRVz3mg9e1ZLo?= =?us-ascii?Q?RysMglc1cXqcha3IacD1fDP9EID9a8wYQTSrlaJ+fYOc4TneKTqoIerIykQs?= =?us-ascii?Q?4GvBSzbQWcTLjXnaH7GlNaRKGxqEGgQPsrG59b4/fY91Y4mDwhkGpiZxkjl7?= =?us-ascii?Q?p3keAC/c+laTOK6O2IkEPG1f2GuJe4v/JsUWot9pIlI3uUM8RX4O4CWN1S3g?= =?us-ascii?Q?jg=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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 optna= me, sockptr_t optval, inet_sk(sk)->inet_num !=3D IPPROTO_ICMPV6) return -EOPNOTSUPP; =20 + rcu_read_lock(); mrt =3D ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) + if (!mrt) { + rcu_read_unlock(); return -ENOENT; + } =20 switch (optname) { case MRT6_VERSION: @@ -1895,9 +1898,12 @@ int ip6_mroute_getsockopt(struct sock *sk, int optna= me, sockptr_t optval, val =3D mrt->mroute_do_assert; break; default: + rcu_read_unlock(); return -ENOPROTOOPT; } =20 + rcu_read_unlock(); + if (copy_from_sockptr(&olr, optlen, sizeof(int))) return -EFAULT; =20 --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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: =?us-ascii?Q?kwX8wPYQ889jbjHblMh10EsiCZq9RMW+wwfMhG9dFInna8QStKOX3OF5XR8M?= =?us-ascii?Q?t3lXy1nfqEFqJkA4K2+zeXijWRAhSjQrhA3UXzUt2uzCP/7S78A/n5tIT4eg?= =?us-ascii?Q?73H0167YCsntrC/SkpM6iJ1XR4LEaTd85kQ9gtgNghurWcrJMzbrmIPHCY4q?= =?us-ascii?Q?CvVKhwkRV21mKvaFwTxrdObsDeXfBVuN3Gl6Plj2OSOGh5egDRVqiEDa8xQd?= =?us-ascii?Q?49RHkSls4zvt9uIGWQL0c08qWyAV5LrwY/B92xEkz595/4g8l4feBb8ClsE4?= =?us-ascii?Q?DMychDh5lxSa2I79xseYDC04R5QIWtgvDrxoLNEtkoSC1A72dDY3idxcVP6+?= =?us-ascii?Q?U7kGCnA3XylYglxAW0anDklMTvirtL9U+llSzHF7xX3dzmVwFSDY3+T3TbZ3?= =?us-ascii?Q?A04xfpX6GNeRL3cAU2X9A4RE0TAn2XH72goCm+dAHa+qjJoYhQRU2V4Pj1uG?= =?us-ascii?Q?jitVmWIWslO7opKniqw9DCuIbSpCuY1MoTTx3JZDIGwCzNZc1aAdHpyIN1No?= =?us-ascii?Q?M/JjdvdqyA02T4202CCT/FI9LbnAgW8CgSDmcG7NO28F4fO9W4NBL5VnL/px?= =?us-ascii?Q?kcXQVWmny3x4YC58+6bJLoIRgiLxifTb9BmtxWRx8o+tqdhk+xlDNkFxe2R+?= =?us-ascii?Q?2r51fA0Ww9hSEdBWYUhMZeYBQnSSH3kKMYHzmLI6MQHOd9NgmGkhIpCOcSMB?= =?us-ascii?Q?FMjtTMbhWMhoQk2YrQW6Uzu030wJdk3XxmHeiKg7v0ugu834ZDXGvGjswiWo?= =?us-ascii?Q?LDU6cwdwwb2mwo4wLocIYFKI1NqyNYtujOJx/3C9DJd6IXAfIc6jAUfpApe+?= =?us-ascii?Q?piFcEsiJ8THQfrabb92qs/Vz1o6yY8W480e+YN/FPggVruNKWHtGfQ6/wyWN?= =?us-ascii?Q?UaGW8XqEUtCag+W3NFy+aMTeOPJipZ38nl54r/ffbVe3lALSbMitTNkoSiVc?= =?us-ascii?Q?nmUgF9qv2HtJtAmvaheIBf1OFVSJlNMcj26NNvIjIiY4KWAC91VMNQtvV3Pf?= =?us-ascii?Q?8JM/Ss24St297GMLrnIef6mnidV41Ra9JA/oKh80bYAMvtxlAqMqIH17+qKD?= =?us-ascii?Q?4y+emdtzFYlOE6Tz7uph7DoS3yXsls08ccKuXBjtDGaNdfAbJyo/717De+Wd?= =?us-ascii?Q?6mkmWxvfCcvy0O2RrtqvWWAEUk4KrnfuxbSVwoiYMjNoLYqA29q04sKWlQjD?= =?us-ascii?Q?JV8JMfuOoqfVMX1ZqgbSd3EBkGekRGHwJEg7CsRwvOd0ZXlsDqJMATo7BuTH?= =?us-ascii?Q?oZoXVJH41ChISK4BljRRMf9zvt1vv1S67Bk8CizyTSUrWHDYAtzyDSlDZhjv?= =?us-ascii?Q?kw9LH4rq8M1PE/iATBQTX8jWuGWMfTi4ubkFpZWVF/u7bgHxtNOZcVNzJrU2?= =?us-ascii?Q?80I98m4=3D?= 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-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BV?= =?us-ascii?Q?GW9WKaKuKrXhJoUln34pNcfHqFJsb1KJG77pJvfP78PbU8gGsLBS7lPbLDmQ?= =?us-ascii?Q?6Qs/ddzHQvcjH/w4+FzdvH7ZzbGb/0Fzsf7zCs+k/lrLgREvZ2e5pqs28zVS?= =?us-ascii?Q?+dOtkAk7MAXvRV1ruGpnzx1SNf6IL3RnzCCeXF4sPAloNCAWF18FZtA5qv+h?= =?us-ascii?Q?u59DRxFhUoeZbPf9t39tuXx8K+xG/1oQcUeVLhawDlqZJAgmSmrZna5x4ov+?= =?us-ascii?Q?aMyLBKkXAq0cFH7kCko1QYpY8FvtNQJBGKWJSVhFJosRCB+LZTurVAZfULPS?= =?us-ascii?Q?MEX6yJHCGxBjBOTICLpyKoNS+3Sutc/kPKSeIRFoNQKh6MYsP25XfocGuhQ7?= =?us-ascii?Q?YkNp3SrbLvOXEl3I0VsgYcbzKSPE9+9E9xZ190AI2maDiDmDCMfZDef0Ce85?= =?us-ascii?Q?VlxA3yXOUR3hKS4yo1cVcTbIZ6jUjFecAFF3LbQwR8aITpCBYoiEH027Tw7/?= =?us-ascii?Q?EdnKtrGcKX0emrIOt6AVDb7Ec2hfyiRYEq1NXvhOFwWyw52KQRjqhRvs1zrV?= =?us-ascii?Q?0tfu8SxC9surhIOkeKwN/4jVDENpti3iyiJBkPfHSqXRnwn8D44nMcidQMWM?= =?us-ascii?Q?Dli+vHDk4fvUywGEHwzqQgFeest6DGn0ueWsK5iX5HPJH5PU7QJ3HkxcJJbw?= =?us-ascii?Q?TtN4LTNNCvfbsl3m6OMIPL2Z/UsBSrJ8fbUcfIy7+vX/cw01UJ0UVZrlrf9l?= =?us-ascii?Q?6hl6xat2ao8Oz44e+riQZgvdPrGBvCjtgyDmx148RS/6Oq0aW2hg9iPDykKl?= =?us-ascii?Q?jQ=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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_sk= b, struct nlmsghdr *nlh, grp =3D nla_get_in6_addr(tb[RTA_DST]); tableid =3D tb[RTA_TABLE] ? nla_get_u32(tb[RTA_TABLE]) : 0; =20 + rcu_read_lock(); mrt =3D 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; } =20 /* entries are added/deleted only under RTNL */ - rcu_read_lock(); cache =3D 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; } =20 skb =3D nlmsg_new(mr6_msgsize(false, mrt->maxvif), GFP_KERNEL); - if (!skb) + if (!skb) { + rcu_read_unlock(); return -ENOBUFS; + } =20 err =3D 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; --=20 2.42.0 From nobody Tue Nov 26 12:32:37 2024 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> Content-Transfer-Encoding: quoted-printable 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: linux-kernel@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|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jPxtToUBOr78aKCEr8+OD8lpDk4LdJbKB/QtS0hD/WhpN2PScMrcE8pN9x/T?= =?us-ascii?Q?wF63Co5drSz7NvER4++eOab0O6+Ebu9cBlpmmXiiH2dQL8KPJUT0PJr+oybo?= =?us-ascii?Q?lv7Y0qhHRv8gtDG4u2Cd/LNKYfH9EJ02/H8GyEKXY0gx38CCDu4aiPBpUbVF?= =?us-ascii?Q?k5bqi8v5qzU27LvPYupqSQkeM01+E/wq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2T7ai7NxAVPFyEINxqZ5Fm+3a/aIViAQNxeENctlEFOQopssQJBlP1?= =?us-ascii?Q?AA7Ee1dZhE6iSir7ku25Ippj779X3qsM0GItsI647LXZZ0DVHcvTQIU5wSgv?= =?us-ascii?Q?hSCyRuPLSe12TlhiI5Q00hZDFUOQ46CEEoiNs3TIehJr7kWdqM+GmaAjHNSS?= =?us-ascii?Q?UvnS/uoTHjIvj7UJOVO9x2+XlX3q0uYyAdjMafX0bkKNY0XfpzszihwPiofD?= =?us-ascii?Q?0/ZPLYCqOdqoa+qmlXDuFYOgv5gyB5WtZdMTH5/87NctOfKmwR8X3e7jhDrg?= =?us-ascii?Q?vrLPAUM=3D?= 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: =?us-ascii?Q?3bIeCPUn1/n0VK89MpoC4ufFFWjoZ7OJJ1nnGj3NN/vRh55wmj5IJipPW/6P?= =?us-ascii?Q?N79lIDBiBVK6nhmFVr46jURQZYgMAWn5FepnftxyO+4CntazdzaAl2RD+Lfb?= =?us-ascii?Q?P9gl35zibbdInwQ+ehP6L6/XHDfbZM8VscoNsolkb0mPikymdX03HhrFaf9D?= =?us-ascii?Q?wG1r1KeyPzvj0718VXR4KwY+LtJampgKV13lDPmUeg0Wrg4V6yD6sDkT7Ff9?= =?us-ascii?Q?enB276OnqVbDiMBYRBfmQFNd9TrLnLHqKg2hfcuNefhynV4CfU6Smna/+fZ0?= =?us-ascii?Q?xsG743Vb/wIZRC1toTr7lhKtRrLtvYVkLp9Gl3jsr0EHjPrssP39esj5wReS?= =?us-ascii?Q?8kR7M3nZRueXxk5rj0P/hMM1ZYhiFGBI/65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ii?Q?4fRlJa/i8jqB6IFNFxmA3kJ8unXGJxEkwheWRgecPgogUwroHWUAeC5C+pfY?= =?us-ascii?Q?dCvvJ7P+OwJw42j41CP5VIhL1s3x6MwsvvfNxNS7p4wTYxSftbQCmGBASXs1?= =?us-ascii?Q?V9umWr/CGX1CgCFLodDeScHN1Q+e+ENHeLz9AoYCPXHtspZzs3CX2Aa8xABs?= =?us-ascii?Q?XBb4A3K9DsURhug10DTx2nDFk9IC4Qw/yz+PIVz31hVmuDbbIO1CIfRhVwuj?= =?us-ascii?Q?GbOdlESevgy/3tIoU9E5ZqM2qvd7QXIsAdzx/8E8ea9vp1pLvwJVudj7XztA?= =?us-ascii?Q?4nJH5JH+KuBz3i9lHViyeJYG7IakwseWUIgTUiEpi0tamKvP2xybBm+Afng2?= =?us-ascii?Q?zA=3D=3D?= 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 Content-Type: text/plain; charset="utf-8" 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()) =20 static struct mr_table *ip6mr_mr_table_iter(struct net *net, struct mr_table *mrt) --=20 2.42.0