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


Groups > linux.kernel > #1593766 > unrolled thread

[PATCH 03/18] pstore: Avoid race in module unloading

Started byKees Cook <keescook@chromium.org>
First post2017-03-06 23:30 +0100
Last post2017-03-07 19:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 03/18] pstore: Avoid race in module unloading Kees Cook <keescook@chromium.org> - 2017-03-06 23:30 +0100
    Re: [PATCH 03/18] pstore: Avoid race in module unloading Namhyung Kim <namhyung@gmail.com> - 2017-03-07 17:30 +0100
      Re: [PATCH 03/18] pstore: Avoid race in module unloading Kees Cook <keescook@chromium.org> - 2017-03-07 19:30 +0100

#1593766 — [PATCH 03/18] pstore: Avoid race in module unloading

FromKees Cook <keescook@chromium.org>
Date2017-03-06 23:30 +0100
Subject[PATCH 03/18] pstore: Avoid race in module unloading
Message-ID<ti9iF-6ij-1@gated-at.bofh.it>
Technically, it might be possible for struct pstore_info to go out of
scope after the module_put(), so report the backend name first.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/pstore/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 074fe85a2078..d69ef8a840b9 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -722,10 +722,10 @@ int pstore_register(struct pstore_info *psi)
 	 */
 	backend = psi->name;
 
-	module_put(owner);
-
 	pr_info("Registered %s as persistent store backend\n", psi->name);
 
+	module_put(owner);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(pstore_register);
-- 
2.7.4

[toc] | [next] | [standalone]


#1594404

FromNamhyung Kim <namhyung@gmail.com>
Date2017-03-07 17:30 +0100
Message-ID<tiq9Q-1Dp-11@gated-at.bofh.it>
In reply to#1593766
Hi Kees,

On Tue, Mar 7, 2017 at 6:55 AM, Kees Cook <keescook@chromium.org> wrote:
> Technically, it might be possible for struct pstore_info to go out of
> scope after the module_put(), so report the backend name first.

But in that case, using pstore will crash the kernel anyway, right?
If so, why pstore doesn't keep a reference until unregister?
Do I miss something?

Thanks,
Namhyung


>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  fs/pstore/platform.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 074fe85a2078..d69ef8a840b9 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -722,10 +722,10 @@ int pstore_register(struct pstore_info *psi)
>          */
>         backend = psi->name;
>
> -       module_put(owner);
> -
>         pr_info("Registered %s as persistent store backend\n", psi->name);
>
> +       module_put(owner);
> +
>         return 0;
>  }
>  EXPORT_SYMBOL_GPL(pstore_register);
> --
> 2.7.4
>

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


#1594494

FromKees Cook <keescook@chromium.org>
Date2017-03-07 19:30 +0100
Message-ID<tis1X-2YE-1@gated-at.bofh.it>
In reply to#1594404
On Tue, Mar 7, 2017 at 8:16 AM, Namhyung Kim <namhyung@gmail.com> wrote:
> Hi Kees,
>
> On Tue, Mar 7, 2017 at 6:55 AM, Kees Cook <keescook@chromium.org> wrote:
>> Technically, it might be possible for struct pstore_info to go out of
>> scope after the module_put(), so report the backend name first.
>
> But in that case, using pstore will crash the kernel anyway, right?
> If so, why pstore doesn't keep a reference until unregister?
> Do I miss something?

I could be wrong with this, since the backend can't call unregister
until register has finished... I'll drop this patch.

-Kees

>
> Thanks,
> Namhyung
>
>
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>>  fs/pstore/platform.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
>> index 074fe85a2078..d69ef8a840b9 100644
>> --- a/fs/pstore/platform.c
>> +++ b/fs/pstore/platform.c
>> @@ -722,10 +722,10 @@ int pstore_register(struct pstore_info *psi)
>>          */
>>         backend = psi->name;
>>
>> -       module_put(owner);
>> -
>>         pr_info("Registered %s as persistent store backend\n", psi->name);
>>
>> +       module_put(owner);
>> +
>>         return 0;
>>  }
>>  EXPORT_SYMBOL_GPL(pstore_register);
>> --
>> 2.7.4
>>



-- 
Kees Cook
Pixel Security

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web