linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fs: add iput_not_last()
@ 2025-11-05 21:20 Mateusz Guzik
  2025-11-05 21:20 ` [PATCH 2/2] landlock: fix splats from iput() after it started calling might_sleep() Mateusz Guzik
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mateusz Guzik @ 2025-11-05 21:20 UTC (permalink / raw)
  To: mic, brauner
  Cc: linux-security-module, linux-fsdevel, viro, eadavis, gnoack, jack,
	jannh, max.kellermann, m, syzbot+12479ae15958fc3f54ec,
	Mateusz Guzik

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 fs/inode.c         | 12 ++++++++++++
 include/linux/fs.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/fs/inode.c b/fs/inode.c
index ec9339024ac3..cff1d3af0d57 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1967,6 +1967,18 @@ void iput(struct inode *inode)
 }
 EXPORT_SYMBOL(iput);
 
+/**
+ *	iput_not_last	- put an inode assuming this is not the last reference
+ *	@inode: inode to put
+ */
+void iput_not_last(struct inode *inode)
+{
+	VFS_BUG_ON_INODE(atomic_read(&inode->i_count) < 2, inode);
+
+	WARN_ON(atomic_sub_return(1, &inode->i_count) == 0);
+}
+EXPORT_SYMBOL(iput_not_last);
+
 #ifdef CONFIG_BLOCK
 /**
  *	bmap	- find a block number in a file
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c895146c1444..98fc088a461f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2823,6 +2823,7 @@ extern int current_umask(void);
 
 extern void ihold(struct inode * inode);
 extern void iput(struct inode *);
+void iput_not_last(struct inode *);
 int inode_update_timestamps(struct inode *inode, int flags);
 int generic_update_time(struct inode *, int);
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-11 11:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 21:20 [PATCH 1/2] fs: add iput_not_last() Mateusz Guzik
2025-11-05 21:20 ` [PATCH 2/2] landlock: fix splats from iput() after it started calling might_sleep() Mateusz Guzik
2025-11-06  8:45   ` Mickaël Salaün
2025-11-06  9:43 ` [PATCH 1/2] fs: add iput_not_last() Jan Kara
2025-11-11 11:46 ` Christian Brauner
2025-11-11 11:53   ` Mateusz Guzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).