All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Christopher Yeoh <cyeoh@au1.ibm.com>
Cc: linux-kernel@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Howells <dhowells@redhat.com>
Subject: Re: [PATCH] Fix race in process_vm_rw_core
Date: Fri, 13 Jan 2012 14:30:50 -0800	[thread overview]
Message-ID: <20120113143050.df23a02c.akpm@linux-foundation.org> (raw)
In-Reply-To: <20120113220028.4ba7cead@Gantu.yeoh.info>

On Fri, 13 Jan 2012 22:00:28 +1030
Christopher Yeoh <cyeoh@au1.ibm.com> wrote:

> Hi Linus,
> 
> Below is a patch which fixes the race in process_vm_core found by
> Oleg (http://article.gmane.org/gmane.linux.kernel/1235667/).
> It consolidates some code with mm_for_maps since what they do is almost
> identical.
> 
> Oleg - I've kept the breakout of ptrace_may_attach and get_task_mm to
> preserve only having to take the task lock once. I see some performance
> difference with a microbenchmark but haven't had a chance to test with
> some HPC benchmarks yet so for the moment I'd like to leave it in. At
> this stage I think its more important to get the race fixed and I'm at
> Linux.conf.au all next week. I'll send a patch out for the 
> rw_copy_check_uvector cleanup after I get back from LCA.
> 
> ...
>
> +struct mm_struct *get_check_task_mm(struct task_struct *task, unsigned int mode)
> +{
> +	struct mm_struct *mm;
> +	int err;
> +
> +	err =  mutex_lock_killable(&task->signal->cred_guard_mutex);
> +	if (err)
> +		return ERR_PTR(err);
> +
> +	task_lock(task);
> +	if (__ptrace_may_access(task, mode)) {
> +		mm = ERR_PTR(-EACCES);
> +		goto out;
> +	}
> +
> +	mm = task->mm;
> +	if (mm) {
> +		if (task->flags & PF_KTHREAD)
> +			mm = NULL;
> +		else
> +			atomic_inc(&mm->mm_users);
> +	}
> +
> +out:
> +	task_unlock(task);
> +	mutex_unlock(&task->signal->cred_guard_mutex);
> +
> +	return mm;
> +}
> +EXPORT_SYMBOL_GPL(get_check_task_mm);

I don't think the export is needed - CONFIG_PROC_FS=m isn't supported.

btw, I'm trying to work out why we didn't make the whole process_vm_access.o
feature Kconfigurable, so people who don't want it do not get burdened
with it?


  parent reply	other threads:[~2012-01-13 22:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13 11:30 [PATCH] Fix race in process_vm_rw_core Christopher Yeoh
2012-01-13 16:04 ` Oleg Nesterov
2012-01-13 23:26   ` Christopher Yeoh
2012-01-14 17:58     ` Oleg Nesterov
2012-01-16  2:56       ` Christopher Yeoh
2012-01-16 18:59         ` Oleg Nesterov
2012-01-13 22:30 ` Andrew Morton [this message]
2012-01-13 23:30   ` Christopher Yeoh

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=20120113143050.df23a02c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cyeoh@au1.ibm.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=torvalds@linux-foundation.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.