public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kirill Korotaev <dev@sw.ru>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	xemul@sw.ru, hch@infradead.org
Subject: Re: [PATCH] unserialized task->files changing (v2)
Date: Tue, 08 Aug 2006 19:53:01 +0400	[thread overview]
Message-ID: <44D8B35D.2070908@sw.ru> (raw)
In-Reply-To: <200608081451.58305.dada1@cosmosbay.com>

Eric,

> Sorry but there is something I dont understand. You ignored my point.
Sorry, I missed it thinking that you are talking about another thing...
Pavel described the race in more details and why barrier doesn't help.
Hope, it became more clear now.

> +void reset_files_struct(struct task_struct *tsk, struct files_struct *files)
> +{
> +       struct files_struct *old;
> +
> +       old = tsk->files;
> +       task_lock(tsk);
> +       tsk->files = files;
> +       task_unlock(tsk);
> +       put_files_struct(old);
> +}
> 
> Its seems very strange to protect tsk->files = files with a 
> task_lock()/task_unlock(). What is it supposed to guard against ???
> 
> If this patch corrects the 'bug', then a simpler fix would  be to use a memory 
> barrier between "tsk->files = files" and "put_files_struct(old);" 
> 
> No need to perform 2 atomics ops on the task lock.
> 
> old = tsk->files;
> tsk->files = files;
> smp_mb();
> put_files_struct(old);
> 
> That would be enough to guard against proc code (because this code only needs 
> to read tsk->files of course)
> 
> The same remark can be said for __exit_files() from kernel/exit.c
> 
> If this task_lock()/task_unlock() patch is really needed, then a comment in 
> the source would be very fair.

Kirill

  parent reply	other threads:[~2006-08-08 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08 11:31 [PATCH] unserialized task->files changing (v2) Kirill Korotaev
2006-08-08 12:51 ` Eric Dumazet
2006-08-08 13:18   ` Pavel V. Emelianov
2006-08-08 15:53   ` Kirill Korotaev [this message]
2006-08-08 15:59     ` Eric Dumazet

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