fuse: check fi is not NULL before calling fuse_passthrough_release()
Subsystems (3)
PATCH 1/1 fuse: check fi is not NULL before calling fuse_passthrough_release()
From: Tristan Madani <[email protected]>
fuse_create_open() calls fuse_sync_release() with a NULL fuse_inode when fuse_iget() fails. This propagates to fuse_prepare_release(), which passes the NULL fi to fuse_inode_backing() via the fuse_passthrough_release() call, resulting in a NULL pointer dereference.
The existing comment in fuse_prepare_release() documents that the inode can be NULL on the error path of fuse_create_open(), and the fi->lock access below is already guarded with if (likely(fi)), but the passthrough release path added by commit 4a90451bbc7f ("fuse:
implement open in passthrough mode") was not given the same protection.
Add the missing NULL check for fi before callingfuse_passthrough_release().
Found by syzkaller.
--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -313,7 +313,7 @@ static void fuse_prepare_release(struct fuse_inode *fi, struct fuse_file *ff,struct fuse_conn *fc = ff->fm->fc;struct fuse_release_args *ra = &ff->args->release_args; -if (fuse_file_passthrough (ff)) +if (fi &&fuse_file_passthrough (ff))fuse_passthrough_release (ff,fuse_inode_backing (fi));/* Inode is NULL on error path of fuse_create_open() */
Signature · 1 line
2.47.3
Quoted 9 lines · Tristan Madani
From: Tristan Madani <[email protected]>
fuse_create_open()callsfuse_sync_release()with a NULLfuse_inodewhenfuse_iget()fails. This propagates tofuse_prepare_release(), which passes the NULL fi tofuse_inode_backing()via thefuse_passthrough_release()call, resulting in a NULL pointer dereference.
Quoted 6 lines
The existing comment in
fuse_prepare_release()documents that the inode can be NULL on the error path offuse_create_open(), and thefi->lockaccess below is already guarded with if (likely(fi)), but the passthrough release path added by commit4a90451bbc7f("fuse:
implement open in passthrough mode") was not given the same protection.
But passthrough open happens after this error patch, so this sounds like an invented problem
Quoted 5 lines
Add the missing NULL check for fi before calling
fuse_passthrough_release().Found by syzkaller.
Where is the report? where is the repro?
Quoted 13 lines
Fixes 4a90451bbc7f ("fuse: implement open in passthrough mode")Signed-off-by Tristan Madani <[email protected]>--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/fuse/file.c +0
-0
fs/fuse/file.c static void fuse_prepare_release(struct fuse_inode *fi, struct fuse_file *ff, · line 318
Quoted 7 lines
fs/fuse/file.c +1
-1@@ -313,7 +313,7 @@ static void fuse_prepare_release(struct fuse_inode *fi, struct fuse_file *ff,struct fuse_conn *fc = ff->fm->fc;struct fuse_release_args *ra = &ff->args->release_args; -if (fuse_file_passthrough (ff)) +if (fi &&fuse_file_passthrough (ff))fuse_passthrough_release (ff,fuse_inode_backing (fi));
This should not be possible and if it were possible, this code would be leaking ff->passthrough.
I don't know how you got to this issue and why, but if you are sending me code fixes from an hallucinating AI agent without really understanding and really reproducing the problem please respect my time and don't!
Thanks,
Amir.