Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Konstantin Adzer" <info@massivetech.ru>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>
Cc: "Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Dan Williams" <djbw@kernel.org>,
	"Vishal Verma" <vishal.l.verma@intel.com>,
	"Dave Jiang" <dave.jiang@intel.com>,
	"Alison Schofield" <alison.schofield@intel.com>,
	"Eric Van Hensbergen" <ericvh@kernel.org>,
	"Latchesar Ionkov" <lucho@ionkov.net>,
	"Dominique Martinet" <asmadeus@codewreck.org>,
	"Christian Schoenebeck" <linux_oss@crudebyte.com>,
	"David Sterba" <dsterba@suse.com>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Luis de Bethencourt" <luisbg@kernel.org>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Chris Mason" <mason@kernel.org>,
	"Ilya Dryomov" <idryomov@gmail.com>,
	"Alex Markuze" <amarkuze@redhat.com>,
	"Xiubo Li" <xiubo.li@clyso.com>,
	"Viacheslav Dubeyko" <slava@dubeyko.com>,
	"Jan Harkes" <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, "Nicolas Pitre" <nico@fluxnic.net>,
	"Tyler Hicks" <code@tyhicks.com>, "Gao Xiang" <xiang@kernel.org>,
	"Chao Yu" <chao@kernel.org>, "Yue Hu" <zbestahu@gmail.com>,
	"Jingbo Xu" <jefflexu@163.com>,
	"Sandeep Dhavale" <dhavale@google.com>,
	"Hongbo Li" <hongbohbli@tencent.com>,
	"Chunhai Guo" <guochunhai@vivo.com>, "Jan Kara" <jack@suse.cz>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Andreas Dilger" <adilger.kernel@dilger.ca>,
	"Baokun Li" <libaokun@linux.alibaba.com>,
	"Ojaswin Mujoo" <ojaswin@linux.ibm.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	"Zhang Yi" <yi.zhang@huawei.com>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Andreas Gruenbacher" <agruenba@redhat.com>,
	"John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de>,
	"Yangtao Li" <frank.li@vivo.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Dave Kleikamp" <shaggy@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Tejun Heo" <tj@kernel.org>,
	"Trond Myklebust" <trondmy@kernel.org>,
	"Anna Schumaker" <anna@kernel.org>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Namjae Jeon" <linkinjeon@kernel.org>,
	"Hyunchul Lee" <hyc.lee@gmail.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Mark Fasheh" <mark@fasheh.com>,
	"Joel Becker" <jlbec@evilplan.org>,
	"Joseph Qi" <joseph.qi@linux.alibaba.com>,
	"Heming Zhao" <heming.zhao@suse.com>,
	"Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	"Amir Goldstein" <amir73il@gmail.com>,
	"Anders Larsen" <al@alarsen.net>,
	"Paulo Alcantara" <pc@manguebit.org>,
	"Ronnie Sahlberg" <ronniesahlberg@gmail.com>,
	"Shyam Prasad N" <sprasad@microsoft.com>,
	"Tom Talpey" <tom@talpey.com>,
	"Bharath SM" <bharathsm@microsoft.com>,
	"Phillip Lougher" <phillip@squashfs.org.uk>,
	"Zhihao Cheng" <chengzhihao1@huawei.com>,
	"Jori Koolstra" <jkoolstra@xs4all.nl>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <jth@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
	v9fs@lists.linux.dev, codalist@coda.cs.cmu.edu,
	linux-ext4@vger.kernel.org, gfs2@lists.linux.dev,
	linux-mtd@lists.infradead.org, devel@lists.orangefs.org,
	samba-technical@lists.samba.org, dsterba@suse.cz,
	"Chuck Lever" <cel@kernel.org>,
	"Jeff Layton" <jlayton@kernel.org>
Subject: Re: [PATCH 3/3] fs: return ERR_PTR() from iget_locked() and friends
Date: Tue, 01 Dec 2026 13:54:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-243428@kernel.org> (raw)
In-Reply-To: <367d7105e3efbc364ff4feb2facd723ad5ab0cc3.1796132090.git.info@massivetech.ru>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 2 related pre-existing issues it does not
introduce:
- [High] isofs: missing error code in out_toomany path of
  isofs_read_level3_size() [1]
- [High] ufs: division-by-zero in ufs_iget() [2]
--

commit adb88fb457bfb90375b2b0cdbe62297aa9ce6146
Author: Konstantin Adzer <info@massivetech.ru>

fs: return ERR_PTR() from iget_locked() and friends

This commit changes iget_locked(), iget5_locked(), iget5_locked_rcu(),
and inode_insert5() to return an ERR_PTR() instead of NULL on failure,
and updates their callers across the tree to check IS_ERR().

[ ... ]

> diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
> index 4824e42995ccf..47212eed8269f 100644
> --- a/fs/isofs/inode.c
> +++ b/fs/isofs/inode.c
> @@ -1504,8 +1504,8 @@ struct inode *__isofs_iget(struct super_block *sb,
>  	inode = iget5_locked(sb, hashval, &isofs_iget5_test,
>  				&isofs_iget5_set, &data);
>  
> -	if (!inode)
> -		return ERR_PTR(-ENOMEM);
> +	if (IS_ERR(inode))
> +		return inode;
>  
>  	if (inode_state_read_once(inode) & I_NEW) {
>  		ret = isofs_read_inode(inode, relocated);

[Severity: High]
This problem wasn't introduced by this patch, but can
isofs_read_level3_size() return 0 on the out_toomany error path when
called from isofs_read_inode() [1]?

fs/isofs/inode.c:isofs_read_level3_size() {
	...
		i++;
		if (i > 100)
			goto out_toomany;
	} while (more_entries);
out:
	kfree(tmpde);
	brelse(bh);
	return 0;
	...
out_toomany:
	printk(KERN_INFO "%s: More than 100 file sections ?!?, aborting...\n"
		"isofs_read_level3_size: inode=%llu\n",
		__func__, inode->i_ino);
	goto out;
}

When an image has a file with more than 100 sections, out_toomany jumps
to out and returns 0, so isofs_read_inode() treats the malformed inode as
valid and unlocks it with truncated size.

[ ... ]

> diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
> index fec701330d67f..9d00e75c8fab2 100644
> --- a/fs/ufs/inode.c
> +++ b/fs/ufs/inode.c
> @@ -653,8 +653,8 @@ struct inode *ufs_iget(struct super_block *sb, unsigned long ino)
>  	}
>  
>  	inode = iget_locked(sb, ino);
> -	if (!inode)
> -		return ERR_PTR(-ENOMEM);
> +	if (IS_ERR(inode))
> +		return inode;
>  	if (!(inode_state_read_once(inode) & I_NEW))
>  		return inode;
>  

[Severity: High]
This problem wasn't introduced by this patch, but can ufs_inotofsba()
divide by zero right after this check when mounting a corrupted UFS image
[2]?

fs/ufs/inode.c:ufs_iget() {
	...
	ufsi = UFS_I(inode);

	bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
}

fs/ufs/ufs_fs.h:
#define	ufs_inotocg(x)		((unsigned int)(x) / uspi->s_ipg)
#define	ufs_inotocgoff(x)	((unsigned int)(x) % uspi->s_ipg)
#define	ufs_inotofsba(x)	(((u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf)

ufs_fill_super() populates uspi->s_ipg and uspi->s_inopf from the on-disk
superblock without checking that they are non-zero, so loading the root
inode in ufs_iget() triggers a divide error if either field is zero.

[1] https://sashiko.dev/#/bug/linux-03286deb-aa65-44af-9d0a-7ac38844847c
[2] https://sashiko.dev/#/bug/linux-6bde18a6-cee5-4787-b073-9e622fcafcd9

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796132090.git.info@massivetech.ru?part=3

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2026-12-01 13:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 13:34 [PATCH 0/3] fs: return ERR_PTR() from iget_locked() and friends Konstantin Adzer
2026-12-01 13:06 ` [PATCH 1/3] fuse: return ERR_PTR() from fuse_iget() Konstantin Adzer
2026-12-01 13:06 ` [PATCH 2/3] hfs: return ERR_PTR() from hfs_iget() Konstantin Adzer
2026-12-01 13:09 ` [PATCH 3/3] fs: return ERR_PTR() from iget_locked() and friends Konstantin Adzer
2026-12-01 13:54   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-243428@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=agruenba@redhat.com \
    --cc=al@alarsen.net \
    --cc=alison.schofield@intel.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=amarkuze@redhat.com \
    --cc=amir73il@gmail.com \
    --cc=anna@kernel.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=asmadeus@codewreck.org \
    --cc=bharathsm@microsoft.com \
    --cc=brauner@kernel.org \
    --cc=cel@kernel.org \
    --cc=chao@kernel.org \
    --cc=chengzhihao1@huawei.com \
    --cc=coda@cs.cmu.edu \
    --cc=codalist@coda.cs.cmu.edu \
    --cc=code@tyhicks.com \
    --cc=corbet@lwn.net \
    --cc=dave.jiang@intel.com \
    --cc=devel@lists.orangefs.org \
    --cc=dhavale@google.com \
    --cc=dhowells@redhat.com \
    --cc=djbw@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=dwmw2@infradead.org \
    --cc=ericvh@kernel.org \
    --cc=frank.li@vivo.com \
    --cc=gfs2@lists.linux.dev \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=guochunhai@vivo.com \
    --cc=hannes@cmpxchg.org \
    --cc=heming.zhao@suse.com \
    --cc=hongbohbli@tencent.com \
    --cc=hubcap@omnibond.com \
    --cc=hyc.lee@gmail.com \
    --cc=idryomov@gmail.com \
    --cc=info@massivetech.ru \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=jaharkes@cs.cmu.edu \
    --cc=jefflexu@163.com \
    --cc=jkoolstra@xs4all.nl \
    --cc=jlayton@kernel.org \
    --cc=jlbec@evilplan.org \
    --cc=johannes@sipsolutions.net \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=jth@kernel.org \
    --cc=konishi.ryusuke@gmail.com \
    --cc=libaokun@linux.alibaba.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=luisbg@kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=mark@fasheh.com \
    --cc=martin@omnibond.com \
    --cc=mason@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=mkoutny@suse.com \
    --cc=naohiro.aota@wdc.com \
    --cc=nico@fluxnic.net \
    --cc=nvdimm@lists.linux.dev \
    --cc=ojaswin@linux.ibm.com \
    --cc=pc@manguebit.org \
    --cc=phillip@squashfs.org.uk \
    --cc=rdunlap@infradead.org \
    --cc=richard@nod.at \
    --cc=ritesh.list@gmail.com \
    --cc=ronniesahlberg@gmail.com \
    --cc=salah.triki@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shaggy@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=slava@dubeyko.com \
    --cc=sprasad@microsoft.com \
    --cc=tj@kernel.org \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    --cc=tytso@mit.edu \
    --cc=v9fs@lists.linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vishal.l.verma@intel.com \
    --cc=xiang@kernel.org \
    --cc=xiubo.li@clyso.com \
    --cc=yi.zhang@huawei.com \
    --cc=zbestahu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox