From: Oleg Nesterov <oleg@redhat.com>
To: Christopher Yeoh <cyeoh@au1.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND] Fix race in process_vm_rw_core
Date: Mon, 30 Jan 2012 16:09:22 +0100 [thread overview]
Message-ID: <20120130150922.GA17643@redhat.com> (raw)
In-Reply-To: <20120130124406.1567af7a@Gantu.yeoh.info>
On 01/30, Christopher Yeoh wrote:
>
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -198,7 +198,7 @@ static int proc_root_link(struct dentry *dentry, struct path *path)
> return result;
> }
>
> -static struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
> +struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
This is not enough, we should move it outside of fs/proc/, otherwise
the kernel can't be compiled without CONFIG_PROC.
> --- a/mm/process_vm_access.c
> +++ b/mm/process_vm_access.c
> @@ -298,23 +298,15 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
> goto free_proc_pages;
> }
>
> - task_lock(task);
> - if (__ptrace_may_access(task, PTRACE_MODE_ATTACH)) {
> - task_unlock(task);
> - rc = -EPERM;
> - goto put_task_struct;
> - }
> - mm = task->mm;
> -
> - if (!mm || (task->flags & PF_KTHREAD)) {
> - task_unlock(task);
> - rc = -EINVAL;
> + mm = mm_access(task, PTRACE_MODE_ATTACH);
> + if (!mm || IS_ERR(mm)) {
> + if (!mm)
> + rc = -EINVAL;
> + else
> + rc = -EPERM;
> goto put_task_struct;
> }
>
> - atomic_inc(&mm->mm_users);
> - task_unlock(task);
> -
Looks obviously correct.
Oleg.
next prev parent reply other threads:[~2012-01-30 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 2:14 [PATCH RESEND] Fix race in process_vm_rw_core Christopher Yeoh
2012-01-30 15:09 ` Oleg Nesterov [this message]
2012-02-01 5:53 ` Christopher Yeoh
2012-02-01 6:09 ` Cong Wang
2012-02-01 6:10 ` Linus Torvalds
2012-02-01 8:08 ` Christopher Yeoh
2012-02-02 1:04 ` 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=20120130150922.GA17643@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cyeoh@au1.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).