All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jan Kara" <jack@suse.cz>, "Christian Brauner" <brauner@kernel.org>
Cc: "Andreas Gruenbacher" <agruenba@redhat.com>,
	gfs2@lists.linux.dev, "Mike Marshall" <hubcap@omnibond.com>,
	"Martin Brandenburg" <martin@omnibond.com>,
	devel@lists.orangefs.org, "Dave Kleikamp" <shaggy@kernel.org>,
	"Carlos Maiolino" <cem@kernel.org>,
	"David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	"Miklos Szeredi" <miklos@szeredi.hu>,
	"Chuck Lever" <cel@kernel.org>,
	"Jeff Layton" <jlayton@kernel.org>,
	"Eric Biggers" <ebiggers@kernel.org>,
	"Jaegeuk Kim" <jaegeuk@kernel.org>,
	linux-fscrypt@vger.kernel.org, "Anna Schumaker" <anna@kernel.org>
Subject: Re: [PATCH v3 13/13] fs: Use inode_or_folios_dirty() in __inode_lru_list_add()
Date: Mon, 23 Nov 2026 09:30:54 +0000	[thread overview]
Message-ID: <sashiko-outbox-228978@kernel.org> (raw)
In-Reply-To: <20261123090040.19006-26-jack@suse.cz>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] fs: UAF of inode->i_mapping in __inode_lru_list_add() after
  dev_dax teardown
--

commit dba191eb05adecdae3b365e1982438c7882c5c1d
Author: Jan Kara <jack@suse.cz>

fs: Use inode_or_folios_dirty() in __inode_lru_list_add()

This commit replaces the I_DIRTY_ALL check in __inode_lru_list_add() with a
call to inode_or_folios_dirty().

> diff --git a/fs/inode.c b/fs/inode.c
> index de207f2f95a98..fb759033aa965 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -552,7 +552,9 @@ static void __inode_lru_list_add(struct inode *inode, bool rotate)
>  {
>  	lockdep_assert_held(&inode->i_lock);
>  
> -	if (inode_state_read(inode) & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE))
> +	if (inode_state_read(inode) & (I_SYNC | I_FREEING | I_WILL_FREE))
> +		return;
> +	if (inode_or_folios_dirty(inode))
>  		return;

[Severity: High]
Can inode_or_folios_dirty() cause a use-after-free on inode->i_mapping
when a device-dax character special file inode is added to the LRU after
dev_dax teardown?

Unlike mapping_shrinkable(&inode->i_data) below and the other LRU and
eviction paths in fs/inode.c, inode_or_folios_dirty() dereferences
inode->i_mapping via mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)
whenever I_DIRTY_ALL is clear.

When a device-dax character device is opened, dax_open() redirects the
special file's inode->i_mapping to &dax_dev->inode.i_data, which is
normally only reset to &inode->i_data in evict() -> cd_forget() if
inode->i_cdev is still non-NULL.  If the dev_dax instance is unbound or
deleted while the special file inode remains cached, cdev_purge() clears
inode->i_cdev without restoring inode->i_mapping, and dev_dax_release() ->
put_dax() -> dax_free_inode() frees dax_dev.  When the last reference to
the special file inode is later dropped in iput_final() ->
__inode_lru_list_add(), inode_or_folios_dirty() reads from the freed
dax_dev->inode.i_data mapping.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123085601.21199-1-jack@suse.cz?part=13

  reply	other threads:[~2026-11-23  9:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:00 [PATCH v3 0/13] fs: Various I_DIRTY_* state handling fixes Jan Kara
2026-11-23  9:00 ` [PATCH v3 01/13] bdev: Drop pointless loop from blkdev_flush_mapping() Jan Kara
2026-11-23  9:00 ` [PATCH v3 02/13] xfs: Drop pointless I_DIRTY_PAGES check in xfs_can_free_cowblocks() Jan Kara
2026-11-23  9:00 ` [PATCH v3 03/13] orangefs: Check PAGECACHE_TAG_DIRTY instead of I_DIRTY_PAGES inode state Jan Kara
2026-12-01 13:15   ` Mike Marshall
2026-11-23  9:00 ` [PATCH v3 04/13] fs: Provide inode_is_dirty() helper Jan Kara
2026-11-23  9:00 ` [PATCH v3 05/13] jfs: Use inode_is_dirty() in jfs_fsync() Jan Kara
2026-11-23  9:00 ` [PATCH v3 06/13] gfs2: Avoid racy dirtiness check in gfs2_fsync() Jan Kara
2026-11-23  9:00 ` [PATCH v3 07/13] fuse: Use inode_is_dirty() check in fuse_evict_inode() Jan Kara
2026-11-23  9:00 ` [PATCH v3 08/13] fs: Provide inode_or_folios_dirty() helper Jan Kara
2026-11-23  9:00 ` [PATCH v3 09/13] gfs2: Fix dirtiness checks in gfs2_write_inode() and evict_linked_inode() Jan Kara
2026-11-23  9:00 ` [PATCH v3 10/13] afs: Use inode_or_folios_dirty() in afs_evict_inode() Jan Kara
2026-11-23  9:00 ` [PATCH v3 11/13] nfsd: Use inode_or_folios_dirty() for dirtiness check in wait_for_concurrent_writes() Jan Kara
2026-11-23  9:00 ` [PATCH v3 12/13] fscrypt: Use inode_or_folios_dirty() instead of explicit state check Jan Kara
2026-11-24 23:16   ` Eric Biggers
2026-11-23  9:00 ` [PATCH v3 13/13] fs: Use inode_or_folios_dirty() in __inode_lru_list_add() Jan Kara
2026-11-23  9:30   ` sashiko-bot [this message]
2026-11-23 17:10     ` Jan Kara
2026-12-01 14:21 ` [PATCH v3 0/13] fs: Various I_DIRTY_* state handling fixes Jan Kara

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-228978@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=cel@kernel.org \
    --cc=cem@kernel.org \
    --cc=devel@lists.orangefs.org \
    --cc=dhowells@redhat.com \
    --cc=ebiggers@kernel.org \
    --cc=gfs2@lists.linux.dev \
    --cc=hubcap@omnibond.com \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=martin@omnibond.com \
    --cc=miklos@szeredi.hu \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shaggy@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.