mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Pekka J Enberg <penberg@cs.helsinki.fi>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] revoke: break cow for private mappings
Date: Wed, 28 Mar 2007 18:04:20 +1000	[thread overview]
Message-ID: <460A2184.8060207@yahoo.com.au> (raw)
In-Reply-To: <Pine.LNX.4.64.0703271014100.793@sbz-30.cs.Helsinki.FI>

Pekka J Enberg wrote:
> From: Pekka Enberg <penberg@cs.helsinki.fi>
> 
> We need to break COW for private mappings to make sure a process cannot
> read new data after an inode has been revoked.

Seems OK.

> 
> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
> ---
>  fs/revoke.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 73 insertions(+), 12 deletions(-)
> 
> Index: uml-2.6/fs/revoke.c
> ===================================================================
> --- uml-2.6.orig/fs/revoke.c	2007-03-26 18:10:24.000000000 +0300
> +++ uml-2.6/fs/revoke.c	2007-03-26 18:27:25.000000000 +0300
> @@ -174,12 +174,58 @@ static inline bool need_revoke(struct vm
>  	if (file->f_path.dentry->d_inode != inode)
>  		return false;
>  
> -	if (!(vma->vm_flags & VM_SHARED))
> -		return false;
> -
>  	return file != to_exclude;
>  }
>  
> +static int __revoke_break_cow(struct task_struct *tsk, struct inode *inode,
> +			      struct file *to_exclude)
> +{
> +	struct mm_struct *mm = tsk->mm;
> +	struct vm_area_struct *vma;
> +	int err = 0;
> +
> +	down_write(&mm->mmap_sem);
> +	for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) {
> +		int ret;
> +
> +		if (vma->vm_flags & VM_SHARED)
> +			continue;
> +
> +		if (!need_revoke(vma, inode, to_exclude))
> +			continue;
> +
> +		ret = get_user_pages(tsk, tsk->mm, vma->vm_start,
> +				     vma->vm_end-vma->vm_start, 1, 1, NULL,
> +				     NULL);

get_user_pages length argument is in # of pages, rather than address range,
I think. vma_pages is what you want?

> +		if (ret < 0) {
> +			err = ret;
> +			break;
> +		}
> +	}
> +	up_write(&mm->mmap_sem);

I think you just need down_read of mmap_sem here?

-- 
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

  reply	other threads:[~2007-03-28  8:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-27  7:14 Pekka J Enberg
2007-03-28  8:04 ` Nick Piggin [this message]
2007-03-28 10:09   ` Pekka Enberg

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=460A2184.8060207@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    /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

all inboxes | Powered by JetHome®