[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201007010639.FDJ17674.JFQOStOFFMHOVL@I-love.SAKURA.ne.jp>
Date: Thu, 1 Jul 2010 06:39:05 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: kees.cook@...onical.com, eparis@...isplace.org
Cc: linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] Yama: add PTRACE exception tracking
Kees Cook wrote:
> @@ -41,18 +41,30 @@ static DEFINE_SPINLOCK(ptracer_relations_lock);
> static int yama_ptracer_add(struct task_struct *tracer,
> struct task_struct *tracee)
> {
> - struct ptrace_relation *relation;
> + int rc = 0;
> + struct ptrace_relation *entry, *relation = NULL;
>
> - relation = kmalloc(sizeof(*relation), GFP_KERNEL);
> - if (!relation)
> - return -ENOMEM;
> - relation->tracer = tracer;
> - relation->tracee = tracee;
> spin_lock(&ptracer_relations_lock);
> - list_add(&relation->node, &ptracer_relations);
> + list_for_each_entry(entry, &ptracer_relations, node)
> + if (entry->tracee == tracee) {
> + relation = entry;
> + break;
> + }
> + if (!relation) {
> + relation = kmalloc(sizeof(*relation), GFP_KERNEL);
You can't use GFP_KERNEL here because a spinlock is held.
> + if (!relation) {
> + rc = -ENOMEM;
> + goto unlock_out;
> + }
> + relation->tracee = tracee;
> + list_add(&relation->node, &ptracer_relations);
> + }
> + relation->tracer = tracer;
> +
> +unlock_out:
> spin_unlock(&ptracer_relations_lock);
>
> - return 0;
> + return rc;
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists