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

From
Namhyung Kim <hidden>
Date
2017-03-07 16:25:12
Also in
linux-acpi, linux-efi, lkml
Reply to
Kees Cook, 2017-03-06
Hi Kees,

On Tue, Mar 7, 2017 at 6:55 AM, Kees Cook [off-list ref] 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

quoted hunk ↗ jump to hunk
Signed-off-by: Kees Cook <redacted>
---
 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
Thread (23 messages) 23 messages, 2 authors, last reply 2017-03-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help