From patchwork Mon Oct 14 15:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835202 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2056.outbound.protection.outlook.com [40.107.241.56]) (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 160E91AB517; Mon, 14 Oct 2024 15:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918793; cv=fail; b=XKgS96kSHnvVkx7ivH9mRqj2S2GOKdz0bIAtAMI2Ktx8tDEQGehIR4Igj6SSViGY0iun0TKohXBp58mCLz4i0P2cyig04LNOUDDKZZTK9aJYqA7QwRhKd98zubEiA4qQ6+3t2C6AbP31aXIgTeIEuIjU8A0SRrFf+YeK6/iRWmY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918793; c=relaxed/simple; bh=ib6Faai4OQRqmtopYKqjOO0SsweiMc5aOUhyF3/iuI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JnJdnyj+VxAqt0t8ch5i4wVqwaynXozG1U+s1F4wh+rYpbaLsQHwUl6pZsXvcCqtt4LrN1Fb6hk+kfr1PBKmFFCIxeBxwFb4jRXosVNhVL2kcraSwqBuEMnzDyoKkAokrNaXSmQpCgEzmu9IN4yCKhKI9yGZXnU9N/+Agz4Un5Q= 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=ELeGwVaH; arc=fail smtp.client-ip=40.107.241.56 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="ELeGwVaH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EeT5XLWfnbqds7Cmog+9hqqeqX7uSIB7SmHLvDTvrzwARjNHeHgRfRSMiCxSNCx90RLY1V0B4gS2C3ehGiAqHnO2N2xMrNhMNmdfLKh0gr2AmrQN/C9qPw4hlq3hdYax6grpOxTvz/r7sZMs+v/a2/Nlv73IWfwPSuljdOpLbfAavyG7DI1UuMrsT/AlAAZ6HJ7lFNHB4/mypvyYgsKqceF0+PuZdOJZ4W1DrmwkrW5r+PoP/0HpOhyJpS+7D8PBv4NySiwIZEEK+PyEvz4Kid6v5heSIUtffcWx20cXQkrTQIeVFi9rUhz+lPoYFx+s13YAsPf5vihmbOyD6+1bJw== 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=9tWeL6x6otq58JBciWHLWg2V3W5/9/f7qlubIloiMjU=; b=HXEjJ8RJWxw1PML3m9xkODWeQYomRk4pskQu3irb3gSHXpz/SP78XLJAke7SGTihSyOTJVlzJWMxvLangZe7M/mIi8cKwmZiV7Fq0BmuZmrajbl0kcN6Zix6TCksHPMk6sZP/BA2PQSqupWRihIK0r3lf1xnPF2PuLNOtU8Jrai8zLqrWBcL+A2ruvDgnAReEQu7tTAsDsOhp8IzhGrc1WJ9qa7346EyUC/MESQ+yJPB7TZ3y7UOviGIBZchymZ8/XkzSbc0M/QeCxJX0cadcDHkBQmiI8nYHyLhNqjiE9g5H+VD4iyQRX8/o55m5CaHYa3XOlVN9H7JHW2gPpo4ww== 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=9tWeL6x6otq58JBciWHLWg2V3W5/9/f7qlubIloiMjU=; b=ELeGwVaHMEOAcoZXnrDF7C/d4xN/+oQAl0HeSL+Kg8/uzuk3htjYCsUlOL7dB2WS2to9szbtYHBXZ8sEHfP4fmY9yfIxZQmai1Itfx5HejiTHBNPJEskJ+XCMmvl9ZjDW5dV5J7On/8wOZTQC4Dl1vsbr4loV0b2B98Wv9lDyXbYDKk+K1ILtOvzTBp6YODOYJ3y7q9oKj3dW7YDiqsVX/Fpl+/O9QQ2PmhlrOFCejU5afmKPPgLT24N6vNmjrg5u8Z0JvM5HcN4hdE7OSgx8xv5yvgzZrbYGrOGpKUpBNpLjNvG7xA7Ue/c2n3H/aJCGN/bE2+hpgUD2woLf5YPCA== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:08 +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.8048.020; Mon, 14 Oct 2024 15:13:08 +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 v5 01/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_vif_seq_start() Date: Mon, 14 Oct 2024 17:05:47 +0200 Message-ID: <20241014151247.1902637-2-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 6889c552-e995-4c3b-e8b7-08dcec62b5e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: FKELyt/cclV6SAxbE1RG85j/cFQy9sYksR3YeWhQnF6pmuExA+1fmxuV/Mlk2UhSoSqxAEpKicfLvOIK7xM66xD/G8LBmlneE1hKBjtmTYxY09LZm73Tm4mz4wS2YEh030Zu1uOV0QF7rhL8/MXKUhlfmkSIBCncS5AvkncCQEw2PSUsJ7r2xbETp8dS1lA+AqS/FCosPDI+jP3HksA99NY4ORIvWsmeb1j1x2UJRzKXrUx6D6Ezrq/dduaFa93vpMFRQ38ef4TLf4B4JSeB4INksnjkUokRiDQ220WQMEKuM2PnmzzgUKrGRIoACiYaieYnQsIW+aPSEN5SLTd1ZZi2RBxMEWNxKmtlcQmkxA7vec6y60FK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eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5HDNvlpxR5g+kZBVSiPQH01JNocLM5ppJuiv+CRYqul/8tKBuXqV2dDzQ1JJB0bLqj0ZS/VNrk8FqTSqoj9XZEZSrQUUMWVQpH/vpqow7IEkdXYtcdmpp/vX0W/gaWYbd/+4xCExH0HGUBK0G/ExNPTUibJf+1d71oLSqRLYZ8V1SpntSFRRU+xWiOxzC1EGPVdDwvyMdKVgC/3bAlkAcniGdFxkjIa+bqkyVjrDss/wLxUWeAvg3745/i5CV2thIXbSfdJrvEHtTxEjWHqJY9hMJE5NbKMFLkGczKnzHuhnk38Gkx5S9jOYWU9ViMIak/Cd75q9UqKBL/pPXcN1vdD+vEiCefRAWs7kXkHSRF0FvuJO3RqLTATqXZ3HXDmbW4uDGcsBUoyj0o5pFC+V/vy4blsEYXdBANlUytLTxp0PRWtZG8h73DiSef9G6Lt2WuAp3bKWQ+b1ritzuQuhzEAIzF750ah0qwM0hbLnrM4sqj3DG2w7lptIXYlOEewuJA8ZkGwDhvVHEJlf+RRTA4uTpuel+kA65ubJg5zERbdXwEjESuMJ2vmgejbm+3FLqd6q3OTRmsVRcAHqQHsMu2PY70YGdrbLvePsMQoaKOlHPoL5/Gj9hPBmNC1uVs87rzBifUTG7QAF7VxN3pxC51aHLqihfxH8kDxTo3hWnYfrtXlkQatrRlUEfr4W/5kXGuc30/IVEcjE/AHeIYY6h4iUqFBmu0yDKKWHiOG9gCU4D0D+Mn4Py2v6YPUM4FY3AWbcihrggfA3H/irTF+F5dnLJ1g2D9P4F+IWn4pFqSmv/lDYcDGPYruju2vyceBzF8AJtYexTDhFpbWSiPbCfYukEu0QHH+00NCBqBkSk+Ggr5dv+YuCddWa56GTT4S+ONr2w632Iz4saY5RBXs0SiDeO0VSpIqiD530tRlGjXOGSZoTD6vArDy+sZdX5+R57mSBiruyIp0HZrqQqCR62y3xG4lzU1Sm22qFgF9fELFultUJ2eYqojSFPcMW4TH6nozC8vED5ZEUm/wSXHOWO5d4V4SfMM48USd1scJLcZCBlmt5mtfsr579tHkF9Cbb8ebOmXqA6KY2wWHbqtmEslNdHO3ijoisjlOV17gItjh1C36WLYSnqd4NZYEXf1bpqM1DwXxnpZsIi0w3+4qYb+dZYCDMyorTXzkv8iK99apjQc/T323P+NR24siacaFOvNUXqqmr6ofkUxYG9XzSXH1VE3uz34ZU7VLgv+ah1ySTclQ+e5jwQzhsIJYCVFZOzG7RnBEy9nVW9F/lXo4dLbrSG6xCasCEEUSFSSz4pc1c86gll29oeMqggN8oyfuN2BZh4ZgS8m7p3+Pc7qnb7joEXewMzO7V6ZdLkbjm4uigGqoUyRAeWdIyYnIzcxrytRu6KnZfXivACoPBNFpMTjMorKtfr0YfXIgY/NqohJQhXoV7IuZn/OmzwwjG5wRvudsHBnIMxrpYx6IuC3aB4Hr/CmCT+HFGvOFo+dvNN7PD8OZNuxJl4QTJfSPvbaWZTporwZP6aNdxBteBGSon1OLoJSWZahgYfU8aEyAmW4IYViffS+MQmuI4y8Zv3I4IsLd85LsE/D+GJGExwpVtLQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6889c552-e995-4c3b-e8b7-08dcec62b5e8 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:08.3608 (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: sKEKEXOcLrnK643H5gRvlJZMgaXgQD/90iK2DUlOWqg6gtJKEPqheX2oPs4oUwH+WYhL/C4qkrVIW3vT7DUyu01PmUwIi7QEeXyBMMNCRKo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done 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 2ce4ae0d8dc3..268e77196753 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -411,13 +411,13 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos) struct net *net = seq_file_net(seq); struct mr_table *mrt; + rcu_read_lock(); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); if (!mrt) return ERR_PTR(-ENOENT); iter->mrt = mrt; - rcu_read_lock(); return mr_vif_seq_start(seq, pos); } From patchwork Mon Oct 14 15:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835203 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2056.outbound.protection.outlook.com [40.107.241.56]) (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 0DD2E1AC427; Mon, 14 Oct 2024 15:13:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918796; cv=fail; b=FNOdI2n8E0MCGw9pRuKp9o2a9s7MGCMzVUCznI6B9SukoOpwvRSLaGyQu66Gi6iJA2BYO9SZ5yVfftIyIQlobQYtJ69eVjbwJKz4EBhwKSNpJjJr+jIsJjegIVq4gE/ywBic17+RBNoB9BYZ/SbgxBv+cwt54/Q5YGQ8G/BDr9I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918796; c=relaxed/simple; bh=ZRwSxzEq/JG7RG85egQwcj7nqtw521c8nHnSOEiUfFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=sjhKR8kuxZTb1H6GmINjb94N8MpieQhKgVt0ITERf6gaen7pu6N5NfhGIW494uERaQwggl7oJCzEoKfZs1lYx4mbXKOGl5xuQf31OauGBvBIKV1QQaCRqbZ3AQkkkVfMKaYz1C1uOa0IxsL3I7y9hjs2nZdUUnrytR7NlyZFeJ4= 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=FqiTNbqK; arc=fail smtp.client-ip=40.107.241.56 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="FqiTNbqK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rHMuCvbItqJeEKB74hWjaZAMIu1Wo/SYuRo9TaVfXZF555qXwTwUZ1/1Pk/dYJVThEDjGJxmyFqnKuR9KYf23NTYQKwChJHcgDgBZYEAkAYHOPiJ4yBmNbg7OSUrHnYSaYxbl1IFfFLrjqgeWP6AwpzG2sUasPyKgjiVNgdLCPmS4nMOAAdvit2iHVjvlKALfhztXFFDRLoTYKQPfbuEfz4mkIYcFyvXou7y+quAIlciD1CRuTEzVZ01/dGMtoAk2XbLTVX4mLMDKYdCvH2r6Ekcwgf97W0pcHV2vzUVjHjkZbD23aTtqS4USfgSd9AiJ0F0CJ9NF6C5l+sxt+vNig== 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=DvDfLSpKbVmCwX1prww8uQeglFjudRba0RVIrk/XYZA=; b=TUlPvG22uCc4r+K7MH7JJ52ZHoR25TlsU0DZRbUWTUwvycbsjepubo/0hoXWyVp0zK3TFb2kL7YHqGVPuh0abXie9d0xg5RFJi6ChvzFWautQQ/M0MwEJ+ovGtFdkGlFs4bE+vYAhH3nmdkiKfXr40lq1mO4dV1drvSeDDi1sdAEOYaYrAZOACi80I+nmRrB/IHBklzo9XdGA0D+V9CZGvBBRrH3jVOC6Zf21kJMpZAC3J12FYTr3TlTkJ9mrYJEiuzUF7OGl5OQ4VVA80BeSnXUY2GlCT1vjOTEhqvD2YUQT3dlct/J3Jpmf7AgWyl3xyc729LH6LDjrEX6TUxqsg== 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=DvDfLSpKbVmCwX1prww8uQeglFjudRba0RVIrk/XYZA=; b=FqiTNbqKxfI72vT1E6XQ6vYCHEQFr3CnbB2u9b9IPFnt2GYPlvzURSfhjBz7MPGe8shf86Ektr20M+dF0Q8YJx9hB4NzeuLgBXkzetGnrPVmhCUNZGCBsUpBzPmufnNAU3tpS3uZd+Tk8cyNt4Cp4VJ2KbxqDH5uJh5X0hx3LMCUUXJDSJPSToD5GNLcB1vSeuwPkEEisGxgXIYIIV5lw+hu5ZivBeNXh9KD8trfij4Am748tBiZXloxECJudHSIWVIMlz43Wq/Fu9AXm1mdKVXaaOA8jMA4f6bwRuO+bk6A9i+aVoe5CQEVKx/fWmpildbJkKoZ/dsXS+g+IniZ4w== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:09 +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.8048.020; Mon, 14 Oct 2024 15:13:09 +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 v5 02/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_ioctl() Date: Mon, 14 Oct 2024 17:05:48 +0200 Message-ID: <20241014151247.1902637-3-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: a4265647-a31e-4609-a85a-08dcec62b68d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: 2IwcTYabDFPdGOefU7RIbqA8Ip2Dk8QGsnTuXZE2kZNMi9zuJgBrA1zm/jH88gYujU5HRSu3ZV+Y1ePqCMEJrYlpqtQhrYDtJIf8deyf0i/BX7MfIgg1xo3um4iuVpmbGgHLVW/uaMrzWIjZVNLaF7XWdDF70SjP1KItFxnnzGJaktHapEVIH5fvN6yia3Uc+EeV9QqouDFhXdcJRoW5oyz32IE9hUAOjwZPvVQVjAmFVnocVIRi7kKia4xFBz4Q8Jti5D0XEv1xU3rQm9psxMFGdP2eoP8Tr0C5ukS199N93vxIiM7Zw16scNIHRa6j0to5XIfPNTKmBwIapTQRZX1eefeQgi99fnYe9rEJXCmYXLazAD+10t+REYRMxkDNxReiIMezXiAmnkHsAwPObx5TENd7CF1KTH2XNzIk6eYSx/OKY4OgnXCB07Tht283JJnbWHaNZ7d1AXzt5DKirOAIwOk+knRV71GNEkbukvfZQb76maiS8WiRWZ928uJbvNZg3EtS1Z1BHIdvbm8K3ep7FawoiH/DgQQFlgti4k8riZp3n7EVuySrwRjOlw8MjP5gaJAmd5bqYoLur1HcarmtgVuJEWpPafh+1WCu6UNXdShSV8wEYLImCnrsBpbBxiVWG/Qiy/YzZ0Weg9pE1RgknRzOeeXupvk2nXZNR4/GwwDYsre6ReTxQZoNiXlbzM39kf7OEH+b1LsRXJ7xMpdxGfzv5Zs4a5ll7XHi5aSVzwl8raJXf4cFufb2HQHIA3jAq8BmOd1lFecW6KjBK+2P/G3MP9YMrGPxlBFTDlyiTmzDgWlD2VhbQ+j46l3tbfaKzSFXWTgcd5Jbt7x1FCdgheqQyF7g2Cc0EXCQrYk4jWhuEO3+myRYdMU6CpJrCDQu61ZVIX3CPFddYoELRsogjr6hLeYAZtwKMFf4YejkLcLVyJu19JfWPu9xQui9JeAvNSuYlu5+ms89iwqOAXrlwO+iARs3GF/ee9lTSPfZKixTjJahdXlkyi3hPQoLGwaqQzRo2nFmboSmUBoGNS4J4ayRdKOy5c5GS1WjgdJBt2wk4oX3KNmtGVcvweaMEvNx8tmttBLNgy3kesBYOdNFt8vJ/O2ZPSptFi3EkGVQltWtvx5gOsZpyJai/Md1xvMtymbmoTXJpBoHxYwiWj8ovbIxGqNyFQo0r0+UhpiIj9NQVhojkyHIMhmnHX+T4ZPQdfC3JCWp4GgzEC3FWMtDOsXWxDDRAM00uEQGbNsILKCZRBzjGURxCSydVC+WRYIfqYo1Ynz1OUjyoFN9zIvWWnpsUFbrvXiBbH5J/E2kA3PA1KD2Oh76OJvG0Hsh5DjD577ebKExiW2G5QxoUg== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /iI5VU05aE4xUKTSI7hdVOZwPq/8caqBtl4x7mjCxc9uyjY94pkfCdigBCEt6ursWS502zjuoQPL3jFbNokR3t6N3Lm+tRtU+Ro1QXBE5t5nzuroKGgvp9I5ZVOQ5ze+WwtzQIM9Y88xsnxbVOpABNDJSzOW4G4yXrXMpibUWjrPL67Xy6HVpTVZdfCUyN89bCfkXZg2v+TAWQhGqTxUEXS1S5BotRXjNG/+0ygC1zlRnxwBCS7+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M3K2f0VKOX8hMT3GznTT1wFEg5tlqTmMfmvwEpUuRzTnuS5S3pzdi6CghpiC2587lzO+PBwMTJc1GKf4/7Uhb9Ov8pVRCL4CZRE90Qik9+At6SeO2X+o2S4fe9MrVfWsewZE7OwhKjCWhhoeM6urmDZttE/c5kIxls9/D/OlS30FbEuXcSOkIOUJfqvlO/CUsauWTSEUFMql60IPowoWtm1gxfTQmkFgOdgtasF0kbX93tzyV5uOf7/Vei7OTKVNOqeoEIguqF3QtHQ/JaSjrOxag== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4265647-a31e-4609-a85a-08dcec62b68d X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:09.4064 (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: rSPYXVaXASJmzX8cKnLzijq8E1FYc/SI5i3LBtzs6KQcZW5wyBhen2CPzH+TEn4wKenOlCqVmHiVTLvEqJZemNdI5XT1IyYSz06FNxWnUFM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done under RCU or RTNL lock. Detected by Lockdep-RCU: [ 48.834645] WARNING: suspicious RCU usage [ 48.834647] 6.1.103-584209f6d5-nokia_sm_x86 #1 Tainted: G S O [ 48.834649] ----------------------------- [ 48.834651] /net/ipv6/ip6mr.c:132 RCU-list traversed in non-reader section!! [ 48.834654] other info that might help us debug this: [ 48.834656] rcu_scheduler_active = 2, debug_locks = 1 [ 48.834658] no locks held by radvd/5777. [ 48.834660] stack backtrace: [ 48.834663] CPU: 0 PID: 5777 Comm: radvd Tainted: G S O 6.1.103-584209f6d5-nokia_sm_x86 #1 [ 48.834666] Hardware name: Nokia Asil/Default string, BIOS 0ACNA113 06/07/2024 [ 48.834673] Call Trace: [ 48.834674] [ 48.834677] dump_stack_lvl+0xb7/0xe9 [ 48.834687] lockdep_rcu_suspicious.cold+0x2d/0x64 [ 48.834697] ip6mr_get_table+0x9f/0xb0 [ 48.834704] ip6mr_ioctl+0x50/0x360 [ 48.834713] ? sk_ioctl+0x5f/0x1c0 [ 48.834719] sk_ioctl+0x5f/0x1c0 [ 48.834723] ? find_held_lock+0x2b/0x80 [ 48.834731] sock_do_ioctl+0x7b/0x140 [ 48.834737] ? proc_nr_files+0x30/0x30 [ 48.834744] sock_ioctl+0x1f5/0x360 [ 48.834754] __x64_sys_ioctl+0x8d/0xd0 [ 48.834760] do_syscall_64+0x3c/0x90 [ 48.834765] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 48.834769] RIP: 0033:0x7fda5f56e2ac [ 48.834773] Code: 1e fa 48 8d 44 24 08 48 89 54 24 e0 48 89 44 24 c0 48 8d 44 24 d0 48 89 44 24 c8 b8 1 0 00 00 00 c7 44 24 b8 10 00 00 00 0f 05 <3d> 00 f0 ff ff 89 c2 77 0b 89 d0 c3 0f 1f 84 00 00 00 00 00 48 8b [ 48.834776] RSP: 002b:00007fff52d4bda8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 48.834782] RAX: ffffffffffffffda RBX: 000000000171cd80 RCX: 00007fda5f56e2ac [ 48.834784] RDX: 00007fff52d4bdb0 RSI: 0000000000008913 RDI: 0000000000000003 [ 48.834787] RBP: 000000000171cd30 R08: 0000000000000007 R09: 000000000000003c [ 48.834789] R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000003 [ 48.834791] R13: 0000000000000000 R14: 0000000000000004 R15: 000000000040d43c [ 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 268e77196753..2085342c1fcd 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1884,47 +1884,56 @@ int ip6mr_ioctl(struct sock *sk, int cmd, void *arg) struct mfc6_cache *c; struct net *net = sock_net(sk); struct mr_table *mrt; + int err; + rcu_read_lock(); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + err = -ENOENT; + goto out; + } switch (cmd) { case SIOCGETMIFCNT_IN6: vr = (struct sioc_mif_req6 *)arg; - if (vr->mifi >= mrt->maxvif) - return -EINVAL; + if (vr->mifi >= mrt->maxvif) { + err = -EINVAL; + goto out; + } vr->mifi = array_index_nospec(vr->mifi, mrt->maxvif); - rcu_read_lock(); vif = &mrt->vif_table[vr->mifi]; if (VIF_EXISTS(mrt, vr->mifi)) { vr->icount = READ_ONCE(vif->pkt_in); vr->ocount = READ_ONCE(vif->pkt_out); vr->ibytes = READ_ONCE(vif->bytes_in); vr->obytes = READ_ONCE(vif->bytes_out); - rcu_read_unlock(); - return 0; + err = 0; + goto out; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto out; case SIOCGETSGCNT_IN6: sr = (struct sioc_sg_req6 *)arg; - rcu_read_lock(); c = ip6mr_cache_find(mrt, &sr->src.sin6_addr, &sr->grp.sin6_addr); if (c) { sr->pktcnt = c->_c.mfc_un.res.pkt; sr->bytecnt = c->_c.mfc_un.res.bytes; sr->wrong_if = c->_c.mfc_un.res.wrong_if; - rcu_read_unlock(); - return 0; + err = 0; + goto out; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto out; default: - return -ENOIOCTLCMD; + err = -ENOIOCTLCMD; + goto out; } + +out: + rcu_read_unlock(); + return err; } #ifdef CONFIG_COMPAT From patchwork Mon Oct 14 15:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835204 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2056.outbound.protection.outlook.com [40.107.241.56]) (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 4F0841AE001; Mon, 14 Oct 2024 15:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918798; cv=fail; b=LFLFDMJBrG0dAIHTJkv6d1fDYCiYFzJcdZauL/GxDkQTnVf/tDhRDJEQ4CEtkgToXdkIzgRuN7PGZW/YfCThPMzuw0UgERZrreXF36woEFpfezxzBz6ztWU97oeQor3WjVc4d8oq55XqPvI83OQdRnA6N5aSfcR0GeNgwV0jijA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918798; c=relaxed/simple; bh=H8HZ8k8sgBQxl39lr1Vh1RDT8rQmjhbNuEaG8tfZdJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=KRq5eGDc9EJ8MLQEXv+JAj8zIMtwua7ey4wE0capWy4uUjvk85OSvMMDZBzOTOe75bYWzC4TlBtX88TX6Y07rckNLF9SsLJL1bjQoQmMUj1SzX/qwsQefB0kL/nEGfavW1eD+jRjOL2OyTwoi0+aejxJgxCYvnXllny/f33XVuA= 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=B7qodzMs; arc=fail smtp.client-ip=40.107.241.56 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="B7qodzMs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SypPQ108WptxfXD0SqdxZlzTBppLTclez3C6f6fA+/KDlUWLCxmxhpEiJpK2Qm/QvxRqeY+w2nEPYJ94wLzEdBBN691Y4FqswcmxnDH+ahoz+zWSX62j7dGjjSx348MV52D7Ynr/2HdCkzpUPgTpP3hPbH1pG7XpA2LzZyet9K+LOlqK5HzrRhrqqvsjt8M67XSHGxI36dmj3bZzGgYxUH4r2q+ZXiBgbIVIXDbrQZxDTda/rQZp4S7a4+iDXem8Id/F+hg/zzGwzNfrZ6EGyNCSqMf7afEOkCgAwePIxvXwj6NLVDvMY8naAwnC8e8Y5oGTYs0/S+IO2mVE5CN6GQ== 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=jiVi8tUiW0odjPphqccBtB/TmJHet0QExhsO6ZRjgl4=; b=hQxqLpWZTyP+3O01+nstv6TazDvVMdOmRbSXVCxyLsjY007fmO4TcIQqoXJ1WumRwexN9J53OQdcD3qfr4jeqpiTL3yjZ5iY4WbDGQogtG0m3stL1HPYF97fdm33cEEg/A85VeHmOhl7g+p00g6AquBrcwM/+4Qr8bfsCKwJ/lCmDUPGS6cADatSNkxVrrbIQ8oCy/x2ID/Vc5sRoaB/0R251zPqOf89vVznrmjgU6WoEYeDQ8osljytvkFb+9EfS6K2jPO4833N6TRiBHCH3gUtcSyXg7ZmnQIv80NS3KPUDH06pJuHZvPAk9a243qa8mr1KR8ykWuIocN8XNCRkg== 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=jiVi8tUiW0odjPphqccBtB/TmJHet0QExhsO6ZRjgl4=; b=B7qodzMsrWwoPqnoFo2Vp1w+CNj4V7qmz372p14I45HCLuloUVR3RcSRe5NL0h4mAuAM7NMnLYxtV3SCKRv3h6S1sviIG2bHwMoeKmA64P+3tXM/7DFgVU8aDxtn59eBlIJalRajGLTbo9ARhYid2qLkEv/ABvrzyW9NZl4WJRxfr8/c4QMJJDt9wR20v8b1kDvN9LbqSt4l+/pZ10OZC5Hjotaqo1w/ohZQdM6XZI1iU+oXdJ+iu1sgMhlp5AnTwlbsA6l9PHosz640X+nYw/Lh1wu1BDNTKC+qGFBfPvqC2bs7A2ObUhgjOtKtI+XBo5uw4+Ql5sSfY6v6LDMAFg== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:10 +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.8048.020; Mon, 14 Oct 2024 15:13:10 +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 v5 03/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_compat_ioctl() Date: Mon, 14 Oct 2024 17:05:49 +0200 Message-ID: <20241014151247.1902637-4-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: ec3dc677-6ab0-43d1-29bd-08dcec62b71b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: swv8TBdOurM6px9FbFLPTYbk/mcp/2IDB658NLzS800cgP566ObcmssL5/EkMJNPpxV9a0I4PQAcca3HU4C2mUu+cmsdzWqcW6JTotZowuTzZzcPl8iku0StaSSTNNu0/t92ya8qE39k7ywEh/RPUxkIpPh+n5m48jhIkm58tE74NPaH+ZvzqdbITZy/cEs4vJScnvGSALS/qrwT/i0EQW3Oz6ASaA5ky5Y8tItbamAkF5MQHhIGmtxCuQ2oZFlaPrdjYetAmTmnrvZ7DyeVv8FL1lt079mC22YIUdPOZ70C9+mCrfxw85z3m9prCjZqs6iaeh5PKe7lmMrb+T3ycH1XvtHGp801PDV2T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:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sOfGuPJfElMz3jtosIeaFF4OYX8lvEoY/AFhNEG9sZUXYcpuXD+WZ3whgNSRTxfBEd0mU3KdsuLrQ6aBfiasImAsjTkcf/mK5XgLc2ZcYEcURSIsuNJYQmaqH1UHuZrMC4hQQMFk3OOo/1gcOqC62CJI9DbKGOtqAGfoXdtqzz1+HX/wFQh2N7dQk9kutpr1JcZ7Q43D9sQDbAwGtv1NVqvuOtjwYzzYnqcI+JL8JFk58nv+/IMYejxRvgCAEJ5Woulo5N2Yw0Uax9r33PXddIJcESxluo4EW01fm0tXsxibNedNJSV7KTyDxrT+QJBN7f/pKvxPwrglGUc4iDEbBxCHhFUz/YwpvvFP2g5qqAbjpWdRjBdWFkTynPNFSZrfOyIG3GLPeFXomevJ/5RraVL3FVgMWvNLY8tHRgxDMOc+ZmFevQkNiSJDhTsEmDAq8xRzwlIUmwbCroWsJ+rYnek2nRmx9LbPYeYSN6bzobtTQIdTAlq4Vcze3LfbWDBGMaRtEuqxFJ98bNJsiuLcaDsVNxslbh2UXZevz/yl3SI064TARWx66qOURG+mUxdXEmaZyPORIIiceV9Yjfa0wx6CCLwUcm7heMkDBY6/zpBEHKPtzubD2usjj+uoCyB/fH9t99FtoJBbIYHCia0D4M3IX1fATVb49a3f4Moi+tbPq2WCj4n++2glcgrRO4tCsMuhrhXbLNfMfpKhpyKWyUB/Q9wrPAVTAFCcsqRet6VyRAG3Hxu4Sxmx88XWm6ELww08pg/Z80BebrNMI2Nq6l9IVjmluZ360iKWAdoUquB/IIRS6un6Q/5wztTEx7TD/uEjw7/jtLijd/YlHc3AaINW5JjhVQVO9XTeeB+LlNjwosJPCaquK/tVNyeDVu3+HUeCW1BbS6VW8tKei1XEEkKYcjXo47L2cJteTMgGi9GjHVEIj6ij61LXhoKabiWsfhqAd2gMdLvBqTvkZkKCKySqQEQdKMLz+1SmPTRl9Qd+nGVc5RtkxZaXZBRk1keyGAP0cUrFagCy5P1pMHHLrhGKIqxf5tleiMFi3juIX4N9onI+73bOnleG36uqV/LKND3T3IX+8PU4qtZyPpvI5z/u3WU0E1BANnplcIhqHwIoXww9BwSWvA4aAqFzxI0LcwaM2QhdyXZLPHGBAsmm/ojoS8WJzw4uwTf+2fjSHyUwy5uJIX3kSrsyfXA92rrWIGfPBxiIWXMPj6gS4YSljCd6BgvqxI8EF2dmcPqIZ74Vfsuf/V2lTvTNrE+lMlsmf4xFU2EytCXu1mI4WA+MfbOP9WtKTwQ0h2EXdHa/BvDOq23xVVMqZIn/f5cIpQvrHILMh/BArHMoNJ3vAYYd/4dlabCFWbsrtqTs1uZ2LcItq5e7Rp8PtpjBZMNBZdVlyesjtZog8KUNbgeiYuQAzjXIg7DyuRMfDheFqmn9KOjFJ8DuMmoHdSfgRP7+Bn2gGr+GmZt45oCKIFfw/kjH8PS71wPUp+ojyvru7RpWwCNls9Gl3ch9Vlmxdat5/P0GgNamQZL+5mjPc21QkE/EAg38lRmPgfrSLD9b4vC43iCtY5ZlTLehUaHmKOzaJYR5mmBlT0NQlkXwVDnPLV8/YQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec3dc677-6ab0-43d1-29bd-08dcec62b71b X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:10.3713 (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: rumL+390CUhLL68Z1C0KNpT34sUPr7hylH32Nsaxir1LVAUUE8TyLhGWB3aR1KJWOXPMeeVjM4YjVBYM/MjH3T4TOZLWTpyF1/q87zHdKFY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done 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 | 49 +++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 2085342c1fcd..b84444040e0e 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1961,19 +1961,36 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) struct mfc6_cache *c; struct net *net = sock_net(sk); struct mr_table *mrt; - - mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + int err; switch (cmd) { case SIOCGETMIFCNT_IN6: if (copy_from_user(&vr, arg, sizeof(vr))) return -EFAULT; - if (vr.mifi >= mrt->maxvif) - return -EINVAL; + break; + case SIOCGETSGCNT_IN6: + if (copy_from_user(&sr, arg, sizeof(sr))) + return -EFAULT; + break; + default: + return -ENOIOCTLCMD; + } + + + rcu_read_lock(); + mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); + if (!mrt) { + err = -ENOENT; + goto out; + } + + switch (cmd) { + case SIOCGETMIFCNT_IN6: + if (vr.mifi >= mrt->maxvif) { + err = -EINVAL; + goto out; + } vr.mifi = array_index_nospec(vr.mifi, mrt->maxvif); - rcu_read_lock(); vif = &mrt->vif_table[vr.mifi]; if (VIF_EXISTS(mrt, vr.mifi)) { vr.icount = READ_ONCE(vif->pkt_in); @@ -1986,13 +2003,9 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) return -EFAULT; return 0; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; + err = -EADDRNOTAVAIL; + goto out; case SIOCGETSGCNT_IN6: - if (copy_from_user(&sr, arg, sizeof(sr))) - return -EFAULT; - - rcu_read_lock(); c = ip6mr_cache_find(mrt, &sr.src.sin6_addr, &sr.grp.sin6_addr); if (c) { sr.pktcnt = c->_c.mfc_un.res.pkt; @@ -2004,11 +2017,13 @@ int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg) return -EFAULT; return 0; } - rcu_read_unlock(); - return -EADDRNOTAVAIL; - default: - return -ENOIOCTLCMD; + err = -EADDRNOTAVAIL; + goto out; } + +out: + rcu_read_unlock(); + return err; } #endif From patchwork Mon Oct 14 15:05:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835206 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2069.outbound.protection.outlook.com [40.107.249.69]) (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 004291B4F2A; Mon, 14 Oct 2024 15:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918800; cv=fail; b=iUIj1b701/v/b2bez6T7aRmCj2da7l5jTjwVC+cTimeMM4lmfDAWyNXifPVMCXmyybS4YUajJK9XFxLvixiW5oJ+9ID9UXfTTptIxL/Hlk8SZwR85uelm9kjwPIJHeW/PV5+IQEVwMbfQWxcdON299FvDa5+2S8vmEl+fkNYnrE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918800; c=relaxed/simple; bh=tJ0iyqfaOtQhRg/d2qxFxSh1uZbPrtp8Mj+lzr9CT1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JthUjULtpv/C5wO2wWV4YQZKT5/Sh1p7uAqCkp1Y2ORGQx+w5X7q2K688YhcxBGTdO49ayfNFd958mbR6t9PdRSanXFuN+OrvvcGtvKEzgKmqyRW3cLhDsP+eiMwQXal24tNTz+h2bgs9cT2k2DkBwEApzbtDkLzpNclogmLVEY= 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=Ln1Xrtia; arc=fail smtp.client-ip=40.107.249.69 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="Ln1Xrtia" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p4ky0UKhAUtgmDmMTWRt4rtgAI818ep464tBxrbH33ZM6mTswKmyQs7PFaKGKj7PAOtsERFUSh3M9e8VucmbuRXXqexC82yQG7nv7oK+QQCIOPjFpJL3XENek5wTgnhYSpbjfVtqheccQyE3XnFLpUFgnZDMhr8sNpdMLpaekSalce+eyWoUTYfY+UKbv0MWHhGxNv8zQbth7VaI49OQ4PC4gCchKeySniPrS7NKvKkfPlTRRH1TyqrdQU4MyW4Lkxu6QvIZXvIPZlstV+zxnTcS7gxXbDvRhfV+dyfBzSB4L/ozhFWZ2435YgrprkDUXYFXZdu3am6aRQf3kcE6eg== 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=UlFliFYEiT2k20zUehCmEE/OTyU+WRGiVUdr+buZxY0=; b=KIzxc4GQF+5gm06ShogoyZr2huTv7iFkalpTzD3L6gERbwJtCy3zPaNINIWvThDOMok8xiFvNS/fMAkYfOXZXUaUUmEXQ9F/YeTFlQ7cbTVcMXL0DX98J74MSrZTjifOrt7d7akOjViXrEQXpFQqL0/7wSVbMhHNrFR2PIGEgtpWZUqgOfVRCzIE76SukqOWx0oU+CWa8yTnkTpq5kYPit61QzvbOtEzlwEB6zrmppeagTp73a2E6AjHw6S2A7l7vr9IWhi6GUA1jDp3Lywdu3dZuUKd3Z+0Wwr8zGmDIfDoGS7AAjPpdRa08hixUAioRPNtN4MVrAWAWTw5uWqpfA== 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=UlFliFYEiT2k20zUehCmEE/OTyU+WRGiVUdr+buZxY0=; b=Ln1Xrtia/RcQNnaNklYXDvjqmEo3hnhHmTqNr8MgHFdKlEaKCSWJPBH6eKOHYBnVHxJDC73tV5iGJwyrYhp6HpaX/C+nq/zIqReabAyb7MwnlBGVNCF8esdAVyE9w7ESWnpF44+OVKQsk/sfZqo0jgZhiwsvdC9EXqSlcrs/7zSa9+ycvr7PQz26YWIwmKS1BGFn0VO8itEFIgRAIh7KuOgq/5yK/RqiVwGLMa2L5DXsZ9Nm/Zr5ehK5WtF7n6C0Ep2OeVtUxen352Q2xp564w9LRzjccORdjjlD1X+l3h/BtUjak3FYfrk4Q8Rb7rAIe6lWXWtrmFIYlv4FhhMSgQ== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:11 +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.8048.020; Mon, 14 Oct 2024 15:13:11 +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 v5 04/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_get_route() Date: Mon, 14 Oct 2024 17:05:50 +0200 Message-ID: <20241014151247.1902637-5-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 87854762-5e76-40e4-c80d-08dcec62b7ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: EpCGuT7sRxDmEgbjlRpahncOukYHFYzHAlR+ku+wizoT6ThbLvvk32AxAwA4PZmpla8ttm30J066E5s1Ww2i9dwRVM8iZGMYZWB5L2IPSzJrY2nwtzkKMWVkJBkovZ0Qv2OAdySrRC50HqcwcZFnYvf9XpxEXxNdXpnhXtvsE5xlCGrFNs8WQY9N3191kYs1saxBXE8IojMTv5EGowhGZCiVE6Vfi00r+VL8Iw4JVfLPqoGq50RAB2c6gcOvGyyJhhyf57Cw43N4qc3IWWAwBhpqZa6DXnXX1v3hNVy1r1/atcrN3yMLN6Gy5CkWo2f4GevbUjA91y51ZOj6kFoUkpc/GWwXULXMS5B0soSPE+5Kk/keRZioBMsgzP+h0o8jwn7MDcTW75nurfvJuWrQB6PR8bR4B6Z0L0wiVDr1oBKLZ+Wb699IzVFvR221FTKnXdreYBNP8PwsoxkrUEIvlAjkJrJI9Fx74bkvTVXS1oS1PjzddZDkspfBcqsDlACPAAfHIzG/lSY1rmar6gN4s5W96n7++8LXRsiDyMDuKBSw5x3wZR2Ihsj+llcMj1vzhLWYM0rRFlD/PBrhD80ziZnTO7xmziGyKQNz/ei10wnZGCHJ1PSmJDkFVDKuCIKfZK5TSOAHYEOW+uwlOkkRGiaA2XBGxSlFruQNcK7Z7OMzVwmiqxVpEepo7A0NldP5TkD6lfDVOOyDFmClOccXuvbxk9n294oIw3X1Ej3dcsqo+yxilH0ag2WqxheQc30cKrAgy17B/pyU3FqA6YY1hMFnw6mbcj/ymoSl2L+hCaFAFNNiDFbY0IyNxOx5mMRslHc1CcU1vBPA6Z1jvLLI+efWSttfp//hxBJ4jjhP8Lfi5om9fkg0dbBPycCPyDY9n63rF5kpHujbhqz5v36xJe5j862+oUCotAB039bzA3qW/z1vyESf7Vlrb6WdQgzNf9hUMfWoLa+GH9FrYjGNvuTnyakcf8Wl9SAFqAja+bKpT5GAouWXA2zuANgC1HSb1DqSGeAbYgVwHHWqtzvaw4xBIO7YmP0p6okCFfIN69mTKeRcogvx5ipdwI5eXeE2Y5beA+ulEg53vJvcpFUvQahtqqdKZZy1DL/PEsXFVOqPsKPO6+E+TtogrCGtcw2jYOT3WJIxl2QV0leoRL/xnrvPNJTY1pZBWnnDp2gS2G6pJTzlRfy/BOqnlDYT73x0+HL97o/J6ZcbBc7FpDl30efaGSF92AvqTV1btQvNq8HbmCACJoEfwppJ6fPO+LdXdBIbnH6/VNXazHBsI9ccPcWL+evOTX36T8Y2BWU6EtFRNahJuD27mPdThmxoA6tclWSkqEZs+LxgXDaYzIBoGQ== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tjvpMTMi4knnqH1Qh2vdBNMqKiDFoYnm+Oj0mf8MxaPQyk2D+3LAYx93tizyHKpQoUD4t9xDhbO34+q43u3YSjVdHZ5CmKMhXoyLOvRczpDcjn3qZzvXbNScoAkYbeH1NJNo3Q4YMgAne4MgXlAPpznYuUSXbgzhMx2ucbJ54BVUneUN1DIeQ0CKRv4yIonCNDdJbRLpZHP9pgGVHD+JnTDTJ1CknTLdElHVUD8eoWSEexZPFqyTDaERDvfiLrcDvkAodW76MNXDTpvsBFofILc59a/9sosd/WhzAHnFvexfZzydoh4xN0dMlEXMUe0rHpqmtL9dIVSA5XTJEvDa6BiMt27IrUcQzQQvi5M0cNlrKArfR5uRXsZRIaA6D/DRyqAUP7YwynjI88OIdAtPnsGjiNY7zPFbKEUyC5g2i7lMH4DqEOC3QlCLy+eDz/A7rkZDTgpBUzFdctdKjZarh340R84n/vjYWKwSbCxELkni7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Lgog/DilOhGkVSeeGQFJNbmQxK+fsMTCE3avA6wnrKTav1u0VS8yw== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87854762-5e76-40e4-c80d-08dcec62b7ab X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:11.2922 (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: abMmGYw7tlvMp854e9owZmIplsbRWeHNoZVf+HxOdP1y4NMDcUv21/WzuV7C5MJGmWZrL3V4ONoWxeGzBuJixpUPt5JP46QpF53JTOeadkk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done 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 b84444040e0e..c47564f0c868 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -2299,11 +2299,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, struct mfc6_cache *cache; struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); + rcu_read_lock(); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); - if (!mrt) - return -ENOENT; + if (!mrt) { + err = -ENOENT; + goto out; + } - rcu_read_lock(); cache = ip6mr_cache_find(mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr); if (!cache && skb->dev) { int vif = ip6mr_find_vif(mrt, skb->dev); @@ -2321,15 +2323,15 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, dev = skb->dev; if (!dev || (vif = ip6mr_find_vif(mrt, dev)) < 0) { - rcu_read_unlock(); - return -ENODEV; + err = -ENODEV; + goto out; } /* really correct? */ skb2 = alloc_skb(sizeof(struct ipv6hdr), GFP_ATOMIC); if (!skb2) { - rcu_read_unlock(); - return -ENOMEM; + err = -ENOMEM; + goto out; } NETLINK_CB(skb2).portid = portid; @@ -2351,12 +2353,13 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, iph->daddr = rt->rt6i_dst.addr; err = ip6mr_cache_unresolved(mrt, vif, skb2, dev); - rcu_read_unlock(); - return err; + goto out; } err = mr_fill_mroute(mrt, skb, &cache->_c, rtm); + +out: rcu_read_unlock(); return err; } From patchwork Mon Oct 14 15:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835205 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2056.outbound.protection.outlook.com [40.107.241.56]) (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 591161B4F14; Mon, 14 Oct 2024 15:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918800; cv=fail; b=LfR4KuJ5O1vDTNBYMeqe8n9vVvdi8iwmXinJFU4pGo/ZVRWoWBGKcKdLUZRd3uwmjLhNle2FqEG3ARNqSNM5gZctIH0cPEHd+4rx/vlWIxvj1WyVY7+auaoiIkdzooXi2lvdwPXYl+7GDdoXoiUD39fP9Y4iQ/POIXK9CLrMZ0k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918800; c=relaxed/simple; bh=Sro7sFxX1Dl+c+kHUEOB/UwzRmqFmvsQoikgx+h+igw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=rqdZ+qE3/0xB62T4/108IG853G+vHgEWR3y7uWwDAxS9HgErhDW8y6fpfzmNd9edglbf5OnAeuqqWR3y3l3dsmuJSXXJr6U0GPJxOp/xjbW/IGwkOXNGZaGGfqPiHEIFJEKyOMXjIlSqf82HbYw+nPyI+rxGC0in0wMrDiboMk8= 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=OSOtKaHj; arc=fail smtp.client-ip=40.107.241.56 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="OSOtKaHj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rBQh+XKLXfNwMOpN8jO89VCw4Rqa03m2Y4QPJSgXwMaOv+JDHxqjLpRm4bIrZD2EB+DVi++IdCEVxlAh8SMoH88TQVqIUJe8JTyxMYql1DSoogCCJUXVqIwZza1495wZjqg5FSSbCEuCeVSJq0fxdkURODYwomlHiDN6xWLvVQh8VaVFqfSQGh/AufEOS65bZuUGgdM8eMpdoUfvIGsZOxIjmgyJPMPkyVGT2kltMTHdYBkgtQIqunkOcrfqaVtf3yP5mJTbQupADtbxY6SnoSHR82MNeuK5gK9M1MvJdpiEGZ7V+C+CUR+CV5rN3v56NRknUxxqgnuw/GGaTdSvBg== 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=ycIg+E/wpAnSLvZg1OcUiBoAyq8QQYUbe/Z8/03mWcM=; b=DYbLtfExWt+aVq4EpsQab/NbIhKeNGTa90G2L41IT0QjzoJ4AAKT+iCzxJqH4GoiC3OCMGUsrgK4yW4KpTU5zIeyclkMYJdBAMYPX13VpgoKoYbniFhn3ZLjGjP0DYKWwdJLEEZrqzHei3LiJaFLI95Yov0CskgwctzQWfKmiPg8R7yhfyT+3VV+VQBrNdKrH2a5B2CDWL93sgtAzilBOICTq/6W3W8kTBYcZjD+8xiF+pygkASHE2HiofWMUCfZyt7luyxMijFIFeBm0BBTQLfhnbUxC9l2om4uG9VssHvDeK07UHSi3498Ep0plCQMabfdkQTOG1vvsBNjNSoRTw== 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=ycIg+E/wpAnSLvZg1OcUiBoAyq8QQYUbe/Z8/03mWcM=; b=OSOtKaHjmA3KL02h8d10VrpBzYmRfjAn8YVSarDBCDA3hGH2dxOgm1pamDqvZLLkQPHNPiewwR9TG6x4nZMLN7GQLe6naP3Nx9PXJDEPIm6Y3YvUMX80Ss1CrCPhsqdXB8nB5BMjPxQt0huZXwPd75gp1aePYyjiNtItfbZx3uc9Oq7FCLLLkH9OkfMEuAjwDDkYxvfijPoBM8UNF8xbV9xzaWZ765k37OPNVAseDQXkYbbIEoFPw1PsvZYw3qRIwYm7ixI+gBqXUSxwMfmp2+4ZakMYrf08KjyfXWF6NvKBZCEcr0m1CcHVvSfiK+cgz5EdWRDdvvn838FVqmXRRw== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:12 +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.8048.020; Mon, 14 Oct 2024 15:13:12 +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 v5 05/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_new_table() Date: Mon, 14 Oct 2024 17:05:51 +0200 Message-ID: <20241014151247.1902637-6-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 3270b463-6167-4a91-f1e0-08dcec62b82d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: ISCGpbM7nxUA4wYTWWmkNMw2M1mAnIpNCu5a5SaMp/UewarHquQT2YPEgUOr+7Wdu7OvTZKtfgYcmD1fr5KswwfVcpkZEK4wicgryU1UnEDDawDF63E8Z10+XpzUyGuXrl02NypgBtf1GJUM0nIfyggKmJVuN1JN/qbEGwCzmvId+xJs/nY8/A+mwnB6XsnuQ5GxE7zNS+gWwQ4lTHGPx+2urlMIH7QVdk6z+sQiRxkafMj2MCPr5bK2a/J1L/dwCJ2ncCXkBxDkLfsgV8FwqG6+dbby1Mm6zgSVLMC646QnBmIsrhHfbA9g/T1sBB1/MT3fr6js+9uLaNIpMy1oGa/eZ2o8LyfZQMzOCPiCA0IGImuAwgaahyqchAIr82PP+vXSXdR6owBzeGwW3t3Dy7hzrUtd4sFT38AhhuxcjeiUrOPGlxbzbbNfYlJ4QsNSuMgoXgpvw0fHUsotZA3hgqj1DMcntfT4pNRoJmaM8Ve1FCKtduuRKOhCdi7CnWFhgOHLN3pLFbbocWopIcmPHUH6hLzPKulvaIyaxLrD9um4JD4LJpuSx1FY8cShGf5zORQLcF8obsU/5TRaUPlpQmX8UwG2ksLfWyDDymBN+0Vr+RqSddepR9HRG8Q4z8r3jRsjU3TldNKGABBinemwLSOsDqb/3PddZcxlnflGcGlyWVOLM6stoGCicByEBRwV62uwfLaAVczJsfaNfjyaFZxPw7gDEbVb2tI7A8jHnQUT8PxrUchpwwXMzrq6PlYEHre1X+TP8jCcBiOhZ8mjqxDH2O4NS7YTnmX7xfI6acJdEPQi9zWv+y17vmFLT8vvJl5Y5+xXgl+3Vm1tNghNBbB9vF9Qef1UsHCapl1yjGeEUuc0ff47wdRaxy8MLJahK1bco95fkSNn0XjkaUzFHeXobg2hMr/mLdIy6A5xGIacrFMkzxR6aORltuI7Zxb9UJmHWyNdYlyBT2TPgs0IuJ4+BTLBgZfMLId64FsLfPSqUmpyE44bpW/rfn1xC6YnX9fLoaeVINNApCG8VOOPIS9qrMmczLHPzHOlOwftBMuIif5t0J/Z9ZkQOkoicYeO+E2xuk2B9h6l2EPQrjUe3+2E650/aNBX3nDGpHiX8PKYvWYhW4BvPHpTHWHKBo5SmbnNLs96c/MZTPjGCkFU0jBBRgjfuinqNrGfFTpbCSnKC5iz8Lknw7F9ZzDLKKtltxtuVSgONdCLeNbTBRnGr1/FCfR6jemybsM+OD469YceTv2yH3YnJ8q4DYK/E55lmxOREfrne8nQHn5xjpGM64DqEOYs59TCAiESjUnbxg9ZYV68rWIw6fCaBrAEuLvbcr8dSwopCEqJiMnf9l6JWA== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /WsHPAjvtQOT+g8Lf7fPQBsCXDLm0zRFOx1lQdRkXvgEhZGV0eCT/3/yRQpkCSpxIIeKat1HWU0xEMx/WhnWucMDUSjgJbU4e/zmqafSX+4C6A4ATK9NA6EEu85tt0h2K9LnfxMQQeo8yruK8z3NWbNXZ7bvEZdMLiV3ywaKD141KP0KBUR6ZI+2uZJkOAA2OgOldqufyVu6GZrVRMIVQDyVM8yd9TLl5M1W5lok5TbBoe6tCNMBThO+bMpyamHA1/yt/bRw2l7P07FUbsgiXsrVVG+b/L05SpVDFQ2+CexFP3Sv0SiYNgIn0YJUgH4cOzqrFXv/1lDEDEYd3RnFCD3awwz4nOReMSx+vxbBwRBq3oWDMZWiIDhzSRJiE4+uXq25DR/NI60FLUCJkNvrbcR52OWbNC1o//8e4OMsMMbh9h6MWQKuHw9dmRCAbZ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GK/ubQYgE2HfvatG24ijoNXqxlXwBz4yKENkAQK5kzORH1KuZIqQ/VUcknB7GoLwNJH9MqTc26NAfRb23CSjU5Rrf8A== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3270b463-6167-4a91-f1e0-08dcec62b82d X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:12.1567 (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: vg5ZIpKuWPTkkE6fewrDkT0bBgKfeL50uAvraE8CeGPlnO2UTrHEUXLSP11TLPmRxfTxeXjePl4iGU+bplDptYUDm84ZpD+Rj9QE3y/mRSU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done under RCU or RTNL lock. Detected by Lockdep-RCU: [ 10.247131] WARNING: suspicious RCU usage [ 10.247133] 6.1.103-49518b10de-nokia_sm_x86 #1 Not tainted [ 10.247135] ----------------------------- [ 10.247137] /net/ipv6/ip6mr.c:131 RCU-list traversed in non-reader section!! [ 10.247140] other info that might help us debug this: [ 10.247142] rcu_scheduler_active = 2, debug_locks = 1 [ 10.247144] 1 lock held by swapper/0/1: [ 10.247147] #0: ffffffff82b374d0 (pernet_ops_rwsem){+.+.}-{3:3}, at: register_pernet_subsys+0x15/0x40 [ 10.247164] stack backtrace: [ 10.247166] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.1.103-49518b10de-nokia_sm_x86 #1 [ 10.247170] Hardware name: Nokia Asil/Default string, BIOS 0ACNA114 07/18/2024 [ 10.247175] Call Trace: [ 10.247178] [ 10.247181] dump_stack_lvl+0xb7/0xe9 [ 10.247189] lockdep_rcu_suspicious.cold+0x2d/0x64 [ 10.247198] ip6mr_get_table+0x8a/0x90 [ 10.247203] ip6mr_net_init+0x7c/0x200 [ 10.247209] ops_init+0x37/0x1f0 [ 10.247215] register_pernet_operations+0x129/0x230 [ 10.247221] ? af_unix_init+0xca/0xca [ 10.247227] register_pernet_subsys+0x24/0x40 [ 10.247231] ip6_mr_init+0x42/0xf2 [ 10.247235] inet6_init+0x133/0x3b9 [ 10.247238] do_one_initcall+0x74/0x290 [ 10.247247] kernel_init_freeable+0x251/0x294 [ 10.247253] ? rest_init+0x174/0x174 [ 10.247257] kernel_init+0x16/0x12c [ 10.247260] ret_from_fork+0x1f/0x30 [ 10.247271] Signed-off-by: Stefan Wiehler Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") --- net/ipv6/ip6mr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index c47564f0c868..5171d64e046b 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -382,7 +382,9 @@ static struct mr_table *ip6mr_new_table(struct net *net, u32 id) { struct mr_table *mrt; + rcu_read_lock(); mrt = ip6mr_get_table(net, id); + rcu_read_unlock(); if (mrt) return mrt; From patchwork Mon Oct 14 15:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835207 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2056.outbound.protection.outlook.com [40.107.241.56]) (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 5CA8D1B85E1; Mon, 14 Oct 2024 15:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918802; cv=fail; b=rp99c34cp5o52AzGA+r2ZeXnPbEw+EexUYyduuTNYSe/R4GjoCUOD0/3ckeK56gEC5NBeEzEbNDRmu8tVjz8rB/0D+f43eBofxFuQv0mumPwQyAl4eOPvy358kUVJbU8zIsyunU3lb6u268w+bL7drDqKZn2CNDKJ6rQX395VNg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918802; c=relaxed/simple; bh=bA3mYruUYHF1cPcJztzem+zh0xnfb/LwqJXi2R6yrrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JKGNlz5MqaahyQC8b/c0TJv18JpFwKlMCui/JMCNpecw968sXbKrPKsByNO7MkKGZwisqDqnM7z+xwg3HBlw3w6drVOod9qz9Gm6Hb1GHtko3s5F7HR2qlg6TIeWV0GQQsghv0kLOSJuhGp8KtWt6o02BksdpJwA1rFYdfYHZ6c= 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=gx7PNFFW; arc=fail smtp.client-ip=40.107.241.56 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="gx7PNFFW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jDZkIRJ9/4DvgrHIoR8aCdtDONni/sVxyU+EPDlsfNs1CgREjUgkUJTYOE4b/XXi40sIuITDMTgMtoqO5Oc6QnIvLQ17x6FpNMikVJNVZsSG0k9RoD/oVxAOMgRInNys4gENUc2tndZQF5WK8mhZzlTKhTHMND/4VfWFoNzKCi60Mw+e9biDc6GjTXflb+G54FtdriQ2Qnp12hoyM2nC7Tva/vPtZ4H8hV89SDoEuLUCp+53iVRQ3q38sR/jGFzLD/rJeVy1Qa4TJi76YBiW0BiD1AK1bQRzFrP7q3sji/eJrvuShJZTmAQ/RmOjCmPk/aB4v2llZDr7R17Ec1+bbA== 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=waUinzHAEBpb0n34fV4DhvrgjqrSi74LhDrjAFG/EhM=; b=bWwwvx5rk+tw7FTMNoTsWorMdVdP2tAli+YKz9VE7/z8mgV+iD7n/4ijHC3RN3qzTllb0VQC2mogyUNnXjJJS1/ODCr40aJ7guTuPRTVNcsdqyXjRCA16/0XDroAwxaFOLGVoZUDhb1V4Y93yVeTuKWeBxGE1iml38nt9B0t/OGJnDO98J9wzYwoVG23qyUy9RL+HWcNxmwEUkCxPWdU4BDI3jciwCA8qqqJvGbwQL8QeWAu0jG6EKbHdf/OtDsEqindsdyfOXumnRk7XaS139yP4P1fONPH+yUuS5Ep0aFDx8LNmBmZw1Vk0mJyJA/bdtYW9bnfkpu0hKq/J5OGaw== 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=waUinzHAEBpb0n34fV4DhvrgjqrSi74LhDrjAFG/EhM=; b=gx7PNFFWJ8fi4GTeHOEnJqlDv6+G/WQW7WVT6iBw2NQSWJDxwxDsr+Hbik4ToEea3F+NAVrQ22z5l1UZsiMAFPoY7EXFg29rZ4/QeMGaxrsbIZXCynJ59EeuTF57M9g96SmvNgS1uP7kHjhKKqh4GckH5o7cIxcgQUbjktiEDAxLMX0WmyLzOQNUB5NRWmaWZkhDUOVdlHN0IKUWxjJRSAQOTrab/sU4k76LVBA/JvE1YXbH2n6BifuaKSII+s9553UTdXSbuUDOsgOFRkPZWMzQnofK8C+fZFbHRgVI+694J7vyFXvsytShMkg4dvJQsV/9kYSv3KFFimuJDCpu6w== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:13 +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.8048.020; Mon, 14 Oct 2024 15:13:13 +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 v5 06/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_mfc_seq_start() Date: Mon, 14 Oct 2024 17:05:52 +0200 Message-ID: <20241014151247.1902637-7-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 22187977-bed9-4d26-9449-08dcec62b8aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: AcBkGMBUK7hETshF382bvQa1k7/Hnx4G+ylD4UGCWEcJE5UTKphp1YJNzFU9sJ9d2EFY61WjnbsTpGAKSmkF3STrxluoVS9zWAE8wJ4RnqJPKTIOBGdjgA7TGLXd7jQSaPMa9ekurdnFvIPUGPy8+rM95+2bLqdIk/Bk8RowPvy0k/qKCjb68Z+IuygkJQgaSyouYI3Vfl97EcKfvdDbi/+1wwq1kj3YN2g2BUV/o3CARPcf6JlfaABpF/D5J2ZMD/0/QMFrxoZ3X2qwZCE0sAayWrweJya3Fzfx6kVfALnEIHd/0yv6Lrkesyk88kILSwsBAIUXdH2sWFM0XSmK+AL9u1a9O41sLbbWPkGx4lr5C41pcxkZamo83IpUc/gN3rS1KJDc3GF+TOhIF1z5AkwQynNDku53kEZkCoxiWj9+gDcc2iksSnmF5Qpam6kjbmi5CSCk0LxoxtuM3meta+gt2es8Da1CajXhNpZFO10XhEjaPRLB3NL0KKxDV8bq5pDmTapXXon3DGi83n4hOokDSyrfzEBkax8l5cfDES1wWCo2ww3ZLZFTLIHq4elnPhbKyKfsb6F0lhi3oLJXbJk0LXO40gzyNOq1L0hT/JVSvJtEgo82A6JeRK+fMVEDsgSACEKpYkc13lr8BAzCbE+0udENQmTyQmn6HDwseQG7nHnnwp7JmAcdRwJgBqw9TMtY7i8lTex3klM0/4Zc8jjP7S9yoTc3Pc2USrtX6VYlgEVTr7H7YFgi70vRKwJwMMxHNY+PcSfplWz8/VjzaU75xStcZKlSZ0E+6c5weChF9Wy8SJiOfKyRIP5/hsRus6MKK9K/ieg0ta4koXa+zXRRIR+oCRmEId+JSSXG/kSzCwOwXbnoX/FKX+zRXQjIJ9rSziBS5mQ/RaIuGTuz7mdncBfy0aZUCkWRCE8zUceWI/J5dzcK3F4aV3AvU0x6tZUtN0kRhwZJfqJJClwci039HNI5x4hOdA26qRwwWhHDDWUSuWqgEfJrKmXkODolji0+uaugdw0F8dIItLJJ634OwiaGF85CezQw13gID7f2sHQiVcZacHRk7/Lpv7FiUFIPe6f+i5PPvCMKPkrEQXiHVtinx91Cp5Rh/v2SuBA4hDTC2SlCIvRBvnhYz/O4cFD6X2OfGK606tGnOU/JkrPeLKFcvIfhRXXMiIoze7rwl1NTtHQ7b3VbGEa9CBn/NUD5otWtv4DMlOEYKvXBjgzuH/DSzSsKDEK9uzRR40jKiltxvOkSrxcCTmjFQVTnh6MRWPJGeXDiASMZCfh3JmVWsF6Ueps+04IUi2gEI9G732FfmHu7xFz1Pn56FAW+h/fOAikZBGciV12sJBAFTA== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: crxF538O18+DBFY99yF3dGaElpZ1C4LNHkd+5KZLWZBManaoOZ8xXkVCsqC+tTZmWM4C47QZ2Q3Vd56PxducMLbYchOlrpd9O6zkLy9ai23oQ+11hHUK8I1MzMMbsqKXDrroFI+oRbQ2cXWVPhwTyw59hKDEVqOMhzjU5zKn6+rsF1fgYkzxPgzw6yN+eORfqu13fwuIM+oXWzG2ERzFcUmkfoupkm2717m+wQ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lcHbgDpueT/T2v/BNTcFpBqMzeTnnIWKOkCfTCJU6LsqtgLXbUWlVozbNuUUZdjOwBjQkJNeccRw692Su7CHFenK14p20arWnAvCTlQP0ZJ1PYdA42gWqPRQ1/i4Mqrh5dKXpJeawBdGTRZi6/ik5/Ubv1hmve+4Iki6XDxBRaHz/rfDmtv1fCgbYxHQ8/w1GI03+8gniZ2+0Zd2oJpi9xZZoh52V4KYA+1EgShlrahUCrp42s5+MAhMZh/5OdIngOdJXuPFeAqhg2OZx8Ax7km5pwja/pquCz3GU0UUrE7Ig== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22187977-bed9-4d26-9449-08dcec62b8aa X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:12.9839 (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: DFS6zMm+6rSVW4kKhwYDm3pSNJXDlp9W71IwJwnrf8SfpX4DJqNKG/Sh+R03pP9BWEp+PlUvdw3u+STTabBqs5/1zNYC/otmwNSksEZRSoM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 5171d64e046b..ecb9e86fe45a 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -467,7 +467,9 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos) struct net *net = seq_file_net(seq); struct mr_table *mrt; + rcu_read_lock(); mrt = ip6mr_get_table(net, RT6_TABLE_DFLT); + rcu_read_unlock(); if (!mrt) return ERR_PTR(-ENOENT); From patchwork Mon Oct 14 15:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835208 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2069.outbound.protection.outlook.com [40.107.249.69]) (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 D1F301BC063; Mon, 14 Oct 2024 15:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918802; cv=fail; b=mBaYlkySOctar7QpsWnftN1mCgEF9Afh2Ti0T8mh3NLImMpEo2DzNCmAI0dntM22bhXOo//1rBFTxFI8zeoMTn4SPdetRPSw/RF31D8j2d9irNOKgTN9Pd35lLdf8iFm2TyePE5VkTDCGbTi27aRRGWju6o3rosnnW/NI4Bs4Z8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918802; c=relaxed/simple; bh=uNPSrxx5q1hUk1b0BLN0tuZRsSWwhgD7UivxKUuvSqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=W7wAAeclj5CM87bEw9qRUpEGONlelKkHRdwM9Dp/rtLcLmhUnSlaHTf/yosRYKSx1yjUI0jbwJvnp+mpRWmO8ghX/Hoo1N5qCCXdb0QQ68GXT5z89waIGR4Z6EvmhaXf80CA0DxuGY4oi04h+R2Y8NQjRGhPn6K1E7wu2vhX2Jo= 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=n7SitMhT; arc=fail smtp.client-ip=40.107.249.69 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="n7SitMhT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QEXFtL6IVU+uhN6WQpbiToe7llt6DNtNSYyTm/UVpoHhdEQf7EpJvtvG07JQ6mW9kJ1OgTkbgrSsKRgeVI+I+sE0rCK34b1G+4jjW6Fd+Y88XljZX2rgv29EKy1LhSxdLDRY6ZbEJVyoUhyw2CBcWIakfTHAE8B9G+qJO4gO5hqVaLJN6rBW6VE0o+UM3ZfpUd1Dvuvcz/xOwLJ8YD+4zL67FgYHUsPf6ClBf4kZ24cKZI1v9F+MNrUe8tOIQMeK4mNmf4FRuBjbKUlhAUujgYEc1rzYNAiQTtdPl9DSmbf3a8xhTlNOjMof16F5BoR9H9W7z+CoKxWPxJdR/QsmVg== 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=b7Te0e1NWmEHgDBxg3djRHVGSiYFJFAJHD9djD61o7I=; b=hA6ZBo2ATIGutQcvo4WjOR+vmp5eLpPzOC0ncu2An8fkxl5Z7bD3uUo1aPF4AOaDi+1I288E2d2LbHEPBjmlkzUuWkH+QLpdeRgPPgwbVps7m25L0lo0YAMwhhgFClvTMJ6UvCqjB5vlnPBXvmZkK6R9oAMC1T+LSOr7NIpfPME2HmL4Z8z2JAN5KVHC7jAy6cAZaknMb1mB5QDG84C7pIltyNEAA1p2zUwxuDKhCoDNLsThIUzq8rszsXLuJ4Z+2dTMLo/S65GIrhdmgQkb1ChQ1Bju5WtA8j9p1Mbep2MVlalOyswobYmbB1N5AzAZqCK1UP9QvUOnBlr0JPNvQw== 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=b7Te0e1NWmEHgDBxg3djRHVGSiYFJFAJHD9djD61o7I=; b=n7SitMhT4LpnVmmYm/s6POFzdnUwTJVJ1SESzuIlsT0z4WrBEGx7B07tQloENb+peONOQUxHkNLA7CkCiVeot2O4E3ohUVVvKP22gJdn6DX+UdhBALYSbLWCdfVt9X4qtw9Q7vq3s4zyBRsgtzYOZK9MsNIjQ8qR3PYm3GR9b4Tg6aBrx9cPXM7rYEz+yCyI95buOIbZApEstJWQ43vL6TmtKpnDx77plVSb2IADFDYm6CwSyIURbas5jTC2VgCPNbVlyOX0sFs/lWGYyqSn5BlYdJCNZ8UgnyWsT1MEXU3izVn8YOy7Cy9GBXcd0v+rkeMiQD543i99Q1yUKMHc2g== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:13 +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.8048.020; Mon, 14 Oct 2024 15:13:13 +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 v5 07/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6_mroute_setsockopt() Date: Mon, 14 Oct 2024 17:05:53 +0200 Message-ID: <20241014151247.1902637-8-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 71892a0b-665d-4792-94e9-08dcec62b923 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: IARU/QbAQTIEwMNgdMOx0xRy+lhv/1qLzQnYc4nsLEMhi+BQnHMf95o2RbODMOLM+RH0LGrmrgGLYACE/EnM5uEpxk+dyZEj+gWu8OnSC5uOSiS8ibyuoj1zqxpDy5DOvIaUtbKzyMTcu1lJvMaMK9uirk3hhmWoizBvjN0WAQgG6olgDQp2OF0rAlCX0X9EJp6l3yWsljd1J4FJJAZ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c+8e/xW3e/NLvksKnETtdcPBltSl4WiDdQluAx0mIfrKuwl/iCdijIA3XTVERs2gdg== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7kVcGY1C3S18/8dSOonqD38ufdF6iCJJcZJSRVl/Kej74gj9Gmq1Q3q8ErfxrdH3pQ0aHz0x0XgUPqU36M9aCQ3Ze9ok9tAQRcqwjSoXGo94aU30OV86du9X4fxjQl/ZSwwDFNrOmVGC4hMlVIxyFRXh9sc3EAApCk9V2Fb2gE4T/bFoE4IaO37vOBJIyGi0trmrRG1gy6OpsEWfABkVgSGdaAh1RhcPHde2XwMYi/NdC7JK3w9qPszruYAJ3y+604aBwFDU8dZQ3LF5MdYpV7wKiiQwYohOJOgsVwm7qcXVmjsUujhFPkFCQvDQpXZ5xbG75d8//haEazufDKmFUfIeACEcM6TvBeP106OD3YeP/jMy4zDnB4GYd7nXIm8M3ZulUKhcfeMHLZKfQnM3Kf+zEC3JE79vhuoUpjrMdVMd7UGerVei9z/SCcnBXm+EIxYAfGgC12sOuoeVoMIWwRZ8tbaV9fD0UVB6IP7/CX9nwr0nAsehxlEB0QrC99SHuUzL2EM7kIQPjgOz/WcMiGH5k/l0JK/gI5IdP5OirxUk9twdOJicoWKjma7QhQMKa6E71RngEGQ07+bRsZG90ooGeOTfrN1i7JYhmH2oxuzkx796nvCnWHPFWNp4l1wlLtuHiqNbsu+a2VMcd602yFeHsvSkCf64GzgI4dtUMkoXPAcFypOOEXiJBpVvkQbvd4L2y8mbrELfblyXntQjD18l3ZtjEeQrCvyw82kLF3XMvq5mtU+h6MU1TLFTTHbVBDJ4t9BvXLi2O+yAXfo5krXrM5K5cHf6flmlfMpRMzCPGy83/Txsh8djnw1t7g/fxKMTx23eTgM5HeIerki6Di1FttovjN1SHGG9NfEudYJ9IBP+nOD5dGButAbF8pXTXTDraQUt3rV/y/dRxPFCv5BAMFA+LN5vDYHIxtXz3Pz1poWR1Ndhitw4bPe/XZJVQg8z9s8PPFR4AcXTKXFFJ1cPapk4zydeRr5OSvSKODI4Ao/L4WRbH/Sbq//nFmyF+L4cCp38BHi0nZd/Mv8VxCejN7mYtPqTsyGxl66gfug70ZxKFifd1hhCw8mOrIGsXMVP7on+qRQflL91J1k0aLtYnouqqSt0MQkmfEK57WfgZY5xC1d8t8/zAyDHefO2Ubt8Mrh8dOePL2fvsDLHXpmHKa2YCa0eT+mlw9ydhjnTsSKfDfSQcCFi9GDsoRLO903Z4Y8/3Fqqts4j4h/m0zdRHxFf9oKEi+gQlMI5TnIPRej0cGbteL/m/zaBmfAr/u+zA2rhRaoeVI1s7S44Cw61RhuwsUvaEJacc4CY9I4Q5u9YWHgdvZRTY2t+6kj3QQvzMKuMyUD9zjjsY7RGXMYjWYiFhCiHjxrbC6o/taKizAVnkfkEpV+m6ca7OSF6E7xujkO1A/RLYaa32yPeAIlWPeVx2Du0ncmbllDgQz+qZbMPfLsHBcSRK4FDYwTs7Q41fnVm4kJ0+5WnSa54wFmkcXDuhZeP/rGw/LIr9i/waXxRZmgfLJCX06rtRTTQnS5RtI6sUkl+UJC1TjK3Ih1yD1EilzWwr20JZ75T1FoTRrEaqat9pE1zOmU5YlPUf4jUFjkcBaS0IsK5LfAhJA== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71892a0b-665d-4792-94e9-08dcec62b923 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:13.7653 (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: PC/+M4gwNIRAjKkUS1+FA5fs6LyzNvY+LwQuPeBWMVDvVSgFa1l6hG1qqpDhSrZcfqazfz0mi0MTlH5yVtjJPIixpG3LyAg/cvNYaZQ1jI0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index ecb9e86fe45a..b54353bee2f8 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1668,7 +1668,9 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval, inet_sk(sk)->inet_num != IPPROTO_ICMPV6) return -EOPNOTSUPP; + rcu_read_lock(); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); + rcu_read_unlock(); if (!mrt) return -ENOENT; From patchwork Mon Oct 14 15:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835210 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2056.outbound.protection.outlook.com [40.107.241.56]) (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 500971C2335; Mon, 14 Oct 2024 15:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918804; cv=fail; b=n2rD8+IfkSfPS+bJ8F61sbDtat75j6HxvjJIe8yR70+WWYj6n62n9muHvV62acg8lny89YTm5euc/2EjNUihMjlHIyuqeUwRUgGN+1Fv2Pu/kUBWbQZE6SKSI/sZgQTIku84So+NtGdwnGeI4guG1tat077disyuoKoinrVPsqw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918804; c=relaxed/simple; bh=IvbnZYuAbIJmfRjKsGI9i/M5B4xWewtEeTJCldFB2J0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=uc0G149GWjJBTmsTto2B7lXyAfMbisBYIb93/rWkZiX8UO9RmcJ5hfc3emQZQcVUeWpKr0mUfGx3xgwSROPFQZqg4O3iDH6bChy357ZUhnbjtPwmvYL1FQl9TqgArzDUidEEBuNDeCgKH3JYDp2HHOhYvpiwuU65FH+pxh2875g= 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=k5bl4O6n; arc=fail smtp.client-ip=40.107.241.56 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="k5bl4O6n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GzLuowu8ANfYXFEPxEuiK0+NG1n2MP8Otv2VhOjk15ZgJvPkpE+9mLnYBqchWmMk2PWvgnfXJmUgJslr3P5r94fdFUaJYJWZJgqPVjThHR+hmANG63WzuxTqZcs7wJNqrk62k8KQgmS2rjgdTYT9YOC7fmSWklcx/hOfmc6loC2q7c2/2FIoxvDFeQ2lWZLbZqwH6j2CLFDdGlLOvSgySVIcBXUmDHFDH/9Da5rNC7SBdz4ZVr92tkHZgBJ4RYCmhNvRaoUiCoMd+ERrZVk6BvSsU5o5zM111TINeAOcgQCsUZPxlwr7ifR8GQuphzCoS75PqEzH9MbGSY9k4Q1L3g== 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=q/AABujRAVW/xTdIs+1sSIkUsS4ZGj00n5APkd0C1Kc=; b=y+VyMzZnbs5COlzAxlT4iHU7T8t4C4KkigRGadkjZdRjzq3InWOMlDUU6af8nCT5fmSTyfqYTDNhhEDCyYIYSJ8ChlZrsXIS6mTtIQuqSkMI9omdrNfiH+yyZfi+904OjYdmkry90oMhep7tjgCkhkHXXegEYXb1VmYLsdzKucKaOGwakJwJqynULgIXR0ZeUVEI28gnZ+8zA7MCRyrv2Tdk1DAELrhLcBTy+LyR+vGvKNf2L0QcbTW0fTDMB3DQQsl6o3ID2vpyslah40FXw9gitOjUiO+HZc5lDZPpXK2Sxo6k4BuAl79JQfl4hoYQrylHxxkbu2/+4LPjwrpHxQ== 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=q/AABujRAVW/xTdIs+1sSIkUsS4ZGj00n5APkd0C1Kc=; b=k5bl4O6nQKp0Li/U52QNTBxnSqi8EDp5hzkqnDNhgsYpdZ+kXdNxJ3AH34MVklkoedNYC9a4IbWjdbxkecOnBDScFQAArXJGzlVPuqTI4sFmt5i6Nd/p5a6SSUQFdo5RtIHUhxBL15JovsXwK/j+/yqGA/WoOqCc3DA+iXuLVSW4Ybf7lnc1WI6GQWrFxG5/y3Q25RIXMu4yA0r2OSHLoAxcLmk58uHLZ8D6dZ6yR1qe+ZE5tvQBp8iiZ4Q67vJN7xdSNkylgF+FJaWuhi7NVSW731vIPu6HeYsUjp9AM0QUpIt2OF4msC+8s32UoUlPK6VWWVwwNNtx2aGKbtOssQ== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:14 +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.8048.020; Mon, 14 Oct 2024 15:13:14 +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 v5 08/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6_mroute_getsockopt() Date: Mon, 14 Oct 2024 17:05:54 +0200 Message-ID: <20241014151247.1902637-9-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 187f0187-9bab-404a-1622-08dcec62b9a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: ySFriV4mNcBUjUUpT76OplMON4VUBluHtLnYpuW3PZl8ATRXRNbjmobQmBMnOzkRGc3DArQq4XUoou0mrKi9pvZNu2cmjDmmSlu+hfJUBgp/+vFB38fN5wWOY6tyAQRp0jPTrz5k31Yrj9VkATT9dUch+mYpEh/EFIBueHiyFJFRXDSG2zT8nzgi/wwbTjhoGhxn62ZhOUT0FK0IiwDbEbz1m3wty6pHfDl9NiWMCDR/vUaaa3jXoKxNL+6U7OluueLvKfCvQQB11C3yMa0W7V11TP1G69itkd8mIeL0/vb6m/D7FY85pfilMNcYKdXWUTCa19vak9nch7XjUcSNyYB2NmCmJ1f1HR6RBG62gtEhb43jhCgOVbq2mjfJ9u20vEso5MJCShRc+Bzag384Ow2W4mB+RU+yOwuhmijILL5ILEzhCHB9Vd6LiPU7444Ft4xqzkEfmYPHQK8+vWh0ONMYOHJ2FOaKX48Gnl+3gsa0CYAQlUhnontcPw+LMXKwXyWwsiAUiMc1U6K1D+JdWS2tepTks9rcXUSB6Z+CSm0JajwPu0/FAulI5kDIK9I7fAozZYxjGBBS9VPSl8sS74qgD5dTqDonQa3wHpuLaqNEK86XA5LJpVeLuoI4lT/FlXclbkozAm7hYa0w3CYu287NFJrKw5ws5WIYB7DHgi9rjgbZrq9G1WlwFNH6Es7srzZ3PE/Ir3Ajxfq9R0qJZlNTNvgfSM318hx/1nVJMU2ZLc/TpxkaHQletwK8qPWyH63w9xuOAVu4/zW2srQXpn3V1+sLnHQUAK+X5CdJi4rTEXwachVzpfAWrQlAd4H2mJIp4mrM0Z2zbYPoX5Kl230vsD4lEgDMe3bC0MyTEqCRUC3kPRV2BBJZtT7s00iUM23pE03Ay5oLGE3WKDLIoaxYI9+q7JQxG3RvuYwn6lDmYwcB4hysbZB+w9d2FG7KzIBad+B15oAb6IJGvcLY8AgtFzbr3bN/UyWKxRPBH2XDKMP0uV84to5XU7YY1nOvfIjysyjzu+plkCpItgZGqRBz8JwnkxGIbJMZkVgdjPEv8k5mi9yC7DrzSIkzEuhbOgC3pn4Td6UrxSubCXOzJi7ASGe1JqTADFBA5S/Q5E7DuAOY/m7fggC/LcjBHeZtvvew7Udab5onwxWeg46tJKK/kcg5YhbmGiJU/QVWPvjVz762WfbCAALv3luQohweL0ZEcdXSaMY06e0AEoM0TSGpH2w8R8ipK0H86JANZtL0I6u2YP7it/tIwwwAsBarI+jvinI3Bp2ELyQlktEMeAz8qBq9+vN56RGkscYVRMzcUZrPFdtmHZFMsw1MNInIiTuOJ4UHUB5GRgkVsnajYw== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dNoUk/A7jRYY8HssvO0y16C5owZUWti1kEfXbMv+LgiQ0XGIAc9CVAjvG5w2fmHv8MFvdteHW9eVh3NrRcxSGvg/M4SOwh+GxDykymcdbwVtk/LPORG91sUEVGImsbCdiRVQ8AIQSQltAOtpANDDWKkdZseYAbjtQ8PO7J2/SMJbYiFScG+BVPVIhrSOKz94YB8yBRKY6E4b/QXi6onZp4BbpTgOvVErJkyt3sntdr/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IIP6H0+FHHp1xy9uify7BpMvaqa9gltGR29GcdGpzZM9PBwaoaqS/kpSMOeqy7+9ugfOGYiQY+3/JZLrwwy3SuSWmHWkvykzG2VmmMMIhend97rCUq/RnBMgA3bcxjbsVVE2RgpZeOjZ8fMvcofffc4EMyx4wvyOHxmHSfalTKZZWQnWEK7b+NJ0+XyVocoh3gf0tGhH0QJoiXGkEtfUnjIbNT6+152mP6f7zOxErJAdSExw+9seqDhzyh+S34J3Obs4zN/eM1t7WGvuVQYR9u0lWUOznf/gyr9xn8sMwUXlOtbsxlg== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 187f0187-9bab-404a-1622-08dcec62b9a0 X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:14.5840 (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: cHLEevHPCFohHz50W4twuuQhw7n+vZLF9eXpk1TuJ1z3NUEUJOa6+oKbh7UpGyDhe0y/FQB8Sq2LR+reFK8dB7PiGxzdBPOm+NIzgru4jXc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index b54353bee2f8..af921e9731ec 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1845,7 +1845,9 @@ int ip6_mroute_getsockopt(struct sock *sk, int optname, sockptr_t optval, inet_sk(sk)->inet_num != IPPROTO_ICMPV6) return -EOPNOTSUPP; + rcu_read_lock(); mrt = ip6mr_get_table(net, raw6_sk(sk)->ip6mr_table ? : RT6_TABLE_DFLT); + rcu_read_unlock(); if (!mrt) return -ENOENT; From patchwork Mon Oct 14 15:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835211 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2069.outbound.protection.outlook.com [40.107.249.69]) (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 A9A2E1C302E; Mon, 14 Oct 2024 15:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918804; cv=fail; b=gC8Y6F8BMr06zTGQ/rwOT9qea+P9Epq5QlmLO8xsWsh7ezC/I+mb79x4gafA75tKtIA+k2HcAiSIIzbwBttBrCPIz0fB4Eco3yFFlPKrNMikwW13nV71AEJfkSp5YPg46KBQYMSndSomjvID14Snux0BkoaQNBohSk5S1S4c9ZI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918804; c=relaxed/simple; bh=v9mYVK23KMrFTQ0SBulN6xa2/1MW4F8z+gjj3zmk10o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=trNGeEOBKaFS3tOIeYfMnvpxag1++1IC8LydggmKhS27di0U4XMKTlAf2UA3IA42qnqnXruwkiB/7BdgihTxd4qv8jtTatcVTJ8pypCxpZBppuIxM+qx5Yv9tVeZWw1sgOrHaWGO/RxHCXMBopAxO9omCdwG883u85rTSp+7+G0= 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=d+utkF6b; arc=fail smtp.client-ip=40.107.249.69 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="d+utkF6b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kc2OWgWU8yKS31MV+3hu/w5YefAgQuwCHyhrX38XQkUtX4hO4CrmevSqrD/FeO1+Q6qg+qTqfUzOSYntJtx5SYgpwFJ0e5m3jZf1LlRJlPZM8VOHcnglfofh083CuucFnevQs5agvK9yCKbXa3i4x1hv2eXe7w27Q8h6u+mPjEEhUNO7K2E+MMyz+Q8uj1eDc9E0W0HFVr2U3BgHaCL2GZzbqlx23lyaQPslvLkY5FOnAoEZt6agVyeMCI7t2+XrIo2jpNAp08I5imSVvmQ/d/ORAG1EOZVL0rBnAiW01i7LqBHFI5YP4JGHkxoqwQNpqSQISIenBZiWKZ+Gkb0NRg== 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=OkA1Pnin4WrNswcShBwME0jInUjGTAbG5vZOR/OAaGE=; b=suGPc0HlsV2Fedr+fkf0FcUc9lMfIYWdAbugQlAL9ThcEwBLTOfc9ykvuwIRSpKzssmgL+rDmd6iefFjnWZDUuUcD6SRXtDkgVLE8mFeWxIge/kr0hCd//hvYC6fjY2RKsU86Uay3GJFFQE1IMFWRNOHyTj3va6neL8iS0BP7B+w4FvpoPfoN6WjdaNmujaXWmic/XPQgj3Gj6PusEwrpwRgKXsmTL65A23ADXMMi8zTlO1510IKxF/PZ5/U1RNEtBlz2lNvca2WDUd/twhGmZH3qLFLKtd157wsX71L77EzXv1PLl/juxri3v6mdO7AqJ+D180MWETpCgfAcpdwfg== 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=OkA1Pnin4WrNswcShBwME0jInUjGTAbG5vZOR/OAaGE=; b=d+utkF6bYysfdqxjHKnp8CH5RvuQs1qZsTQvND8RcbM5TUj8HsOc9kkUk39hbd6tNWi/pyizpatmleI71+M9cCoLyQ8Vg3637ve11JFdJaEn0eCn8IzvSNw4Ko9XjGuybcI4PD7VkT0BCKEfoLXOd7X+y4W81qppZUiwY4w9Euxi6r5KkZJbe9ePzTluej+lmRHYIZf/TUbeWEvTm+OIObQVjiMDLStrCT4NlHtXOxkWpyT9IY/ov1V/zuL5o/1RdhWTxwiUJeMP0rXKZyovE7KbkT9sgmpbU4832E5o5OujYEYDtWamk2X+G5lYAHaJIkrcgpbnxWAb0kbXCyMXhg== 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 DU0PR07MB8905.eurprd07.prod.outlook.com (2603:10a6:10:316::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:15 +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.8048.020; Mon, 14 Oct 2024 15:13:15 +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 v5 09/10] ip6mr: Lock RCU before ip6mr_get_table() call in ip6mr_rtm_getroute() Date: Mon, 14 Oct 2024 17:05:55 +0200 Message-ID: <20241014151247.1902637-10-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DU0PR07MB8905:EE_ X-MS-Office365-Filtering-Correlation-Id: 444b7f27-1458-4c0b-55ec-08dcec62ba1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: by3uf5gE23WyZLcSiOyCO7uJfXDcSxBTe7sbIoRt5OycGFicDpg335wFtRw5cvc1QygWecK9fyQrCyfRLKpPbJRT2bzNjTXFTvMaLVKeiT/+ZxNwDERjmju5EBfV09JTvL1Ne6sPTzISyDZD8nbu34zLnWDfdGG8lLoN5uteAPMkZxzEw/pxKSr2MxKOSjVt1yW9qHntbV4jWHxBBQHtouLrNX/xOai4Y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gki6bCuRBclRmlO+ye7CE8SIYBe2zYA4Bj72qTGqAegtEMPxfg== 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)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X55ItipCsCGIl3HKOpCC5WOG5V4+I/C1CFlOc6fm118rpMK2rl5agVbD21q4/3UuGV+tzcYIRCbb53e0Kuwl0aacF86O+1RMnl78L0kZ+a2GFy89AnSco1jmPmw7mW9e4bTRIFfiIuuqpt+HLyGzT4I0wr81eegPn1wW5YjUQR2PGpXud+T0N4nqmrN8L848gUD03Ce9LK3Xgb0v9vvKKo+dZQfQuF0LLV0omf5I8y5xEJwgTLuTyEeln++H8Y6gRQTbZ0nPCSI8xGrgxDcgM9wmeQwY8iYrWzUiFep8rXUOCdJTznXXA6QcC+DzRAjItYPTXHJ7rVDWeW0SsPF+SXQmSIdUb7FZxrLQnBy7HVXlQuUokoETYk1NxkwF4X6ka7EgWPy4Cd00to9fMs8H1J7+4/eEc+SZXtuOdX6Hrl+EL7H7+q/F1NBgyXmCGTjpPkEYT1l7D3dZyIUWiu01KMnxglwXZLjfIAOtsvvAx6+4GAHykarhfvxl7AkCV9mgGjW5pV8qU8wIy+6mLKSeUKVb+llpH4tJjpz+lMYkje/Gm5MhR6gRjaPibYlMqlK4KjsooeGtmXMXmmi5nr9jtz13vHAV+V1OPQrBHOo5AMye8i3podWHIvvSxQxdeBevw688C8zWsBc0eHv8vWDXtpqxVe7Yzbl7JccaKhc7mpv3tEh++KuYvjxi12qQco4+5qAbf6FHq345yK+PCz38kxy5SrVzOCzmjmRnFy2/7sVWsYKIWMZp+XU7gY0wLJFXruz6sU5AgSXdluki3iv2iG1JfliQaaNajlbV0Se5eXajTRIj8+OPu7XLZphdkDICfrQCLSjlMDczoMMZF8W15EPuryqJIt8lfB3gV2HtBi1npoNkhyHftXAQB8ES52taYp9etURGDuu3KHrDJd2BTn6Tls6You908+SVkdRzKH08dLsAUMIOVHLyTpFXgGZEHX/GGykE6HWbKyCbv1odAMCg7bJRlwThfGgnTXaYTeI+tJxgyt3MhIpNpia0xFzJUf0QDh/PlbjdR7ZA1OGhcQcki8bpZXX+J9hYsC3O6f/f/kndLHHnge7l8AnPGudVLFbsmbkmY1GALZFS7+QOtPiZl0SYsiqAmBJnvr6UlaM5WsltCtEPsaM/Lsb866Lsfogca7mYGdu3CajogtL05SDPxLTlXYR8zJZwHeZ5w30AHwjYL53BraSCA+dfPCTxHpbYrZzLc4Vjt7aXojXn2soW1NBPbaKL968u6u15J/wZOWH1jKfljiVXmEWOg7lBXK9J0Tk9NzThbanVwSN8wRm13KlSqBLPX+fh8k15sRLkKrNYvQsFQmGF2FAC3VinOVFbXKYPQ5oUSbrtM6+cJBF2X2EOKQH3R8QvzeSHXjxQDhyXtpOZQvhUe8IiWBV/z4VG4xjsfYYBxryFuehFssp8UPOCJDumtcphNJlOiOK9NzJwYUo1xghpETfL1LJqgv1aSUU6e2i9Q5mkHWduE+axQrGVyZfYwtYDuQYL4xYDmlYYxronBPVWWyBWil+BQAscexUzIL+PuUW6kcS+idsBGI2NyYdqmNF5C2dH9Je4cU2wnDmXNnWK6l0WcT1M9Y0FkXue09hXmwxSh5aGhQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 444b7f27-1458-4c0b-55ec-08dcec62ba1a X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:15.3900 (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: mJe1yELAMx5wKH10/spBk3/ruifR3gIuirZ5Wi3s7Rdu1ID7kfkd5ipPVY263i2DlO7UfReg9Bmnq8RwNHsjKDOrlkUbT69ZjLI2wj/9gpA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB8905 X-Patchwork-Delegate: kuba@kernel.org When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table() must be done under RCU or RTNL lock. Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index af921e9731ec..01b58156e06a 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -2594,14 +2594,15 @@ static int ip6mr_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, grp = nla_get_in6_addr(tb[RTA_DST]); tableid = tb[RTA_TABLE] ? nla_get_u32(tb[RTA_TABLE]) : 0; + rcu_read_lock(); mrt = ip6mr_get_table(net, tableid ?: RT_TABLE_DEFAULT); if (!mrt) { + rcu_read_unlock(); NL_SET_ERR_MSG_MOD(extack, "MR table does not exist"); return -ENOENT; } /* entries are added/deleted only under RTNL */ - rcu_read_lock(); cache = ip6mr_cache_find(mrt, &src, &grp); rcu_read_unlock(); if (!cache) { From patchwork Mon Oct 14 15:05:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wiehler X-Patchwork-Id: 13835209 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2046.outbound.protection.outlook.com [40.107.20.46]) (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 0F9691B4F2B; Mon, 14 Oct 2024 15:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918802; cv=fail; b=L+6gqgW7pmSc8eEUWeC9y0vNUtmQbQyk/k1h9gr19ZHANlC+Wee9nshqZIcGLymmgkHgnekA8LBIryLCTP2EEmJyeT02kvvJuPMlUXXdwsS50jONiRbnaLh/EZDpjFWBM1OAn1wDAZ59oruqvvaRNcDjVyRVxj81Zh49E6YiZlc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918802; c=relaxed/simple; bh=Dh6mB7dPxWk/NdWcY3Fw1HEL7eDKqBF+sgfJyG29Gx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ove3dPfEHR9c8F3NsONi87OYVySbVPtHPiU1I6bzCydTxL7YY+kfPWqG96p2G4hwGIvNK/wAAooJ1OHartsgG95EGGc0wOXqi9hC70IChTMdynigqic1MRDd+9qzOZWQVjMq/AZmAV9VaGdBPS/N541uAZaI2DIXcyms24GvfTc= 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=OVQwgOgs; arc=fail smtp.client-ip=40.107.20.46 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="OVQwgOgs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BYpRBSq8msgJZsrGFwBpTp7kEPwZAmEziMTz6YIQ6ch+lq7z/c+Ov7deJFvMheGlnNjLbEZTnFQVUF2JYNHfaOEmBkxz97K9/KW5lCLu0IUr21WhLfcrxLLZiuW3avJcM8yl3ZkoAIzZENocsGzB1AoUB7HpE7rpvTvIES2Y0WXrPBcGvO25+A4l3KjB5Lx96Gglsd4VdXpUt/nUSnov7bTYR4NYL3GrQwOnS0rqxynBCzDyUwKUfjXZ4VaHQm65kfz7a1cQCUl8U2JrpYw2kP6w+VfqlT72Fb2NQ/e558QMDOaFWxxHz9Clb2RwnMwZIFSctrkBALfTeoKWLDAlhg== 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=MJ/RYkwPtUg6ac8ofSc9ayOWp5PzT3N/N72IbCKbTcc=; b=CfJh4fRTLMuD0EhsrC1GuUvrAV3JHNZIsz3YuERG9spq/2FeHEp8drBG97aAP2cB4D5W6u86ODBK134IU3JLH5/lBS+ncx+y6PBx7s8Z8MmeT5I6puxISqPwecMeJUOJcNVOL6oH+agnWto5BoPW1+syVl+tOl/Sww+sJo/zGnNjpXCNiCr3I7g7nI07XzlJlco+g1k9RBgnJqYO2cC8YYTGGshcpW9JlV1JPdoIyVjr4WOFUw3ZT6i3tLjwR0aL+h+pjnWkuPC97gnPmAQpG8ob62ysKZNM6j364mKZT1jcf7rsprzkDkRLm3jDgqlB3NaZvew51hd/19DKlL1GXg== 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=MJ/RYkwPtUg6ac8ofSc9ayOWp5PzT3N/N72IbCKbTcc=; b=OVQwgOgs7AgtQD7WATbBAEYHquF8if6xXNkaHBQ2z2D8qjLiQflwYpQQ6aB5fqtE8Ppt0CjYQhpT7uehqeJYBz2DpZSoMTLBTXLQlMGlaK8k2AcmfBFf4yaK8dFI1Qdbo+zQneYS3l+vII9nWz2aE8GSIiCCZ0XOa0pak818Nek/NQtccJGN9uKxG37jLADpT/nNC0SEPjSLVl9hD/EuOlBJM9AeobB2mGWSn3Ee9lrMARJX9oQeLnU0/UpioaxcViQNcGi1rXWthsYvDTpQxIg5WHofuDZIAlSJsu2Ih9kv7HbmTSPkz5D6bu5k6UbJ9uTgJQw6ihtSDtPicYBHCA== 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 DB9PR07MB7964.eurprd07.prod.outlook.com (2603:10a6:10:2a0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 15:13:16 +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.8048.020; Mon, 14 Oct 2024 15:13:16 +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 v5 10/10] Revert "ipv6: Fix suspicious RCU usage warning in ip6mr" Date: Mon, 14 Oct 2024 17:05:56 +0200 Message-ID: <20241014151247.1902637-11-stefan.wiehler@nokia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241014151247.1902637-1-stefan.wiehler@nokia.com> References: <20241014151247.1902637-1-stefan.wiehler@nokia.com> X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAWPR07MB9688:EE_|DB9PR07MB7964:EE_ X-MS-Office365-Filtering-Correlation-Id: 467542dd-23a3-4c3e-f283-08dcec62baab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: EBH90/tQ05HOoU5JtzSUGgayFI57lK2KI71voFmGVwiLEG26IwkDfnPGdmUzcn2LMWpC0pBVV7ZR31bCTK6Q8NRPlYcXKtiPyaRg2irQNmxgW6ik2jPXX2L74bdD4sM8UaqWiryi+kNnatMsNv7QLlqjzVhwY73KbHPibollFY2e+a7LDvS91AwR8ZBpAhpbBclkArx9IhaFTzsBJM34E82Raut0SPxPxjy8dAQ955pjpHsbH53FniukVAvMsAnO921yxGHUvdUjLpTmbt8sGTkrSxQNIm6e/vmW0DtiEmZBQBpbCNz6ETldce+LmBnIvTDe6Iy0BeXLRK3dmpLjpDGQ6F21T8c8Ei5BONA7GgacAj7rBweQ8VnuKxioTfdJR+ZHBburTLkNqA030EJfSpOBvasL4Eod5ILlHVs4fwtD5/jUv6oFxvDoy5TfIG36NtezdCjzzIH9RB8z8PSepcz8NrbdMZRdJkQJ9ji5uhRu7chPFRe4bsANk0Qho5lB06AOqWk8jS+a1R0dKxAcWyqKBV67j/crtTHOmolRL5ShT0Kg/DfQWSWg/ghiv00oUnXuOmznTI/rN+tzCOVMLg0tVPS3bAUd5e/9qm7wNeGMQr49IRuGv92ZsSM0bctV7+B/IyPDUS2d5sZuzyJgxjrh5AFz0JL9TQ+eV2+clPRaDPbPVk4vYWfABDSxnID1LF5ZdVKhtei4nSXXsHCJts9fe/pnGN3aMKf4la5AnsyJYejmbKgTWtegO8EmHraNTQ/nb7+sIg0XBsiqzsjfYk1MMhpspPn0jCb3PUEZ9qiYH5G8c61cvzPS6bhz0d+QHdKSL13X6Fm57YkfBgsrcPcCBbOTVD/P5eMWbw88moLtZQ65UXMntJATcZ/3hD7ZTBLajFpa5iigDCP7n7Xuskp30c5H/By2qJFbCmE7X0hw7itMg0BC18Q661pSE+1OADOoxiyA+aLFjFZqacCJrkB0eRhRkKRZdY2eKlT1fQ4B0r0vNtfjCiU8IDyxAWAD0v3lGJE/Zxn5WAgYbZFOBqc4BXgqdqmlwNxPDwrkVaVBGJYM4NU9fwcaxPxbukDTclrZp2PGwQpjzttH7Drbe8UMEGMBm/jXS2Z/Ds7ia46JInH8wRYnLj9k0QCJCs60pP+WGUUVp5uwHdHo4JoxYa4Td3UMt1ByjnDGU3wHMTOAonBgBL6MgHvrqS1zFilSgegtL00w1a7zaB4ZPSMbyCMxCK5B8ByjuwUIjaubDUymfFhu93TzKTqOqvuBVtYgCQkHKzStSdL05ygPzMUUJVxmKDRFddA1hbSVvO457d39Z5agHELyOoP1+9RiEYBtRvwT1lFA98quJC/9fzwZUA== 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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: txRKHygqz4AyTTeH8bF+p2qtfNT2vmB3kvpZ1fui0KFrD5buFW8WuNbzHpY5TJVoTXMqSxJLLLw8I/Dq1EG5RIm37pZdVjUeC6caAqiF6DYvaLgxeVem8tf0hi+HPiMD2lMH8JI1XAb4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DmYDenQjWVKEvD5G5tLhqGUE2vHe3FesrW6eP9xk6zswHQd75WiEdLeE3tKw5iqiJUKvnjcOoho38xDjz8RWsg7Uiysid6/2L1rg5989iPxiZ1c2w/Cfrt6joV5DfCV/8P7/dJ9zBXW6H2Q/apDgrimCI4IMZzZhLlMaczAFrAVF8seE8MNsCfSE3GRC1gHLbshyn9U8g/Xq3id6m81Rn2/Os1Wvkv1EOAuWutecKhBh9m1cJD6COIMZ26Fhv/ltyughMPgzKxFmiwwnHK4tygIKiBkYoBI952qOWQ9ws+0LZ0zrfQ09dLc1odhhpi2lXePr/9pm5itmAp0b+zC88sQMEH6q53+W7yUI+mzgjO5841iB3UugpXWetU50MoTDXk4YQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 467542dd-23a3-4c3e-f283-08dcec62baab X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 15:13:16.3631 (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: HM4B3ZWqeKQJZ2SSWgCeCgiw2HqyGFPKjEXpMCE1HrjS/kBZghqFmSro25aSk3ScBTYaWaZDq5iN9rz4oeRhrQ22fR9m+D1q/3jmmqFd5ps= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7964 X-Patchwork-Delegate: kuba@kernel.org This reverts commit b6dd5acde3f165e364881c36de942c5b252e2a27. We should not suppress Lockdep-RCU splats when calling ip6mr_get_table() without RCU or RTNL lock. Signed-off-by: Stefan Wiehler --- net/ipv6/ip6mr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 01b58156e06a..e52abedafc9e 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -105,8 +105,7 @@ static void ipmr_expire_process(struct timer_list *t); #ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES #define ip6mr_for_each_table(mrt, net) \ list_for_each_entry_rcu(mrt, &net->ipv6.mr6_tables, list, \ - lockdep_rtnl_is_held() || \ - list_empty(&net->ipv6.mr6_tables)) + lockdep_rtnl_is_held()) static struct mr_table *ip6mr_mr_table_iter(struct net *net, struct mr_table *mrt)