All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH 6/7] mm: kill vma flag VM_EXECUTABLE
Date: Mon, 2 Apr 2012 22:05:51 +0400	[thread overview]
Message-ID: <20120402180551.GJ7607@moon> (raw)
In-Reply-To: <4F79DE84.8020807@openvz.org>

On Mon, Apr 02, 2012 at 09:14:44PM +0400, Konstantin Khlebnikov wrote:
...
> >
> >Ah, it's about locking. I misundertand it at first.
> >Oleg, forget about my email then.
> 
> Yes, it's about locking. Please review patch for your code from attachment.

Thanks a lot, Konstantin! This should do the trick.

> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index cff94cd..4a41270 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -437,6 +437,7 @@ extern int get_dumpable(struct mm_struct *mm);
>  					/* leave room for more dump flags */
>  #define MMF_VM_MERGEABLE	16	/* KSM may merge identical pages */
>  #define MMF_VM_HUGEPAGE		17	/* set when VM_HUGEPAGE is set on vma */
> +#define MMF_EXE_FILE_CHANGED	18	/* see prctl(PR_SET_MM_EXE_FILE) */
>  
>  #define MMF_INIT_MASK		(MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
>  
> diff --git a/kernel/sys.c b/kernel/sys.c
> index da660f3..b217069 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -1714,17 +1714,11 @@ static bool vma_flags_mismatch(struct vm_area_struct *vma,
>  
>  static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
>  {
> +	struct vm_area_struct *vma;
>  	struct file *exe_file;
>  	struct dentry *dentry;
>  	int err;
>  
> -	/*
> -	 * Setting new mm::exe_file is only allowed when no VM_EXECUTABLE vma's
> -	 * remain. So perform a quick test first.
> -	 */
> -	if (mm->num_exe_file_vmas)
> -		return -EBUSY;
> -
>  	exe_file = fget(fd);
>  	if (!exe_file)
>  		return -EBADF;
> @@ -1745,17 +1739,28 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
>  	if (err)
>  		goto exit;
>  
> +	down_write(&mm->mmap_sem);
> +	/*
> +	 * Forbid mm->exe_file change if there are mapped some other files.
> +	 */
> +	err = -EEXIST;
> +	for (vma = mm->mmap; vma; vma = vma->vm_next) {
> +		if (vma->vm_file &&
> +		    !path_equal(&vma->vm_file->f_path, &exe_file->f_path))
> +			goto out_unlock;
> +	}

If I understand right, this snippet is emulating old behaviour (ie as
it was with num_exe_file_vmas), thus -EBUSY might be more appropriate?
But it's really a small nit I think. Thanks again.

	Cyrill

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH 6/7] mm: kill vma flag VM_EXECUTABLE
Date: Mon, 2 Apr 2012 22:05:51 +0400	[thread overview]
Message-ID: <20120402180551.GJ7607@moon> (raw)
In-Reply-To: <4F79DE84.8020807@openvz.org>

On Mon, Apr 02, 2012 at 09:14:44PM +0400, Konstantin Khlebnikov wrote:
...
> >
> >Ah, it's about locking. I misundertand it at first.
> >Oleg, forget about my email then.
> 
> Yes, it's about locking. Please review patch for your code from attachment.

Thanks a lot, Konstantin! This should do the trick.

> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index cff94cd..4a41270 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -437,6 +437,7 @@ extern int get_dumpable(struct mm_struct *mm);
>  					/* leave room for more dump flags */
>  #define MMF_VM_MERGEABLE	16	/* KSM may merge identical pages */
>  #define MMF_VM_HUGEPAGE		17	/* set when VM_HUGEPAGE is set on vma */
> +#define MMF_EXE_FILE_CHANGED	18	/* see prctl(PR_SET_MM_EXE_FILE) */
>  
>  #define MMF_INIT_MASK		(MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
>  
> diff --git a/kernel/sys.c b/kernel/sys.c
> index da660f3..b217069 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -1714,17 +1714,11 @@ static bool vma_flags_mismatch(struct vm_area_struct *vma,
>  
>  static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
>  {
> +	struct vm_area_struct *vma;
>  	struct file *exe_file;
>  	struct dentry *dentry;
>  	int err;
>  
> -	/*
> -	 * Setting new mm::exe_file is only allowed when no VM_EXECUTABLE vma's
> -	 * remain. So perform a quick test first.
> -	 */
> -	if (mm->num_exe_file_vmas)
> -		return -EBUSY;
> -
>  	exe_file = fget(fd);
>  	if (!exe_file)
>  		return -EBADF;
> @@ -1745,17 +1739,28 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
>  	if (err)
>  		goto exit;
>  
> +	down_write(&mm->mmap_sem);
> +	/*
> +	 * Forbid mm->exe_file change if there are mapped some other files.
> +	 */
> +	err = -EEXIST;
> +	for (vma = mm->mmap; vma; vma = vma->vm_next) {
> +		if (vma->vm_file &&
> +		    !path_equal(&vma->vm_file->f_path, &exe_file->f_path))
> +			goto out_unlock;
> +	}

If I understand right, this snippet is emulating old behaviour (ie as
it was with num_exe_file_vmas), thus -EBUSY might be more appropriate?
But it's really a small nit I think. Thanks again.

	Cyrill

  reply	other threads:[~2012-04-02 18:05 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-31  9:25 [PATCH 0/7] mm: vma->vm_flags diet Konstantin Khlebnikov
2012-03-31  9:25 ` Konstantin Khlebnikov
2012-03-31  9:29 ` [PATCH 1/7] mm, x86, PAT: rework linear pfn-mmap tracking Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31 17:09   ` [PATCH 1/7 v2] " Konstantin Khlebnikov
2012-03-31 17:09     ` Konstantin Khlebnikov
2012-04-03  0:46     ` [x86 PAT PATCH 0/2] x86 PAT vm_flag code refactoring Suresh Siddha
2012-04-03  0:46       ` Suresh Siddha
2012-04-03  0:46       ` [x86 PAT PATCH 1/2] x86, pat: remove the dependency on 'vm_pgoff' in track/untrack pfn vma routines Suresh Siddha
2012-04-03  0:46         ` Suresh Siddha
2012-04-03  5:37         ` Konstantin Khlebnikov
2012-04-03  5:37           ` Konstantin Khlebnikov
2012-04-03 23:31           ` Suresh Siddha
2012-04-04  4:43             ` Konstantin Khlebnikov
2012-04-04  4:43               ` Konstantin Khlebnikov
2012-04-05 11:56             ` Konstantin Khlebnikov
2012-04-05 11:56               ` Konstantin Khlebnikov
2012-04-06  0:01               ` [v3 VM_PAT PATCH 0/3] x86 VM_PAT series Suresh Siddha
2012-04-06  0:01                 ` Suresh Siddha
2012-04-06  0:01                 ` [v3 VM_PAT PATCH 1/3] x86, pat: remove the dependency on 'vm_pgoff' in track/untrack pfn vma routines Suresh Siddha
2012-04-06  0:01                   ` Suresh Siddha
2012-04-06  0:01                 ` [v3 VM_PAT PATCH 2/3] x86, pat: separate the pfn attribute tracking for remap_pfn_range and vm_insert_pfn Suresh Siddha
2012-04-06  0:01                   ` Suresh Siddha
2012-04-06  0:01                 ` [v3 VM_PAT PATCH 3/3] mm, x86, PAT: rework linear pfn-mmap tracking Suresh Siddha
2012-04-06  0:01                   ` Suresh Siddha
2012-04-03  0:46       ` [x86 PAT PATCH 2/2] " Suresh Siddha
2012-04-03  0:46         ` Suresh Siddha
2012-04-03  5:48         ` Konstantin Khlebnikov
2012-04-03  5:48           ` Konstantin Khlebnikov
2012-04-03  5:55           ` Konstantin Khlebnikov
2012-04-03  5:55             ` Konstantin Khlebnikov
2012-04-03  6:03       ` [x86 PAT PATCH 0/2] x86 PAT vm_flag code refactoring Konstantin Khlebnikov
2012-04-03  6:03         ` Konstantin Khlebnikov
2012-04-03 23:14         ` Suresh Siddha
2012-04-03 23:14           ` Suresh Siddha
2012-04-04  4:40           ` Konstantin Khlebnikov
2012-04-04  4:40             ` Konstantin Khlebnikov
2012-03-31  9:29 ` [PATCH 2/7] mm: introduce vma flag VM_ARCH_1 Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31 22:25   ` Benjamin Herrenschmidt
2012-03-31 22:25     ` Benjamin Herrenschmidt
2012-03-31  9:29 ` [PATCH 3/7] mm: kill vma flag VM_CAN_NONLINEAR Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31 17:01   ` Linus Torvalds
2012-03-31 17:01     ` Linus Torvalds
2012-03-31  9:29 ` [PATCH 4/7] mm: kill vma flag VM_INSERTPAGE Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31  9:29 ` [PATCH 5/7] mm, drm/udl: fixup vma flags on mmap Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31  9:29 ` [PATCH 6/7] mm: kill vma flag VM_EXECUTABLE Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31 20:13   ` Oleg Nesterov
2012-03-31 20:13     ` Oleg Nesterov
2012-03-31 20:39     ` Cyrill Gorcunov
2012-03-31 20:39       ` Cyrill Gorcunov
2012-04-02  9:46       ` Konstantin Khlebnikov
2012-04-02  9:46         ` Konstantin Khlebnikov
2012-04-02  9:54         ` Cyrill Gorcunov
2012-04-02  9:54           ` Cyrill Gorcunov
2012-04-02 10:13           ` Konstantin Khlebnikov
2012-04-02 10:13             ` Konstantin Khlebnikov
2012-04-02 14:48         ` Oleg Nesterov
2012-04-02 14:48           ` Oleg Nesterov
2012-04-02 16:02           ` Cyrill Gorcunov
2012-04-02 16:02             ` Cyrill Gorcunov
2012-04-02 16:19           ` Konstantin Khlebnikov
2012-04-02 16:19             ` Konstantin Khlebnikov
2012-04-02 16:27             ` Cyrill Gorcunov
2012-04-02 16:27               ` Cyrill Gorcunov
2012-04-02 17:14               ` Konstantin Khlebnikov
2012-04-02 18:05                 ` Cyrill Gorcunov [this message]
2012-04-02 18:05                   ` Cyrill Gorcunov
2012-04-02 23:04     ` Matt Helsley
2012-04-02 23:04       ` Matt Helsley
2012-04-03  5:10       ` Konstantin Khlebnikov
2012-04-03  5:10         ` Konstantin Khlebnikov
2012-04-03 18:16         ` Matt Helsley
2012-04-03 18:16           ` Matt Helsley
2012-04-03 19:32           ` Cyrill Gorcunov
2012-04-03 19:32             ` Cyrill Gorcunov
2012-04-05 20:29             ` Matt Helsley
2012-04-05 20:29               ` Matt Helsley
2012-04-05 20:53               ` Cyrill Gorcunov
2012-04-05 20:53                 ` Cyrill Gorcunov
2012-04-05 21:04               ` Konstantin Khlebnikov
2012-04-05 21:04                 ` Konstantin Khlebnikov
2012-04-05 21:44                 ` Matt Helsley
2012-04-05 21:44                   ` Matt Helsley
2012-04-05 21:55                   ` Linus Torvalds
2012-04-05 21:55                     ` Linus Torvalds
2012-04-06  4:36                     ` Konstantin Khlebnikov
2012-04-06  4:36                       ` Konstantin Khlebnikov
2012-04-02 23:18   ` Matt Helsley
2012-04-02 23:18     ` Matt Helsley
2012-04-03  5:06     ` Konstantin Khlebnikov
2012-04-03  5:06       ` Konstantin Khlebnikov
2012-04-06 22:48       ` Andrew Morton
2012-04-06 22:48         ` Andrew Morton
2012-03-31  9:29 ` [PATCH 7/7] mm: move madvise vma flags to the end Konstantin Khlebnikov
2012-03-31  9:29   ` Konstantin Khlebnikov
2012-03-31 14:06 ` [PATCH 0/7] mm: vma->vm_flags diet Andi Kleen
2012-03-31 14:06   ` Andi Kleen

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=20120402180551.GJ7607@moon \
    --to=gorcunov@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=eparis@redhat.com \
    --cc=khlebnikov@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oleg@redhat.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 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.