linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: + syscalls-x86-add-__nr_kcmp-syscall-v8.patch added to -mm tree
@ 2012-02-15 14:36 Oleg Nesterov
  2012-02-15 15:10 ` Cyrill Gorcunov
  2012-02-15 16:06 ` Oleg Nesterov
  0 siblings, 2 replies; 48+ messages in thread
From: Oleg Nesterov @ 2012-02-15 14:36 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Eric W. Biederman, Pavel Emelyanov, Andrey Vagin,
	KOSAKI Motohiro, Ingo Molnar, H. Peter Anvin, Thomas Gleixner,
	Glauber Costa, Andi Kleen, Tejun Heo, Matt Helsley, Pekka Enberg,
	Eric Dumazet, Vasiliy Kulikov, Alexey Dobriyan, Valdis.Kletnieks,
	Michal Marek, Frederic Weisbecker, Andrew Morton, linux-kernel

> +/* The caller must have pinned the task */
> +static struct file *
> +get_file_raw_ptr(struct task_struct *task, unsigned int idx)
> +{
> +	struct fdtable *fdt;
> +	struct file *file;
> +
> +	spin_lock(&task->files->file_lock);

task->files can be NULL, we can race with exit_files().

> +	fdt = files_fdtable(task->files);
> +	if (idx < fdt->max_fds)
> +		file = fdt->fd[idx];

You can probably rely on rcu instead of ->file_lock, but this is minor.

> +SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
> +		unsigned long, idx1, unsigned long, idx2)
> +{
> +	struct task_struct *task1, *task2;
> +	int ret;
> +
> +	rcu_read_lock();
> +
> +	/*
> +	 * Tasks are looked up in caller's PID namespace only.
> +	 */
> +	task1 = find_task_by_vpid(pid1);
> +	task2 = find_task_by_vpid(pid2);
> +	if (!task1 || !task2)
> +		goto err_no_task;
> +
> +	get_task_struct(task1);
> +	get_task_struct(task2);
> +
> +	rcu_read_unlock();
> +
> +	/*
> +	 * One should have enough rights to inspect task details.
> +	 */
> +	if (!ptrace_may_access(task1, PTRACE_MODE_READ) ||
> +	    !ptrace_may_access(task2, PTRACE_MODE_READ)) {
> +		ret = -EACCES;

Well, probably this is fine... but may be you can add a comment.
The task can change its credentials right after ptrace_may_access()
succeeds. This _looks_ wrong, perhaps it makes sense to  add the
"we do not care" note.

Oleg.


^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2012-04-11 18:38 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-15 14:36 + syscalls-x86-add-__nr_kcmp-syscall-v8.patch added to -mm tree Oleg Nesterov
2012-02-15 15:10 ` Cyrill Gorcunov
2012-02-15 15:38   ` Oleg Nesterov
2012-02-15 16:13     ` Cyrill Gorcunov
2012-02-15 16:22       ` Oleg Nesterov
2012-02-15 17:53         ` Cyrill Gorcunov
2012-02-15 18:43           ` Oleg Nesterov
2012-02-15 19:56             ` Cyrill Gorcunov
2012-02-15 19:57               ` Vasiliy Kulikov
2012-02-15 20:05                 ` Cyrill Gorcunov
2012-02-15 20:25                   ` Cyrill Gorcunov
2012-02-15 21:09                     ` Cyrill Gorcunov
2012-02-15 21:58                       ` Cyrill Gorcunov
2012-02-16 14:49                         ` Oleg Nesterov
2012-02-16 15:13                           ` Cyrill Gorcunov
2012-02-16 16:49                             ` Cyrill Gorcunov
2012-02-16 17:40                               ` Oleg Nesterov
2012-02-16 17:58                                 ` Cyrill Gorcunov
2012-02-16 19:03                                   ` Oleg Nesterov
2012-02-16 19:20                                     ` H. Peter Anvin
2012-02-16 19:29                                     ` Cyrill Gorcunov
2012-02-16 19:52                                       ` Andrew Morton
2012-02-16 20:01                                         ` Cyrill Gorcunov
2012-02-16 18:21                               ` Vasiliy Kulikov
2012-02-16 18:34                                 ` Cyrill Gorcunov
2012-02-16 18:33                                   ` Vasiliy Kulikov
2012-02-16 18:49                                 ` Oleg Nesterov
2012-02-15 18:32   ` Cyrill Gorcunov
2012-02-15 19:06     ` Oleg Nesterov
2012-02-15 19:18       ` Cyrill Gorcunov
2012-02-15 16:06 ` Oleg Nesterov
2012-02-15 16:27   ` Cyrill Gorcunov
2012-04-09 22:10     ` Andrew Morton
2012-04-09 22:24       ` Cyrill Gorcunov
2012-04-09 23:22         ` H. Peter Anvin
2012-04-10 22:37           ` Cyrill Gorcunov
2012-04-10 22:39             ` H. Peter Anvin
2012-04-10 22:48               ` Cyrill Gorcunov
2012-04-10 23:08             ` Oleg Nesterov
2012-04-10 23:32               ` H. Peter Anvin
2012-04-10 23:42                 ` Oleg Nesterov
2012-04-11  6:39                   ` Cyrill Gorcunov
2012-04-11 18:31                     ` Oleg Nesterov
2012-04-11  0:02           ` Valdis.Kletnieks
2012-04-10  3:25       ` Eric W. Biederman
2012-04-10 22:54         ` Cyrill Gorcunov
2012-04-10 23:58       ` Valdis.Kletnieks
2012-04-11  0:06         ` H. Peter Anvin

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).