public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree
@ 2014-08-22 19:22 Oleg Nesterov
  2014-08-22 20:15 ` Cyrill Gorcunov
  0 siblings, 1 reply; 11+ messages in thread
From: Oleg Nesterov @ 2014-08-22 19:22 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Kees Cook, Tejun Heo, Andrew Vagin, Eric W. Biederman,
	H. Peter Anvin, Serge Hallyn, Pavel Emelyanov, Vasiliy Kulikov,
	KAMEZAWA Hiroyuki, Michael Kerrisk, Julien Tinnes, Andrew Morton,
	linux-kernel

Hi Cyrill,

I think the patch is fine but I can't understand the usage of mmap_sem
and alloc_lock,

> +	stack_vma = find_vma(mm, (unsigned long)prctl_map->start_stack);

OK, find_vma() needs mmap_sem. But otherwise, why this should be called
under down_read(&mm->mmap_sem) ? What this lock tries to protect?

> +	if (prctl_map.auxv_size) {
> +		up_read(&mm->mmap_sem);
> +		memset(user_auxv, 0, sizeof(user_auxv));
> +		error = copy_from_user(user_auxv,
> +				       (const void __user *)prctl_map.auxv,
> +				       prctl_map.auxv_size);
> +		down_read(&mm->mmap_sem);

And if we actually need this lock, why it is safe to drop it temporary?
And why we can't move this copy_from_user() up before down_read) in any
case?

> +	if (prctl_map.auxv_size) {
> +		/* Last entry must be AT_NULL as specification requires */
> +		user_auxv[AT_VECTOR_SIZE - 2] = AT_NULL;
> +		user_auxv[AT_VECTOR_SIZE - 1] = AT_NULL;
> +
> +		task_lock(current);
> +		memcpy(mm->saved_auxv, user_auxv, sizeof(user_auxv));
> +		task_unlock(current);

Again, could you explain this task_lock() ?

Oleg.


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

end of thread, other threads:[~2014-08-23 20:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-22 19:22 + prctl-pr_set_mm-introduce-pr_set_mm_map-operation-v3.patch added to -mm tree Oleg Nesterov
2014-08-22 20:15 ` Cyrill Gorcunov
2014-08-23 11:53   ` Oleg Nesterov
2014-08-23 12:22     ` Cyrill Gorcunov
2014-08-23 13:14       ` Oleg Nesterov
2014-08-23 13:30         ` Oleg Nesterov
2014-08-23 14:18           ` Cyrill Gorcunov
2014-08-23 15:32             ` Oleg Nesterov
2014-08-23 16:33               ` Cyrill Gorcunov
2014-08-23 19:29                 ` Oleg Nesterov
2014-08-23 20:11                   ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox