From: Oleg Nesterov <oleg@tv-sign.ru>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: + proc-export-a-processes-resource-limits-via-proc-pid.patch added to -mm tree
Date: Sun, 19 Aug 2007 12:57:07 +0400 [thread overview]
Message-ID: <20070819085707.GB83@tv-sign.ru> (raw)
In-Reply-To: <20070818232352.GA25994@hmsreliant.think-freely.org>
On 08/18, Neil Horman wrote:
>
> +static int proc_pid_limits(struct task_struct *task, char *buffer)
> +{
> + unsigned int i;
> + int count = 0;
> + unsigned long flags;
> + char *bufptr = buffer;
> +
> + struct rlimit rlim[RLIM_NLIMITS];
> +
> + rcu_read_lock();
> + lock_task_sighand(task,&flags);
> + if (task->signal == NULL){
> + unlock_task_sighand(task, &flags);
> + rcu_read_unlock();
> + return 0;
> + }
> + memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS);
> + unlock_task_sighand(task, &flags);
> + rcu_read_unlock();
No, no. If lock_task_sighand() fails, ->signal _should be_ == NULL, but the
"if (task->signal == NULL)" check is not reliable, we don't have any barriers
to serialize with __exit_signal().
More importantly, it is very wrong to do unlock_task_sighand() in that case,
this means NULL pointer dereference.
What we need is:
rcu_read_lock();
if (!lock_task_sighand(task, &flags)) {
rcu_read_unlock();
return 0;
}
memcpy(rlim, task->signal->rlim, sizeof(rlim));
unlock_task_sighand(task, &flags);
rcu_read_unlock();
No need to check ->signal != NULL if lock_task_sighand() succeeds.
Oleg.
next prev parent reply other threads:[~2007-08-19 8:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-17 22:22 Oleg Nesterov
2007-08-18 11:58 ` Neil Horman
2007-08-18 12:59 ` Oleg Nesterov
2007-08-18 18:55 ` Neil Horman
2007-08-18 19:03 ` Oleg Nesterov
2007-08-18 23:23 ` Neil Horman
2007-08-19 8:57 ` Oleg Nesterov [this message]
2007-08-19 13:03 ` Neil Horman
2007-08-19 15:19 ` Oleg Nesterov
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=20070819085707.GB83@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@tuxdriver.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
all inboxes | Powered by JetHome®