From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Vagin <avagin@openvz.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Roland McGrath <roland@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Pavel Emelyanov <xemul@parallels.com>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 2/2] ptrace: add ability to attach a file descriptor to another task
Date: Sun, 18 Dec 2011 19:17:02 +0100 [thread overview]
Message-ID: <20111218181702.GA22240@redhat.com> (raw)
In-Reply-To: <1324032383-791758-3-git-send-email-avagin@openvz.org>
On 12/16, Andrew Vagin wrote:
>
> Signed-off-by: Andrew Vagin <avagin@openvz.org>
Nice changelog ;)
I agree with Tejun, this doesn't look like the good idea to me...
As for the patch itself,
> @@ -826,6 +827,32 @@ int ptrace_request(struct task_struct *child, long request,
> break;
> }
> #endif
> + case PTRACE_DUPFD:
> + {
> + struct file *file = fget_raw(data);
> + ret = -EBADF;
> +
> + if (!file)
> + break;
> +
> + task_lock(child);
> + if (!child->files)
> + goto out_getfd;
> +
> + ret = alloc_task_fd(child, 0, 0);
alloc_fdtable() does kmalloc(GFP_KERNEL)/vmalloc(), not good under
spin_lock().
> + if (ret < 0) {
> + fput(file);
We can't do this under task_lock() too.
A tracer's sub-thread (or any CLONE_FILES task) can close this file,
it is possible that we have the last reference.
Probably, instead of the new *_task_* helpers, you can add
alloc_file_fd/fd_files_install which take the result of
get_files_struct() as the additional argument. This way you can
avoid task_lock().
Oleg.
next prev parent reply other threads:[~2011-12-18 18:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-16 10:46 [PATCH 0/2] ptrace: add ability to attach a file descriptor to another process Andrew Vagin
2011-12-16 10:46 ` [PATCH 1/2] fs: add ability to attach and to allocate fd for non current tasks Andrew Vagin
2011-12-16 10:46 ` [PATCH 2/2] ptrace: add ability to attach a file descriptor to another task Andrew Vagin
2011-12-18 18:17 ` Oleg Nesterov [this message]
2011-12-16 16:05 ` [PATCH 0/2] ptrace: add ability to attach a file descriptor to another process Tejun Heo
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=20111218181702.GA22240@redhat.com \
--to=oleg@redhat.com \
--cc=avagin@openvz.org \
--cc=gorcunov@openvz.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@parallels.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
Powered by JetHome