public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Vitaliy Gusev <vgusev@openvz.org>
Cc: Pavel Emelyanov <xemul@openvz.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bsdacct: delete timer with sync intension
Date: Wed, 31 Mar 2010 12:56:37 -0700	[thread overview]
Message-ID: <20100331125637.3ce5e8a1.akpm@linux-foundation.org> (raw)
In-Reply-To: <201003251735.10907.vgusev@openvz.org>

On Thu, 25 Mar 2010 17:35:10 +0300
Vitaliy Gusev <vgusev@openvz.org> wrote:

> acct_exit_ns --> acct_file_reopen deletes timer without
> check timer execution on other CPUs. So acct_timeout() can
> change an unmapped memory.
> 

That sounds ugly.

> 
> ---
>  kernel/acct.c |   17 +++++++++--------
>  1 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/acct.c b/kernel/acct.c
> index a6605ca..6ac80ca 100644
> --- a/kernel/acct.c
> +++ b/kernel/acct.c
> @@ -353,17 +353,18 @@ restart:
>  
>  void acct_exit_ns(struct pid_namespace *ns)
>  {
> -	struct bsd_acct_struct *acct;
> +	struct bsd_acct_struct *acct = ns->bacct;
>  
> -	spin_lock(&acct_lock);
> -	acct = ns->bacct;
> -	if (acct != NULL) {
> -		if (acct->file != NULL)
> -			acct_file_reopen(acct, NULL, NULL);
> +	if (acct == NULL)
> +		return;
>  
> -		kfree(acct);
> -	}
> +	del_timer_sync(&acct->timer);
> +	spin_lock(&acct_lock);
> +	if (acct->file != NULL)
> +		acct_file_reopen(acct, NULL, NULL);
>  	spin_unlock(&acct_lock);
> +
> +	kfree(acct);
>  }
>  

Is this sufficient?  acct_file_reopen() does a del_timer(), so
acct_timeout() could be running concurrently with acct_file_reopen(),
but acct_file_reopen() is merrily altering data at *acct.

Perhaps acct_file_reopen() should be using del_timer_sync()?



check_free_space() is doing a similar thing:

	        del_timer(&acct->timer);
	        acct->needcheck = 0;

the currently-running timer handler now goes and sets needcheck again!


Methinks the whole thing needs a bit of a rethink, bearing in mind how
del_timer() actually works.


      reply	other threads:[~2010-03-31 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 14:35 [PATCH] bsdacct: delete timer with sync intension Vitaliy Gusev
2010-03-31 19:56 ` Andrew Morton [this message]

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=20100331125637.3ce5e8a1.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgusev@openvz.org \
    --cc=xemul@openvz.org \
    /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