From: Geliang Tang <geliangtang@163.com>
To: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>,
Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
linux-kernel@vger.kernel.org, Geliang Tang <geliangtang@163.com>
Subject: Re: [PATCH 1/2] pstore: check PSTORE_FLAGS_FRAGILE in pstore_unregister
Date: Sun, 25 Oct 2015 10:22:32 +0800 [thread overview]
Message-ID: <20151025022232.GA1181@bogon> (raw)
In-Reply-To: <CAGXu5j+sUGsDsoef_crgETqCNMN_GFuPryHKYzAmiw0-04aYnw@mail.gmail.com>
On Fri, Oct 23, 2015 at 09:54:31AM -0700, Kees Cook wrote:
> On Fri, Oct 23, 2015 at 7:56 AM, Geliang Tang <geliangtang@163.com> wrote:
> > When PSTORE_FLAGS_FRAGILE flag is set, only kmsg is registered in
> > pstore_register. So, under these circumstances, only kmsg needs to
> > be unregistered in pstore_unregister.
> >
> > Signed-off-by: Geliang Tang <geliangtang@163.com>
>
> Would it make more sense to have the pstore_unregister_* calls be
> defensive, like kfree() is? In other words, it would be safe to call
> them, even if they hadn't been registered?
>
> Either way, I'm fine with this. Good catch!
>
> -Kees
>
Thanks for your reply.
pstore_unregister_* is defensive as you expected. I have tested it. it
is safe to call them if they haven't been registered. This won't cause
any trouble.
But logically, we should check this flag in pstore_unregister.
-Geliang Tang
> > ---
> > fs/pstore/platform.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> > index 0aab920..7ad2038 100644
> > --- a/fs/pstore/platform.c
> > +++ b/fs/pstore/platform.c
> > @@ -496,9 +496,12 @@ EXPORT_SYMBOL_GPL(pstore_register);
> >
> > void pstore_unregister(struct pstore_info *psi)
> > {
> > - pstore_unregister_pmsg();
> > - pstore_unregister_ftrace();
> > - pstore_unregister_console();
> > + if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
> > + pstore_unregister_pmsg();
> > + pstore_unregister_ftrace();
> > + pstore_unregister_console();
> > + }
> > +
> > pstore_unregister_kmsg();
> >
> > free_buf_for_compression();
> > --
> > 2.5.0
> >
> >
>
>
>
> --
> Kees Cook
> Chrome OS Security
prev parent reply other threads:[~2015-10-25 2:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 14:56 [PATCH 1/2] pstore: check PSTORE_FLAGS_FRAGILE in pstore_unregister Geliang Tang
2015-10-23 14:56 ` [PATCH 2/2] efi-pstore: implement efivars_pstore_exit() Geliang Tang
2015-10-23 16:54 ` [PATCH 1/2] pstore: check PSTORE_FLAGS_FRAGILE in pstore_unregister Kees Cook
2015-10-25 2:22 ` Geliang Tang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151025022232.GA1181@bogon \
--to=geliangtang@163.com \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox