From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Don't risk NULL deref in marker
Date: Mon, 25 Feb 2008 21:59:02 -0500 [thread overview]
Message-ID: <20080226025902.GA13199@Krystal> (raw)
In-Reply-To: <200802260014.24253.jesper.juhl@gmail.com>
* Jesper Juhl (jesper.juhl@gmail.com) wrote:
>
> get_marker() may return NULL, so test for it.
>
Hrm, yes, if we have two marker_probe_unregister callers calling it for
the same marker, one expecting it to fail and they race, yes, it can
happen. Although this is not expected to happen often if the caller acts
sanely, it's a good thing to fix it. Thanks!
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
>
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
>
> diff --git a/kernel/marker.c b/kernel/marker.c
> index 50effc0..f211f08 100644
> --- a/kernel/marker.c
> +++ b/kernel/marker.c
> @@ -698,12 +698,11 @@ int marker_probe_unregister(const char *name,
> {
> struct marker_entry *entry;
> struct marker_probe_closure *old;
> - int ret = 0;
> + int ret = -ENOENT;
>
> mutex_lock(&markers_mutex);
> entry = get_marker(name);
> if (!entry) {
> - ret = -ENOENT;
> goto end;
> }
> if (entry->rcu_pending)
> @@ -713,12 +712,16 @@ int marker_probe_unregister(const char *name,
> marker_update_probes(); /* may update entry */
> mutex_lock(&markers_mutex);
> entry = get_marker(name);
> + if (!entry) {
> + goto end;
> + }
> entry->oldptr = old;
> entry->rcu_pending = 1;
> /* write rcu_pending before calling the RCU callback */
> smp_wmb();
> call_rcu(&entry->rcu, free_old_closure);
> remove_marker(name); /* Ignore busy error message */
> + ret = 0;
> end:
> mutex_unlock(&markers_mutex);
> return ret;
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
prev parent reply other threads:[~2008-02-26 2:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 23:14 [PATCH] Don't risk NULL deref in marker Jesper Juhl
2008-02-26 2:59 ` Mathieu Desnoyers [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=20080226025902.GA13199@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=jesper.juhl@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.