Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp177144rdb; Thu, 21 Dec 2023 06:17:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkVaSW4hJVJ7ONa/1RfV1x2eDzsozid6UK1eUU/WBzzbkNtsu4GQxdreJYPjPyrqdIyxR4 X-Received: by 2002:a05:6358:419f:b0:173:260:4775 with SMTP id w31-20020a056358419f00b0017302604775mr1680930rwc.40.1703168243249; Thu, 21 Dec 2023 06:17:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703168243; cv=none; d=google.com; s=arc-20160816; b=oAaNa/Dj99zWg0U+gGrxNg8ClbjSvcmkPfMj9Zi62peHaQRaEfwThjXiorYQyRWoWn /LPjs2YIeNmPwFC6dcUPHoVLGyAAJeNbA/g/PQjfClEIkrSHDOUkzBAwPNqTt3dj2iyl 4lHGXyDTJI7xJbXmmcypcxKwd5u4t7CI00qTRqaO6kFqnjrrYbvDJ3GBNKCfU2RHkeIF fZTwRS7IYTbVmFovasXBpu3wDZ306bonqpw9lxdwlKg5uqxUYbRTWCEGxKrofytlfY88 TRfap/szC1FV9zhU+tweBFvv3MT3GMZScdUgPgzUr0oDMLdq55ciGyQ9Z7ckdYqAR0Lm PrAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:cc:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=51o+bxBLUFgiPfp10W8p0LE+IV2TSglp3G9csNZd3C0=; fh=VPDggvB+eP8/S/Uj31BaGSnXgS6qQyACBgywZPMVBzI=; b=UGNe72UQnJOM6oleszKXphQ/QGB4TuHEsekXouP5W9s1t3hP2XFM+gasf9PB1S1728 EI0Bc77vAznkEp5DYcPAs2nGe3msoqcQSty5T51WvzN0eLW0L0RBeY8ruAuqtjlaW2d5 MIUPInh8+kcxAiNDVM+hEUN7qcvaSkERnW4FZsYhOX6hyPOIkqiPnpTBVWLq3DKMo2JU rCDqTZbYVdqV69xf+ZVdm2jh7u9wCfzVGeH/IgSXF21VLlLS0zeHHtRfu0tVVHXZG8LF a9pJ0rUvubQGJrOJvKNOt19JSOdwOtfCdtCCnvhhoiWtnpXN0W6oYO0bDnUygaFMN72r 7FdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8537-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8537-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bz3-20020a056a02060300b005c215b317e9si1698314pgb.478.2023.12.21.06.17.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 06:17:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8537-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8537-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8537-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 39CDAB25571 for ; Thu, 21 Dec 2023 14:02:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C9DA78E65; Thu, 21 Dec 2023 13:53:22 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (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 671FA7765B; Thu, 21 Dec 2023 13:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=I-love.SAKURA.ne.jp Received: from fsav414.sakura.ne.jp (fsav414.sakura.ne.jp [133.242.250.113]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 3BLDqPBm014091; Thu, 21 Dec 2023 22:52:25 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav414.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav414.sakura.ne.jp); Thu, 21 Dec 2023 22:52:25 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav414.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 3BLDqONe014083 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Thu, 21 Dec 2023 22:52:25 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Thu, 21 Dec 2023 22:52:20 +0900 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: [syzbot] [fs?] INFO: trying to register non-static key in debugfs_file_get Content-Language: en-US To: syzbot , Greg Kroah-Hartman , Johannes Berg , syzkaller-bugs@googlegroups.com References: <000000000000fc306f060d052b5f@google.com> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, rafael@kernel.org From: Tetsuo Handa In-Reply-To: <000000000000fc306f060d052b5f@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit #syz fix: Revert "debugfs: annotate debugfs handlers vs. removal with lockdep" By the way, use of cmpxchg() implies that this path might run in parallel? If yes, I think you need to finish lockdep_init_map() before cmpxchg(), or concurrently running threads might reach lock_map_acquire_read() before lockdep_init_map() completes... d_fsd = READ_ONCE(dentry->d_fsdata); if (!((unsigned long)d_fsd & DEBUGFS_FSDATA_IS_REAL_FOPS_BIT)) { fsd = d_fsd; } else { fsd = kmalloc(sizeof(*fsd), GFP_KERNEL); if (!fsd) return -ENOMEM; fsd->real_fops = (void *)((unsigned long)d_fsd & ~DEBUGFS_FSDATA_IS_REAL_FOPS_BIT); refcount_set(&fsd->active_users, 1); init_completion(&fsd->active_users_drained); if (cmpxchg(&dentry->d_fsdata, d_fsd, fsd) != d_fsd) { kfree(fsd); fsd = READ_ONCE(dentry->d_fsdata); } +#ifdef CONFIG_LOCKDEP + fsd->lock_name = kasprintf(GFP_KERNEL, "debugfs:%pd", dentry); + lockdep_register_key(&fsd->key); + lockdep_init_map(&fsd->lockdep_map, fsd->lock_name ?: "debugfs", + &fsd->key, 0); +#endif } /* * In case of a successful cmpxchg() above, this check is * strictly necessary and must follow it, see the comment in * __debugfs_remove_file(). * OTOH, if the cmpxchg() hasn't been executed or wasn't * successful, this serves the purpose of not starving * removers. */ if (d_unlinked(dentry)) return -EIO; if (!refcount_inc_not_zero(&fsd->active_users)) return -EIO; + lock_map_acquire_read(&fsd->lockdep_map); On 2023/12/21 22:35, syzbot wrote: > HEAD commit: b10a3ccaf6e3 Merge tag 'loongarch-fixes-6.7-2' of git://gi.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=1278f06ce80000 > kernel config: https://syzkaller.appspot.com/x/.config?x=70dcde26e6b912e5 > dashboard link: https://syzkaller.appspot.com/bug?extid=fb20af23d0671a82c9a2 > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40