mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] squashfs: Fix current master
@ 2020-08-10 11:12 Sascha Hauer
  2020-08-10 11:12 ` [PATCH 1/3] fs: squashfs: set s_op in time Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-08-10 11:12 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

squashfs is broken since 43902e5763 ("fs: free inodes we no longer need").
This series fixes it.

Sascha Hauer (3):
  fs: squashfs: set s_op in time
  fs: squashfs: Do not free root inode
  fs: Use iget_locked() rather than squashfs specific function

 fs/squashfs/inode.c    | 18 +-----------------
 fs/squashfs/squashfs.c |  3 +--
 fs/squashfs/squashfs.h |  1 -
 fs/squashfs/super.c    |  1 -
 4 files changed, 2 insertions(+), 21 deletions(-)

-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/3] fs: squashfs: set s_op in time
  2020-08-10 11:12 [PATCH 0/3] squashfs: Fix current master Sascha Hauer
@ 2020-08-10 11:12 ` Sascha Hauer
  2020-08-10 11:12 ` [PATCH 2/3] fs: squashfs: Do not free root inode Sascha Hauer
  2020-08-10 11:12 ` [PATCH 3/3] fs: Use iget_locked() rather than squashfs specific function Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-08-10 11:12 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

When calling squashfs_mount() s_op needs to be set already, otherwise
calling alloc_inode() yields in a NULL pointer derefence.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/squashfs/squashfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index 69451f7b84..be03618b2f 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -101,6 +101,7 @@ static int squashfs_probe(struct device_d *dev)
 	if (ret)
 		goto err_out;
 
+	sb->s_op = &squashfs_super_ops;
 
 	ret = squashfs_mount(fsdev, 0);
 	if (ret) {
@@ -110,8 +111,6 @@ static int squashfs_probe(struct device_d *dev)
 
 	squashfs_set_rootarg(fsdev);
 
-	sb->s_op = &squashfs_super_ops;
-
 	return 0;
 
 err_out:
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] fs: squashfs: Do not free root inode
  2020-08-10 11:12 [PATCH 0/3] squashfs: Fix current master Sascha Hauer
  2020-08-10 11:12 ` [PATCH 1/3] fs: squashfs: set s_op in time Sascha Hauer
@ 2020-08-10 11:12 ` Sascha Hauer
  2020-08-10 11:12 ` [PATCH 3/3] fs: Use iget_locked() rather than squashfs specific function Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-08-10 11:12 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

With inode reference counting in place the core will free the root
inode, so do not free it in the squashfs code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/squashfs/super.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index e2b7b8d5a1..35df3a0307 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -83,7 +83,6 @@ void squashfs_put_super(struct super_block *sb)
 	}
 
 	if (sb->s_root) {
-		kfree(squashfs_i(sb->s_root->d_inode));
 		kfree(sb->s_root);
 		sb->s_root = NULL;
 	}
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] fs: Use iget_locked() rather than squashfs specific function
  2020-08-10 11:12 [PATCH 0/3] squashfs: Fix current master Sascha Hauer
  2020-08-10 11:12 ` [PATCH 1/3] fs: squashfs: set s_op in time Sascha Hauer
  2020-08-10 11:12 ` [PATCH 2/3] fs: squashfs: Do not free root inode Sascha Hauer
@ 2020-08-10 11:12 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-08-10 11:12 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

Use iget_locked() to let the core allocate the inode. This properly
initializes all fields in the new inode, especially it adds the new
inode to the list of all inodes for the filesystem. This prevents a NULL
pointer derefence when iput() removes the inode from that list.

This fixes squashfs support which is broken since 43902e5763 ("fs: free
inodes we no longer need")

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/squashfs/inode.c    | 18 +-----------------
 fs/squashfs/squashfs.h |  1 -
 2 files changed, 1 insertion(+), 18 deletions(-)

diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 470536e589..64155d47db 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -44,22 +44,6 @@
 #include "squashfs_fs_i.h"
 #include "squashfs.h"
 
-struct inode *iget_locked_squashfs(struct super_block *sb, unsigned long ino)
-{
-	struct inode *inode;
-	struct squashfs_inode_info *ei;
-
-	ei = malloc(sizeof(struct squashfs_inode_info));
-	inode = &ei->vfs_inode;
-	if (inode) {
-		inode->i_ino = ino;
-		inode->i_sb = sb;
-		inode->i_state = I_SYNC | I_NEW;
-	}
-
-	return inode;
-}
-
 /*
  * Initialise VFS inode with the base inode information common to all
  * Squashfs inode types.  Sqsh_ino contains the unswapped base inode
@@ -94,7 +78,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
 struct inode *squashfs_iget(struct super_block *sb, long long ino,
 				unsigned int ino_number)
 {
-	struct inode *inode = iget_locked_squashfs(sb, ino_number);
+	struct inode *inode = iget_locked(sb, ino_number);
 	int err;
 
 	TRACE("Entered squashfs_iget\n");
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
index 31c9bc454e..825df2aedd 100644
--- a/fs/squashfs/squashfs.h
+++ b/fs/squashfs/squashfs.h
@@ -52,7 +52,6 @@ static inline struct squashfs_page *squashfs_page(struct page *page)
 
 #define WARNING(s, args...)	pr_warn("SQUASHFS: "s, ## args)
 
-struct inode *iget_locked_squashfs(struct super_block *sb, unsigned long ino);
 char *squashfs_devread(struct squashfs_sb_info *fs, int byte_offset,
 		int byte_len);
 extern int squashfs_mount(struct fs_device_d *fsdev,
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-08-10 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10 11:12 [PATCH 0/3] squashfs: Fix current master Sascha Hauer
2020-08-10 11:12 ` [PATCH 1/3] fs: squashfs: set s_op in time Sascha Hauer
2020-08-10 11:12 ` [PATCH 2/3] fs: squashfs: Do not free root inode Sascha Hauer
2020-08-10 11:12 ` [PATCH 3/3] fs: Use iget_locked() rather than squashfs specific function Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox