All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirill Korotaev <dev@sw.ru>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] unserialized task->files changing
Date: Tue, 08 Aug 2006 14:43:38 +0400	[thread overview]
Message-ID: <44D86ADA.5000904@sw.ru> (raw)
In-Reply-To: <200608081223.10434.dada1@cosmosbay.com>

Eric Dumazet wrote:
> 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() ?

yeah, never do assignments in declarations :)

BTW, not sure about kthread_exit_files() yet, but looks like it suffers too.

unshare_files() changes current->files w/o locking as well. but I can't see
where it puts the old files... hmm...

Kirill

      reply	other threads:[~2006-08-08 10:44 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
2006-08-08 10:43     ` Kirill Korotaev [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=44D86ADA.5000904@sw.ru \
    --to=dev@sw.ru \
    --cc=akpm@osdl.org \
    --cc=dada1@cosmosbay.com \
    --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 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.