Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp541245pxb; Wed, 29 Sep 2021 04:48:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPnGfnhTN7VHcCILktUhDWsMMl0DF91KStpjcVyDvz1A3uJvgbHZslwurEdEt/JiB7EQ0q X-Received: by 2002:a17:906:b043:: with SMTP id bj3mr13353627ejb.572.1632916120750; Wed, 29 Sep 2021 04:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632916120; cv=none; d=google.com; s=arc-20160816; b=DaVwX4CQAuhyGrKY9zUzZzO4zMWhGoznoEcOCKsF2PNoFlpA/bGP7TboDu4RhohwwR PS+zxVJkWAgO7thNdPxZw9TXABaSnd2QpZ8D+aU9N/k4Cm+1EDvi/08RAId0b1W6M9s3 /TrYZzze3aMcbVEPVkkTjJqEPGPaMS/tXZkckc91oFG8UuxXFtZRhGFKSECC32Uk8HRe t8783LU0ert/1g18+X/7g5IhH5cIgMWw604mFNd6Hx5Fr1xV+wb4xTxNBNgt6a9dF+Ya ceNiF8QDktf+xsIvuxloc2iCRpdYPB9/w7fdpfF86E8K8uno+mQ64c03SEu9TTYV/doN 0cXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WhTjJ7wdzY1J8/wX9gZp6pKZ6vYnX8HdvzM7zzjnMts=; b=Zzg8hBqi7TKSsVp6K1DH7ISGwvG6bGTrTf1xv+2UHePOa2jnl+/ZrLpXV3oCfZExhm G1pc1oVuAN0pQMYElhz/d/SERAERvE/ys6yh6lPt4JvnEvKAT6L5vOS155d3FpWrKAzk X2LVZ32YjbmjDLujvztUhBrtx8FFxMDZ6E4xsqymz+1Z+I2FInp6BxtkJI62eNnZqGOA LAztMJh+e6BTMuMlUPz+0D9x3vMk5IKjzVOC2mQSp1T7bFRpZnI+fqsmRcqnWK7lWlh+ IXLFT3xJz0N7RTnIVVFN+VAP4TjG1/bpRj/o+1ugwfQjknN2oi8TwVXzZ0nVY6IwXN7L 1hIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V8VrcA5C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si2398896eje.331.2021.09.29.04.48.16; Wed, 29 Sep 2021 04:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V8VrcA5C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245415AbhI2KSl (ORCPT + 99 others); Wed, 29 Sep 2021 06:18:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:49430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245419AbhI2KSf (ORCPT ); Wed, 29 Sep 2021 06:18:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C38AA613D3; Wed, 29 Sep 2021 10:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632910614; bh=Y3WlE9/x8kkM4OdWBGlw4lrvVpqya0gDTOnqHUTWG08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8VrcA5CUPkhOqftCql97IxkAsMr9Plp6k2Lm4+WSfiAG2t+R1+bMnZUBr9my09eK uzItATWebU5qGqd91zwMLFjNnwiUTHhCsGE0AVGIct0+wao1FsyianKY4Oy19nXCbH iAHyL1bQ2T44YOJjXHC95UsDyn1Ywca0eeUfhcWiTE7ME9UB+99nGjkn7KJNLpRH+a XUQrGzOktX9W1t5i9Kh6XPc9HANXBc5vuvhggc+ep0bbP/UZxRDqiZ/LlQYNIZ3dUI Lo2Zhpve5UxqFlVMDLg672QgvN181RmdgwwYjllA/kbQyt9cmqUEq4cZQXWpSVlm8c aWNspAxNuVO5g== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Alexandre Belloni , Andrew Lunn , Ariel Elior , Bin Luo , Claudiu Manoil , Coiby Xu , Derek Chickles , drivers@pensando.io, Eric Dumazet , Felix Manlunas , Florian Fainelli , Geetha sowjanya , Greg Kroah-Hartman , GR-everest-linux-l2@marvell.com, GR-Linux-NIC-Dev@marvell.com, hariprasad , Ido Schimmel , intel-wired-lan@lists.osuosl.org, Ioana Ciornei , Jerin Jacob , Jesse Brandeburg , Jiri Pirko , Jonathan Lemon , Linu Cherian , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-rdma@vger.kernel.org, linux-staging@lists.linux.dev, Manish Chopra , Michael Chan , Moshe Shemesh , netdev@vger.kernel.org, oss-drivers@corigine.com, Richard Cochran , Saeed Mahameed , Salil Mehta , Satanand Burla , Shannon Nelson , Shay Drory , Simon Horman , Subbaraya Sundeep , Sunil Goutham , Taras Chornyi , Tariq Toukan , Tony Nguyen , UNGLinuxDriver@microchip.com, Vadym Kochan , Vivien Didelot , Vladimir Oltean , Yisen Zhuang Subject: [PATCH net-next 1/5] devlink: Add missed notifications iterators Date: Wed, 29 Sep 2021 13:16:35 +0300 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky The commit mentioned in Fixes line missed a couple of notifications that were registered before devlink_register() and should be delayed too. As such, the too early placed WARN_ON() check spotted it. WARNING: CPU: 1 PID: 6540 at net/core/devlink.c:5158 devlink_nl_region_notify+0x184/0x1e0 net/core/devlink.c:5158 Modules linked in: CPU: 1 PID: 6540 Comm: syz-executor.0 Not tainted 5.15.0-rc2-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:devlink_nl_region_notify+0x184/0x1e0 net/core/devlink.c:5158 Code: 38 41 b8 c0 0c 00 00 31 d2 48 89 ee 4c 89 e7 e8 72 1a 26 00 48 83 c4 08 5b 5d 41 5c 41 5d 41 5e e9 01 bd 41 fa e8 fc bc 41 fa <0f> 0b e9 f7 fe ff ff e8 f0 bc 41 fa 0f 0b eb da 4c 89 e7 e8 c4 18 RSP: 0018:ffffc90002d6f658 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff88801f08d580 RSI: ffffffff87344e94 RDI: 0000000000000003 RBP: ffff88801ee42100 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffff87344d8a R11: 0000000000000000 R12: ffff88801c1dc000 R13: 0000000000000000 R14: 000000000000002c R15: ffff88801c1dc070 FS: 0000555555e8e400(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055dd7c590310 CR3: 0000000069a09000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: devlink_region_create+0x39f/0x4c0 net/core/devlink.c:10327 nsim_dev_dummy_region_init drivers/net/netdevsim/dev.c:481 [inline] nsim_dev_probe+0x5f6/0x1150 drivers/net/netdevsim/dev.c:1479 call_driver_probe drivers/base/dd.c:517 [inline] really_probe+0x245/0xcc0 drivers/base/dd.c:596 __driver_probe_device+0x338/0x4d0 drivers/base/dd.c:751 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:781 __device_attach_driver+0x20b/0x2f0 drivers/base/dd.c:898 bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:427 __device_attach+0x228/0x4a0 drivers/base/dd.c:969 bus_probe_device+0x1e4/0x290 drivers/base/bus.c:487 device_add+0xc35/0x21b0 drivers/base/core.c:3359 nsim_bus_dev_new drivers/net/netdevsim/bus.c:435 [inline] new_device_store+0x48b/0x770 drivers/net/netdevsim/bus.c:302 bus_attr_store+0x72/0xa0 drivers/base/bus.c:122 sysfs_kf_write+0x110/0x160 fs/sysfs/file.c:139 kernfs_fop_write_iter+0x342/0x500 fs/kernfs/file.c:296 call_write_iter include/linux/fs.h:2163 [inline] new_sync_write+0x429/0x660 fs/read_write.c:507 vfs_write+0x7cf/0xae0 fs/read_write.c:594 ksys_write+0x12d/0x250 fs/read_write.c:647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f328409d3ef Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 99 fd ff ff 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 cc fd ff ff 48 RSP: 002b:00007ffdc6851140 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f328409d3ef RDX: 0000000000000003 RSI: 00007ffdc6851190 RDI: 0000000000000004 RBP: 0000000000000004 R08: 0000000000000000 R09: 00007ffdc68510e0 R10: 0000000000000000 R11: 0000000000000293 R12: 00007f3284144971 R13: 00007ffdc6851190 R14: 0000000000000000 R15: 00007ffdc6851860 Fixes: 474053c980a0 ("devlink: Notify users when objects are accessible") Reported-by: Eric Dumazet Signed-off-by: Leon Romanovsky --- net/core/devlink.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 06edb2f1d21e..35c74c8e5e2f 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -1074,6 +1074,9 @@ static void devlink_rate_notify(struct devlink_rate *devlink_rate, WARN_ON(cmd != DEVLINK_CMD_RATE_NEW && cmd != DEVLINK_CMD_RATE_DEL); WARN_ON(!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)); + if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)) + return; + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) return; @@ -5155,7 +5158,8 @@ static void devlink_nl_region_notify(struct devlink_region *region, struct sk_buff *msg; WARN_ON(cmd != DEVLINK_CMD_REGION_NEW && cmd != DEVLINK_CMD_REGION_DEL); - WARN_ON(!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)); + if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED)) + return; msg = devlink_nl_region_notify_build(region, snapshot, cmd, 0, 0); if (IS_ERR(msg)) @@ -8981,6 +8985,8 @@ static void devlink_notify_register(struct devlink *devlink) struct devlink_trap_group_item *group_item; struct devlink_trap_item *trap_item; struct devlink_port *devlink_port; + struct devlink_rate *rate_node; + struct devlink_region *region; devlink_notify(devlink, DEVLINK_CMD_NEW); list_for_each_entry(devlink_port, &devlink->port_list, list) @@ -8997,6 +9003,12 @@ static void devlink_notify_register(struct devlink *devlink) list_for_each_entry(trap_item, &devlink->trap_list, list) devlink_trap_notify(devlink, trap_item, DEVLINK_CMD_TRAP_NEW); + list_for_each_entry(rate_node, &devlink->rate_list, list) + devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW); + + list_for_each_entry(region, &devlink->region_list, list) + devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); + devlink_params_publish(devlink); } @@ -9006,9 +9018,17 @@ static void devlink_notify_unregister(struct devlink *devlink) struct devlink_trap_group_item *group_item; struct devlink_trap_item *trap_item; struct devlink_port *devlink_port; + struct devlink_rate *rate_node; + struct devlink_region *region; devlink_params_unpublish(devlink); + list_for_each_entry_reverse(region, &devlink->region_list, list) + devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_DEL); + + list_for_each_entry_reverse(rate_node, &devlink->rate_list, list) + devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL); + list_for_each_entry_reverse(trap_item, &devlink->trap_list, list) devlink_trap_notify(devlink, trap_item, DEVLINK_CMD_TRAP_DEL); -- 2.31.1