Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,12 @@ static bool simplefs_try_remove_entry(struct simplefs_dir_block *dblock,
* - cleanup index block of the new inode
* - add new file/directory in parent index
*/
#if SIMPLEFS_AT_LEAST(6, 3, 0)
#if SIMPLEFS_AT_LEAST(7, 3, 0)
static int simplefs_create(struct mnt_idmap *id,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
#elif SIMPLEFS_AT_LEAST(6, 3, 0)
static int simplefs_create(struct mnt_idmap *id,
struct inode *dir,
struct dentry *dentry,
Expand Down Expand Up @@ -1070,8 +1075,16 @@ static int simplefs_rename(struct inode *src_dir,
RELEASE_BUFFER_HEAD(src_bi_bh);
return ret;
}

#if SIMPLEFS_AT_LEAST(6, 15, 0)
#if SIMPLEFS_AT_LEAST(7, 3, 0)
static struct dentry *simplefs_mkdir(struct mnt_idmap *id,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
{
int ret = simplefs_create(id, dir, dentry, mode | S_IFDIR);
return ret ? ERR_PTR(ret) : NULL;
}
#elif SIMPLEFS_AT_LEAST(6, 15, 0)
static struct dentry *simplefs_mkdir(struct mnt_idmap *id,
struct inode *dir,
struct dentry *dentry,
Expand Down
11 changes: 9 additions & 2 deletions super.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ static journal_t *simplefs_get_dev_journal(struct super_block *sb,
unsigned long offset;
journal_t *journal;
int errno = 0;
#if SIMPLEFS_AT_LEAST(6, 9, 0)
#if SIMPLEFS_AT_LEAST(7, 3, 0)
struct file *bdev_file;
bdev_file = fs_bdev_file_open_by_dev(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: fs_bdev_file_open_by_dev() registers a (device, superblock) claim entry and must be paired with fs_bdev_file_release(), but both cleanup paths still use the plain-file model: the out_bdev: error path calls bare fput(bdev_file) (line ~395) and simplefs_put_super() (line ~139) never releases sbi->s_journal_bdev_file at all. On the 7.3 path this leaks the claim entry and leaves the device-to-superblock table referencing a freed struct super_block after unmount, so later device removal/freeze/thaw propagation can hit a dangling pointer. Add a SIMPLEFS_AT_LEAST(7, 3, 0) branch that calls fs_bdev_file_release(bdev_file, sb) in out_bdev: and in simplefs_put_super() (and NULL out sbi->s_journal_bdev_file) before the generic 6.9 fput/sync paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At super.c, line 270:

<comment>`fs_bdev_file_open_by_dev()` registers a (device, superblock) claim entry and must be paired with `fs_bdev_file_release()`, but both cleanup paths still use the plain-file model: the `out_bdev:` error path calls bare `fput(bdev_file)` (line ~395) and `simplefs_put_super()` (line ~139) never releases `sbi->s_journal_bdev_file` at all. On the 7.3 path this leaks the claim entry and leaves the device-to-superblock table referencing a freed `struct super_block` after unmount, so later device removal/freeze/thaw propagation can hit a dangling pointer. Add a `SIMPLEFS_AT_LEAST(7, 3, 0)` branch that calls `fs_bdev_file_release(bdev_file, sb)` in `out_bdev:` and in `simplefs_put_super()` (and NULL out `sbi->s_journal_bdev_file`) before the generic 6.9 `fput`/sync paths.</comment>

<file context>
@@ -265,7 +265,12 @@ static journal_t *simplefs_get_dev_journal(struct super_block *sb,
-#if SIMPLEFS_AT_LEAST(6, 9, 0)
+#if SIMPLEFS_AT_LEAST(7, 3, 0)
+    struct file *bdev_file;
+    bdev_file = fs_bdev_file_open_by_dev(
+        journal_dev, BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
+        sb, sb);
</file context>

journal_dev, BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
sb, sb);
#elif SIMPLEFS_AT_LEAST(6, 9, 0)
struct file *bdev_file;
bdev_file = bdev_file_open_by_dev(
journal_dev, BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES,
Expand Down Expand Up @@ -385,7 +390,9 @@ static journal_t *simplefs_get_dev_journal(struct super_block *sb,
return journal;

out_bdev:
#if SIMPLEFS_AT_LEAST(6, 9, 0)
#if SIMPLEFS_AT_LEAST(7, 3, 0)
fs_bdev_file_release(bdev_file, sb);
#elif SIMPLEFS_AT_LEAST(6, 9, 0)
fput(bdev_file);
#elif SIMPLEFS_AT_LEAST(6, 7, 0)
bdev_release(bdev_handle);
Expand Down
Loading