public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Kirill Korotaev <dev@sw.ru>, Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] unserialized task->files changing
Date: Tue, 8 Aug 2006 12:23:09 +0200	[thread overview]
Message-ID: <200608081223.10434.dada1@cosmosbay.com> (raw)
In-Reply-To: <20060808101208.GA25956@infradead.org>

On Tuesday 08 August 2006 12:12, Christoph Hellwig wrote:
> On Tue, Aug 08, 2006 at 02:07:49PM +0400, Kirill Korotaev wrote:
> > Fixed race on put_files_struct on exec with proc.
> > Restoring files on current on error path may lead
> > to proc having a pointer to already kfree-d files_struct.
>
> This is three times the exact same code sequence, it should probably go
> into a helper:
>
> void reset_current_files(struct files_struct *files)
> {
> 	struct files_struct *old = current->files;
>
> 	task_lock(current);
> 	current->files = files;
> 	task_unlock(current);
> 	put_files_struct(old);
> }


More over I think you want to task_lock() before reading current->files 
into 'old'

task_lock(current);
old = current->files;
current->files = files;
task_unlock(current);
put_files_struct(old);

or maybe a xchg() ?


  reply	other threads:[~2006-08-08 10:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08 10:07 [PATCH] unserialized task->files changing Kirill Korotaev
2006-08-08 10:12 ` Christoph Hellwig
2006-08-08 10:23   ` Eric Dumazet [this message]
2006-08-08 10:43     ` Kirill Korotaev

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=200608081223.10434.dada1@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=akpm@osdl.org \
    --cc=dev@sw.ru \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.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