From patchwork Mon Sep 16 15:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Liu X-Patchwork-Id: 1986175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6q5R2mF1z1y1g for ; Tue, 17 Sep 2024 01:46:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sqDvT-0006Ig-8h; Mon, 16 Sep 2024 15:46:07 +0000 Received: from mail-bn8nam12on2044.outbound.protection.outlook.com ([40.107.237.44] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sqDvQ-0006I4-KD for kernel-team@lists.ubuntu.com; Mon, 16 Sep 2024 15:46:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GXr29D/XusYAnT+s832NSC716Tv66Lu8YM1agN23pRXRUB8IQSt111S47l+UE1p6euAzmtmJNUZeIdm+5qWMNIu9n2Ik0/pWxIgUtYMDPMSAmyKWkqeJpz6Eupgtc/fJJTWp5VAsdNBipMCBtbYKBMjhDRPeCUuor+BtSHlK+8LVdboossZDOSFxEWGZg9CwhkWRiHg1UVEt8+OXHj7fErc0SgpxKK5uZw/QocXma4WAPSxHjTTGYZTRAUfv9IBnyQZUyxKNVikjC2ahweUrxu+2qdUfPRDbWUB1XGztK7lg/8W6p+UOOJiJmqu5+jNlM/W0jEbiaKURFxp7auVlwA== 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=VyMX6brCmhjAxgsLUv3SsvFLYRFwoi5pCH2RQuNfAkQ=; b=aDOTDxLGTQ/Hkjm6uj4n5mmMAnFX8RboT8Y5v+7g0rmEnWG53HlhPhk4e7w6RICfBXtd3+xFp3iybnXJQzO4wT7O5XKKcOYIhi053sNXnK8b1tJjrXLUUxEAY7Jz0oI2TnP/ohQPpnFDvEf8RhOkVBj2jwEDxACFpepwqLzwx/2gWK2uOzrSPQ5aqCnChgvHnryt26J+FGsgcaUEvNoBCjRBREN33xzkH5ASDholaqY4wV9Uv+TTAbngrWx/toFovGnDO5Picstl5J4ok9HGhOlANYtrob6H5cw70+OocphcFWh8wqtYvyTmGhYCg7cb3jwbtzEhnwGwJn2yQ/mFYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=lists.ubuntu.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) Received: from MW4PR04CA0209.namprd04.prod.outlook.com (2603:10b6:303:86::34) by SJ2PR12MB7991.namprd12.prod.outlook.com (2603:10b6:a03:4d1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Mon, 16 Sep 2024 15:46:00 +0000 Received: from SJ1PEPF00002310.namprd03.prod.outlook.com (2603:10b6:303:86:cafe::17) by MW4PR04CA0209.outlook.office365.com (2603:10b6:303:86::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Mon, 16 Sep 2024 15:46:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SJ1PEPF00002310.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 15:46:00 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 16 Sep 2024 08:45:49 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 16 Sep 2024 08:45:49 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 16 Sep 2024 08:45:48 -0700 From: Feng Liu To: Subject: [SRU][J:linux-bluefield][PATCH v1 1/1] sched: act_ct: take care of padding in struct zones_ht_key Date: Mon, 16 Sep 2024 11:45:46 -0400 Message-ID: <20240916154546.94631-2-feliu@nvidia.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20240916154546.94631-1-feliu@nvidia.com> References: <20240916154546.94631-1-feliu@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002310:EE_|SJ2PR12MB7991:EE_ X-MS-Office365-Filtering-Correlation-Id: a1fd004c-44f2-48c0-b0f3-08dcd666a9cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: qR4tqJrpOsOYI4HWCO8Fh7vhum8CAn/Hb775zhBucP/YoFo3KDpDYCnf76eY1MhFN73ntwQghwx71JlDGV/H5M94Qbmjrtu9fSNmQULCPHOjcsHTOlvZe1COooqccV133kYM1NQWvfzrPlznwzbVxAcMz7WB+uDwE09ZPG/86i6P4v3zvJLOBXCGTVQ/dzoz8s0weV90Krv1sVgMHcb/wQD9NeUIEJajxeNxbZnjrcCd3CE1x2Y9u4gOAhD+7CwzO9ZPb591U2JvHu1AD5S3GEjniQ7yOvOy5fnZFt1oDHRbMxoxJyFj2pGEhvhBZEghlYLbX/ecOu5Z6pPUaIsSxV0pLke8T8mXyVFoL9nyxEeM+inn0RwZ7lneeqS4Bae2e3wQQuA7jeOUleJ2aGIsSgFokBoaFcFseeKvhizSQO95Hcd9Ki5Ft7JOIZJKpt4VMv+ABUj6CGrqVqNAfeKE07437cKS8Xge2LA/rg8pO96RO1I3prXBTl8q3rH5FXTfDx+IsDrAJrPkJV9xDJv+NhugEM7Uw7lAzJ1wYY3YymM0NJcBpYXqgxGr8oN8g5E0uOLKpBKIWx1caBOw6Id6zWpK8pa6/+bseZmQpMBLrFQ3uARK6Ddb736sEbgfNqCoHkVMl8jjH1zHg7m8HL+rnuoSPnPd6y/j0zT2866aj5u/FIIb6lq9YH37V5BaETkkF885UZs6RzkGWMh4K9X2IEh0vlizq+TcVoTQB5eTRtVWVWjLQjlvF6qiXxDgh3p5d5tZDQQYnhHcdHywuGJ3wmFOXYBrQvoiDCEA/kb0KasGRTAtBtURW2ZrooiawJTJgQ9eYYAkO3EYjgbpVrOFZ+AQye4uCeSqZqiJ5R/cjMfSt21cbbgAQ9679PIiBHhPYRTQ2rX8JXZjdRGKjxFc824Si3MoYW91quu5fIAXGZKnv1Z8C3eGKTBtvf+WgZUx3Oypkhyr1rMel5CuXn34y24S6HoaQo4s8l+Hq6wvClt87MfeC4UQogQWpuDp30D3LVBFlBcQHXvoDqeDmTaHF80gK1oCQvvgay1r9Au+p/KO7c2HHna+LgTbTirEKOjZLItJzWGqFLVvLsuZlwM/YG8aUwYJryMrtS5J96cDcsnHy/jPkLjNAad3hpj5Um3AoXAB9e9GhxQf+wKjOGvqOKJPSrRwhA0I2Yq/1/XhWbng+J/kpw1xXDU/CvXooOsKJyTwsl3WOdYVaaCgxcnZ0hKi2YwRg0eGXNR4eGzh6+Em3CED8vwui8Fp9YJCkmmiqN79IJS9WaMSyF+D74z/G2fp7AWohGmLXQAxAxU8w8nt41WGzFUJUWq1Ne3yfcwmIE7NvWkhCI/z+O1UL1fXUGx8iDoui9yWnQ5qpYDCs3MI/QAIvBfqHb1sav2wjukPYJ32mNp7i8PUY38FGsJCEEHKYCYOjoxzLdULSUK3ya8BmBLp0XTi9AM7aFkP0riW X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 15:46:00.3293 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1fd004c-44f2-48c0-b0f3-08dcd666a9cd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002310.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7991 Received-SPF: softfail client-ip=40.107.237.44; envelope-from=feliu@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bodong@nvidia.com, vlad@nvidia.com, dann.frazier@canonical.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Eric Dumazet BugLink: https://bugs.launchpad.net/bugs/2080318 Blamed commit increased lookup key size from 2 bytes to 16 bytes, because zones_ht_key got a struct net pointer. Make sure rhashtable_lookup() is not using the padding bytes which are not initialized. BUG: KMSAN: uninit-value in rht_ptr_rcu include/linux/rhashtable.h:376 [inline] BUG: KMSAN: uninit-value in __rhashtable_lookup include/linux/rhashtable.h:607 [inline] BUG: KMSAN: uninit-value in rhashtable_lookup include/linux/rhashtable.h:646 [inline] BUG: KMSAN: uninit-value in rhashtable_lookup_fast include/linux/rhashtable.h:672 [inline] BUG: KMSAN: uninit-value in tcf_ct_flow_table_get+0x611/0x2260 net/sched/act_ct.c:329 rht_ptr_rcu include/linux/rhashtable.h:376 [inline] __rhashtable_lookup include/linux/rhashtable.h:607 [inline] rhashtable_lookup include/linux/rhashtable.h:646 [inline] rhashtable_lookup_fast include/linux/rhashtable.h:672 [inline] tcf_ct_flow_table_get+0x611/0x2260 net/sched/act_ct.c:329 tcf_ct_init+0xa67/0x2890 net/sched/act_ct.c:1408 tcf_action_init_1+0x6cc/0xb30 net/sched/act_api.c:1425 tcf_action_init+0x458/0xf00 net/sched/act_api.c:1488 tcf_action_add net/sched/act_api.c:2061 [inline] tc_ctl_action+0x4be/0x19d0 net/sched/act_api.c:2118 rtnetlink_rcv_msg+0x12fc/0x1410 net/core/rtnetlink.c:6647 netlink_rcv_skb+0x375/0x650 net/netlink/af_netlink.c:2550 rtnetlink_rcv+0x34/0x40 net/core/rtnetlink.c:6665 netlink_unicast_kernel net/netlink/af_netlink.c:1331 [inline] netlink_unicast+0xf52/0x1260 net/netlink/af_netlink.c:1357 netlink_sendmsg+0x10da/0x11e0 net/netlink/af_netlink.c:1901 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x30f/0x380 net/socket.c:745 ____sys_sendmsg+0x877/0xb60 net/socket.c:2597 ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2651 __sys_sendmsg net/socket.c:2680 [inline] __do_sys_sendmsg net/socket.c:2689 [inline] __se_sys_sendmsg net/socket.c:2687 [inline] __x64_sys_sendmsg+0x307/0x4a0 net/socket.c:2687 x64_sys_call+0x2dd6/0x3c10 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Local variable key created at: tcf_ct_flow_table_get+0x4a/0x2260 net/sched/act_ct.c:324 tcf_ct_init+0xa67/0x2890 net/sched/act_ct.c:1408 Fixes: 88c67aeb1407 ("sched: act_ct: add netns into the key of tcf_ct_flow_table") Reported-by: syzbot+1b5e4e187cc586d05ea0@syzkaller.appspotmail.com Signed-off-by: Eric Dumazet Cc: Xin Long Reviewed-by: Simon Horman Reviewed-by: Xin Long Signed-off-by: David S. Miller (cherry picked from commit 2191a54f63225b548fd8346be3611c3219a24738) Signed-off-by: Feng Liu --- net/sched/act_ct.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index d94d412f05bf..5b7507245c7e 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -42,6 +42,8 @@ static DEFINE_MUTEX(zones_mutex); struct zones_ht_key { struct net *net; u16 zone; + /* Note : pad[] must be the last field. */ + u8 pad[]; }; struct tcf_ct_flow_table { @@ -58,7 +60,7 @@ struct tcf_ct_flow_table { static const struct rhashtable_params zones_params = { .head_offset = offsetof(struct tcf_ct_flow_table, node), .key_offset = offsetof(struct tcf_ct_flow_table, key), - .key_len = sizeof_field(struct tcf_ct_flow_table, key), + .key_len = offsetof(struct zones_ht_key, pad), .automatic_shrinking = true, };