From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 9D9EB3F54CB for ; Tue, 4 Aug 2026 14:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785854032; cv=none; b=PYaNkGIXTR8GWjr6nwwR48+te0qqiAyNYHJr1t2YDKymV1EfJ6JO0nP4nC5r5LxCZcPkA+TQcz0Y8tSvorfcv0ukLG0CT8w1Pyc8+UFjYMEOFXv7gBvrG5GHM7+s99aurK08Lca0H0pTmNOEgId0qwpnNiEQChU2dIsSXYJC69g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785854032; c=relaxed/simple; bh=q6nFZ1R6gzXut+K/+tnOlHI88I/nj/Df9nXi6+JJ8e4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tS3YFfYy53ZNHLkUtWE2C/y2DQHBJi2AWtdgVgxl81uRPJFmfhH7jBaHv1tpI2stLKW6t0aeBweXwOjfXodSvnp4wPtir5XillcqT01rypaSY/nwFQuIqksH2xOWD4YyuwiUV2Q8GI2l7Paj5y8Pms8qnsOlL8t+zCfcUOEIdm0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EwBcZbFY; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=qiNhL1md; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EwBcZbFY"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="qiNhL1md" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785854019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sMR8kYlXa1CTxfv23QQO2kULReZbJe35SSbkC/BppCQ=; b=EwBcZbFYgasCAGTHT/cc9l4bWy5p3iU8fM8GH73UOwcpgJU+90e4t4leMCTLhaICoUoCkY /MMy5NNQiJqFYce39Q1zD3aHvvSlQ9VU++ulcSY3xpM1Vj5q86ccxnOlJgA1bHYEI6bWWl OhqWHPTiVFU/BRIoQj0YBg6JRfegpmI= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-M5F5kM55MrijnFYrVb8mpw-1; Tue, 04 Aug 2026 10:33:38 -0400 X-MC-Unique: M5F5kM55MrijnFYrVb8mpw-1 X-Mimecast-MFC-AGG-ID: M5F5kM55MrijnFYrVb8mpw_1785854017 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-493bfc3b84aso18114435e9.0 for ; Tue, 04 Aug 2026 07:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1785854017; x=1786458817; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=sMR8kYlXa1CTxfv23QQO2kULReZbJe35SSbkC/BppCQ=; b=qiNhL1mdYWBpSxiSJo2PiVO2pjTqdQhqUZalBMspe76dltCOwROb6m7b4bUJwBogL5 7aNKrCbVolqtvBEsZ2Ei5eSQufZdNar3cJgO86B60+FJMp4B9UpfIGenrnI/oGD7fJ4z DPULb7WQlspQa6MSBxrDAHx5Iq8aCsoO0NoL+snyawI177uEDAwmMrFW3CmdomT3lxHv Jkjbwy4f3KnK7zBGj2pWwkQRzIIV8UPiT5e9GPtwrjKGFOm3MLkZS4C502Y2AgGvI8Dz 1gNLWYr5pONySRcXqRmDYSEG+gXRwm1yFYDzNdEvI82o/qMgBqh2u312fnUnO8lDJhkF j70w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785854017; x=1786458817; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sMR8kYlXa1CTxfv23QQO2kULReZbJe35SSbkC/BppCQ=; b=l+cJFNfvGcOTRRcu3iO5zm/UGbwGr0kZrHPpNvePcJgXmvh1qHy0KXUxTTjDuryTtT Vfoe9HyjWgvPKjdgdJZmmAkyyzUC3pgweOYP7GaUnfymPgOJ45isFoTxkHt9YPC8GoYW 7icSny9xHmRqa+k7Hipx0OmbXV1+Yoi5rdolONDe5hZ9xlQXncpjPxgFMBTJ1R1P2hQQ TmLjVMK8lLZYN5t2jZUf5Iadt6X1jhoFwk2i5KyyjIJeBEKGKG4BfNzhhQ2mh2kpW3ou A9xVYUWGh4hO6xYu0LYEdSjix+0x4qN3RTzInqJNr/Yk+p+qnAGl+rCIvhOiyGWIumat 84Mw== X-Gm-Message-State: AOJu0Yy5sxWPwpKFS61cusCYaTJqkc9LWbZqrKdaOmOuwzDF/Fk4XDg+ KK00VwdwWw6WToQvoAYBER9xy0bHwb6dca8BYPwZTUwNmWcTlCMSWdCIM3/++q2vtjbpkuiV4zL U4eB8rospKjcUlFEUcXJoy33XYIjeVoN5mLvGeLPzyUol2gQtBdVFhobQ4OcTS+TfaA== X-Gm-Gg: AR+sD13c8h/RmvhTPkIugkvNPq4Hh9gZ8/Slds+sRnthzRu1w7PODSRYHR3YAfmXaTo 1GZkBPMwpRRoCTKbgSt0GWhpjLQItCKMQy1dbbZ3OieBv5Y45Od/ebYYQjAtXMSFqzQcUyQNEj9 NV9m/nJTRYvWSDxX7ecySzMUZtqpr7sf0wHdlBi9oDonoWqycqG1Y4G8NtEI9YE4tpszmjpNEK7 YMp1vtwJAMY4H2fmsgBTbKCCor6LeOZArgjpVZAln55l0YSVWjAm4OnsccvgWwRKZZzzMsBFUOw a2dwjv53zcP/ecKqPUvWt2ql4UKMdPgYi0TIS00TD+L+D4r9sJmqJTyDQ0EhOZLxSeoOZB9h1ok BSKe0Ufz3OxdAEQKL99tV7nqK6zaJPWXUY2bSBIPAl7tOEZJwGKRjwHxHyh8MksvZTPCLgB3nRc 4= X-Received: by 2002:a05:600c:5395:b0:493:faf3:3ea5 with SMTP id 5b1f17b1804b1-4980c66c751mr434202945e9.4.1785854016759; Tue, 04 Aug 2026 07:33:36 -0700 (PDT) X-Received: by 2002:a05:600c:5395:b0:493:faf3:3ea5 with SMTP id 5b1f17b1804b1-4980c66c751mr434201535e9.4.1785854016281; Tue, 04 Aug 2026 07:33:36 -0700 (PDT) Received: from [192.168.188.103] (ip239-44-231-195.pool-bba.aruba.it. [195.231.44.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4994a100e14sm91151965e9.14.2026.08.04.07.33.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Aug 2026 07:33:35 -0700 (PDT) Message-ID: Date: Tue, 4 Aug 2026 16:33:34 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] netdevsim: fix deadlock in nsim_bus_dev_max_vfs_write() To: syzbot , syzkaller-bugs@googlegroups.com, Slawomir Stepien , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, syzbot@lists.linux.dev References: From: Paolo Abeni Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/31/26 11:55 AM, syzbot wrote: > From: Slawomir Stepien > > There is an ABBA deadlock between the devlink instance lock and the debugfs > active file reference mechanism. > > When a device is being removed (e.g., via nsim_drv_remove()), the driver > acquires the devlink instance lock and then calls > debugfs_remove_recursive(). This function blocks waiting for all active > file operations on the debugfs files to complete. > > Concurrently, if a user writes to the "max_vfs" debugfs file, the VFS layer > acquires an active reference to the file. The write handler, > nsim_bus_dev_max_vfs_write(), then attempts to acquire the devlink instance > lock, which is already held by the removal task. > > This creates a circular dependency resulting in a deadlock: > > INFO: task blocked for more than 143 seconds. > Call Trace: > wait_for_completion+0x2ca/0x5e0 kernel/sched/completion.c:153 > __debugfs_file_removed fs/debugfs/inode.c:751 [inline] > remove_one+0x2df/0x3b0 fs/debugfs/inode.c:758 > __simple_recursive_removal+0x215/0x520 fs/libfs.c:623 > debugfs_remove+0x5b/0x70 fs/debugfs/inode.c:781 > nsim_dev_debugfs_exit drivers/net/netdevsim/dev.c:372 [inline] > nsim_drv_remove+0xc0/0x170 drivers/net/netdevsim/dev.c:1803 > > INFO: task blocked for more than 143 seconds. > Call Trace: > __mutex_lock+0x7bf/0x1550 kernel/locking/mutex.c:821 > nsim_bus_dev_max_vfs_write+0x229/0x3d0 drivers/net/netdevsim/dev.c:276 > full_proxy_write+0x127/0x1f0 fs/debugfs/file.c:388 > vfs_write+0x296/0xba0 fs/read_write.c:685 > > To fix this, use devl_trylock() in nsim_bus_dev_max_vfs_write() instead of > devl_lock(). If the lock cannot be acquired, return -EBUSY. This aborts the > write operation, releases the debugfs active file reference, and allows the > pending debugfs_remove_recursive() to proceed. > > Assisted-by: Gemini:gemini-3.5-flash Gemini:gemini-3.1-pro-preview syzbot > Reported-by: syzbot+3147c5de186107ffc7a1@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3147c5de186107ffc7a1 > Link: https://syzkaller.appspot.com/ai_job?id=fcdda182-bebf-49ab-ada0-d4d2e814ebf7 > Signed-off-by: Slawomir Stepien > > --- > diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c > index aed9ad5f1..421cd7327 100644 > --- a/drivers/net/netdevsim/dev.c > +++ b/drivers/net/netdevsim/dev.c > @@ -273,7 +273,11 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file, > return -ENOMEM; > > nsim_dev = file->private_data; > - devl_lock(priv_to_devlink(nsim_dev)); > + if (!devl_trylock(priv_to_devlink(nsim_dev))) { > + ret = -EBUSY; I think this should return restart_syscall(). This kind of schema is calling for trouble, but for netdevsim should be okish. /P