From nobody Thu Apr 9 17:07:57 2026 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C34142C375A for ; Fri, 6 Mar 2026 13:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772802787; cv=none; b=n/CMj3bWDnwgyxrFF8pznqXfejxZ33jN9+UKFRUCEEPOJDBrDrx9UQlGxNRSRPe+HYz3Z9rHxG0FKzckK4X+QYNuT9oqofkrTQpzxgISgkaTfGujTJXqq48WFgfL9kYa5Vaw7ystRsq6lfMfnZhrnX0BzLr7db63nLKH69UlGsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772802787; c=relaxed/simple; bh=Ma22cwDy8BoDOacrcbvHxGFFJ7WiKc5bQcn74c8ViU0=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=DCWo1UjNtGTWFCgojUKxluI+qm9rB+n/fnlQ5keyDvxZ1wDp7h7XOtzuiXO4BnEYZkgX1dnc4/KCpA2CSJmM2LfZR/wIx9VPZj9L5d6j4D0Ws4YxfpetwEsLRPYecjJeSzl6iytFvVkImN5yDGD7HDk/p+5WDDN9AddAEc9MHpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-67a1e063795so33695239eaf.1 for ; Fri, 06 Mar 2026 05:13:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772802779; x=1773407579; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FE0z9+v2j/HhzGXJuORX2Al6STAMgEg9P4Mr4+IWpXM=; b=lYFoOgjqra02N8QcttcSKyqVKG3SeRc106R6LFrYW7cn4uVOPekbdiTshMqNeSTibc guB1T5YK9LxN8baaKCQ3Vb+HD0HJx1fYDJnSpRQXg/LJSi864UNWEJ41fUUqhWDTL+Zd DLI9uUeNye3B8Lyrhsi+gps4bXLjjgC6dbNqjJwVBBlOQaSm6QBCJ3cRSIEcJyxjcuGn vB0VII1sA/gpoN1MAJ/5+IwjD3NQ1wp9Pi5VtVAXXqmoXP0GU1lajVbfyV1NzvvK8tWl yG+X0O0aOI4aTjTPKL9gae9kps+tfTvUe1kPfn4s1N0EW+CICaMgRijXnvCxUa/6N4rg 7XlQ== X-Gm-Message-State: AOJu0Yyq1N2TZdsIW/HbIznKjTlVW3aNSeS1xEs4z5w2w2J2Cfy9jvAR hvzVKm9V9UTPIq1SSJJIXHIWIEW4gHdCvnLyyt68ChdrHyBpYkJjLAQ9WCtvRxjoSMQlJZETmIb OREUNb8Pkamds3xfA0arUWQl3I8mHIS7zwogQSwNgDCF68oM8bqVVR+FH/u4= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:448e:b0:67a:9918:5646 with SMTP id 006d021491bc7-67b944c28a5mr3300952eaf.2.1772802779576; Fri, 06 Mar 2026 05:12:59 -0800 (PST) Date: Fri, 06 Mar 2026 05:12:59 -0800 In-Reply-To: <69a9251d.a70a0220.2f119.0003.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69aad2db.050a0220.13f275.0020.GAE@google.com> Subject: Forwarded: [PATCH] gfs2: add debug printk to trace existing entry in gfs2_create_inode From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] gfs2: add debug printk to trace existing entry in gfs2_cre= ate_inode Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master Add a debug printk when gfs2_dir_search finds an existing entry in gfs2_create_inode. This helps confirm whether the rwsem unlock WARNING in filename_symlinkat is caused by gfs2_create_inode returning false success (0) when file is NULL and an existing entry is found on a corrupted GFS2 image. The printk logs the directory inode, creation mode, file pointer, found inode, and rwsem owner at the point where the existing entry is detected. This is a temporary diagnostic patch and should be reverted once the root cause is confirmed. Reported-by: syzbot+2ed46b6b748df855347f@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D2ed46b6b748df855347f Signed-off-by: Deepanshu Kartikey --- fs/gfs2/inode.c | 30 +++++++++++++++++++++++++++++- fs/namei.c | 30 ++++++++++++++++++++++++++++-- kernel/locking/rwsem.c | 20 ++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 8344040ecaf7..2be4a899c665 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -36,6 +36,9 @@ #include "super.h" #include "glops.h" =20 +void *gfs2_debug_watched_rwsem; +EXPORT_SYMBOL(gfs2_debug_watched_rwsem); + static const struct inode_operations gfs2_file_iops; static const struct inode_operations gfs2_dir_iops; static const struct inode_operations gfs2_symlink_iops; @@ -725,19 +728,26 @@ static int gfs2_create_inode(struct inode *dir, struc= t dentry *dentry, error =3D gfs2_rindex_update(sdp); if (error) goto fail; + pr_warn("DEBUG GFS2: after glock_nq dir=3D%px rwsem owner=3D%px current= =3D%px\n", + dir, READ_ONCE(dir->i_rwsem.owner), current); =20 error =3D gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, &d_gh); + pr_warn("DEBUG GFS2 A: dir=3D%px rwsem owner=3D%px\n", dir, READ_ONCE(dir= ->i_rwsem.owner)); if (error) goto fail; gfs2_holder_mark_uninitialized(&gh); =20 error =3D create_ok(dip, name, mode); + pr_warn("DEBUG GFS2 B: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, RE= AD_ONCE(dir->i_rwsem.owner), error); if (error) goto fail_gunlock; =20 inode =3D gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl); error =3D PTR_ERR(inode); if (!IS_ERR(inode)) { + pr_warn("DEBUG GFS2: gfs2_create_inode found existing entry! dir=3D%px m= ode=3D%o file=3D%px inode=3D%px S_ISDIR=3D%d rwsem owner=3D%px current=3D%p= x\n", + dir, mode, file, inode, S_ISDIR(inode->i_mode), + READ_ONCE(dir->i_rwsem.owner), current); if (S_ISDIR(inode->i_mode)) { iput(inode); inode =3D NULL; @@ -759,6 +769,7 @@ static int gfs2_create_inode(struct inode *dir, struct = dentry *dentry, } =20 error =3D gfs2_diradd_alloc_required(dir, name, &da); + pr_warn("DEBUG GFS2 C: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, RE= AD_ONCE(dir->i_rwsem.owner), error); if (error < 0) goto fail_gunlock; =20 @@ -820,16 +831,19 @@ static int gfs2_create_inode(struct inode *dir, struc= t dentry *dentry, blocks++; =20 error =3D alloc_dinode(ip, aflags, &blocks); + pr_warn("DEBUG GFS2 D: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, RE= AD_ONCE(dir->i_rwsem.owner), error); if (error) goto fail_free_inode; =20 gfs2_set_inode_blocks(inode, blocks); =20 error =3D gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &= ip->i_gl); + pr_warn("DEBUG GFS2 D1: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, R= EAD_ONCE(dir->i_rwsem.owner), error); if (error) goto fail_dealloc_inode; =20 error =3D gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_iopen_glops, CREATE, &= io_gl); + pr_warn("DEBUG GFS2 D2: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, R= EAD_ONCE(dir->i_rwsem.owner), error); if (error) goto fail_dealloc_inode; gfs2_cancel_delete_work(io_gl); @@ -837,13 +851,17 @@ static int gfs2_create_inode(struct inode *dir, struc= t dentry *dentry, =20 retry: error =3D insert_inode_locked4(inode, ip->i_no_addr, iget_test, &ip->i_no= _addr); + pr_warn("DEBUG GFS2 D3: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, R= EAD_ONCE(dir->i_rwsem.owner), error); if (error =3D=3D -EBUSY) goto retry; if (error) goto fail_gunlock2; =20 + gfs2_debug_watched_rwsem =3D &dir->i_rwsem; error =3D gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT | GL_NOPID, &ip->i_iopen_gh); + gfs2_debug_watched_rwsem =3D NULL; + pr_warn("DEBUG GFS2 E: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, RE= AD_ONCE(dir->i_rwsem.owner), error); if (error) goto fail_gunlock2; =20 @@ -862,7 +880,7 @@ static int gfs2_create_inode(struct inode *dir, struct = dentry *dentry, } init_dinode(dip, ip, symname); gfs2_trans_end(sdp); - + pr_warn("DEBUG GFS2 F: dir=3D%px rwsem owner=3D%px\n", dir, READ_ONCE(dir= ->i_rwsem.owner)); glock_set_object(ip->i_gl, ip); glock_set_object(io_gl, ip); gfs2_set_iop(inode); @@ -888,11 +906,15 @@ static int gfs2_create_inode(struct inode *dir, struc= t dentry *dentry, goto fail_gunlock4; =20 error =3D link_dinode(dip, name, ip, &da); + pr_warn("DEBUG GFS2 G: dir=3D%px rwsem owner=3D%px error=3D%d\n", dir, RE= AD_ONCE(dir->i_rwsem.owner), error); if (error) goto fail_gunlock4; =20 mark_inode_dirty(inode); d_instantiate(dentry, inode); + pr_warn("DEBUG GFS2 H: dir=3D%px rwsem owner=3D%px\n", dir, READ_ONCE(dir= ->i_rwsem.owner)); + pr_warn("DEBUG GFS2: before glock_dq dir=3D%px rwsem owner=3D%px current= =3D%px\n", + dir, READ_ONCE(dir->i_rwsem.owner), current); /* After instantiate, errors should result in evict which will destroy * both inode and iopen glocks properly. */ if (file) { @@ -900,6 +922,8 @@ static int gfs2_create_inode(struct inode *dir, struct = dentry *dentry, error =3D finish_open(file, dentry, gfs2_open_common); } gfs2_glock_dq_uninit(&d_gh); + pr_warn("DEBUG GFS2: after glock_dq dir=3D%px rwsem owner=3D%px current= =3D%px\n", + dir, READ_ONCE(dir->i_rwsem.owner), current); gfs2_qa_put(ip); gfs2_glock_dq_uninit(&gh); gfs2_glock_put(io_gl); @@ -937,7 +961,11 @@ static int gfs2_create_inode(struct inode *dir, struct= dentry *dentry, posix_acl_release(acl); fail_gunlock: gfs2_dir_no_add(&da); + pr_warn("DEBUG GFS2: fail_gunlock before glock_dq dir=3D%px rwsem owner= =3D%px current=3D%px error=3D%d\n", + dir, READ_ONCE(dir->i_rwsem.owner), current, error); gfs2_glock_dq_uninit(&d_gh); + pr_warn("DEBUG GFS2: fail_gunlock after glock_dq dir=3D%px rwsem owner=3D= %px current=3D%px\n", + dir, READ_ONCE(dir->i_rwsem.owner), current); if (!IS_ERR_OR_NULL(inode)) { if (inode_state_read_once(inode) & I_NEW) iget_failed(inode); diff --git a/fs/namei.c b/fs/namei.c index 58f715f7657e..768944691e24 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2922,7 +2922,13 @@ static struct dentry *__start_dirop(struct dentry *p= arent, struct qstr *name, } else { inode_lock_nested(dir, I_MUTEX_PARENT); } + pr_warn("DEBUG LOCK: __start_dirop locked dir=3D%px count=3D%ld owner=3D%= px current=3D%px\n", + dir, atomic_long_read(&dir->i_rwsem.count), + READ_ONCE(dir->i_rwsem.owner), current); dentry =3D lookup_one_qstr_excl(name, parent, lookup_flags); + pr_warn("DEBUG LOCK: __start_dirop after lookup dir=3D%px count=3D%ld own= er=3D%px current=3D%px dentry_err=3D%d\n", + dir, atomic_long_read(&dir->i_rwsem.count), + READ_ONCE(dir->i_rwsem.owner), current, IS_ERR(dentry)); if (IS_ERR(dentry)) inode_unlock(dir); return dentry; @@ -2944,6 +2950,11 @@ struct dentry *start_dirop(struct dentry *parent, st= ruct qstr *name, void end_dirop(struct dentry *de) { if (!IS_ERR(de)) { + struct inode *dir =3D d_inode(de->d_parent); + pr_warn("DEBUG: end_dirop: de=3D%px parent=3D%px inode=3D%px rwsem count= =3D%ld owner=3D%px current=3D%px\n", + de, de->d_parent, dir, + atomic_long_read(&dir->i_rwsem.count), + READ_ONCE(dir->i_rwsem.owner), current); inode_unlock(de->d_parent->d_inode); dput(de); } @@ -4922,7 +4933,9 @@ static struct dentry *filename_create(int dfd, struct= filename *name, dentry =3D start_dirop(path->dentry, &last, reval_flag | create_flags); if (IS_ERR(dentry)) goto out_drop_write; - + pr_warn("DEBUG: after start_dirop: dentry=3D%px parent=3D%px parent_inode= =3D%px rwsem owner=3D%px current=3D%px\n", + dentry, dentry->d_parent, d_inode(dentry->d_parent), + (void *)atomic_long_read(&d_inode(dentry->d_parent)->i_rwsem.count), cur= rent); if (unlikely(error)) goto fail; =20 @@ -4959,7 +4972,10 @@ EXPORT_SYMBOL(start_creating_path); */ void end_creating_path(const struct path *path, struct dentry *dentry) { - end_creating(dentry); + if (!IS_ERR(dentry)) { + inode_unlock(d_inode(path->dentry)); + dput(dentry); + } mnt_drop_write(path->mnt); path_put(path); } @@ -5595,6 +5611,9 @@ int vfs_symlink(struct mnt_idmap *idmap, struct inode= *dir, struct dentry *dentry, const char *oldname, struct delegated_inode *delegated_inode) { + pr_warn("DEBUG VFS: before symlink: dir=3D%px sb_type=3D%s symlink_fn=3D%= ps rwsem owner=3D%px current=3D%px\n", + dir, dir->i_sb->s_type->name, dir->i_op->symlink, + READ_ONCE(dir->i_rwsem.owner), current); int error; =20 error =3D may_create_dentry(idmap, dir, dentry); @@ -5613,6 +5632,9 @@ int vfs_symlink(struct mnt_idmap *idmap, struct inode= *dir, return error; =20 error =3D dir->i_op->symlink(idmap, dir, dentry, oldname); + pr_warn("DEBUG VFS: after symlink: dir=3D%px sb_type=3D%s error=3D%d rwse= m owner=3D%px current=3D%px\n", + dir, dir->i_sb->s_type->name, error, + READ_ONCE(dir->i_rwsem.owner), current); if (!error) fsnotify_create(dir, dentry); return error; @@ -5639,6 +5661,10 @@ int filename_symlinkat(struct filename *from, int ne= wdfd, struct filename *to) if (!error) error =3D vfs_symlink(mnt_idmap(path.mnt), path.dentry->d_inode, dentry, from->name, &delegated_inode); + pr_warn("DEBUG: after vfs_symlink: error=3D%d dentry=3D%px parent=3D%px p= arent_inode=3D%px rwsem owner=3D%px path_dentry=3D%px path_inode=3D%px\n", + error, dentry, dentry->d_parent, d_inode(dentry->d_parent), + (void *)atomic_long_read(&d_inode(path.dentry)->i_rwsem.count), + path.dentry, d_inode(path.dentry)); end_creating_path(&path, dentry); if (is_delegated(&delegated_inode)) { error =3D break_deleg_wait(&delegated_inode); diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index 24df4d98f7d2..9c5969a585c6 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -146,6 +146,11 @@ static inline void rwsem_set_owner(struct rw_semaphore= *sem) =20 static inline void rwsem_clear_owner(struct rw_semaphore *sem) { + extern void *gfs2_debug_watched_rwsem; + if (sem =3D=3D gfs2_debug_watched_rwsem) { + pr_warn("DEBUG WATCHPOINT: rwsem_clear_owner on watched rwsem=3D%px!\n",= sem); + dump_stack(); + } lockdep_assert_preemption_disabled(); atomic_long_set(&sem->owner, 0); } @@ -1452,6 +1457,11 @@ static inline void __downgrade_write(struct rw_semap= hore *sem) void __init_rwsem(struct rw_semaphore *sem, const char *name, struct lock_class_key *key) { + extern void *gfs2_debug_watched_rwsem; + if (sem =3D=3D gfs2_debug_watched_rwsem) { + pr_warn("DEBUG WATCHPOINT: init_rwsem on watched rwsem=3D%px!\n", sem); + dump_stack(); + } init_rwbase_rt(&(sem)->rwbase); =20 #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -1629,6 +1639,11 @@ EXPORT_SYMBOL(down_write_trylock); */ void up_read(struct rw_semaphore *sem) { + extern void *gfs2_debug_watched_rwsem; + if (sem =3D=3D gfs2_debug_watched_rwsem) { + pr_warn("DEBUG WATCHPOINT: up_read on watched rwsem=3D%px!\n", sem); + dump_stack(); + } rwsem_release(&sem->dep_map, _RET_IP_); __up_read(sem); } @@ -1639,6 +1654,11 @@ EXPORT_SYMBOL(up_read); */ void up_write(struct rw_semaphore *sem) { + extern void *gfs2_debug_watched_rwsem; + if (sem =3D=3D gfs2_debug_watched_rwsem) { + pr_warn("DEBUG WATCHPOINT: up_write on watched rwsem=3D%px!\n", sem); + dump_stack(); + } rwsem_release(&sem->dep_map, _RET_IP_); __up_write(sem); } --=20 2.43.0