ceph: Fix uninitialized dentry pointer in ceph_real_mount()
PATCH 1/1 ceph: Fix uninitialized dentry pointer in ceph_real_mount()
fs/ceph/super.c: In function ‘ceph_real_mount’:
fs/ceph/super.c:818: warning: ‘root’ may be used uninitialized in this function
If s_root is already valid, dentry pointer root is never initialized, and returned by ceph_real_mount(). This will cause a crash later when the caller dereferences the pointer.
Fix this by initializing root early.
---
Compile-tested only.
--- fs/ceph/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/super.c +2 -1
@@ -821,7 +821,8 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)dout ("mount start %p\n" , fsc);mutex_lock (&fsc->client->mount_mutex); -if (!fsc->sb->s_root) { + root = fsc->sb->s_root; +if (!root) {const char *path; err =__ceph_open_session (fsc->client, started);if (err <0 )
Signature · 1 line
1.9.1
Quoted 22 lines · Geert Uytterhoeven
fs/ceph/super.c: In function ‘ceph_real_mount’:
fs/ceph/super.c:818: warning: ‘root’ may be used uninitialized in this functionIf
s_rootis already valid, dentry pointer root is never initialized, and returned byceph_real_mount(). This will cause a crash later when the caller dereferences the pointer.Fix this by initializing root early.
Fixes ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath")Signed-off-by Geert Uytterhoeven <[email protected]>---
Compile-tested only.--- fs/ceph/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/ceph/super.c +0
-0
fs/ceph/super.c static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) · line 828
Quoted 9 lines
fs/ceph/super.c +2
-1@@ -821,7 +821,8 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)dout ("mount start %p\n" , fsc);mutex_lock (&fsc->client->mount_mutex); -if (!fsc->sb->s_root) { + root = fsc->sb->s_root; +if (!root) {const char *path; err =__ceph_open_session (fsc->client, started);if (err <0 )
For sb->s_root is not NULL case, we also need to increase sb->s_root's reference count. I applied this patch and fixed it.
Regards
Yan, Zheng
Quoted 3 lines
--
1.9.1
Hi Zheng,
Quoted 27 lines · Zheng
Quoted 25 lines · Geert Uytterhoeven
fs/ceph/super.c: In function ‘ceph_real_mount’:
fs/ceph/super.c:818: warning: ‘root’ may be used uninitialized in this functionIf
s_rootis already valid, dentry pointer root is never initialized, and returned byceph_real_mount(). This will cause a crash later when the caller dereferences the pointer.Fix this by initializing root early.
Fixes ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath")Signed-off-by Geert Uytterhoeven <[email protected]>---
Compile-tested only.--- fs/ceph/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/ceph/super.c +0
-0@@ -821,7 +821,8 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)dout ("mount start %p\n" , fsc);mutex_lock (&fsc->client->mount_mutex);
Quoted 9 lines
fs/ceph/super.c static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) · line 828
Quoted 6 lines
fs/ceph/super.c +2
-1-if (!fsc->sb->s_root) { + root = fsc->sb->s_root; +if (!root) {const char *path; err =__ceph_open_session (fsc->client, started);if (err <0 )For
sb->s_rootis not NULL case, we also need to increase sb->s_root's reference count.
OK
Quoted 1 line
I applied this patch and fixed it.
Thanks for handling!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds