From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 CFDEE30C624 for ; Thu, 22 Jan 2026 14:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769092185; cv=none; b=TXzcuHpLvrjvCgfFjVZv9AYufjgvPVZf3STek/+0EXQYxUbOlnGgq3njWgVLhVnJaRYdzap4PYTTHTgOnAmmT3ybZAA9MZyGChcj3PQ8lDzUtx9ND0Dpu8UXpnGMFJIdiWlvqfbfO1zvVehCe+WIsmSHHl4Ti38tUpA6eB9GzYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769092185; c=relaxed/simple; bh=cz+JlD34fRs/pROTZrvc12hKh4tyzrxS8BcTZwwO9EI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iWII02eT+fPrGOSk4qX+LBdh6DpwWOus6ExR2i2f9ZeCVvdtMHaXfuWZ9AhQsEksdlTa75KRN1B0TwGMQU47DY4kOIPtnaEDTCNEExyYwxw9pbHZUKvMczaQ4nkxTbwqsy4Mcqolf3ZzQtdL8xWMPdmtAkWjK5T8MIMC0DT/qh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cZ2GtT73; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cZ2GtT73" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-7b22ffa2a88so665193b3a.1 for ; Thu, 22 Jan 2026 06:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769092183; x=1769696983; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=k2bB6UcFN/QmZIeetEeQNfw5hOnI8IdcR9tXmdiu+0M=; b=cZ2GtT73IE/jaGvvMsPsZTLe50F1yM+v7+yIoUXsN499U0soDLin9rr9XOMv4QiU92 2nh0ypIcb4Q9s1k7+cod5dMj4VFVE6d0jhV7dgA9D0mE5mEaoLis9txYihldq2nqAv/s kHSjntWak2qaVQXMb4DsV8YTXR76oJs0pylzNKYrzAEDzAm+XfKu6G3uTLN7DO9nQMY0 zCpLqTRTKygMEOG1mZhEP2Xmd8jNNbWdh/JWtO2179mxnZ/KHcHaVhAUUBrNWGYIz/fQ oNylTf3b0pIGlPCUFK1OL+TBS4LLPenWFHwmf+oAdMCzNQhGa5FX86DM2eNq+bf9jXTO ooBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769092183; x=1769696983; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k2bB6UcFN/QmZIeetEeQNfw5hOnI8IdcR9tXmdiu+0M=; b=AhNNmWbQRt1hpb470KqIsNQbujpm5KlhAxwrpf/mb0F+8dsyJQrL7HUo4mDnDlFUlr UM0IS1yOG6qdXIuRnQ2uzobL/SeNdL7Vi2vkZRElYP3/CbW0iHZqtQOeXo2bMS6Hqgg7 +B/3HbfZ77HM7J6Udshs/m5YTWxW5ysFCZTYl/0vn9ieDHeza9gH925J87GWvrjBIpI4 V91wXHDkIeZ2V7tgo5VwaNQH2HBMc8tJ+8vUXD8uzpXW++AbvggNcR8Xy6iYDI9TOv9G 97slfwRNUWd7LLLjkDfdmXATxpqNbkGwNg9z6aS+Xvl+DRcoF9E5eVONXXGe2LLF4hGZ +f9w== X-Forwarded-Encrypted: i=1; AJvYcCWXWFBDXJLGxUWrlRG+6zQIkNlB/v5YY1ggSaq21AM3xU4/xjr4dVGtCsW4rNV45Da1JNg4PjrGhA5pbpM=@vger.kernel.org X-Gm-Message-State: AOJu0YywawcT2bkWtU088K5JYkDAEYO+SiDQXThPHNxvuD3Pj649Q5Yg LAFbX6f9kYeb9LJFYEU3+ZMFxSCCbWHKjHAIvILCu5wgkwowyL2Q+yDT X-Gm-Gg: AZuq6aK6F2gHMyesgiVxrzQnvfuDH/XsHnhtAmtU0y1ElMbe0wdmvV/rX/kJelKnC7s GGyG/JrUGJF6VckYRhZUV9LvasdOu6YUCQHV8preiyT4nmEYQYTIMGlNYwJY+dMN09267tOttDB 1qXJGt68MQuxlVGddpIDI74tqPAomfK0OK2688Ndx1KeXp9Gkb4PHvKdS8NB6SxQkjjg/Cmtphf CdcyR9Lm+5MZayWfQI88kxKS72QK/rU3eVYh1X1QIKTeuno0o5+iGzFoNt/Ab9juVcRSGaGni5p GX+Fq2K8Es6EnmbqmYDDMd5MPEGzVzT0M66ePrmLg8LSFbwcin2eQnH7ioQWZE3yXD9GRzi7UG6 0D3IdVVpNENtS0lRovYg4M6wDv1cQJqbmGsG6ivGRtdRtDbV424GRSPx2m7szhDukyKeKQ2b/XL y3wSdbWUZLXoM= X-Received: by 2002:a05:6a21:3984:b0:38d:eeca:b330 with SMTP id adf61e73a8af0-38e00d1557amr21189377637.40.1769092183005; Thu, 22 Jan 2026 06:29:43 -0800 (PST) Received: from inspiron ([111.125.231.221]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c5edf354b3bsm11023239a12.24.2026.01.22.06.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 06:29:42 -0800 (PST) Date: Thu, 22 Jan 2026 19:59:33 +0530 From: Prithvi To: Dmitry Bogdanov Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de, jlbec@evilplan.org, linux-fsdevel@vger.kernel.org, linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, khalid@kernel.org, syzbot+f6e8174215573a84b797@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: Re: [PATCH] scsi: target: Fix recursive locking in __configfs_open_file() Message-ID: <20260122142933.662srnqeqmx7eqk3@inspiron> References: <20260108191523.303114-1-activprithvi@gmail.com> <20260115032012.yb5ylmumcirrmsbr@inspiron> <20260122095634.GA15012@yadro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260122095634.GA15012@yadro.com> On Thu, Jan 22, 2026 at 12:56:34PM +0300, Dmitry Bogdanov wrote: > On Thu, Jan 15, 2026 at 08:50:12AM +0530, Prithvi wrote: > > > > On Fri, Jan 09, 2026 at 12:45:23AM +0530, Prithvi Tambewagh wrote: > > > In flush_write_buffer, &p->frag_sem is acquired and then the loaded store > > > function is called, which, here, is target_core_item_dbroot_store(). > > > This function called filp_open(), following which these functions were > > > called (in reverse order), according to the call trace: > > > > > > down_read > > > __configfs_open_file > > > do_dentry_open > > > vfs_open > > > do_open > > > path_openat > > > do_filp_open > > > file_open_name > > > filp_open > > > target_core_item_dbroot_store > > > flush_write_buffer > > > configfs_write_iter > > > > > > Hence ultimately, __configfs_open_file() was called, indirectly by > > > target_core_item_dbroot_store(), and it also attempted to acquire > > > &p->frag_sem, which was already held by the same thread, acquired earlier > > > in flush_write_buffer. This poses a possibility of recursive locking, > > > which triggers the lockdep warning. > > > > > > Fix this by modifying target_core_item_dbroot_store() to use kern_path() > > > instead of filp_open() to avoid opening the file using filesystem-specific > > > function __configfs_open_file(), and further modifying it to make this > > > fix compatible. > > > > > > Reported-by: syzbot+f6e8174215573a84b797@syzkaller.appspotmail.com > > > Closes: https://syzkaller.appspot.com/bug?extid=f6e8174215573a84b797 > > > Tested-by: syzbot+f6e8174215573a84b797@syzkaller.appspotmail.com > > > Cc: stable@vger.kernel.org > > > Signed-off-by: Prithvi Tambewagh > > > --- > > > drivers/target/target_core_configfs.c | 13 +++++++------ > > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c > > > index b19acd662726..f29052e6a87d 100644 > > > --- a/drivers/target/target_core_configfs.c > > > +++ b/drivers/target/target_core_configfs.c > > > @@ -108,8 +108,8 @@ static ssize_t target_core_item_dbroot_store(struct config_item *item, > > > const char *page, size_t count) > > > { > > > ssize_t read_bytes; > > > - struct file *fp; > > > ssize_t r = -EINVAL; > > > + struct path path = {}; > > > > > > mutex_lock(&target_devices_lock); > > > if (target_devices) { > > > @@ -131,17 +131,18 @@ static ssize_t target_core_item_dbroot_store(struct config_item *item, > > > db_root_stage[read_bytes - 1] = '\0'; > > > > > > /* validate new db root before accepting it */ > > > - fp = filp_open(db_root_stage, O_RDONLY, 0); > > > - if (IS_ERR(fp)) { > > > + r = kern_path(db_root_stage, LOOKUP_FOLLOW, &path); > > > + if (r) { > > > pr_err("db_root: cannot open: %s\n", db_root_stage); > > > goto unlock; > > > } > > > - if (!S_ISDIR(file_inode(fp)->i_mode)) { > > > - filp_close(fp, NULL); > > > + if (!d_is_dir(path.dentry)) { > > > + path_put(&path); > > > pr_err("db_root: not a directory: %s\n", db_root_stage); > > > + r = -ENOTDIR; > > > goto unlock; > > > } > > > - filp_close(fp, NULL); > > > + path_put(&path); > > > > > > strscpy(db_root, db_root_stage); > > > pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root); > > > > > > base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787 > > > -- > > > 2.34.1 > > > > > You missed the very significant thing in the commit message - that this > lockdep warning is due to try to write its own filename to dbroot file: > > db_root: not a directory: /sys/kernel/config/target/dbroot > > That is why the semaphore is the same - it is of the same file. > > Without that explanation nobody understands wheter it is a false positive or not. > > The fix itself looks good. > > Reviewed-by: Dmitry Bogdanov Hello Dmitry, Thanks a lot for the feedback! I missed out this curcial explanation in the commit message. I will update the commit message and send a v2 patch for the same. Best Regards, Prithvi