From: Eric Dumazet <dada1@cosmosbay.com>
To: Kirill Korotaev <dev@sw.ru>
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, 8 Aug 2006 14:51:57 +0200 [thread overview]
Message-ID: <200608081451.58305.dada1@cosmosbay.com> (raw)
In-Reply-To: <44D87611.7070705@sw.ru>
On Tuesday 08 August 2006 13:31, 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.
>
> ->files changing at exit.c and khtread.c are safe as
> exit_files() makes all things under lock.
>
> v2 patch changes:
> - introduced reset_files_struct() as Christoph Hellwig suggested
>
> Found during OpenVZ stress testing.
Sorry but there is something I dont understand. You ignored my point.
+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.
Eric
next prev parent reply other threads:[~2006-08-08 12:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-08 11:31 Kirill Korotaev
2006-08-08 12:51 ` Eric Dumazet [this message]
2006-08-08 13:18 ` Pavel V. Emelianov
2006-08-08 15:53 ` Kirill Korotaev
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=200608081451.58305.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 \
--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
Powered by JetHome