Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1500346 > unrolled thread

[PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount()

Started byGeert Uytterhoeven <geert@linux-m68k.org>
First post2016-10-13 17:20 +0200
Last post2016-10-17 09:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-13 17:20 +0200
    Re: [PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount() "Yan, Zheng" <ukernel@gmail.com> - 2016-10-14 04:50 +0200
      Re: [PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-17 09:50 +0200

#1500346 — [PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount()

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-10-13 17:20 +0200
Subject[PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount()
Message-ID<srPXB-5cV-41@gated-at.bofh.it>
    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.

Fixes: ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.
---
 fs/ceph/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index a29ffce981879d5f..794c5fd0e0cf5e45 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -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)
-- 
1.9.1

[toc] | [next] | [standalone]


#1500676

From"Yan, Zheng" <ukernel@gmail.com>
Date2016-10-14 04:50 +0200
Message-ID<ss0Jj-3Jv-3@gated-at.bofh.it>
In reply to#1500346
On Thu, Oct 13, 2016 at 11:15 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>     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.
>
> Fixes: ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Compile-tested only.
> ---
>  fs/ceph/super.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index a29ffce981879d5f..794c5fd0e0cf5e45 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -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


> --
> 1.9.1
>

[toc] | [prev] | [next] | [standalone]


#1501657

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-10-17 09:50 +0200
Message-ID<staQh-wi-27@gated-at.bofh.it>
In reply to#1500676
Hi Zheng,

On Fri, Oct 14, 2016 at 4:47 AM, Yan, Zheng <ukernel@gmail.com> wrote:
> On Thu, Oct 13, 2016 at 11:15 PM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
>>     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.
>>
>> Fixes: ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath")
>> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> ---
>> Compile-tested only.
>> ---
>>  fs/ceph/super.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
>> index a29ffce981879d5f..794c5fd0e0cf5e45 100644
>> --- a/fs/ceph/super.c
>> +++ b/fs/ceph/super.c
>> @@ -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.

OK

> I applied this patch and fixed it.

Thanks for handling!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web